Changeset 13817 for trunk/ImmediateNotifyPlugin/lib/Foswiki/Plugins/ImmediateNotifyPlugin/Twitter.pm
- Timestamp:
- 01/24/12 21:16:27 (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ImmediateNotifyPlugin/lib/Foswiki/Plugins/ImmediateNotifyPlugin/Twitter.pm
r13777 r13817 3 3 =begin TML 4 4 5 ---+ package TweetOnSavePlugin5 ---+ package ImmediateNotifyPlugin 6 6 7 7 =cut 8 8 9 package Foswiki::Plugins:: TweetOnSavePlugin;9 package Foswiki::Plugins::ImmediateNotifyPlugin::Twitter; 10 10 11 11 use strict; 12 12 13 13 require Foswiki::Func; # The plugins API 14 require Foswiki::Plugins; # For the API version15 14 16 15 require Net::Twitter; 17 16 require WWW::Shorten::Bitly; 18 17 19 # $VERSION is referred to by Foswiki, and is the only global variable that20 # *must* exist in this package.21 # This should always be $Rev: 3417 (2009-04-12) $ so that Foswiki can determine the checked-in22 # status of the plugin. It is used by the build automation tools, so23 # you should leave it alone.24 our $VERSION = '$Rev: 3417 (2009-04-12) $';25 26 # This is a free-form string you can use to "name" your own plugin version.27 # It is *not* used by the build automation tools, but is reported as part28 # of the version number in PLUGINDESCRIPTIONS.29 our $RELEASE = '$Date: 2008-12-14 18:49:56 +0100 (Sun, 14 Dec 2008) $';30 31 our $SHORTDESCRIPTION = 'Update status on twitter or compatible network on topic save';32 33 our $NO_PREFS_IN_TOPIC = 1;34 35 our %isNewTopic = ();36 37 our @excludeWebs = ();38 39 =begin TML40 41 ---++ initPlugin($topic, $web, $user) -> $boolean42 * =$topic= - the name of the topic in the current CGI query43 * =$web= - the name of the web in the current CGI query44 * =$user= - the login name of the user45 * =$installWeb= - the name of the web the plugin topic is in46 (usually the same as =$Foswiki::cfg{SystemWebName}=)47 48 =cut49 50 sub initPlugin {51 my( $topic, $web, $user, $installWeb ) = @_;52 53 # check for Plugins.pm versions54 if( $Foswiki::Plugins::VERSION < 2.0 ) {55 Foswiki::Func::writeWarning( 'Version mismatch between ',56 __PACKAGE__, ' and Plugins.pm' );57 return 0;58 }59 60 # $Foswiki::cfg{Plugins}{EmptyPlugin}{ExampleSetting} = 1;61 62 # Optional: See %SYSTEMWEB%.DevelopingPlugins#ConfigSpec for information63 # on integrating your plugin configuration with =configure=.64 65 # Always provide a default in case the setting is not defined in66 # my $setting = $Foswiki::cfg{Plugins}{EmptyPlugin}{ExampleSetting} || 0;67 68 #Foswiki::Func::registerTagHandler( 'EXAMPLETAG', \&_EXAMPLETAG );69 70 #Foswiki::Func::registerRESTHandler('example', \&restExample);71 72 if(defined($Foswiki::cfg{Plugins}{TweetOnSavePlugin}{ExcludeWebs})) {73 @excludeWebs=split(/\s*,\s*/,$Foswiki::cfg{Plugins}{TweetOnSavePlugin}{ExcludeWebs});74 }75 76 # Plugin correctly initialized77 return 1;78 }79 80 # The function used to handle the %EXAMPLETAG{...}% macro81 # You would have one of these for each macro you want to process.82 #sub _EXAMPLETAG {83 # my($session, $params, $theTopic, $theWeb) = @_;84 # # $session - a reference to the Foswiki session object (if you don't know85 # # what this is, just ignore it)86 # # $params= - a reference to a Foswiki::Attrs object containing87 # # parameters.88 # # This can be used as a simple hash that maps parameter names89 # # to values, with _DEFAULT being the name for the default90 # # (unnamed) parameter.91 # # $theTopic - name of the topic in the query92 # # $theWeb - name of the web in the query93 # # Return: the result of processing the macro. This will replace the94 # # macro call in the final text.95 #96 # # For example, %EXAMPLETAG{'hamburger' sideorder="onions"}%97 # # $params->{_DEFAULT} will be 'hamburger'98 # # $params->{sideorder} will be 'onions'99 #}100 101 =begin TML102 103 ---++ earlyInitPlugin()104 105 This handler is called before any other handler, and before it has been106 determined if the plugin is enabled or not. Use it with great care!107 108 If it returns a non-null error string, the plugin will be disabled.109 110 =cut111 112 #sub earlyInitPlugin {113 # return undef;114 #}115 116 =begin TML117 118 ---++ initializeUserHandler( $loginName, $url, $pathInfo )119 * =$loginName= - login name recovered from $ENV{REMOTE_USER}120 * =$url= - request url121 * =$pathInfo= - pathinfo from the CGI query122 Allows a plugin to set the username. Normally Foswiki gets the username123 from the login manager. This handler gives you a chance to override the124 login manager.125 126 Return the *login* name.127 128 This handler is called very early, immediately after =earlyInitPlugin=.129 130 *Since:* Foswiki::Plugins::VERSION = '2.0'131 132 =cut133 134 #sub initializeUserHandler {135 # my ( $loginName, $url, $pathInfo ) = @_;136 #}137 138 =begin TML139 140 ---++ registrationHandler($web, $wikiName, $loginName )141 * =$web= - the name of the web in the current CGI query142 * =$wikiName= - users wiki name143 * =$loginName= - users login name144 145 Called when a new user registers with this Foswiki.146 147 *Since:* Foswiki::Plugins::VERSION = '2.0'148 149 =cut150 151 #sub registrationHandler {152 # my ( $web, $wikiName, $loginName ) = @_;153 #}154 155 =begin TML156 157 ---++ commonTagsHandler($text, $topic, $web, $included, $meta )158 * =$text= - text to be processed159 * =$topic= - the name of the topic in the current CGI query160 * =$web= - the name of the web in the current CGI query161 * =$included= - Boolean flag indicating whether the handler is162 invoked on an included topic163 * =$meta= - meta-data object for the topic MAY BE =undef=164 This handler is called by the code that expands %<nop>MACROS% syntax in165 the topic body and in form fields. It may be called many times while166 a topic is being rendered.167 168 Only plugins that have to parse the entire topic content should implement169 this function. For expanding macros with trivial syntax it is *far* more170 efficient to use =Foswiki::Func::registerTagHandler= (see =initPlugin=).171 172 Internal Foswiki macros, (and any macros declared using173 =Foswiki::Func::registerTagHandler=) are expanded _before_, and then again174 _after_, this function is called to ensure all %<nop>MACROS% are expanded.175 176 *NOTE:* when this handler is called, <verbatim> blocks have been177 removed from the text (though all other blocks such as <pre> and178 <noautolink> are still present).179 180 *NOTE:* meta-data is _not_ embedded in the text passed to this181 handler. Use the =$meta= object.182 183 *Since:* $Foswiki::Plugins::VERSION 2.0184 185 =cut186 187 #sub commonTagsHandler {188 # my ( $text, $topic, $web, $included, $meta ) = @_;189 #190 # # If you don't want to be called from nested includes...191 # # if( $included ) {192 # # # bail out, handler called from an %INCLUDE{}%193 # # return;194 # # }195 #196 # # You can work on $text in place by using the special perl197 # # variable $_[0]. These allow you to operate on $text198 # # as if it was passed by reference; for example:199 # # $_[0] =~ s/SpecialString/my alternative/ge;200 #}201 202 =begin TML203 204 ---++ beforeCommonTagsHandler($text, $topic, $web, $meta )205 * =$text= - text to be processed206 * =$topic= - the name of the topic in the current CGI query207 * =$web= - the name of the web in the current CGI query208 * =$meta= - meta-data object for the topic MAY BE =undef=209 This handler is called before Foswiki does any expansion of its own210 internal variables. It is designed for use by cache plugins. Note that211 when this handler is called, <verbatim> blocks are still present212 in the text.213 214 *NOTE*: This handler is called once for each call to215 =commonTagsHandler= i.e. it may be called many times during the216 rendering of a topic.217 218 *NOTE:* meta-data is _not_ embedded in the text passed to this219 handler.220 221 *NOTE:* This handler is not separately called on included topics.222 223 =cut224 225 #sub beforeCommonTagsHandler {226 # my ( $text, $topic, $web, $meta ) = @_;227 #228 # # You can work on $text in place by using the special perl229 # # variable $_[0]. These allow you to operate on $text230 # # as if it was passed by reference; for example:231 # # $_[0] =~ s/SpecialString/my alternative/ge;232 #}233 234 =begin TML235 236 ---++ afterCommonTagsHandler($text, $topic, $web, $meta )237 * =$text= - text to be processed238 * =$topic= - the name of the topic in the current CGI query239 * =$web= - the name of the web in the current CGI query240 * =$meta= - meta-data object for the topic MAY BE =undef=241 This handler is called after Foswiki has completed expansion of %MACROS%.242 It is designed for use by cache plugins. Note that when this handler243 is called, <verbatim> blocks are present in the text.244 245 *NOTE*: This handler is called once for each call to246 =commonTagsHandler= i.e. it may be called many times during the247 rendering of a topic.248 249 *NOTE:* meta-data is _not_ embedded in the text passed to this250 handler.251 252 =cut253 254 #sub afterCommonTagsHandler {255 # my ( $text, $topic, $web, $meta ) = @_;256 #257 # # You can work on $text in place by using the special perl258 # # variable $_[0]. These allow you to operate on $text259 # # as if it was passed by reference; for example:260 # # $_[0] =~ s/SpecialString/my alternative/ge;261 #}262 263 =begin TML264 265 ---++ preRenderingHandler( $text, \%map )266 * =$text= - text, with the head, verbatim and pre blocks replaced267 with placeholders268 * =\%removed= - reference to a hash that maps the placeholders to269 the removed blocks.270 271 Handler called immediately before Foswiki syntax structures (such as lists) are272 processed, but after all variables have been expanded. Use this handler to273 process special syntax only recognised by your plugin.274 275 Placeholders are text strings constructed using the tag name and a276 sequence number e.g. 'pre1', "verbatim6", "head1" etc. Placeholders are277 inserted into the text inside <!--!marker!--> characters so the278 text will contain <!--!pre1!--> for placeholder pre1.279 280 Each removed block is represented by the block text and the parameters281 passed to the tag (usually empty) e.g. for282 <verbatim>283 <pre class='slobadob'>284 XYZ285 </pre>286 </verbatim>287 the map will contain:288 <pre>289 $removed->{'pre1'}{text}: XYZ290 $removed->{'pre1'}{params}: class="slobadob"291 </pre>292 Iterating over blocks for a single tag is easy. For example, to prepend a293 line number to every line of every pre block you might use this code:294 <verbatim>295 foreach my $placeholder ( keys %$map ) {296 if( $placeholder =~ /^pre/i ) {297 my $n = 1;298 $map->{$placeholder}{text} =~ s/^/$n++/gem;299 }300 }301 </verbatim>302 303 __NOTE__: This handler is called once for each rendered block of text i.e.304 it may be called several times during the rendering of a topic.305 306 *NOTE:* meta-data is _not_ embedded in the text passed to this307 handler.308 309 Since Foswiki::Plugins::VERSION = '2.0'310 311 =cut312 313 #sub preRenderingHandler {314 # my( $text, $pMap ) = @_;315 #316 # # You can work on $text in place by using the special perl317 # # variable $_[0]. These allow you to operate on $text318 # # as if it was passed by reference; for example:319 # # $_[0] =~ s/SpecialString/my alternative/ge;320 #}321 322 =begin TML323 324 ---++ postRenderingHandler( $text )325 * =$text= - the text that has just been rendered. May be modified in place.326 327 *NOTE*: This handler is called once for each rendered block of text i.e.328 it may be called several times during the rendering of a topic.329 330 *NOTE:* meta-data is _not_ embedded in the text passed to this331 handler.332 333 Since Foswiki::Plugins::VERSION = '2.0'334 335 =cut336 337 #sub postRenderingHandler {338 # my $text = shift;339 # # You can work on $text in place by using the special perl340 # # variable $_[0]. These allow you to operate on $text341 # # as if it was passed by reference; for example:342 # # $_[0] =~ s/SpecialString/my alternative/ge;343 #}344 345 =begin TML346 347 ---++ beforeEditHandler($text, $topic, $web )348 * =$text= - text that will be edited349 * =$topic= - the name of the topic in the current CGI query350 * =$web= - the name of the web in the current CGI query351 This handler is called by the edit script just before presenting the edit text352 in the edit box. It is called once when the =edit= script is run.353 354 *NOTE*: meta-data may be embedded in the text passed to this handler355 (using %META: tags)356 357 *Since:* Foswiki::Plugins::VERSION = '2.0'358 359 =cut360 361 #sub beforeEditHandler {362 # my ( $text, $topic, $web ) = @_;363 #364 # # You can work on $text in place by using the special perl365 # # variable $_[0]. These allow you to operate on $text366 # # as if it was passed by reference; for example:367 # # $_[0] =~ s/SpecialString/my alternative/ge;368 #}369 370 =begin TML371 372 ---++ afterEditHandler($text, $topic, $web, $meta )373 * =$text= - text that is being previewed374 * =$topic= - the name of the topic in the current CGI query375 * =$web= - the name of the web in the current CGI query376 * =$meta= - meta-data for the topic.377 This handler is called by the preview script just before presenting the text.378 It is called once when the =preview= script is run.379 380 *NOTE:* this handler is _not_ called unless the text is previewed.381 382 *NOTE:* meta-data is _not_ embedded in the text passed to this383 handler. Use the =$meta= object.384 385 *Since:* $Foswiki::Plugins::VERSION 2.0386 387 =cut388 389 #sub afterEditHandler {390 # my ( $text, $topic, $web ) = @_;391 #392 # # You can work on $text in place by using the special perl393 # # variable $_[0]. These allow you to operate on $text394 # # as if it was passed by reference; for example:395 # # $_[0] =~ s/SpecialString/my alternative/ge;396 #}397 398 =begin TML399 400 ---++ beforeSaveHandler($text, $topic, $web, $meta )401 * =$text= - text _with embedded meta-data tags_402 * =$topic= - the name of the topic in the current CGI query403 * =$web= - the name of the web in the current CGI query404 * =$meta= - the metadata of the topic being saved, represented by a Foswiki::Meta object.405 406 This handler is called each time a topic is saved.407 408 *NOTE:* meta-data is embedded in =$text= (using %META: tags). If you modify409 the =$meta= object, then it will override any changes to the meta-data410 embedded in the text. Modify *either* the META in the text *or* the =$meta=411 object, never both. You are recommended to modify the =$meta= object rather412 than the text, as this approach is proof against changes in the embedded413 text format.414 415 *Since:* Foswiki::Plugins::VERSION = 2.0416 417 =cut418 419 sub beforeSaveHandler {420 my ( $text, $topic, $web, $meta ) = @_;421 422 if ( Foswiki::Func::topicExists($web, $topic) ) {423 $isNewTopic{$$}=0;424 } else {425 $isNewTopic{$$}=1;426 }427 # You can work on $text in place by using the special perl428 # variable $_[0]. These allow you to operate on $text429 # as if it was passed by reference; for example:430 # $_[0] =~ s/SpecialString/my alternative/ge;431 }432 18 433 19 =begin TML … … 459 45 return if(grep(/^$web$/,@excludeWebs)); 460 46 461 my $tweet=$Foswiki::cfg{Plugins}{ TweetOnSavePlugin}{Template} || '$user $action topic $web.$topic $url';47 my $tweet=$Foswiki::cfg{Plugins}{ImmediateNotifyPlugin}{Template} || '$user $action topic $web.$topic $url'; 462 48 463 49 my $action='saved'; … … 468 54 # only shorten url if url is actually used 469 55 my $url=Foswiki::Func::getViewUrl($web,$topic); 470 if( ($tweet=~/\$url/) and (defined($Foswiki::cfg{Plugins}{ TweetOnSavePlugin}{BitlyUser})) ) {56 if( ($tweet=~/\$url/) and (defined($Foswiki::cfg{Plugins}{ImmediateNotifyPlugin}{BitlyUser})) ) { 471 57 $url=WWW::Shorten::Bitly::makeashorterlink( 472 58 $url, 473 $Foswiki::cfg{Plugins}{ TweetOnSavePlugin}{BitlyUser},474 $Foswiki::cfg{Plugins}{ TweetOnSavePlugin}{BitlyKey}59 $Foswiki::cfg{Plugins}{ImmediateNotifyPlugin}{BitlyUser}, 60 $Foswiki::cfg{Plugins}{ImmediateNotifyPlugin}{BitlyKey} 475 61 ); 476 62 } … … 486 72 my $twitter = Net::Twitter->new( 487 73 traits => [qw/API::REST/], 488 username => $Foswiki::cfg{Plugins}{ TweetOnSavePlugin}{StatusUser},489 password => $Foswiki::cfg{Plugins}{ TweetOnSavePlugin}{StatusPassword}74 username => $Foswiki::cfg{Plugins}{ImmediateNotifyPlugin}{StatusUser}, 75 password => $Foswiki::cfg{Plugins}{ImmediateNotifyPlugin}{StatusPassword} 490 76 ); 491 77 … … 496 82 } 497 83 498 =begin TML499 500 ---++ afterRenameHandler( $oldWeb, $oldTopic, $oldAttachment, $newWeb, $newTopic, $newAttachment )501 502 * =$oldWeb= - name of old web503 * =$oldTopic= - name of old topic (empty string if web rename)504 * =$oldAttachment= - name of old attachment (empty string if web or topic rename)505 * =$newWeb= - name of new web506 * =$newTopic= - name of new topic (empty string if web rename)507 * =$newAttachment= - name of new attachment (empty string if web or topic rename)508 509 This handler is called just after the rename/move/delete action of a web, topic or attachment.510 511 *Since:* Foswiki::Plugins::VERSION = '2.0'512 513 =cut514 515 #sub afterRenameHandler {516 # my ( $oldWeb, $oldTopic, $oldAttachment,517 # $newWeb, $newTopic, $newAttachment ) = @_;518 #}519 520 =begin TML521 522 ---++ beforeAttachmentSaveHandler(\%attrHash, $topic, $web )523 * =\%attrHash= - reference to hash of attachment attribute values524 * =$topic= - the name of the topic in the current CGI query525 * =$web= - the name of the web in the current CGI query526 This handler is called once when an attachment is uploaded. When this527 handler is called, the attachment has *not* been recorded in the database.528 529 The attributes hash will include at least the following attributes:530 * =attachment= => the attachment name531 * =comment= - the comment532 * =user= - the user id533 * =tmpFilename= - name of a temporary file containing the attachment data534 535 *Since:* Foswiki::Plugins::VERSION = 2.0536 537 =cut538 539 #sub beforeAttachmentSaveHandler {540 # my( $attrHashRef, $topic, $web ) = @_;541 #}542 543 =begin TML544 545 ---++ afterAttachmentSaveHandler(\%attrHash, $topic, $web, $error )546 * =\%attrHash= - reference to hash of attachment attribute values547 * =$topic= - the name of the topic in the current CGI query548 * =$web= - the name of the web in the current CGI query549 * =$error= - any error string generated during the save process550 This handler is called just after the save action. The attributes hash551 will include at least the following attributes:552 * =attachment= => the attachment name553 * =comment= - the comment554 * =user= - the user id555 556 *Since:* Foswiki::Plugins::VERSION = 2.0557 558 =cut559 560 #sub afterAttachmentSaveHandler {561 # my( $attrHashRef, $topic, $web ) = @_;562 #}563 564 =begin TML565 566 ---++ mergeHandler( $diff, $old, $new, \%info ) -> $text567 Try to resolve a difference encountered during merge. The =differences=568 array is an array of hash references, where each hash contains the569 following fields:570 * =$diff= => one of the characters '+', '-', 'c' or ' '.571 * '+' - =new= contains text inserted in the new version572 * '-' - =old= contains text deleted from the old version573 * 'c' - =old= contains text from the old version, and =new= text574 from the version being saved575 * ' ' - =new= contains text common to both versions, or the change576 only involved whitespace577 * =$old= => text from version currently saved578 * =$new= => text from version being saved579 * =\%info= is a reference to the form field description { name, title,580 type, size, value, tooltip, attributes, referenced }. It must _not_581 be wrtten to. This parameter will be undef when merging the body582 text of the topic.583 584 Plugins should try to resolve differences and return the merged text.585 For example, a radio button field where we have586 ={ diff=>'c', old=>'Leafy', new=>'Barky' }= might be resolved as587 ='Treelike'=. If the plugin cannot resolve a difference it should return588 undef.589 590 The merge handler will be called several times during a save; once for591 each difference that needs resolution.592 593 If any merges are left unresolved after all plugins have been given a594 chance to intercede, the following algorithm is used to decide how to595 merge the data:596 1 =new= is taken for all =radio=, =checkbox= and =select= fields to597 resolve 'c' conflicts598 1 '+' and '-' text is always included in the the body text and text599 fields600 1 =<del>conflict</del> <ins>markers</ins>= are used to601 mark 'c' merges in text fields602 603 The merge handler is called whenever a topic is saved, and a merge is604 required to resolve concurrent edits on a topic.605 606 *Since:* Foswiki::Plugins::VERSION = 2.0607 608 =cut609 610 #sub mergeHandler {611 # my ( $diff, $old, $new, $info ) = @_;612 #}613 614 =begin TML615 616 ---++ modifyHeaderHandler( \%headers, $query )617 * =\%headers= - reference to a hash of existing header values618 * =$query= - reference to CGI query object619 Lets the plugin modify the HTTP headers that will be emitted when a620 page is written to the browser. \%headers= will contain the headers621 proposed by the core, plus any modifications made by other plugins that also622 implement this method that come earlier in the plugins list.623 <verbatim>624 $headers->{expires} = '+1h';625 </verbatim>626 627 Note that this is the HTTP header which is _not_ the same as the HTML628 <HEAD> tag. The contents of the <HEAD> tag may be manipulated629 using the =Foswiki::Func::addToHEAD= method.630 631 *Since:* Foswiki::Plugins::VERSION 2.0632 633 =cut634 635 #sub modifyHeaderHandler {636 # my ( $headers, $query ) = @_;637 #}638 639 =begin TML640 641 ---++ redirectCgiQueryHandler($query, $url )642 * =$query= - the CGI query643 * =$url= - the URL to redirect to644 645 This handler can be used to replace Foswiki's internal redirect function.646 647 If this handler is defined in more than one plugin, only the handler648 in the earliest plugin in the INSTALLEDPLUGINS list will be called. All649 the others will be ignored.650 651 *Since:* Foswiki::Plugins::VERSION 2.0652 653 =cut654 655 #sub redirectCgiQueryHandler {656 # my ( $query, $url ) = @_;657 #}658 659 =begin TML660 661 ---++ renderFormFieldForEditHandler($name, $type, $size, $value, $attributes, $possibleValues) -> $html662 663 This handler is called before built-in types are considered. It generates664 the HTML text rendering this form field, or false, if the rendering665 should be done by the built-in type handlers.666 * =$name= - name of form field667 * =$type= - type of form field (checkbox, radio etc)668 * =$size= - size of form field669 * =$value= - value held in the form field670 * =$attributes= - attributes of form field671 * =$possibleValues= - the values defined as options for form field, if672 any. May be a scalar (one legal value) or a ref to an array673 (several legal values)674 675 Return HTML text that renders this field. If false, form rendering676 continues by considering the built-in types.677 678 *Since:* Foswiki::Plugins::VERSION 2.0679 680 Note that you can also extend the range of available681 types by providing a subclass of =Foswiki::Form::FieldDefinition= to implement682 the new type (see =Foswiki::Extensions.JSCalendarContrib= and683 =Foswiki::Extensions.RatingContrib= for examples). This is the preferred way to684 extend the form field types.685 686 =cut687 688 #sub renderFormFieldForEditHandler {689 # my ( $name, $type, $size, $value, $attributes, $possibleValues) = @_;690 #}691 692 =begin TML693 694 ---++ renderWikiWordHandler($linkText, $hasExplicitLinkLabel, $web, $topic) -> $linkText695 * =$linkText= - the text for the link i.e. for =[<nop>[Link][blah blah]]=696 it's =blah blah=, for =BlahBlah= it's =BlahBlah=, and for [[Blah Blah]] it's =Blah Blah=.697 * =$hasExplicitLinkLabel= - true if the link is of the form =[<nop>[Link][blah blah]]= (false if it's ==<nop>[Blah]] or =BlahBlah=)698 * =$web=, =$topic= - specify the topic being rendered699 700 Called during rendering, this handler allows the plugin a chance to change701 the rendering of labels used for links.702 703 Return the new link text.704 705 *Since:* Foswiki::Plugins::VERSION 2.0706 707 =cut708 709 #sub renderWikiWordHandler {710 # my( $linkText, $hasExplicitLinkLabel, $web, $topic ) = @_;711 # return $linkText;712 #}713 714 =begin TML715 716 ---++ completePageHandler($html, $httpHeaders)717 718 This handler is called on the ingredients of every page that is719 output by the standard CGI scripts. It is designed primarily for use by720 cache and security plugins.721 * =$html= - the body of the page (normally <html>..$lt;/html>)722 * =$httpHeaders= - the HTTP headers. Note that the headers do not contain723 a =Content-length=. That will be computed and added immediately before724 the page is actually written. This is a string, which must end in \n\n.725 726 *Since:* Foswiki::Plugins::VERSION 2.0727 728 =cut729 730 #sub completePageHandler {731 # my( $html, $httpHeaders ) = @_;732 # # modify $_[0] or $_[1] if you must change the HTML or headers733 # # You can work on $html and $httpHeaders in place by using the734 # # special perl variables $_[0] and $_[1]. These allow you to operate735 # # on parameters as if they were passed by reference; for example:736 # # $_[0] =~ s/SpecialString/my alternative/ge;737 #}738 739 =begin TML740 741 ---++ restExample($session) -> $text742 743 This is an example of a sub to be called by the =rest= script. The parameter is:744 * =$session= - The Foswiki object associated to this session.745 746 Additional parameters can be recovered via de query object in the $session.747 748 For more information, check %SYSTEMWEB%.CommandAndCGIScripts#rest749 750 For information about handling error returns from REST handlers, see751 Foswiki::Support.Faq1752 753 *Since:* Foswiki::Plugins::VERSION 2.0754 755 =cut756 757 #sub restExample {758 # my ($session) = @_;759 # return "This is an example of a REST invocation\n\n";760 #}761 84 762 85 1;
Note: See TracChangeset
for help on using the changeset viewer.
