Difference: TWikiPlugins (32 vs. 33)

Revision 3316 May 2007 - TWikiContributor

Line: 1 to 1
Deleted:
<
<
 
Changed:
<
<

TWiki Plugins

>
>

TWiki Plugins

  Add functionality to TWiki with readily available Plugins; create Plugins based on APIs
Added:
>
>
 

Overview

You can add Plugins to extend TWiki functionality, without altering the core code. A plug-in approach lets you:

Line: 38 to 39
 

On-Site Pretesting

Changed:
<
<
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.
>
>
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 satisfied 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 Performance

Changed:
<
<
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 ab utility. Example on Unix:
time wget -qO /dev/null /twiki/bin/view/TWiki/AbcPlugin
>
>
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 ab utility. Example on Unix:
time wget -qO /dev/null /twiki/bin/view/TWiki/AbcPlugin
  TIP If you need to install an "expensive" Plugin, but you only need its functionality only in a subset of your data, you can disable it elsewhere by defining the %DISABLEDPLUGINS% TWiki variable.
Changed:
<
<
Define DISABLEDPLUGINS to be a comma-separated list of names of plugins to disable. Define it in Public.TWikiPreferences to disable those plugins everywhere, in the WebPreferences topic to disable them in an individual web, or in a topic to disable them in that topic. For example,
>
>
Define DISABLEDPLUGINS to be a comma-separated list of names of plugins to disable. Define it in Public.TWikiPreferences to disable those plugins everywhere, in the WebPreferences topic to disable them in an individual web, or in a topic to disable them in that topic. For example,
 
   * Set DISABLEDPLUGINS = SpreadSheetPlugin, EditTablePlugin
Line: 64 to 65
 

Plugin Evaluation Order

Changed:
<
<
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.
>
>
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 spreadsheet CALCs. This can be done with {PluginsOrder} in the Plugins section of configure.
 

Plugin-Specific Settings

Line: 76 to 77
  Plugin status variables let you list all active Plugins wherever needed.
Added:
>
>
This site is running TWiki version TWiki-6.1.0, Mon, 16 Jul 2018, build 30610, Plugin API version 6.10

 

%ACTIVATEDPLUGINS%

On this TWiki site, the enabled Plugins are: SpreadSheetPlugin, BackupRestorePlugin, BatchUploadPlugin, BeautifierPlugin, BibliographyPlugin, BibtexPlugin, BreadCrumbsPlugin, CalendarPlugin, ChartPlugin, ColorPickerPlugin, CommentPlugin, CounterPlugin, DatabasePlugin, DatePickerPlugin, EditTablePlugin, EmbedPDFPlugin, ExcelImportExportPlugin, FilterPlugin, FlexWebListPlugin, FlowchartPlugin, FormPlugin, GaugePlugin, GeoLookupPlugin, GluePlugin, GnuPlotPlugin, HeadlinesPlugin, IfDefinedPlugin, ImageGalleryPlugin, ImagePlugin, InterwikiPlugin, JQueryPlugin, JQueryTwistyPlugin, LatexModePlugin, LightboxPlugin, LocalTimePlugin, ObjectPlugin, PercentCompletePlugin, PreferencesPlugin, QRCodePlugin, RackPlannerPlugin, RecentVisitorPlugin, RedDotPlugin, RedirectPlugin, RemoteFileAttachPlugin, RenderListPlugin, RevisionLinkPlugin, SendEmailPlugin, SendMailPlugin, SetGetPlugin, ShareMePlugin, SkillsPlugin, SlideShowPlugin, SmiliesPlugin, SourceHighlightPlugin, TWikiDrawPlugin, TWikiSheetPlugin, TablePlugin, TagCloudPlugin, TagMePlugin, TimeSincePlugin, TimeTablePlugin, TinyMCEPlugin, TopicCreatePlugin, TwistyPlugin, UserInfoPlugin, VotePlugin, WatchlistPlugin, WebPermissionsPlugin, WysiwygPlugin.

