|  |  TWiki Plugins  | 
|
| < <
 | Plug-in enhanced feature add-ons, with a Plugin API for developers | 
| > >
 | Add functionality to TWiki with readily available Plugins; create Plugins based on APIs | 
|  |  Overview  | 
|
| < <
 | You can add Plugins to extend TWiki's functionality, without altering the core program code. A plug-in approach lets you: | 
| > >
 | You can add Plugins to extend TWiki functionality, without altering the core code. A plug-in approach lets you: | 
|  | 
 add virtually unlimited features while keeping the main TWiki code compact and efficient;
 heavily customize an installation and still do clean updates to new versions of TWiki;
 | 
|  | Everything to do with TWiki Plugins - demos, new releases, downloads, development, general discussion - is available at TWiki.org, in the  TWiki:Plugins  web. | 
|
| < <
 |  Preinstalled Plugins  | 
| > >
 | TWiki Plugins are developed and contributed by interested members of the community. Plugins are provided on an 'as is' basis; they are not a part of TWiki, but are independently developed and maintained. | 
|  |  | 
|
| < <
 | TWiki comes with a set of Plugins as part of the standard installation. 
 DefaultPlugin: Optionally handles some legacy variables from older versions of TWiki. You can control this option from TWikiPreferences. (Perl programmers can also add rules for simple custom processing.)
 EmptyPlugin: Is a fully functional module, minus active code; it does nothing and serves as a template for new Plugin development
 CommentPlugin: %COMMENTPLUGIN_SHORTDESCRIPTION%
 InterwikiPlugin: Use it for shorthand linking to remote sites, ex: TWiki:Pluginsexpands to TWiki:Plugins on TWiki.org. You can edit the predefined set of of Wiki-related sites, and add your own EditTablePlugin: Edit TWiki tables using edit fields, date pickers and drop down boxes
 RenderListPlugin: %RENDERLISTPLUGIN_SHORTDESCRIPTION%
 SlideShowPlugin: Create web based presentations based on topics with headings.
 SmiliesPlugin: Render smilies as icons, like  :-) as or  :eek: as  SpreadSheetPlugin: Add spreadsheet calculation like "$SUM( $ABOVE() )"to TWiki tables or anywhere in topic text TablePlugin: Control attributes of tables and sorting of table columns
 | 
| > >
 |  Tip: TWiki:TWiki.TWikiPluginsSupplement  on TWiki.org has supplemental documentation on TWiki Plugins. | 
|  |  Installing Plugins  | 
|
| < <
 | Each TWikiPlugin comes with full documentation: step-by-step installation instructions, a detailed description of any special requirements, version details, and a working example for testing. | 
| > >
 | Each TWiki Plugin comes with its own documentation: step-by-step installation instructions, a detailed description of any special requirements, version details, and a working example for testing. Many Plugins have an install script that automates these steps for you.
Special Requirements: Some Plugins need certain Perl modules to be preinstalled on the host system. Plugins may also use other resources, like graphics, other modules, applications, and templates. You should be able to find detailed instructions in the Plugin's documentation. | 
|  |  | 
|
| < <
 | Most Plugins can be installed in three easy steps, with no programming skills required: 
Special Requests: Some Plugins need certain Perl modules to be preinstalled on the host system. Plugins may also use other resources, like graphics, other modules, applications, templates. In these cases, detailed instructions are in the Plugin documentation.
Each Plugin has a standard release page, located in the TWiki:Plugins Download the zip file containing the Plugin, documentation, and any other required files, from TWiki:Plugins . Distribute the files to their proper locations - unzip the zip archive in your TWiki installation directory - if have a standard TWiki installation, this will distribute automatically. Otherwise, place the files according to the directory paths listed on the Plugin top in TWiki:Plugins . Check the demo example on the Plugin topic: if it's working, the installation was fine!
  web at TWiki.org. In addition to the documentation topic ( SomePlugin), there's a separate development page.
 Doc page: Read all available info about the Plugin; download the attached distribution files.
 Dev page: Post feature requests, bug reports and general dev comments; topic title ends in Dev(SomePluginDev). User support: Post installation, how to use type questions (and answers, if you have them) in the TWiki:Support web. | 
| > >
 | Each Plugin has a standard release topic, located in the TWiki:Plugins  web at TWiki.org. There's usually a number of other related topics, such as a developers page, and an appraisal page. | 
