← Index
NYTProf Performance Profile   « line view »
For ./view
  Run on Fri Jul 31 19:05:14 2015
Reported on Fri Jul 31 19:08:10 2015

Filename/var/www/foswiki11/lib/Foswiki/Plugins/RenderPlugin.pm
StatementsExecuted 23 statements in 1.05ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11136µs143µsFoswiki::Plugins::RenderPlugin::::initPluginFoswiki::Plugins::RenderPlugin::initPlugin
11114µs27µsFoswiki::Plugins::RenderPlugin::::BEGIN@18Foswiki::Plugins::RenderPlugin::BEGIN@18
11110µs16µsFoswiki::Plugins::RenderPlugin::::BEGIN@19Foswiki::Plugins::RenderPlugin::BEGIN@19
1119µs43µsFoswiki::Plugins::RenderPlugin::::BEGIN@30Foswiki::Plugins::RenderPlugin::BEGIN@30
1114µs4µsFoswiki::Plugins::RenderPlugin::::BEGIN@22Foswiki::Plugins::RenderPlugin::BEGIN@22
1114µs4µsFoswiki::Plugins::RenderPlugin::::BEGIN@21Foswiki::Plugins::RenderPlugin::BEGIN@21
1113µs3µsFoswiki::Plugins::RenderPlugin::::BEGIN@23Foswiki::Plugins::RenderPlugin::BEGIN@23
0000s0sFoswiki::Plugins::RenderPlugin::::restExpandFoswiki::Plugins::RenderPlugin::restExpand
0000s0sFoswiki::Plugins::RenderPlugin::::restRenderFoswiki::Plugins::RenderPlugin::restRender
0000s0sFoswiki::Plugins::RenderPlugin::::restTagFoswiki::Plugins::RenderPlugin::restTag
0000s0sFoswiki::Plugins::RenderPlugin::::restTemplateFoswiki::Plugins::RenderPlugin::restTemplate
0000s0sFoswiki::Plugins::RenderPlugin::::writeDebugFoswiki::Plugins::RenderPlugin::writeDebug
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
2#
3# Copyright (C) 2008-2014 Michael Daum http://michaeldaumconsulting.com
4#
5# This program is free software; you can redistribute it and/or
6# modify it under the terms of the GNU General Public License
7# as published by the Free Software Foundation; either version 2
8# of the License, or (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details, published at
14# http://www.gnu.org/copyleft/gpl.html
15
16package Foswiki::Plugins::RenderPlugin;
17
18230µs240µs
# spent 27µs (14+13) within Foswiki::Plugins::RenderPlugin::BEGIN@18 which was called: # once (14µs+13µs) by Foswiki::Plugin::BEGIN@2.27 at line 18
use strict;
# spent 27µs making 1 call to Foswiki::Plugins::RenderPlugin::BEGIN@18 # spent 13µs making 1 call to strict::import
19225µs221µs
# spent 16µs (10+6) within Foswiki::Plugins::RenderPlugin::BEGIN@19 which was called: # once (10µs+6µs) by Foswiki::Plugin::BEGIN@2.27 at line 19
use warnings;
# spent 16µs making 1 call to Foswiki::Plugins::RenderPlugin::BEGIN@19 # spent 6µs making 1 call to warnings::import
20
21220µs14µs
# spent 4µs within Foswiki::Plugins::RenderPlugin::BEGIN@21 which was called: # once (4µs+0s) by Foswiki::Plugin::BEGIN@2.27 at line 21
use Foswiki::Func ();
# spent 4µs making 1 call to Foswiki::Plugins::RenderPlugin::BEGIN@21
22219µs14µs
# spent 4µs within Foswiki::Plugins::RenderPlugin::BEGIN@22 which was called: # once (4µs+0s) by Foswiki::Plugin::BEGIN@2.27 at line 22
use Foswiki::Sandbox() ;
# spent 4µs making 1 call to Foswiki::Plugins::RenderPlugin::BEGIN@22
23267µs13µs
# spent 3µs within Foswiki::Plugins::RenderPlugin::BEGIN@23 which was called: # once (3µs+0s) by Foswiki::Plugin::BEGIN@2.27 at line 23
use Encode ();
# spent 3µs making 1 call to Foswiki::Plugins::RenderPlugin::BEGIN@23
24
251500nsour $VERSION = '3.21';
261300nsour $RELEASE = '3.21';
271200nsour $SHORTDESCRIPTION = 'Render <nop>WikiApplications asynchronously';
281100nsour $NO_PREFS_IN_TOPIC = 1;
29
302854µs277µs
# spent 43µs (9+34) within Foswiki::Plugins::RenderPlugin::BEGIN@30 which was called: # once (9µs+34µs) by Foswiki::Plugin::BEGIN@2.27 at line 30
use constant TRACE => 0; # toggle me
# spent 43µs making 1 call to Foswiki::Plugins::RenderPlugin::BEGIN@30 # spent 34µs making 1 call to constant::import
31
32###############################################################################
33sub writeDebug {
34 print STDERR '- RenderPlugin - '.$_[0]."\n" if TRACE;
35}
36
37
38###############################################################################
39
# spent 143µs (36+107) within Foswiki::Plugins::RenderPlugin::initPlugin which was called: # once (36µs+107µs) by Foswiki::Plugin::__ANON__[/var/www/foswiki11/lib/Foswiki/Plugin.pm:241] at line 234 of /var/www/foswiki11/lib/Foswiki/Plugin.pm
sub initPlugin {
4012µs my ($topic, $web, $user, $installWeb) = @_;
41
4214µs130µs Foswiki::Func::registerRESTHandler('tag', \&restTag,
# spent 30µs making 1 call to Foswiki::Func::registerRESTHandler
43 authenticate => 0,
44 validate => 0,
45 http_allow => 'GET,POST',
46 );
47
4814µs124µs Foswiki::Func::registerRESTHandler('template', \&restTemplate,
# spent 24µs making 1 call to Foswiki::Func::registerRESTHandler
49 authenticate => 0,
50 validate => 0,
51 http_allow => 'GET,POST',
52 );
53
5414µs128µs Foswiki::Func::registerRESTHandler('expand', \&restExpand,
# spent 28µs making 1 call to Foswiki::Func::registerRESTHandler
55 authenticate => 0,
56 validate => 0,
57 http_allow => 'GET,POST',
58 );
59
6014µs126µs Foswiki::Func::registerRESTHandler('render', \&restRender,
# spent 26µs making 1 call to Foswiki::Func::registerRESTHandler
61 authenticate => 0,
62 validate => 0,
63 http_allow => 'GET,POST',
64 );
65
6616µs return 1;
67}
68
69###############################################################################
70sub restRender {
71 my ($session, $subject, $verb) = @_;
72
73 my $query = Foswiki::Func::getCgiQuery();
74 my $theText = $query->param('text') || '';
75
76 return ' ' unless $theText; # must return at least on char as we get a
77 # premature end of script otherwise
78
79 my $theTopic = $query->param('topic') || $session->{topicName};
80 my $theWeb = $query->param('web') || $session->{webName};
81 my ($web, $topic) = Foswiki::Func::normalizeWebTopicName($theWeb, $theTopic);
82 $web = Foswiki::Sandbox::untaint($web, \&Foswiki::Sandbox::validateWebName);
83 $topic = Foswiki::Sandbox::untaint($topic, \&Foswiki::Sandbox::validateTopicName);
84
85 my $result = Foswiki::Func::expandCommonVariables($theText, $topic, $web) || ' ';
86 $result = Foswiki::Func::renderText($result, $web);
87
88 my $contentType = $query->param("contenttype");
89 $session->writeCompletePage($result, undef, $contentType);
90
91 return;
92}
93
94###############################################################################
95sub restExpand {
96 my ($session, $subject, $verb) = @_;
97
98 # get params
99 my $query = Foswiki::Func::getCgiQuery();
100 my $theText = $query->param('text') || '';
101
102 return ' ' unless $theText; # must return at least on char as we get a
103 # premature end of script otherwise
104
105 my $theTopic = $query->param('topic') || $session->{topicName};
106 my $theWeb = $query->param('web') || $session->{webName};
107 my ($web, $topic) = Foswiki::Func::normalizeWebTopicName($theWeb, $theTopic);
108 $web = Foswiki::Sandbox::untaint($web, \&Foswiki::Sandbox::validateWebName);
109 $topic = Foswiki::Sandbox::untaint($topic, \&Foswiki::Sandbox::validateTopicName);
110
111 # and render it
112 my $result = Foswiki::Func::expandCommonVariables($theText, $topic, $web) || ' ';
113
114 my $contentType = $query->param("contenttype");
115 $session->writeCompletePage($result, undef, $contentType);
116
117 return;
118}
119
120###############################################################################
121sub restTemplate {
122 my ($session, $subject, $verb) = @_;
123
124 my $query = Foswiki::Func::getCgiQuery();
125 my $theTemplate = $query->param('name');
126 return '' unless $theTemplate;
127
128 my $theExpand = $query->param('expand');
129 return '' unless $theExpand;
130
131 my $theTopic = $query->param('topic') || $session->{topicName};
132 my $theWeb = $query->param('web') || $session->{webName};
133 my ($web, $topic) = Foswiki::Func::normalizeWebTopicName($theWeb, $theTopic);
134 $web = Foswiki::Sandbox::untaint($web, \&Foswiki::Sandbox::validateWebName);
135 $topic = Foswiki::Sandbox::untaint($topic, \&Foswiki::Sandbox::validateTopicName);
136
137 Foswiki::Func::loadTemplate($theTemplate);
138
139 require Foswiki::Attrs;
140 my $attrs = new Foswiki::Attrs($theExpand);
141
142 my $tmpl = $session->templates->tmplP($attrs);
143
144 # and render it
145 my $result = Foswiki::Func::expandCommonVariables($tmpl, $topic, $web) || ' ';
146
147 my $theRender = Foswiki::Func::isTrue(scalar $query->param('render'), 0);
148 if ($theRender) {
149 $result = Foswiki::Func::renderText($result, $web);
150 }
151
152 my $contentType = $query->param("contenttype");
153 $session->writeCompletePage($result, undef, $contentType);
154
155 return;
156}
157
158###############################################################################
159sub restTag {
160 my ($session, $subject, $verb) = @_;
161
162 #writeDebug("called restTag($subject, $verb)");
163
164 # get params
165 my $query = Foswiki::Func::getCgiQuery();
166
167 my $theTag = $query->param('name') || 'INCLUDE';
168 my $theDefault = $query->param('param') || '';
169 my $theRender = $query->param('render') || 0;
170
171 $theRender = ($theRender =~ /^\s*(1|on|yes|true)\s*$/) ? 1:0;
172
173 my $theTopic = $query->param('topic') || $session->{topicName};
174 my $theWeb = $query->param('web') || $session->{webName};
175 my ($web, $topic) = Foswiki::Func::normalizeWebTopicName($theWeb, $theTopic);
176 $web = Foswiki::Sandbox::untaint($web, \&Foswiki::Sandbox::validateWebName);
177 $topic = Foswiki::Sandbox::untaint($topic, \&Foswiki::Sandbox::validateTopicName);
178
179 # construct parameters for tag
180 my $params = $theDefault?'"'.$theDefault.'"':'';
181 foreach my $key ($query->param()) {
182 next if $key =~ /^(name|param|render|topic|XForms:Model)$/;
183 my $value = $query->param($key);
184 $params .= ' '.$key.'="'.$value.'" ';
185 }
186
187 # create TML expression
188 my $tml = '%'.$theTag;
189 $tml .= '{'.$params.'}' if $params;
190 $tml .= '%';
191
192 #writeDebug("tml=$tml");
193
194 # and render it
195 my $result = Foswiki::Func::expandCommonVariables($tml, $topic, $web) || ' ';
196 if ($theRender) {
197 $result = Foswiki::Func::renderText($result, $web);
198 }
199
200 #writeDebug("result=$result");
201
202 my $contentType = $query->param("contenttype");
203 $session->writeCompletePage($result, undef, $contentType);
204
205 return;
206}
207
20814µs1;