%PLUGINDESCRIPTIONS%

  • SpreadSheetPlugin (2018-07-05, $Rev: 30478 (2018-07-16) $): Add spreadsheet calculation like "$SUM( $ABOVE() )" to TWiki tables or anywhere in topic text
  • BackupRestorePlugin (2018-07-10, $Rev: 30551 (2018-07-16) $): Administrator utility to backup, restore and upgrade a TWiki site
  • BatchUploadPlugin (1.4, $Rev: 17006 (12 Dec 2008) $): Attach multiple files at once by uploading a zip archive
  • BeautifierPlugin (2012-12-02, $Rev: 24286 (2012-12-02) $): Highlight and format source code fragments of various languages
  • BibliographyPlugin (2011-03-09, $Rev: 20645 (2011-03-09) $): Cite bibliography in one topic and get an automatically created references list
  • BibtexPlugin (1.6, $Rev: 19851 (2010-11-15) $): Embeds BibTeX entries in a TWiki page
  • BreadCrumbsPlugin (2010-08-01, $Rev: 19303 (2010-08-01) $): A flexible way to display breadcrumbs navigation
  • CalendarPlugin (2012-12-03, $Rev: 24315 (2012-12-04) $): Show a monthly calendar with highlighted events
  • ChartPlugin (2013-05-23, $Rev: 25974 (2013-05-23) $): Visualize TWiki tables with area charts, bar charts, line graphs, scatter charts and sparklines
  • ColorPickerPlugin (2018-07-05, $Rev: 30442 (2018-07-16) $): Color picker, packaged for use in TWiki forms and TWiki applications
  • CommentPlugin (2018-07-05, $Rev: 30530 (2018-07-16) $): Quickly post comments to a page without an edit/preview/save cycle
  • CounterPlugin (2010-09-05, $Rev: 19433 (2010-09-04) $): Show a site visit counter in a TWiki topic
  • DatabasePlugin (2011-11-11, $Rev: 22417 (2011-11-11) $): Provide access to data in a SQL database
  • DatePickerPlugin (2018-07-05, $Rev: 30446 (2018-07-16) $): Pop-up calendar with date picker, for use in TWiki forms, HTML forms and TWiki plugins
  • EditTablePlugin (2018-07-05, $Rev: 30448 (2018-07-16) $): Edit TWiki tables using edit fields, date pickers and drop down boxes
  • EmbedPDFPlugin (2011-05-10, $Rev: 21206 (2011-05-11) $): Embed PDF documents in TWiki pages
  • ExcelImportExportPlugin (TWiki, $Rev: 0$): Renders an attached Excel spreadsheet as TWiki table
  • FilterPlugin (2010-07-25, $Rev: 19240 (2010-07-25) $): Substitute and extract information from content by using regular expressions
  • FlexWebListPlugin (2010-07-25, $Rev: 19261 (2010-07-26) $): Flexible way to display hierarchical weblists
  • FlowchartPlugin (2012-12-02, $Rev: 24291 (2012-12-02) $): Create a flowchart from topic text
  • FormPlugin (2015-02-25, $Rev: 28764 (2015-02-25) $): Create simple and advanced web forms using TWiki forms
  • GaugePlugin (2013-05-16, $Rev: 25944 (2013-05-16) $): Create gauges (graphical or not), typically used for dashboards
  • GeoLookupPlugin (2015-01-09, $Rev: 28639 (2015-01-09) $): Lookup geolocation by IP address or domain name
  • GluePlugin (2.1, $Rev: 18553 (2010-04-30) $): Enable markup to span multiple lines
  • GnuPlotPlugin (2011-03-12, $Rev: 20701 (2011-03-13) $): Allows users to plot data and functions using GnuPlot
  • HeadlinesPlugin (2018-07-13, $Rev: 30560 (2018-07-16) $): Show headline news in TWiki pages based on RSS and ATOM news feeds from external sites
  • IfDefinedPlugin (v1.1, $Rev: 18548 (2010-04-29) $): Render content conditionally
  • ImageGalleryPlugin (2011-07-21i - v3.74, $Rev: 21797 (2011-07-21) $): Show image gallery with auto-generated thumbnails from attachments
  • ImagePlugin (2010-08-01, $Rev: 19301 (2010-08-01) $): Control the display and alignment of images using an easy syntax
  • InterwikiPlugin (2018-07-05, $Rev: 30454 (2018-07-16) $): Write ExternalSite:Page to link to a page on an external site based on aliases defined in a rules topic
  • JQueryPlugin (2018-07-05, $Rev: 30456 (2018-07-16) $): jQuery JavaScript library for TWiki
  • JQueryTwistyPlugin (2010-07-25, $Rev: 19236 (2010-07-25) $): Twisty section JavaScript library to open/close content dynamically
  • LatexModePlugin (3.71, $Rev: 16926 (12 Dec 2008) $): Enables LaTeX markup (mathematics and more) in TWiki topics
  • LightboxPlugin (2010-11-09, $Rev: 19812 (2010-11-09) $): TWiki hooks to the Lightbox Javascript package for better thumbnail clickthrough
  • LocalTimePlugin (2010-12-11, $Rev: 19947 (2010-12-11) $): Show the current date and time of a particular city/timezone.
  • ObjectPlugin (2010-08-29, $Rev: 19389 (2010-08-29) $): Embed multi-media Objects into TWiki topics
  • PercentCompletePlugin (2015-05-29, $Rev: 29248 (2015-05-29) $): Percent complete selector, for use in TWiki forms and TWiki applications
  • PreferencesPlugin (2018-07-05, $Rev: 30528 (2018-07-16) $): Allows editing of preferences using fields predefined in a form
  • QRCodePlugin (2012-11-14, $Rev: 24045 (2012-11-15) $): Create QR Code (a matrix barcode) in TWiki pages, useful for mobile applications
  • RackPlannerPlugin (Dakar, $Rev: 15566 (2010-08-19) $): Render a rack overview (e.g. of 19'' computer racks) with HTML tables
  • RecentVisitorPlugin (2011-06-06, $Rev: 21426 (2011-06-06) $): Show recent visitors to a TWiki site
  • RedDotPlugin (2010-07-27, $Rev: 21402 (2011-06-04) $): Renders edit-links as little red dots
  • RedirectPlugin (2015-12-02, $Rev: 29697 (2015-12-03) $): Create a redirect to another topic or website
  • RemoteFileAttachPlugin (2011-01-13, $Rev: 20204 (2011-01-13) $): Download and attach remote files to topics
  • RenderListPlugin (2018-07-05, $Rev: 30468 (2018-07-16) $): Render bullet lists in a variety of formats
  • RevisionLinkPlugin (2.2, $Rev: 19837 (2010-11-10) $): Enable linking to specific topic revisions
  • SendEmailPlugin (2013-01-24, $Rev: 25975 (2013-05-28) $): Allows to send e-mails through an e-mail form.
  • SendMailPlugin (2016-01-19, $Rev: 29910 (2016-01-20) $): Send e-mail from actions in TWiki topics, useful for workflow automation
  • SetGetPlugin (2018-07-05, $Rev: 30472 (2018-07-16) $): Set and get variables and JSON objects in topics, optionally persistently across topic views
  • ShareMePlugin (2012-12-01, $Rev: 24254 (2012-12-01) $): Icon bar to share a TWiki page on popular social media sites such as Facebook, StumbleUpon, Twitter
  • SkillsPlugin (2011-06-04, $Rev: 21404 (2011-06-04) $): Allows users to list their skills, which can then be searched
  • SlideShowPlugin (2018-07-05, $Rev: 30474 (2018-07-16) $): Create web based presentations based on topics with headings.
  • SmiliesPlugin (2018-07-05, $Rev: 30476 (2018-07-16) $): Render smilies as icons, like  :-)  as smile or  :eek:  as eek!
  • SourceHighlightPlugin (2010-08-06, $Rev: 19332 (2010-08-06) $): Highlight and format code fragments using GNU source-highlight
  • TWikiDrawPlugin (2013-05-17, $Rev: 25952 (2013-05-17) $): Vector drawing editor and clickable maps for diagrams and workflows
  • TWikiSheetPlugin (2018-07-15, $Rev: 30604 (2018-07-16) $): Add TWiki Sheet spreadsheet functionality to TWiki tables
  • TablePlugin (2018-07-05, $Rev: 30480 (2018-07-16) $): Control attributes of tables and sorting of table columns
  • TagCloudPlugin (2010-07-26, $Rev: 19266 (2010-07-26) $): Renders a tag cloud given a list of terms
  • TagMePlugin (2018-07-05, $Rev: 30482 (2018-07-16) $): Tag wiki content collectively or authoritatively to find content by keywords
  • TimeSincePlugin (2010-07-27, $Rev: 19277 (2010-07-27) $):
  • TimeTablePlugin (Dakar, $Rev: 18182 (2010-08-19) $): Render a weekly timetable
  • TinyMCEPlugin (2018-07-10, $Rev: 30541 (2018-07-16) $): Integration of the Tiny MCE WYSIWYG Editor
  • TopicCreatePlugin (2014-11-07, $Rev: 28434 (2014-11-07) $): Automatically create a set of topics and attachments at topic save time
  • TwistyPlugin (2018-07-06, $Rev: 30497 (2018-07-16) $): Twisty section JavaScript library to open/close content dynamically
  • UserInfoPlugin (2010-07-25, $Rev: 19259 (2010-07-25) $): Render information about users on a TWiki site
  • VotePlugin (2012-12-10, $Rev: 24404 (2012-12-10) $): Simple way to count votes
  • WatchlistPlugin (2018-07-10, $Rev: 30536 (2018-07-16) $): Watch topics of interest and get notified of changes by e-mail
  • WebPermissionsPlugin (2013-06-18, $Rev: 26000 (2013-06-18) $): View and edit web permissions
  • WysiwygPlugin (2018-07-06, $Rev: 30528 (2018-07-16) $): Translator framework for WYSIWYG editors