|  |  On-Site Pretesting  | 
|
| < <
 | To test new Plugins on your installation before making them public, you may want to use one of these two approaches: 
 Method 1: Safely test on-the-fly by creating separate Production and Test branches in your live TWiki installation.  
 Duplicate the twiki/binandtwiki/libdirectories for the Test version, and adjust the paths in the newlib/TWiki.cfg.  The following directories are shared:twiki/data,twiki/templatesandtwiki/pub. Test Plugins and other new features in the Test installation until you're satisfied. 
  If you modify topics using the new features, live users will likely see unfamiliar new META tags showing up on their pages - to avoid this, create and edit test-only topics to try out new features. Copy the modified files to the Production installation. You can update a TWiki installation live and users won't even notice.
 | 
| > >
 | The recommended approach to testing new Plugins before making them public is to create a second local TWiki installation, and test the Plugin there. You can allow selected users access to the test area. Once you are satisifed that it won't compromise your main installation, you can install it there as well. | 
|  |  | 
|
| < <
 | 
 Method 2: List the Plugin being tested in the DISABLEDPLUGINSvariable in TWikiPreferences. Redefine theDISABLEDPLUGINSvariable in theSandboxweb and do the testing there. | 
| > >
 | InstalledPlugins shows which Plugins are: 1) installed, 2) loading properly, and 3) what TWiki:Codev.PluginHandlers  they invoke. Any failures are shown in the Errors section. The %FAILEDPLUGINS%variable can be used to debug failures. You may also want to check your webserver error log and the various TWiki log files. | 
|  |  | 
|
| < <
 |  Checking that Plugins are Working on a Live Server  | 
| > >
 |  Some Notes on Plugin Performance  | 
|  |  | 
|
| < <
 | InstalledPlugins shows which Plugins are: 1) installed, 2) loading properly and 3) what TWiki:Codev.PluginHandlers  they invoke. Any failures are shown in the Errors section. | 
| > >
 | The performance of the system depends to some extent on the number of Plugins installed and on the Plugin implementation. Some Plugins impose no measurable performance decrease, some do. For example, a Plugin might use many Perl libraries that need to be initialized with each page view (unless you run mod_perl). You can only really tell the performance impact by installing the Plugin and by measuring the performance with and without the new Plugin. Use the TWiki:Plugins.PluginBenchmarkAddOn  , or test manually with the Apache abutility. Example on Unix:
 time wget -qO /dev/null /twiki/bin/view/TWiki/AbcPlugin | 
|  |  | 
|
| < <
 |  A Note on Plugin Performance  | 
