From: Peter T. <pet...@us...> - 2001-07-14 10:04:19
|
Update of /cvsroot/twiki/twiki/lib/TWiki/Plugins In directory usw-pr-cvs1:/tmp/cvs-serv15421/TWiki/Plugins Modified Files: DefaultPlugin.pm EmptyPlugin.pm Log Message: Codev.SimplerPluginInstallation with plug & play Index: DefaultPlugin.pm =================================================================== RCS file: /cvsroot/twiki/twiki/lib/TWiki/Plugins/DefaultPlugin.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** DefaultPlugin.pm 2001/05/27 21:28:15 1.3 --- DefaultPlugin.pm 2001/07/14 10:04:17 1.4 *************** *** 32,43 **** # initPlugin is required, all other are optional. # For increased performance, DISABLE handlers you don't need. # ========================= package TWiki::Plugins::DefaultPlugin; # ========================= ! use vars qw( $web $topic $user $installWeb $VERSION ! $doOldInclude $renderingWeb ); $VERSION = '1.000'; # ========================= sub initPlugin --- 32,52 ---- # initPlugin is required, all other are optional. # For increased performance, DISABLE handlers you don't need. + # + # NOTE: To interact with TWiki use the official TWiki functions + # in the &TWiki::Func module. Do not reference any functions or + # variables elsewhere in TWiki!! + # ========================= package TWiki::Plugins::DefaultPlugin; # ========================= ! use vars qw( ! $web $topic $user $installWeb $VERSION $debug ! $doOldInclude $renderingWeb ! ); ! $VERSION = '1.000'; + # ========================= sub initPlugin *************** *** 45,54 **** ( $topic, $web, $user, $installWeb ) = @_; $renderingWeb = $web; ! # Get preferences ! $doOldInclude = &TWiki::Prefs::getPreferencesFlag( "DEFAULTPLUGIN_OLDINCLUDE" ) || ""; ! ! # Initialized return 1; } --- 54,73 ---- ( $topic, $web, $user, $installWeb ) = @_; + # check for Plugins.pm versions + if( $TWiki::Plugins::VERSION < 1 ) { + &TWiki::Func::writeWarning( "Version mismatch between DefaultPlugin and Plugins.pm" ); + return 0; + } + + # Get plugin preferences + $doOldInclude = &TWiki::Func::getPreferencesFlag( "DEFAULTPLUGIN_OLDINCLUDE" ) || ""; + + # Get plugin debug flag + $debug = &TWiki::Func::getPreferencesFlag( "DEFAULTPLUGIN_DEBUG" ); + $renderingWeb = $web; ! # Plugin correctly initialized ! &TWiki::Func::writeDebug( "- DefaultPlugin::initPlugin( $web.$topic ) is OK" ) if $debug; return 1; } *************** *** 59,63 **** ### my ( $text, $topic, $web ) = @_; # do not uncomment, use $_[0], $_[1]... instead ! # print "DefaultPlugin::commonTagsHandler called<br>"; # This is the place to define customized tags and variables --- 78,82 ---- ### my ( $text, $topic, $web ) = @_; # do not uncomment, use $_[0], $_[1]... instead ! &TWiki::Func::writeDebug( "- DefaultPlugin::commonTagsHandler( $web.$topic )" ) if $debug; # This is the place to define customized tags and variables *************** *** 80,84 **** ### my ( $text, $web ) = @_; # do not uncomment, use $_[0], $_[1] instead ! # print "DefaultPlugin::startRenderingHandler called<br>"; # This handler is called by getRenderedVersion just before the line loop --- 99,103 ---- ### my ( $text, $web ) = @_; # do not uncomment, use $_[0], $_[1] instead ! &TWiki::Func::writeDebug( "- DefaultPlugin::startRenderingHandler( $web.$topic )" ) if $debug; # This handler is called by getRenderedVersion just before the line loop *************** *** 92,96 **** ### my ( $text ) = @_; # do not uncomment, use $_[0] instead ! # print "DefaultPlugin::outsidePREHandler called<br>"; # This handler is called by getRenderedVersion, in loop outside of <PRE> tag --- 111,115 ---- ### my ( $text ) = @_; # do not uncomment, use $_[0] instead ! &TWiki::Func::writeDebug( "- DefaultPlugin::outsidePREHandler( $web.$topic )" ) if $debug; # This handler is called by getRenderedVersion, in loop outside of <PRE> tag *************** *** 118,126 **** # ========================= ! sub DISABLEinsidePREHandler { ### my ( $text ) = @_; # do not uncomment, use $_[0] instead ! # print "DefaultPlugin::insidePREHandler called<br>"; # This handler is called by getRenderedVersion, in loop inside of <PRE> tag --- 137,145 ---- # ========================= ! sub DISABLE_insidePREHandler { ### my ( $text ) = @_; # do not uncomment, use $_[0] instead ! &TWiki::Func::writeDebug( "- DefaultPlugin::insidePREHandler( $web.$topic )" ) if $debug; # This handler is called by getRenderedVersion, in loop inside of <PRE> tag *************** *** 132,140 **** # ========================= ! sub DISABLEendRenderingHandler { ### my ( $text ) = @_; # do not uncomment, use $_[0] instead ! # print "DefaultPlugin::endRenderingHandler called<br>"; # This handler is called by getRenderedVersion just after the line loop --- 151,159 ---- # ========================= ! sub DISABLE_endRenderingHandler { ### my ( $text ) = @_; # do not uncomment, use $_[0] instead ! &TWiki::Func::writeDebug( "- DefaultPlugin::endRenderingHandler( $web.$topic )" ) if $debug; # This handler is called by getRenderedVersion just after the line loop Index: EmptyPlugin.pm =================================================================== RCS file: /cvsroot/twiki/twiki/lib/TWiki/Plugins/EmptyPlugin.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** EmptyPlugin.pm 2001/05/27 21:28:15 1.3 --- EmptyPlugin.pm 2001/07/14 10:04:17 1.4 *************** *** 31,114 **** # # initPlugin is required, all other are optional. ! # For increased performance, DISABLE (or comment) handlers you don't need. # ========================= package TWiki::Plugins::EmptyPlugin; # change the package name!!! # ========================= ! use vars qw( $web $topic $user $installWeb $VERSION ! $myConfigVar ); $VERSION = '1.000'; # ========================= sub initPlugin { ( $topic, $web, $user, $installWeb ) = @_; ! # Get plugin preferences ! $myConfigVar = &TWiki::Prefs::getPreferencesFlag( "EMPTYPLUGIN_VAR1" ) || ""; - # check for TWiki.pm and Plugins.pm versions - if ( $TWiki::VERSION < 1 || - $TWiki::Plugins::VERSION < 1 ) { - return 0; - }; - # Plugin correctly initialized return 1; } # ========================= ! sub commonTagsHandler { ### my ( $text, $topic, $web ) = @_; # do not uncomment, use $_[0], $_[1]... instead ! # print "DefaultPlugin::commonTagsHandler called<br>"; # This is the place to define customized tags and variables # Called by sub handleCommonTags, after %INCLUDE:"..."% } # ========================= ! sub startRenderingHandler { ### my ( $text, $web ) = @_; # do not uncomment, use $_[0], $_[1] instead ! # print "DefaultPlugin::startRenderingHandler called<br>"; # This handler is called by getRenderedVersion just before the line loop } # ========================= ! sub outsidePREHandler { ### my ( $text ) = @_; # do not uncomment, use $_[0] instead ! # print "DefaultPlugin::outsidePREHandler called<br>"; ! # This handler is called by getRenderedVersion, in loop outside of <PRE> tag ! # This is the place to define customized rendering rules ! } # ========================= ! sub insidePREHandler { ### my ( $text ) = @_; # do not uncomment, use $_[0] instead - - # print "DefaultPlugin::insidePREHandler called<br>"; ! # This handler is called by getRenderedVersion, in loop inside of <PRE> tag ! # This is the place to define customized rendering rules } # ========================= ! sub endRenderingHandler { ### my ( $text ) = @_; # do not uncomment, use $_[0] instead ! # print "DefaultPlugin::endRenderingHandler called<br>"; # This handler is called by getRenderedVersion just after the line loop --- 31,136 ---- # # initPlugin is required, all other are optional. ! # For increased performance, all handlers except initPlugin are ! # disabled. To enable a handler remove the leading DISABLE_ from ! # the function name. ! # ! # NOTE: To interact with TWiki use the official TWiki functions ! # in the &TWiki::Func module. Do not reference any functions or ! # variables elsewhere in TWiki!! + # ========================= package TWiki::Plugins::EmptyPlugin; # change the package name!!! # ========================= ! use vars qw( ! $web $topic $user $installWeb $VERSION $debug ! $exampleCfgVar ! ); ! $VERSION = '1.000'; + # ========================= sub initPlugin { ( $topic, $web, $user, $installWeb ) = @_; + + # check for Plugins.pm versions + if( $TWiki::Plugins::VERSION < 1 ) { + &TWiki::Func::writeWarning( "Version mismatch between EmptyPlugin and Plugins.pm" ); + return 0; + } + + # Get plugin preferences, the variable defined by: * Set EXAMPLE = ... + $exampleCfgVar = &TWiki::Prefs::getPreferencesValue( "EMPTYPLUGIN_EXAMPLE" ) || "default"; ! # Get plugin debug flag ! $debug = &TWiki::Func::getPreferencesFlag( "EMPTYPLUGIN_DEBUG" ); # Plugin correctly initialized + &TWiki::Func::writeDebug( "- EmptyPlugin::initPlugin( $web.$topic ) is OK" ) if $debug; return 1; } # ========================= ! sub DISABLE_commonTagsHandler { ### my ( $text, $topic, $web ) = @_; # do not uncomment, use $_[0], $_[1]... instead ! &TWiki::Func::writeDebug( "- EmptyPlugin::commonTagsHandler( $web.$topic )" ) if $debug; # This is the place to define customized tags and variables # Called by sub handleCommonTags, after %INCLUDE:"..."% + # do custom extension rule, like for example: + # $_[0] =~ s/%XYZ%/&handleXyz()/geo; + # $_[0] =~ s/%XYZ{(.*?)}%/&handleXyz($1)/geo; } # ========================= ! sub DISABLE_startRenderingHandler { ### my ( $text, $web ) = @_; # do not uncomment, use $_[0], $_[1] instead ! &TWiki::Func::writeDebug( "- EmptyPlugin::startRenderingHandler( $web.$topic )" ) if $debug; # This handler is called by getRenderedVersion just before the line loop + # do custom extension rule, like for example: + # $_[0] =~ s/old/new/go; } # ========================= ! sub DISABLE_outsidePREHandler { ### my ( $text ) = @_; # do not uncomment, use $_[0] instead ! # &TWiki::Func::writeDebug( "- EmptyPlugin::outsidePREHandler( $web.$topic )" ) if $debug; ! # This handler is called by getRenderedVersion, in loop outside of <PRE> tag. ! # This is the place to define customized rendering rules. ! # Note: This is an expensive function to comment out. ! # Consider startRenderingHandler instead } # ========================= ! sub DISABLE_insidePREHandler { ### my ( $text ) = @_; # do not uncomment, use $_[0] instead ! # &TWiki::Func::writeDebug( "- EmptyPlugin::insidePREHandler( $web.$topic )" ) if $debug; + # This handler is called by getRenderedVersion, in loop inside of <PRE> tag. + # This is the place to define customized rendering rules. + # Note: This is an expensive function to comment out. + # Consider startRenderingHandler instead } # ========================= ! sub DISABLE_endRenderingHandler { ### my ( $text ) = @_; # do not uncomment, use $_[0] instead ! &TWiki::Func::writeDebug( "- EmptyPlugin::endRenderingHandler( $web.$topic )" ) if $debug; # This handler is called by getRenderedVersion just after the line loop *************** *** 119,122 **** 1; - - --- 141,142 ---- |