Added:
>
>
 

%FAILEDPLUGINS%

PluginErrors
SpreadSheetPlugin none
BackupRestorePlugin none
BatchUploadPlugin none
BeautifierPlugin none
BibliographyPlugin none
BibtexPlugin none
BreadCrumbsPlugin none
CalendarPlugin none
ChartPlugin none
ColorPickerPlugin none
CommentPlugin none
CounterPlugin none
DatabasePlugin none
DatePickerPlugin none
EditTablePlugin none
EmbedPDFPlugin none
ExcelImportExportPlugin none
FilterPlugin none
FlexWebListPlugin none
FlowchartPlugin none
FormPlugin none
GaugePlugin none
GeoLookupPlugin none
GluePlugin none
GnuPlotPlugin none
HeadlinesPlugin none
IfDefinedPlugin none
ImageGalleryPlugin none
ImagePlugin none
InterwikiPlugin none
JQueryPlugin none
JQueryTwistyPlugin none
LatexModePlugin none
LightboxPlugin none
LocalTimePlugin none
ObjectPlugin none
PercentCompletePlugin none
PreferencesPlugin none
QRCodePlugin none
RackPlannerPlugin none
RecentVisitorPlugin none
RedDotPlugin none
RedirectPlugin none
RemoteFileAttachPlugin none
RenderListPlugin none
RevisionLinkPlugin none
SendEmailPlugin none
SendMailPlugin none
SetGetPlugin none
ShareMePlugin none
SkillsPlugin none
SlideShowPlugin none
SmiliesPlugin none
SourceHighlightPlugin none
TWikiDrawPlugin none
TWikiSheetPlugin none
TablePlugin none
TagCloudPlugin none
TagMePlugin none
TimeSincePlugin none
TimeTablePlugin none
TinyMCEPlugin none
TopicCreatePlugin none
TwistyPlugin none
UserInfoPlugin none
VotePlugin none
WatchlistPlugin none
WebPermissionsPlugin none
WysiwygPlugin none
HandlerPlugins
afterCommonTagsHandlerLatexModePlugin
afterEditHandlerWysiwygPlugin
afterRenameHandlerTagMePlugin
WatchlistPlugin
afterSaveHandlerFlowchartPlugin
TagMePlugin
WatchlistPlugin
beforeAttachmentSaveHandlerBatchUploadPlugin
beforeCommonTagsHandlerBibtexPlugin
EditTablePlugin
FormPlugin
PreferencesPlugin
TWikiSheetPlugin
TwistyPlugin
WysiwygPlugin
beforeEditHandlerTinyMCEPlugin
WysiwygPlugin
beforeMergeHandlerWysiwygPlugin
beforeSaveHandlerCommentPlugin
TopicCreatePlugin
WatchlistPlugin
WysiwygPlugin
commonTagsHandlerSpreadSheetPlugin
BackupRestorePlugin
BeautifierPlugin
BibtexPlugin
CalendarPlugin
ChartPlugin
CommentPlugin
CounterPlugin
DatabasePlugin
EditTablePlugin
EmbedPDFPlugin
FilterPlugin
FlowchartPlugin
GluePlugin
IfDefinedPlugin
ImageGalleryPlugin
ImagePlugin
JQueryPlugin
LatexModePlugin
LightboxPlugin
LocalTimePlugin
RackPlannerPlugin
RedDotPlugin
RemoteFileAttachPlugin
SlideShowPlugin
SmiliesPlugin
SourceHighlightPlugin
TWikiSheetPlugin
TimeTablePlugin
UserInfoPlugin
initPluginSpreadSheetPlugin
BackupRestorePlugin
BatchUploadPlugin
BeautifierPlugin
BibliographyPlugin
BibtexPlugin
BreadCrumbsPlugin
CalendarPlugin
ChartPlugin
ColorPickerPlugin
CommentPlugin
CounterPlugin
DatabasePlugin
DatePickerPlugin
EditTablePlugin
EmbedPDFPlugin
ExcelImportExportPlugin
FilterPlugin
FlexWebListPlugin
FlowchartPlugin
FormPlugin
GaugePlugin
GeoLookupPlugin
GluePlugin
GnuPlotPlugin
HeadlinesPlugin
IfDefinedPlugin
ImageGalleryPlugin
ImagePlugin
InterwikiPlugin
JQueryPlugin
JQueryTwistyPlugin
LatexModePlugin
LightboxPlugin
LocalTimePlugin
ObjectPlugin
PercentCompletePlugin
PreferencesPlugin
QRCodePlugin
RackPlannerPlugin
RecentVisitorPlugin
RedDotPlugin
RedirectPlugin
RemoteFileAttachPlugin
RenderListPlugin
RevisionLinkPlugin
SendEmailPlugin
SendMailPlugin
SetGetPlugin
ShareMePlugin
SkillsPlugin
SlideShowPlugin
SmiliesPlugin
SourceHighlightPlugin
TWikiDrawPlugin
TWikiSheetPlugin
TablePlugin
TagCloudPlugin
TagMePlugin
TimeSincePlugin
TimeTablePlugin
TinyMCEPlugin
TopicCreatePlugin
TwistyPlugin
UserInfoPlugin
VotePlugin
WatchlistPlugin
WebPermissionsPlugin
WysiwygPlugin
modifyHeaderHandlerWysiwygPlugin
postRenderingHandlerBibtexPlugin
PreferencesPlugin
RedDotPlugin
WysiwygPlugin
preRenderingHandlerBibliographyPlugin
InterwikiPlugin
RemoteFileAttachPlugin
SmiliesPlugin
TablePlugin
redirectCgiQueryHandlerRedDotPlugin
startRenderingHandlerRenderListPlugin
This handler is deprecated - please check for updated versions of the plugins that use it!
69 plugins