| > >
 |  If you need to install an "expensive" Plugin, and you need its functionality only in one web, you can place the Plugin topic into that web. TWiki will initialize the Plugin only if the Plugin topic is found (which won't be the case for other webs.) | 
|  |  | 
|
| < <
 | The performance of the system depends on the number of Plugins installed and on the Plugin implementation. Some Plugins impose no measurable performance decrease, some do. For example, outsidePREHandleris an expensive callback function, or a Plugin might use many Perl libraries that need to be initialized with each page view (unless you run mod_perl). It is recommended to measure the performance with and without a new Plugin. Example for Unix:
 time wget -qO /dev/null https://obelix.beims.me/twiki/bin/view/TWiki/AbcPlugin | 
| > >
 |  Managing Installed Plugins  | 
|  |  | 
|
| < <
 | In case you need to install an "expensive" Plugin and you need its functionality only in one web you can place the Plugin topic into that web. TWiki will initialize the Plugin only if the Plugin topic is found (which won't be the case for other webs.) | 
| > >
 | Some Plugins require additional settings or offer extra options that you have to select. Also, you may want to make a Plugin available only in certain webs, or temporarily disable it. And may want to list all available Plugins in certain topics. You can handle all of these management tasks with simple procedures: | 
|  |  | 
|
| < <
 |  Managing Plugins  | 
| > >
 |  Enabling Plugins  | 
|  |  | 
|
| < <
 | When you finish installing a Plugin, you should be able to read the user instructions and go. In fact, some Plugins require additional settings or offer extra options that you have to select. Also, you may want to make a Plugin available only in certain webs, or temporarily disable it. And may want to list all available Plugins in certain topics. You can handle all of these management tasks with simple procedures. | 
| > >
 | Plugins can be enabled and disabled with the configure script. An installed Plugin needs to be enabled before it can be used. | 
|  |  | 
|
| < <
 |  Setting Preferences  | 
| > >
 |  Plugin Evaluation Order  | 
|  |  | 
|
| < <
 | Installed Plugins can be toggled on or off, site-wide or by web, through TWikiPreferences and individual WebPreferences: | 
| > >
 | By default, TWiki executes Plugins in alphabetical order on Plugin name. It is possible to change the order, for example to evaluate database variables before the speadsheet CALCs. This can be done with {PluginsOrder}in the Plugins section of configure. | 
|  |  | 
|
| < <
 | 
 All Plugin modules present in the lib/TWiki/Pluginsdirectory are activated automatically unless disabled by theDISABLEDPLUGINSPreferences variable in TWikiPreferences. You can optionally list the installed Plugins in theINSTALLEDPLUGINSPreferences variable. This is useful to define the sequence of Plugin execution, or to specify other webs than the TWiki web for the Plugin topics. Settings in TWikiPreferences are:
 Set INSTALLEDPLUGINS = DefaultPlugin, ... Set DISABLEDPLUGINS = EmptyPlugin, ... | 
| > >
 |  Plugin-Specific Settings  | 
|  |  | 
|
| < <
 | Plugin execution order in TWiki is determined by searching Plugin topics in a specific sequence: First, full web.topicnamename, if specified inINSTALLEDPLUGINS; next, the TWiki web is searched; and finally, the current web.
Plugin-specific settings are done in individual Plugin topics. Two settings are standard for each Plugin: | 
| > >
 | Plugin-specific settings are done in individual Plugin topics. Two settings are standard for each Plugin: | 
|  | 
 One line description, used to form the bullets describing the Plugins in the TextFormattingRules topic:
 | 
|
| < <
 | 
 
 
 Set SHORTDESCRIPTION = Blah blah woof woof. | 
| > >
 | 
 
 
 Set SHORTDESCRIPTION = Create dynamic foo bar reports | 
|  | 
 Debug Plugin, output can be seen in data/debug.txt. Set to 0=off or 1=on: | 
|
| < <
 | 
 The settings can be retrieved as Preferences variables like %<pluginname>_<var>%, ex:%DEFAULTPLUGIN_SHORTDESCRIPTION%shows the description of the DefaultPlugin. | 
| > >
 | 
 The settings can be retrieved as Preferences variables like %<pluginname>_<var>%. For example,%DEFAULTPLUGIN_SHORTDESCRIPTION%shows the description of the DefaultPlugin. | 
|  |  Listing Active Plugins  | 
|
| < <
 | Plugin status variables let you list all active Plugins wherever needed. There are two list formats: 
 The %ACTIVATEDPLUGINS%variable lists activated Plugins by name. (This variable is displayed in TWikiPreferences for debugging use.) The %PLUGINDESCRIPTIONS%variable displays a bullet list with a one-line description of each active Plugins. This variable is based on the%<plugin>_SHORTDESCRIPTION%Preferences variables of individual topics and is shown in TextFormattingRules. | 
| > >
 | Plugin status variables let you list all active Plugins wherever needed. | 
|  |  | 
|
| < <
 | 
DEMO: Automatically List Active Plugins Using Variables | 
| > >
 |  On this TWiki site, the enabled Plugins are: SpreadSheetPlugin, BackupRestorePlugin, ColorPickerPlugin, CommentPlugin, DatePickerPlugin, EditTablePlugin, HeadlinesPlugin, InterwikiPlugin, JQueryPlugin, PreferencesPlugin, SetGetPlugin, SlideShowPlugin, SmiliesPlugin, TablePlugin, TagMePlugin, TinyMCEPlugin, TwistyPlugin, WatchlistPlugin, WysiwygPlugin.%ACTIVATEDPLUGINS% | 
|  |  | 
|
| < <
 | Using %ACTIVATEDPLUGINS%:On this TWiki site, the active Plugins are: SpreadSheetPlugin, BackupRestorePlugin, ColorPickerPlugin, CommentPlugin, DatePickerPlugin, EditTablePlugin, HeadlinesPlugin, InterwikiPlugin, JQueryPlugin, PreferencesPlugin, SetGetPlugin, SlideShowPlugin, SmiliesPlugin, TablePlugin, TagMePlugin, TinyMCEPlugin, TwistyPlugin, WatchlistPlugin, WysiwygPlugin.
Using
 %PLUGINDESCRIPTIONS%:You can use any of these active TWiki Plugins:
 | 
| > >
 |  %PLUGINDESCRIPTIONS% | 
|  |  SpreadSheetPlugin (2015-06-07, $Rev: 29570 (2015-11-29) $): Add spreadsheet calculation like "$SUM( $ABOVE() )"to TWiki tables or anywhere in topic text BackupRestorePlugin (2015-01-09, $Rev: 28636 (2015-11-29) $): Administrator utility to backup, restore and upgrade a TWiki site  ColorPickerPlugin (2015-01-10, $Rev: 29507 (2015-11-29) $): Color picker, packaged for use in TWiki forms and TWiki applications  CommentPlugin (2015-01-10, $Rev: 28648 (2015-11-29) $): Quickly post comments to a page without an edit/preview/save cycle  DatePickerPlugin (2015-01-10, $Rev: 29510 (2015-11-29) $): Pop-up calendar with date picker, for use in TWiki forms, HTML forms and TWiki plugins  EditTablePlugin (2015-01-10, $Rev: 29516 (2015-11-29) $): Edit TWiki tables using edit fields, date pickers and drop down boxes  HeadlinesPlugin (2015-11-06, $Rev: 29650 (2015-11-29) $): Show headline news in TWiki pages based on RSS and ATOM news feeds from external sites  InterwikiPlugin (2015-06-18, $Rev: 29526 (2015-11-29) $): Write ExternalSite:Pageto link to a page on an external site based on aliases defined in a rules topic JQueryPlugin (2015-01-10, $Rev: 29532 (2015-11-29) $): jQuery JavaScript library for TWiki  PreferencesPlugin (2015-01-14, $Rev: 29550 (2015-11-29) $): Allows editing of preferences using fields predefined in a form  SetGetPlugin (2015-07-09, $Rev: 29564 (2015-11-29) $): Set and get variables and JSON objects in topics, optionally persistently across topic views  SlideShowPlugin (2015-01-14, $Rev: 29566 (2015-11-29) $): Create web based presentations based on topics with headings.  SmiliesPlugin (2015-02-16, $Rev: 29568 (2015-11-29) $): Render smilies as icons, like  :-) as or  :eek: as  TablePlugin (2015-02-16, $Rev: 29580 (2015-11-29) $): Control attributes of tables and sorting of table columns  TagMePlugin (2015-02-16, $Rev: 29582 (2015-11-29) $): Tag wiki content collectively or authoritatively to find content by keywords  TinyMCEPlugin (2015-02-16, $Rev: 29584 (2015-11-29) $): Integration of the Tiny MCE WYSIWYG Editor  TwistyPlugin (2015-04-28, $Rev: 29600 (2015-11-29) $): Twisty section JavaScript library to open/close content dynamically  WatchlistPlugin (2015-01-15, $Rev: 28820 (2015-11-29) $): Watch topics of interest and get notified of changes by e-mail  WysiwygPlugin (2015-02-16, $Rev: 29604 (2015-11-29) $): Translator framework for WYSIWYG editors 
 | 
|
| < <
 |  | 
| > >
 |  %FAILEDPLUGINS%19 plugins| Handler | Plugins | 
|---|
 | afterEditHandler | WysiwygPlugin |  | afterRenameHandler | TagMePlugin WatchlistPlugin
 |  | afterSaveHandler | TagMePlugin WatchlistPlugin
 |  | beforeCommonTagsHandler | EditTablePlugin PreferencesPlugin
 TwistyPlugin
 WysiwygPlugin
 |  | beforeEditHandler | TinyMCEPlugin WysiwygPlugin
 |  | beforeMergeHandler | WysiwygPlugin |  | beforeSaveHandler | CommentPlugin WatchlistPlugin
 WysiwygPlugin
 |  | commonTagsHandler | SpreadSheetPlugin BackupRestorePlugin
 CommentPlugin
 EditTablePlugin
 JQueryPlugin
 SlideShowPlugin
 SmiliesPlugin
 |  | initPlugin | SpreadSheetPlugin BackupRestorePlugin
 ColorPickerPlugin
 CommentPlugin
 DatePickerPlugin
 EditTablePlugin
 HeadlinesPlugin
 InterwikiPlugin
 JQueryPlugin
 PreferencesPlugin
 SetGetPlugin
 SlideShowPlugin
 SmiliesPlugin
 TablePlugin
 TagMePlugin
 TinyMCEPlugin
 TwistyPlugin
 WatchlistPlugin
 WysiwygPlugin
 |  | modifyHeaderHandler | WysiwygPlugin |  | postRenderingHandler | PreferencesPlugin WysiwygPlugin
 |  | preRenderingHandler | InterwikiPlugin SmiliesPlugin
 TablePlugin
 | 
 | 
|  |  The TWiki Plugin API  | 
|
| < <
 | The Application Programming Interface (API) for TWikiPlugins provides the specifications for hooking into the core TWiki code from your external Perl Plugin module. The Plugin API is new to the Production version of TWiki with the 01-Sep-2001 release. | 
| > >
 | The Application Programming Interface (API) for TWiki Plugins provides the specifications for hooking into the core TWiki code from your external Perl Plugin module. | 
|  |  Available Core Functions  | 
|
| < <
 | The TWikiFuncModule ( lib/TWiki/Func.pm) implements ALL official Plugin functions. Plugins should ONLY use functions published in this module. | 
| > >
 | The TWikiFuncDotPm module ( lib/TWiki/Func.pm) describes all the interfaces available to Plugins. Plugins should only use the interfaces described in this module. | 
|  |  | 
|
| < <
 |  If you use functions not in Func.pm, you run the risk of creating security holes. Also, your Plugin will likely break and require updating when you upgrade to a new version of TWiki. | 
| > >
 |  Note: If you use other core functions not described in Func.pm, you run the risk of creating security holes. Also, your Plugin will likely break and require updating when you upgrade to a new version of TWiki. | 
|  |  Predefined Hooks  | 
|
| < <
 | In addition to TWiki core functions, Plugins can use predefined hooks, or call backs, listed in the lib/TWiki/Plugins/EmptyPlugin.pmmodule. | 
| > >
 | In addition to TWiki core functions, Plugins can use predefined hooks, or callbacks, as described in the lib/TWiki/Plugins/EmptyPlugin.pmmodule. | 
|  | 
 All but the initPlugin are disabled. To enable a call back, remove DISABLE_from the function name. | 
|
| < <
 | 
Most Plugins use either the For best performance, enable only the functions you really need. NOTE: outsidePREHandlerandinsidePREHandlerare particularly expensive. commonTagsHandlerorstartRenderingHandlerfor rendering tasks:
 commonTagsHandler:Use it to expand%XYZPLUGIN%and%XYZPLUGIN{...}%variables startRenderingHandler:Use it for your own rendering rules or to overload TWiki's internal rendering like[[links]] | 
|  | TWiki:Codev/StepByStepRenderingOrder  helps you decide which rendering handler to use. | 
|
| > >
 |  | 
|  |  Hints on Writing Fast Plugins  | 
|
| < <
 | 
 Delay the Plugin initialization to the actual function which is handling the tag. This way all the expensive initialization is done only when needed.
 For example, use an evalblock like:
 | 
| > >
 | 
 Delay initialization as late as possible. For example, if your Plugin is a simple syntax processor, you might delay loading extra Perl modules until you actually see the syntax in the text.
 For example, use an evalblock like this:
 | 
|  | eval { require IPC::Run }
 return "<font color=\"red\">SamplePlugin: Can't load required modules ($@)</font>" if $@; | 
|
| < <
 | 
 You could return errors as strings to show what happened
 | 
|  | 
 You can use a flag to avoid running the initialization twice
 | 
|
| > >
 |  | 
|  |  Plugin Version Detection  | 
|  | 
 
 
 The Plugin initialization code does not register a Plugin that returns FALSE (or that has no initPluginhandler). 
 $TWiki::Plugins::VERSIONin theTWiki::Pluginsmodule contains the TWiki Plugin API version, currently 6.02. | 
|
| < <
 | 
 
 
 You can also use the %PLUGINVERSION{}% variable to query the Plugin API version or the version of installed Plugins.
 | 
| > >
 | 
 
 
 You can also use the %PLUGINVERSION{}%variable to query the Plugin API version or the version of installed Plugins.  Security 
 Badly written Plugins can open huge security holes in TWiki. This is especially true if care isn't taken to prevent execution of arbitrary commands on the server.
 Don't allow sensitive configuration data to be edited by users. it is better to add sensitive configuration options to the %TWiki::cfghash than adding it as preferences in the Plugin topic Always use the TWiki::Sandbox to execute commands.
 Always audit the Plugins you install, and make sure you are happy with the level of security provided. While every effort is made to monitor Plugin authors activities, at the end of the day they are uncontrolled user contributions.
 | 
|  |  Creating Plugins With a reasonable knowledge of the Perl scripting language, you can create new Plugins or modify and extend existing ones. Basic plug-in architecture uses an Application Programming Interface (API), a set of software instructions that allow external code to interact with the main program. The TWiki Plugin API Plugins by providing a programming interface for TWiki. | 
|
| < <
 |  The DefaultPlugin Alternative 
 DefaultPlugin can handle some outdated TWiki variables, found, for example, in sites recently updated from an old version. Settings are in DefaultPlugin topic. You can also add your own simple custom processing rules here, though in all but very simple cases, writing a new Plugin is preferable.
 | 
|  |  Anatomy of a Plugin A basic TWiki Plugin consists of two elements: | 
|  | $var = MyFirstPlugin::Attrs->new(); | 
|
| > >
 |  Measuring and Improving the Plugin Performance A high quality Plugin performs well. You can use the TWiki:Plugins.PluginBenchmarkAddOn to measure your TWiki:Plugins.PluginBenchmarks  . The data is needed as part of the Documentation Topic.
See also Hints on Writing Fast Plugins. | 
|  |  Writing the Documentation Topic  | 
|  | 
 
 
 go back to your site to the TWiki web
 In the GoBox enter your Plugin name, for example MyFirstPlugin, press enter and create the new topic paste & save new Plugin topic on your site
 | 
|
| < <
 | 
 Customize your Plugin topic. 
 In case you plan to publish your Plugin at TWiki.org, use Interwiki names for author names, like TWiki:Main/TWikiGuest . Save your topic, for use in packaging and publishing your Plugin.
 | 
| > >
 | 
 Customize your Plugin topic. 
 Important: In case you plan to publish your Plugin on TWiki.org, use Interwiki names for author names and links to TWiki.org topics, such as TWiki:Main/TWikiGuest . This is important because links should work properly in a Plugin topic installed on any TWiki, not just on TWiki.org. Document the performance data you gathered while measuring the performance
 Save your topic, for use in packaging and publishing your Plugin.
 | 
|  | 
OUTLINE: Doc Topic Contents 
 | 
|  |  Packaging for Distribution  | 
|
| < <
 | A minimum Plugin release consists of a Perl module with a WikiName that ends in Plugin, ex:MyFirstPlugin.pm, and a documentation page with the same name(MyFirstPlugin.txt). | 
| > >
 | The TWiki:Plugins.BuildContrib  is a powerful build environment that is used by the TWiki project to build TWiki itself, as well as many of the Plugins. You don't have to use it, but it is highly recommended!
If you don't want (or can't) use the BuildContrib, then a minimum Plugin release consists of a Perl module with a WikiName that ends in Plugin, ex:MyFirstPlugin.pm, and a documentation page with the same name(MyFirstPlugin.txt). | 
|  |  | 
|
| < <
 | 
 Distribute the Plugin files in a directory structure that mirrors TWiki. If your Plugin uses additional files, include them ALL:
 | 
