Filename | /var/www/foswikidev/core/lib/Foswiki/Plugins/JQueryPlugin/RENDER.pm |
Statements | Executed 12 statements in 406µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 23µs | 48µs | new | Foswiki::Plugins::JQueryPlugin::RENDER::
1 | 1 | 1 | 15µs | 27µs | BEGIN@4 | Foswiki::Plugins::JQueryPlugin::RENDER::
1 | 1 | 1 | 9µs | 13µs | BEGIN@5 | Foswiki::Plugins::JQueryPlugin::RENDER::
1 | 1 | 1 | 4µs | 4µs | BEGIN@7 | Foswiki::Plugins::JQueryPlugin::RENDER::
0 | 0 | 0 | 0s | 0s | restTmpl | Foswiki::Plugins::JQueryPlugin::RENDER::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | |||||
3 | package Foswiki::Plugins::JQueryPlugin::RENDER; | ||||
4 | 2 | 28µs | 2 | 40µs | # spent 27µs (15+12) within Foswiki::Plugins::JQueryPlugin::RENDER::BEGIN@4 which was called:
# once (15µs+12µs) by Foswiki::Plugins::JQueryPlugin::Plugins::BEGIN@1.48 at line 4 # spent 27µs making 1 call to Foswiki::Plugins::JQueryPlugin::RENDER::BEGIN@4
# spent 12µs making 1 call to strict::import |
5 | 2 | 24µs | 2 | 17µs | # spent 13µs (9+4) within Foswiki::Plugins::JQueryPlugin::RENDER::BEGIN@5 which was called:
# once (9µs+4µs) by Foswiki::Plugins::JQueryPlugin::Plugins::BEGIN@1.48 at line 5 # spent 13µs making 1 call to Foswiki::Plugins::JQueryPlugin::RENDER::BEGIN@5
# spent 4µs making 1 call to warnings::import |
6 | |||||
7 | 2 | 324µs | 1 | 4µs | # spent 4µs within Foswiki::Plugins::JQueryPlugin::RENDER::BEGIN@7 which was called:
# once (4µs+0s) by Foswiki::Plugins::JQueryPlugin::Plugins::BEGIN@1.48 at line 7 # spent 4µs making 1 call to Foswiki::Plugins::JQueryPlugin::RENDER::BEGIN@7 |
8 | 1 | 7µs | our @ISA = qw( Foswiki::Plugins::JQueryPlugin::Plugin ); | ||
9 | |||||
10 | # spent 48µs (23+25) within Foswiki::Plugins::JQueryPlugin::RENDER::new which was called:
# once (23µs+25µs) by Foswiki::Plugins::JQueryPlugin::Plugins::load at line 290 of /var/www/foswikidev/core/lib/Foswiki/Plugins/JQueryPlugin/Plugins.pm | ||||
11 | 1 | 500ns | my $class = shift; | ||
12 | 1 | 500ns | my $session = shift || $Foswiki::Plugins::SESSION; | ||
13 | |||||
14 | 1 | 16µs | 1 | 25µs | my $this = bless( # spent 25µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugin::new |
15 | $class->SUPER::new( | ||||
16 | $session, | ||||
17 | name => 'Render', | ||||
18 | version => '1.0.0-beta', | ||||
19 | author => 'Boris Moore', | ||||
20 | homepage => 'http://www.jsviews.com', | ||||
21 | javascript => [ 'jquery.render.js', 'jquery.template-loader.js' ], | ||||
22 | ), | ||||
23 | $class | ||||
24 | ); | ||||
25 | |||||
26 | 1 | 3µs | return $this; | ||
27 | } | ||||
28 | |||||
29 | =begin TML | ||||
30 | |||||
31 | ---++ ClassMethod restTmpl( $session, $subject, $verb ) | ||||
32 | |||||
33 | rest handler to load foswiki templates | ||||
34 | |||||
35 | =cut | ||||
36 | |||||
37 | sub restTmpl { | ||||
38 | my ( $this, $session, $subject, $verb ) = @_; | ||||
39 | |||||
40 | my $result = ''; | ||||
41 | my $request = Foswiki::Func::getRequestObject(); | ||||
42 | my $load = $request->param('load'); | ||||
43 | my $name = $request->param('name') || $load; | ||||
44 | my $web = $session->{webName}; | ||||
45 | my $topic = $session->{topicName}; | ||||
46 | my $contentType = $request->param("contenttype"); | ||||
47 | my $cacheControl = $request->param("cachecontrol"); | ||||
48 | my $doRender = | ||||
49 | Foswiki::Func::isTrue( scalar( $request->param('render') ), 0 ); | ||||
50 | |||||
51 | $cacheControl = "max-age=28800" unless defined $cacheControl; | ||||
52 | |||||
53 | $result = Foswiki::Func::loadTemplate($load) if defined $load; | ||||
54 | |||||
55 | if ( defined $name ) { | ||||
56 | my $attrs = new Foswiki::Attrs($name); | ||||
57 | $result = $session->templates->tmplP($attrs); | ||||
58 | } | ||||
59 | |||||
60 | $result = Foswiki::Func::expandCommonVariables( $result, $topic, $web ) | ||||
61 | || ''; | ||||
62 | $result = Foswiki::Func::renderText( $result, $web ) if $doRender; | ||||
63 | |||||
64 | my $response = $session->{response}; | ||||
65 | |||||
66 | if ( $result eq "" ) { | ||||
67 | $response->header( -status => 500 ); | ||||
68 | $session->writeCompletePage( "ERROR: template '$name' not found", | ||||
69 | undef, $contentType ); | ||||
70 | } | ||||
71 | else { | ||||
72 | $response->header( -"Cache-Control" => $cacheControl ) if $cacheControl; | ||||
73 | $session->writeCompletePage( $result, undef, $contentType ); | ||||
74 | } | ||||
75 | |||||
76 | return; | ||||
77 | } | ||||
78 | |||||
79 | 1 | 3µs | 1; | ||
80 | |||||
81 | __END__ |