Line: 111 to 117
 
  • For example, use an eval block like this:
    eval { require IPC::Run }
    return "<font color=\"red\">SamplePlugin: Can't load required modules ($@)</font>" if $@;
Changed:
<
<
  • You can use a flag to avoid running the initialization twice
  • The TWiki:Plugins.PluginBenchmarkAddOn comes in handy to measure and fine-tune the performance of your Plugin
>
>
  • Keep the main plugin package as small as possible; create other packages that are loaded if and only if they are used. For example, create sub-packages of BathPlugin in lib/TWiki/Plugins/BathPlugin/.
  • Avoid using preferences in the plugin topic; set $NO_PREFS_IN_TOPIC if you possibly can, as that will stop TWiki from reading the plugin topic for every page. Use Config.spec instead.
  • Use registered tag handlers
  • Measure the performance to see the difference
 
Changed:
<
<

Plugin Version Detection

>
>

Version Detection

 
Changed:
<
<
To eliminate the incompatibility problems bound to arise from active open Plugin development, a Plugin versioning system is provided for automatic compatibility checking.
>
>
To eliminate the incompatibility problems that are bound to arise from active open Plugin development, a Plugin versioning system is provided for automatic compatibility checking.
 
Changed:
<
<
  • All modules require a $VERSION='0.000' variable, beginning at 1.000.
