Changeset 806
- Timestamp:
- 11/19/08 12:04:24 (3 years ago)
- Location:
- trunk/TWikiCompatibilityPlugin
- Files:
-
- 1 added
- 3 edited
-
data/TWiki/TWikiCompatibilityPlugin.txt (modified) (1 diff)
-
lib/TWiki/Plugins/TWikiCompatibilityPlugin.pm (modified) (6 diffs)
-
lib/TWiki/Plugins/TWikiCompatibilityPlugin/Config.spec (added)
-
lib/TWiki/Plugins/TWikiCompatibilityPlugin/MANIFEST (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/TWikiCompatibilityPlugin/data/TWiki/TWikiCompatibilityPlugin.txt
r805 r806 9 9 10 10 ---++ Usage 11 Automaticalle maps requests for legacy TWiki web topics to Foswiki free topics as per 12 [[http://foswiki.org/Development/TopicNameMappingTable][TopicNameMappingTable]]. 11 13 12 ---++ Examples13 14 14 15 ---++ Installation Instructions -
trunk/TWikiCompatibilityPlugin/lib/TWiki/Plugins/TWikiCompatibilityPlugin.pm
r805 r806 3 3 # This program is free software; you can redistribute it and/or 4 4 # modify it under the terms of the GNU General Public License 5 # as published by the Free Software Foundation; either version 25 # as published by the Free Software Foundation; either version 3 6 6 # of the License, or (at your option) any later version. 7 7 # … … 16 16 ---+ package TWiki::Plugins::TWikiCompatibilityPlugin 17 17 18 To interact with TWiki use ONLY the official API functions19 in the TWiki::Func module. Do not reference any functions or20 variables elsewhere in TWiki, as these are subject to change21 without prior warning, and your plugin may suddenly stop22 working.23 24 For increased performance, all handlers except initPlugin are25 disabled below. *To enable a handler* remove the leading DISABLE_ from26 the function name. For efficiency and clarity, you should comment out or27 delete the whole of handlers you don't use before you release your28 plugin.29 30 __NOTE:__ When developing a plugin it is important to remember that31 TWiki is tolerant of plugins that do not compile. In this case,32 the failure will be silent but the plugin will not be available.33 See [[%SYSTEMWEB%.Plugins#FAILEDPLUGINS]] for error messages.34 35 __NOTE:__ Defining deprecated handlers will cause the handlers to be36 listed in [[%SYSTEMWEB%.Plugins#FAILEDPLUGINS]]. See37 [[%SYSTEMWEB%.Plugins#Handlig_deprecated_functions]]38 for information on regarding deprecated handlers that are defined for39 compatibility with older TWiki versions.40 41 __NOTE:__ When writing handlers, keep in mind that these may be invoked42 on included topics. For example, if a plugin generates links to the current43 topic, these need to be generated before the afterCommonTagsHandler is run,44 as at that point in the rendering loop we have lost the information that we45 the text had been included from another topic.46 18 47 19 =cut … … 55 27 require TWiki::Func; # The plugins API 56 28 require TWiki::Plugins; # For the API version 57 58 # $VERSION is referred to by TWiki, and is the only global variable that59 # *must* exist in this package.60 29 use vars qw( $VERSION $RELEASE $SHORTDESCRIPTION $debug $pluginName $NO_PREFS_IN_TOPIC ); 61 62 # This should always be $Rev$ so that TWiki can determine the checked-in63 # status of the plugin. It is used by the build automation tools, so64 # you should leave it alone.65 30 $VERSION = '$Rev$'; 66 67 # This is a free-form string you can use to "name" your own plugin version. 68 # It is *not* used by the build automation tools, but is reported as part 69 # of the version number in PLUGINDESCRIPTIONS. 70 $RELEASE = 'TWiki-4.2'; 71 72 # Short description of this plugin 73 # One line description, is shown in the %SYSTEMWEB%.TextFormattingRules topic: 31 $RELEASE = 'Foswiki-1.0'; 74 32 $SHORTDESCRIPTION = 'add TWiki personality to Foswiki'; 75 76 # You must set $NO_PREFS_IN_TOPIC to 0 if you want your plugin to use preferences77 # stored in the plugin topic. This default is required for compatibility with78 # older plugins, but imposes a significant performance penalty, and79 # is not recommended. Instead, use $TWiki::cfg entries set in LocalSite.cfg, or80 # if you want the users to be able to change settings, then use standard TWiki81 # preferences that can be defined in your %USERSWEB%.SitePreferences and overridden82 # at the web and topic level.83 33 $NO_PREFS_IN_TOPIC = 1; 84 85 # Name of this Plugin, only used in this module86 34 $pluginName = 'TWikiCompatibilityPlugin'; 87 35 … … 93 41 * =$user= - the login name of the user 94 42 * =$installWeb= - the name of the web the plugin is installed in 95 96 REQUIRED97 98 Called to initialise the plugin. If everything is OK, should return99 a non-zero value. On non-fatal failure, should write a message100 using TWiki::Func::writeWarning and return 0. In this case101 %FAILEDPLUGINS% will indicate which plugins failed.102 103 In the case of a catastrophic failure that will prevent the whole104 installation from working safely, this handler may use 'die', which105 will be trapped and reported in the browser.106 107 You may also call =TWiki::Func::registerTagHandler= here to register108 a function to handle variables that have standard TWiki syntax - for example,109 =%MYTAG{"my param" myarg="My Arg"}%. You can also override internal110 TWiki variable handling functions this way, though this practice is unsupported111 and highly dangerous!112 113 __Note:__ Please align variables names with the Plugin name, e.g. if114 your Plugin is called FooBarPlugin, name variables FOOBAR and/or115 FOOBARSOMETHING. This avoids namespace issues.116 117 43 118 44 =cut … … 127 53 } 128 54 129 # Example code of how to get a preference value, register a variable handler130 # and register a RESTHandler. (remove code you do not need)131 132 # Set plugin preferences in LocalSite.cfg, like this:133 # $TWiki::cfg{Plugins}{TWikiCompatibilityPlugin}{ExampleSetting} = 1;134 # Always provide a default in case the setting is not defined in135 # LocalSite.cfg. See %SYSTEMWEB%.Plugins for help in adding your plugin136 # configuration to the =configure= interface.137 55 my $setting = $TWiki::cfg{Plugins}{TWikiCompatibilityPlugin}{ExampleSetting} || 0; 138 56 $debug = $TWiki::cfg{Plugins}{TWikiCompatibilityPlugin}{Debug} || 0; 139 57 140 # register the _EXAMPLETAG function to handle %EXAMPLETAG{...}%141 # This will be called whenever %EXAMPLETAG% or %EXAMPLETAG{...}% is142 # seen in the topic text.143 58 TWiki::Func::registerTagHandler( 'EXAMPLETAG', \&_EXAMPLETAG ); 144 145 # Allow a sub to be called from the REST interface146 # using the provided alias147 59 TWiki::Func::registerRESTHandler('example', \&restExample); 148 60 149 # Plugin correctly initialized150 61 return 1; 151 62 } … … 174 85 ---++ earlyInitPlugin() 175 86 176 This handler is called before any other handler, and before it has been 177 determined if the plugin is enabled or not. Use it with great care! 178 179 If it returns a non-null error string, the plugin will be disabled. 180 181 =cut 182 183 sub DISABLE_earlyInitPlugin { 184 return undef; 87 If the TWiki web does not exist, change the request to the %SYSTEMWEB% 88 89 This may not be enough for Plugins that do have intopic preferences. 90 91 =cut 92 93 sub earlyInitPlugin { 94 if (($TWiki::Plugins::SESSION->{webName} eq 'TWiki') && 95 (!TWiki::Func::webExists($TWiki::Plugins::SESSION->{webName}))) { 96 my $TWikiWebTopicNameConversion = $TWiki::cfg{Plugins}{TWikiCompatibilityPlugin}{TWikiWebTopicNameConversion}; 97 $TWiki::Plugins::SESSION->{webName} = $TWiki::cfg{SystemWebName}; 98 if (defined($TWikiWebTopicNameConversion->{$TWiki::Plugins::SESSION->{topicName}})) { 99 $TWiki::Plugins::SESSION->{topicName} = 100 $TWikiWebTopicNameConversion->{$TWiki::Plugins::SESSION->{topicName}}; 101 } 102 } 103 my $MainWebTopicNameConversion = $TWiki::cfg{Plugins}{TWikiCompatibilityPlugin}{MainWebTopicNameConversion}; 104 if (($TWiki::Plugins::SESSION->{webName} eq 'Main') && 105 (defined($MainWebTopicNameConversion->{$TWiki::Plugins::SESSION->{topicName}}))) { 106 $TWiki::Plugins::SESSION->{topicName} = 107 $MainWebTopicNameConversion->{$TWiki::Plugins::SESSION->{topicName}}; 108 } 109 110 return; 185 111 } 186 112 -
trunk/TWikiCompatibilityPlugin/lib/TWiki/Plugins/TWikiCompatibilityPlugin/MANIFEST
r805 r806 2 2 data/TWiki/TWikiCompatibilityPlugin.txt 0644 Documentation 3 3 lib/TWiki/Plugins/TWikiCompatibilityPlugin.pm 0644 Perl module 4 lib/TWiki/Plugins/TWikiCompatibilityPlugin/Configu.spec configuration defaults 4 5
Note: See TracChangeset
for help on using the changeset viewer.
