Start of topic | Skip to actions
TWiki PluginsAdd functionality to TWiki with readily available Plugins; create Plugins based on APIsOverviewYou can add Plugins to extend TWiki functionality, without altering the core code. A plug-in approach lets you:
Installing PluginsEach 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. 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 PretestingThe 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. 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.
Some Notes on Plugin PerformanceThe 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 Apacheab utility. Example on Unix:time wget -qO /dev/null /v/TWiki/AbcPlugin
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.)
Managing Installed PluginsSome 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:Enabling PluginsPlugins can be enabled and disabled with the configure script. An installed Plugin needs to be enabled before it can be used.Plugin Evaluation OrderBy 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.
Plugin-Specific SettingsPlugin-specific settings are done in individual Plugin topics. Two settings are standard for each Plugin:
Listing Active PluginsPlugin status variables let you list all active Plugins wherever needed.
On this TWiki site, the enabled Plugins are: SpreadSheetPlugin, ActionTrackerPlugin, BatchUploadPlugin, BlackListPlugin, CommentPlugin, EditTablePlugin, FilterPlugin, GluePlugin, IfDefinedPlugin, ImageGalleryPlugin, ImagePlugin, InterwikiPlugin, LinkOptionsPlugin, NatSkinPlugin, PreferencesPlugin, RedDotPlugin, RenderListPlugin, SlideShowPlugin, SmiliesPlugin, TablePlugin, ToolTipPlugin, TreePlugin, WysiwygPlugin.
|
Plugin | Errors |
---|---|
SpreadSheetPlugin | none |
ActionTrackerPlugin | none |
BatchUploadPlugin | none |
BlackListPlugin | none |
CalendarPlugin |
TWiki::Plugins::CalendarPlugin could not be loaded. Errors were: Can't locate Date/Calc.pm in @INC (@INC contains: /www/sys/twiki/lib/CPAN/lib//arch/ /www/sys/twiki/lib/CPAN/lib//5.10.1/i386-linux-thread-multi/ /www/sys/twiki/lib/CPAN/lib//5.10.1/ /www/sys/twiki/lib/CPAN/lib// /www/sys/twiki/lib . /usr/local/lib/perl5 /usr/local/share/perl5 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5 /usr/share/perl5) at /www/sys/twiki/lib/TWiki/Plugins/CalendarPlugin.pm line 219. BEGIN failed--compilation aborted at /www/sys/twiki/lib/TWiki/Plugins/CalendarPlugin.pm line 219. Compilation failed in require at (eval 46) line 1. BEGIN failed--compilation aborted at (eval 46) line 1. ---- |
CommentPlugin | none |
EditTablePlugin | none |
FilterPlugin | none |
GluePlugin | none |
IfDefinedPlugin | none |
ImageGalleryPlugin | none |
ImagePlugin | none |
InterwikiPlugin | none |
LinkOptionsPlugin | none |
NatSkinPlugin | none |
PreferencesPlugin | none |
RedDotPlugin | none |
RenderListPlugin | none |
SlideShowPlugin | none |
SmiliesPlugin | none |
TablePlugin | none |
ToolTipPlugin | none |
TreePlugin | none |
WysiwygPlugin | none |
Handler | Plugins |
---|---|
afterEditHandler | ActionTrackerPlugin |
beforeAttachmentSaveHandler | BatchUploadPlugin BlackListPlugin |
beforeCommonTagsHandler | PreferencesPlugin WysiwygPlugin |
beforeEditHandler | ActionTrackerPlugin WysiwygPlugin |
beforeSaveHandler | ActionTrackerPlugin BlackListPlugin CommentPlugin WysiwygPlugin |
commonTagsHandler | SpreadSheetPlugin ActionTrackerPlugin BlackListPlugin CommentPlugin EditTablePlugin FilterPlugin GluePlugin IfDefinedPlugin ImageGalleryPlugin ImagePlugin LinkOptionsPlugin NatSkinPlugin RedDotPlugin SlideShowPlugin SmiliesPlugin TreePlugin |
initPlugin | SpreadSheetPlugin ActionTrackerPlugin BatchUploadPlugin BlackListPlugin CommentPlugin EditTablePlugin FilterPlugin GluePlugin IfDefinedPlugin ImageGalleryPlugin ImagePlugin InterwikiPlugin LinkOptionsPlugin NatSkinPlugin PreferencesPlugin RedDotPlugin RenderListPlugin SlideShowPlugin SmiliesPlugin TablePlugin ToolTipPlugin TreePlugin WysiwygPlugin |
modifyHeaderHandler | WysiwygPlugin |
postRenderingHandler | BlackListPlugin EditTablePlugin NatSkinPlugin PreferencesPlugin RedDotPlugin ToolTipPlugin WysiwygPlugin |
preRenderingHandler | InterwikiPlugin RenderListPlugin SmiliesPlugin TablePlugin |
redirectCgiQueryHandler | RedDotPlugin |
lib/TWiki/Func.pm
) describes all the interfaces available to Plugins. Plugins should only use the interfaces described in this module.
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.
lib/TWiki/Plugins/EmptyPlugin.pm
module.
DISABLE_
from the function name.
eval
block like this:eval { require IPC::Run }
return "<font color=\"red\">SamplePlugin: Can't load required modules ($@)</font>" if $@;
$VERSION='0.000'
variable, beginning at 1.000
.
initPlugin
handler should check all dependencies and return TRUE if the initialization is OK or FALSE if something went wrong. initPlugin
handler).
$TWiki::Plugins::VERSION
in the TWiki::Plugins
module contains the TWiki Plugin API version, currently 1.1. %PLUGINVERSION{}%
variable to query the Plugin API version or the version of installed Plugins.
%TWiki::cfg
hash than adding it as preferences in the Plugin topic MyFirstPlugin.pm
MyFirstPlugin.txt
MyFirstPlugin
topic. Other needed Perl code is best placed in a lib/TWiki/Plugins/MyFirstPlugin/
directory.
The Plugin API handles the details of connecting your Perl module with main TWiki code. When you're familiar with the Plugin API, you're ready to develop Plugins.
lib/TWiki/Plugins/EmptyPlugin.pm
to <name>Plugin.pm
. The EmptyPlugin.pm
module contains mostly empty functions, so it does nothing, but it's ready to be used. Customize it. Refer to the Plugin API specs for more information.
If your Plugin uses its own modules and objects, you must include the name of the Plugin in the package name. For example, write Package MyFirstPlugin::Attrs;
instead of just Package Attrs;
. Then call it using:
use TWiki::Plugins::MyFirstPlugin::Attrs; $var = MyFirstPlugin::Attrs->new();
MyFirstPlugin
, press enter and create the new topic
OUTLINE: Doc Topic Contents
Check the Plugins web on TWiki.org for the latest Plugin doc topic template. Here's a quick overview of what's covered: Syntax Rules: <Describe any special text formatting that will be rendered.>" Example: <Include an example of the Plugin in action. Possibly include a static HTML version of the example to compare if the installation was a success!>" Plugin Settings: <Description and settings for custom Plugin %VARIABLES%, and those required by TWiki.>"Plugin Installation Instructions: <Step-by-step set-up guide, user help, whatever it takes to install and run, goes here.>" Plugin Info: <Version, credits, history, requirements - entered in a form, displayed as a table. Both are automatically generated when you create or edit a page in the TWiki:Plugins web.>"
- Plugins Preferences <If user settings are needed, explain... Entering values works exactly like TWikiPreferences and WebPreferences: six (6) spaces and then:>"
- Set <EXAMPLE = value added>
Plugin
, ex: MyFirstPlugin.pm
, and a documentation page with the same name(MyFirstPlugin.txt
).
lib/TWiki/Plugins/MyFirstPlugin.pm
data/TWiki/MyFirstPlugin.txt
pub/TWiki/MyFirstPlugin/uparrow.gif
[a required graphic]
MyFirstPlugin.zip
) and add the entire directory structure from Step 1. The archive should look like this: lib/TWiki/Plugins/MyFirstPlugin.pm
data/TWiki/MyFirstPlugin.txt
pub/TWiki/MyFirstPlugin/uparrow.gif
MyFirstPlugin
MyFirstPlugin.zip
Dev
, ex: MyFirstPluginDev
. This is the discussion page for future development. (User support for Plugins is handled in TWiki:Support.)
TWiki::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()
and TWiki::Func::readFile()
are provided to persistently store and retrieve simple data in this area.
TWiki::Func::saveAttachment()
function to store the data.
Recommendation for file name: _FooBarPlugin_img123.gif
TWiki::Func::saveAttachment()
function to store the data.
Recommendation for file names in Plugin attachment area: _Main_roundedge-ul.gif
Dev
, such as MyFirstPluginDev
. The Plugin development topic is a great resource to discuss feature enhancements and to get feedback from the TWiki community.
TWiki::Plugins
version in which the handler was first deprecated. For example, if we need to define the endRenderingHandler
for compatibility with TWiki::Plugins
versions before 1.1, we would add this to the plugin:
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::Plugins
before 1.1 will still call the handler as required.
Related Topics: DeveloperDocumentationCategory, AdminDocumentationCategory, TWiki:TWiki.TWikiPluginsSupplement
-- Contributors: TWiki:Main.PeterThoeny, TWiki:Main.AndreaSterbini, TWiki:MainMikeMannix, TWiki:CrawfordCurrie