>
>
  • All plugin packages require a $VERSION variable. This should be an integer, or a subversion version id.
 
Changed:
<
<
  • The initPlugin handler should check all dependencies and return TRUE if the initialization is OK or FALSE if something went wrong.
    • The Plugin initialization code does not register a Plugin that returns FALSE (or that has no initPlugin handler).
>
>
  • The initPlugin handler should check all dependencies and return 1 if the initialization is OK or 0 if something went wrong.
    • The Plugin initialization code does not register a Plugin that returns 0 (or that has no initPlugin handler).
 
  • $TWiki::Plugins::VERSION in the TWiki::Plugins module contains the TWiki Plugin API version, currently 6.10.
    • You can also use the %PLUGINVERSION{}% variable to query the Plugin API version or the version of installed Plugins.
Line: 142 to 150
 

Anatomy of a Plugin

Changed:
<
<
A basic TWiki Plugin consists of two elements:
>
>
A (very) basic TWiki Plugin consists of two files:
 
Changed:
<
<
  • a Perl module, ex: MyFirstPlugin.pm
  • a documentation topic, ex: MyFirstPlugin.txt
>
>
  • a Perl module, e.g. MyFirstPlugin.pm
  • a documentation topic, e.g. MyFirstPlugin.txt
 
Changed:
<
<
The Perl module can be a block of code that connects with TWiki alone, or it can include other elements, like other Perl modules (including other Plugins), graphics, TWiki templates, external applications (ex: a Java applet), or just about anything else it can call.
>
>
The Perl module can be a block of code that talks to with TWiki alone, or it can include other elements, like other Perl modules (including other Plugins), graphics, TWiki templates, external applications (ex: a Java applet), or just about anything else it can call.
 In particular, files that should be web-accessible (graphics, Java applets ...) are best placed as attachments of the 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.