| > >
 | 
 Distribute the Plugin files in a directory structure that mirrors TWiki. If your Plugin uses additional files, include them all:
 | 
|  | 
 
 
 lib/TWiki/Plugins/MyFirstPlugin.pm data/TWiki/MyFirstPlugin.txt pub/TWiki/MyFirstPlugin/uparrow.gif[a required graphic] | 
|  |  Publishing for Public Use  | 
|
| < <
 | You can release your tested, packaged Plugin to the TWiki community through the TWiki:Plugins  web. All Plugins submitted to TWiki.org are available for download and further development in TWiki:Plugins/PluginPackage  . Publish your Plugin in these steps: | 
| > >
 | You can release your tested, packaged Plugin to the TWiki community through the TWiki:Plugins  web. All Plugins submitted to TWiki.org are available for download and further development in TWiki:Plugins/PluginPackage  . | 
|  |  | 
|
| > >
 | Publish your Plugin by following these steps: | 
|  | 
 Post the Plugin documentation topic in the TWiki:Plugins/PluginPackage : 
 enter the Plugin name in the "How to Create a Plugin" section, for example MyFirstPlugin | 
|
| < <
 |  | 
| > >
 |  | 
|  | 
 Attach the distribution zip file to the topic, ex: MyFirstPlugin.zip Link from the doc page to a new, blank page named after the Plugin, and ending in Dev, ex:MyFirstPluginDev. This is the discussion page for future development. (User support for Plugins is handled in TWiki:Support .) | 