Added:
>
>
The TWiki::Plugins.BuildContrib module provides a lot of support for plugins development, including a plugin creator, automatic publishing support, and automatic installation script writer. If you plan on writing more than one plugin, you probably need it.
 

Creating the Perl Module

Copy file 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.

Line: 162 to 172
 $var = MyFirstPlugin::Attrs->new();
Deleted:
<
<

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

Changed:
<
<
The Plugin documentation topic contains usage instructions and version details. It serves the Plugin files as FileAttachments for downloading. (The doc topic is also included in the distribution package.) To create a documentation topic:
>
>
The Plugin documentation topic contains usage instructions and version details. It serves the Plugin files as FileAttachments for downloading. (The doc topic is also included in the distribution package.) To create a documentation topic:
 
  1. Copy the Plugin topic template from TWiki.org. To copy the text, go to TWiki:Plugins/PluginPackage and:
    • enter the Plugin name in the "How to Create a Plugin" section
    • click Create
    • select all in the Edit box & copy
    • Cancel the edit
Changed:
<
<
    • go back to your site to the TWiki web
>
>
    • 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
  1. Customize your Plugin topic.
Line: 197 to 200
  Plugin Settings: <Description and settings for custom Plugin %VARIABLES%, and those required by TWiki.>"
Changed:
<
<
  • Plugins Preferences <If user settings are needed, explain... Entering values works exactly like TWikiPreferences and WebPreferences: six (6) spaces and then:>"
>
>
  • 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 Installation Instructions: <Step-by-step set-up guide, user help, whatever it takes to install and run, goes here.>"

Line: 221 to 224
 
    • data/TWiki/MyFirstPlugin.txt
    • pub/TWiki/MyFirstPlugin/uparrow.gif
Added:
>
>

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.

 

Publishing for Public Use

Line: 245 to 255
 

Plugin Internal Data

Changed:
<
<
You can create a Plugin "work area" using the 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.
>
>
You can create a Plugin "work area" using the TWiki::Func::getWorkArea() function, which gives you a persistent 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.
 

Web Accessible Data

Line: 265 to 275
 
  • Use only alphanumeric characters, underscores, dashes and periods to avoid platform dependency issues and URL issues
  • Example: _Main_roundedge-ul.gif
Added:
>
>

Integrating with configure

Some TWiki extensions have setup requirements that are best integrated into configure rather than trying to use TWiki preferences variables. These extensions use Config.spec files to publish their configuration requirements.

Config.spec files are read during TWiki configuration. Once a Config.spec has defined a configuration item, it is available for edit through the standard configure interface. Config.spec files are stored in the 'plugin directory' e.g. lib/TWiki/Plugins/BathPlugin/Config.spec.

Structure of a Config.spec file

The Config.spec file for a plugin starts with the plugin announcing what it is:
# ---+ BathPlugin
# This plugin senses the level of water in your bath, and ensures the plug
# is not removed while the water is still warm.
This is followed by one or more configuration items. Each configuration item has a type, a description and a default. For example:
# **SELECT Plastic,Rubber,Metal**
# Select the plug type
$TWiki::cfg{BathPlugin}{PlugType} = 'Plastic';

# **NUMBER**
# Enter the chain length in cm
$TWiki::cfg{BathPlugin}{ChainLength} = '30';

# **BOOLEAN EXPERT**
# Turn this option off to disable the water temperature alarm
$TWiki::cfg{BathPlugin}{TempSensorEnabled} = '1';
The type (e.g. **SELECT** ) tells configure to how to prompt for the value. It also tells configure how to do some basic checking on the value you actually enter. All the comments between the type and the configuration item are taken as part of the description. The configuration item itself defines the default value for the configuration item. The above spec defines the configuration items $TWiki::cfg{BathPlugin}{PlugType}, $TWiki::cfg{BathPlugin}{ChainLength}, and $TWiki::cfg{BathPlugin}{TempSensorEnabled} for use in your plugin. For example,
if( $TWiki::cfg{BathPlugin}{TempSensorEnabled} && $curTemperature > 50 ) {
    die "The bathwater is too hot for comfort";
}

The config.spec file is read by configure, and configure then writes LocalSite.cfg with the values chosen by the local site admin.

A range of types are available for use in Config.spec files:

BOOLEAN A true/false value, represented as a checkbox
COMMAND length A shell command
LANGUAGE A language (selected from {LocalesDir}
NUMBER A number
OCTAL An octal number
PASSWORD length A password (input is hidden)
PATH length A file path
PERL A perl structure, consisting of arrays and hashes
REGEX length A perl regular expression
SELECT choices Pick one of a range of choices
SELECTCLASS root Select a perl package (class)
STRING length A string
URL length A url
URLPATH length A relative URL path

All types can be followed by a comma-separated list of attributes.

EXPERT means this an expert option
M means the setting is mandatory (may not be empty)
H means the option is not visible in configure

See lib/TWiki.spec for many more examples.

Config.spec files are also used for other (non-plugin) extensions. in this case they are stored under the Contrib directory instead of the Plugins directory.

 

Maintaining Plugins

Line: 276 to 348
  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.
Changed:
<
<
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.
>
>
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 fulfilled if Plugins are maintained in a compatible manner.
  TIP 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.
Line: 300 to 372
  Related Topics: DeveloperDocumentationCategory, AdminDocumentationCategory, TWiki:TWiki.TWikiPluginsSupplement
Deleted:
<
<
-- Contributors: TWiki:Main.PeterThoeny, TWiki:Main.AndreaSterbini, TWiki:MainMikeMannix, TWiki:CrawfordCurrie
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 1999-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding RHUL Physics Department TWiki? Send feedback
Note: Please contribute updates to this topic on TWiki.org at TWiki:TWiki.TWikiPlugins.