|
| < <
 | 
 Put the Plugin into the CVS repository, see TWiki:Plugins/ReadmeFirst (optional) | 
| > >
 | 
 Put the Plugin into the SVN repository, see TWiki:Plugins/ReadmeFirst (optional)  Once you have done the above steps once, you can use the BuildContrib to upload updates to your Plugin. | 
|  | Thank you very much for sharing your Plugin with the TWiki community   | 
|
| < <
 |  Recommended Storage of Plugin Data  | 
| > >
 |  Recommended Storage of Plugin Specific Data Plugins sometimes need to store data. This can be Plugin internal data such as cache data, or data generated for browser consumption such as images. Plugins should store data using TWikiFuncDotPm functions that support saving and loading of topics and attachments. Plugin Internal Data You can create a Plugin "work area" using theTWiki::Func::getWorkArea()function, which gives you a persistant directory where you can store data files. By default they will not be web accessible. The directory is guaranteed to exist, and to be writable by the webserver user. For convenience,TWiki::Func::storeFile()andTWiki::Func::readFile()are provided to persistently store and retrieve simple data in this area. Web Accessible Data Topic-specific data such as generated images can be stored in the topics attachment area, which is web accessible. Use theTWiki::Func::saveAttachment()function to store the data.
Recommendation for file name:
Web specific data can be stored in the Plugin's attachment area, which is web accessible. Use the Prefix the filename with an underscore (the leading underscore avoids a nameclash with files attached to the same topic)
 Identify where the attachment originated from, typically by including the Plugin name in the file name
 Use only alphanumeric characters, underscores, dashes and periods to avoid platform dependency issues and URL issues
 Example: _FooBarPlugin_img123.gif TWiki::Func::saveAttachment()function to store the data.
Recommendation for file names in Plugin attachment area:
 Prefix the filename with an underscore
 Include the name of the web in the filename
 Use only alphanumeric characters, underscores, dashes and periods to avoid platform dependency issues and URL issues
 Example: _Main_roundedge-ul.gif  Maintaining Plugins  Discussions and Feedback on Plugins Each published Plugin has a Plugin development topic on TWiki.org. Plugin development topics are named after your Plugin and end inDev, such asMyFirstPluginDev. The Plugin development topic is a great resource to discuss feature enhancements and to get feedback from the TWiki community. Maintaining Compatibility with Earlier TWiki Versions The Plugin interface (TWikiFuncDotPm functions and handlers) evolve over time. TWiki 4.0 introduced new API functions to address the needs of Plugin authors. It also deprecated some functions. Some Plugins written for earlier TWiki releases using unofficial TWiki internal functions no longer work on the TWiki 4.0 codebase. All this means that some Plugins need to be updated to work on the TWiki 4.0 codebase.
Organizations typically do not upgrade to the latest TWiki for many months. However, many administrators still would like to install the latest versions of a Plugin on their older TWiki installation. This need is fullfilled if Plugins are maintained in a compatible manner. Tip: Plugins can be written to be compatible with older and newer TWiki releases. This can be done also for Plugins using unofficial TWiki internal functions of an earlier release that no longer work on the latest TWiki codebase. TWiki:TWiki.TWikiPluginsSupplement#MaintainPlugins  has more.  Handling deprecated functions  | 
|  |  | 
|
| < <
 | Plugins sometimes need to store data. This can be Plugin internal data like cache data, or generated data for the browser like images. The following is a recommendation where to store the data. | 
| > >
 | From time-to-time, the TWiki developers will add new functions to the interface (either to TWikiFuncDotPm, or new handlers). Sometimes these improvements mean that old functions have to be deprecated to keep the code manageable. When this happens, the deprecated functions will be supported in the interface for at least one more TWiki release, and probably longer, though this cannot be guaranteed. | 
|  |  | 
|
| < <
 |  Where to store Plugin Internal Data  | 
| > >
 | When a plugin defines deprecated handlers, a warning will be shown in the list generated by %FAILEDPLUGINS%. Admins who see these warnings should check TWiki.org and if necessary, contact the plugin author, for an updated version of the plugin. | 
|  |  | 
|
| < <
 | In case the Plugin generates data just for internal use, or data which is not specific to a topic, store it in the Plugin's attachment directory. | 
| > >
 | Updated plugins may still need to define deprecated handlers for compatibility with old TWiki versions. In this case, the plugin package that defines old handlers can suppress the warnings in %FAILEDPLUGINS%. | 
|  |  | 
|
| < <
 | 
 The Plugin's attachment directory is pubdir/Installweb/FooBarPlugin
 Installwebrefers to the name of the web where the Plugin is installed The Plugin's attachment URL is %PUBURL%/Installweb/FooBarPlugin The filename should start with an underscore, followed by an identifier, e.g. _any_name.ext
 The leading underscore avoids a nameclash with files attached to the Plugin topic
 Use only alphanumeric characters, underscores and periods to avoid platform dependency issues and URL issues
 Do not use subdirectories (rename and delete would fail)
 Use Plugin API functions documented in TWikiFuncModule to ensure portability: 
 Use getPubDir()to get the attachment root directory Use getUrlHost()andgetPubUrlPath()to build the URL in case you create content for the browser Use $installWebto get the name of the web where the Plugin is installed Create the web directory and topic attachment directory if needed
 Hint: Package the Plugin at least with one file attachment. This ensures that the attachment directory already exists
  Where to Store Data for Topics using the Plugin In case the Plugin generates data which is specific to a topic, store it in the topic's attachment directory.
 The topic's attachment directory is pubdir/Webname/TopicName The topic's attachment URL is %PUBURL%/Webname/TopicName The filename should start with an underscore, followed by the Plugin name, an underscore and an identifier, e.g. _FooBarPlugin_any_name.ext
 The leading underscore avoids a nameclash with files attached to the same topic
 Use only alphanumeric characters, underscores and periods to avoid platform dependency issues and URL issues
 Do not use subdirectories (rename and delete would fail)
 Use Plugin API functions documented in TWikiFuncModule to ensure portability: 
 Use getPubDir()to get the attachment root directory Use getUrlHost()andgetPubUrlPath()to build the URL in case you create content for the browser | 
| > >
 | This is done by defining a map from the handler name to the TWiki::Pluginsversion in which the handler was first deprecated. For example, if we need to define theendRenderingHandlerfor compatibility withTWiki::Pluginsversions before 1.1, we would add this to the plugin: | 
|  |  | 
|
| < <
 | Example code to build the file name: | 
|  |  | 
|
| < <
 | sub _make_filename
{
	 my ( $web, $topic, $name ) = @_  ;
	 # Create web directory "pub/$web" if needed
	 my $dir = TWiki::Func::getPubDir() . "/$web";
	 unless( -e "$dir" ) {
		  umask( 002 );
		  mkdir( $dir, 0775 );
	 }
	 # Create topic directory "pub/$web/$topic" if needed
	 $dir .= "/$topic";
	 unless( -e "$dir" ) {
		  umask( 002 );
		  mkdir( $dir, 0775 );
	 }
	 return "$dir/_FooBarPlugin_$name";
} | 
| > >
 | package TWiki::Plugins::SinkPlugin;
use vars qw( %TWikiCompatibility );
$TWikiCompatibility{endRenderingHandler} = 1.1; | 
|  |  | 
|
| > >
 | If the currently-running TWiki version is 1.1 or later, then the handler will not be called and the warning will not be issued. TWiki with versions of TWiki::Pluginsbefore 1.1 will still call the handler as required. | 
|  |  | 
|
| < <
 | -- TWiki:Main/PeterThoeny  - 14 Aug 2004 -- TWiki:Main/AndreaSterbini
  - 29 May 2001 -- TWiki:Main/MikeMannix
  - 03 Dec 2001 | 
| > >
 | Related Topics: DeveloperDocumentationCategory, AdminDocumentationCategory, TWiki:TWiki.TWikiPluginsSupplement  | 
|  |  | 
|
| > >
 | -- Contributors: TWiki:Main.PeterThoeny  , TWiki:Main.AndreaSterbini  , TWiki:MainMikeMannix  , TWiki:CrawfordCurrie  |