Ignore:
Timestamp:
11/19/08 16:05:12 (4 years ago)
Author:
CrawfordCurrie
Message:

Item175: corrected references to TWiki in comments and error messages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/core/data/System/Plugins.txt

    r700 r812  
    33---+ Plugins 
    44 
    5 _Add functionality to TWiki with readily available plugins; create plugins based on APIs_ 
     5_Add functionality to Foswiki with readily available plugins; create plugins based on APIs_ 
    66 
    77%TOC% 
     
    99---++ Overview 
    1010 
    11 You can add plugins to extend TWiki functionality, without altering the core code. A plug-in approach lets you: 
    12  
    13    * add virtually unlimited features while keeping the main TWiki code compact and efficient; 
    14    * heavily customize an installation and still do clean updates to new versions of TWiki; 
    15    * rapidly develop new TWiki functions in Perl using the plugin API. 
    16  
    17 Everything to do with TWiki plugins - demos, new releases, downloads, development, general discussion - is available at TWiki.org, in the <b> TWiki:Plugins </b> web. 
    18  
    19 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. 
    20  
    21 __Relevant links on TWiki.org:__ 
    22    * TWiki:Support.PluginsSupplement - __%T% tip:__ supplemental documentation on plugins 
    23    * TWiki:Plugins.PluginPackage - list of all contributed plugin packages 
    24    * TWiki:Plugins.PluginDevelopment - discussion and feedback on contributed plugins 
    25    * TWiki:Plugins.PluginBrainstorming - open forum for new plugin ideas 
    26    * TWiki:Plugins.PluginPackageHowTo - template to create a new plugin package 
     11You can add plugins to extend Foswiki functionality, without altering the core code. A plug-in approach lets you: 
     12 
     13   * add virtually unlimited features while keeping the main Foswiki code compact and efficient; 
     14   * heavily customize an installation and still do clean updates to new versions of Foswiki; 
     15   * rapidly develop new Foswiki functions in Perl using the plugin API. 
     16 
     17Everything to do with Foswiki plugins - demos, new releases, downloads, development, general discussion - is available at Foswiki.org, in the <b> Foswiki:Extensions </b> web. 
     18 
     19Foswiki 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 Foswiki, but are independently developed and maintained. 
     20 
     21Most TWiki&trade; plugins can also be used with Foswiki if the TWikiCompatibilityPlugin is installed. 
    2722 
    2823__See other types of extensions:__ ContributedAddOns, [[Contribs]], [[Skins]] 
     
    3126---++ Installing Plugins 
    3227 
    33 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. 
     28Each Foswiki 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. 
    3429 
    3530*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. 
    3631 
    37 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. 
     32Each plugin has a standard release topic, located in the Foswiki:Extensions web at Foswiki.org. There's usually a number of other related topics, such as a developers page, and an appraisal page. 
    3833 
    3934#PreTesting 
    4035---+++ On-Site Pretesting 
    4136 
    42 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. 
    43  
    44 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 =[[VarFAILEDPLUGINS][%<nop>FAILEDPLUGINS%]]= macro can be used to debug failures. You may also want to check your webserver error log and the various TWiki log files. 
     37The recommended approach to testing new plugins before making them public is to create a second local Foswiki 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. 
     38 
     39InstalledPlugins shows which plugins are: 1) installed, 2) loading properly, and 3) what plugin handlers they invoke. Any failures are shown in the Errors section. The =[[VarFAILEDPLUGINS][%<nop>FAILEDPLUGINS%]]= macro can be used to debug failures. You may also want to check your webserver error log and the various Foswiki log files. 
    4540 
    4641---+++ Some Notes on Plugin Performance 
    4742 
    48 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:%BR% =time wget -qO /dev/null <nop>%SCRIPTURLPATH{"view"}%/%SYSTEMWEB%/AbcPlugin= 
     43The 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, on real data. 
    4944 
    5045%T% 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 %<nop>DISABLEDPLUGINS% setting. 
     
    7873   * =Set SHORTDESCRIPTION = Control attributes of tables and sorting of table columns= 
    7974  
    80 [[Preference settings]] of active plugins can be retrieved anywhere in TWiki with =%&lt;pluginname&gt;_&lt;var&gt;%=, such as =%<nop>TABLEPLUGIN_SHORTDESCRIPTION%=. They can also be redefined with the =%&lt;pluginname&gt;_&lt;var&gt;%= setting at a lower level in the [[%LOCALSITEPREFS%]] or at the web level. For an easier upgrade it is recommended to customize plugin preference settings in <nop>%LOCALSITEPREFS% only. 
     75[[Preference settings]] of active plugins can be retrieved anywhere in Foswiki with =%&lt;pluginname&gt;_&lt;var&gt;%=, such as =%<nop>TABLEPLUGIN_SHORTDESCRIPTION%=. They can also be redefined with the =%&lt;pluginname&gt;_&lt;var&gt;%= setting at a lower level in the [[%LOCALSITEPREFS%]] or at the web level. For an easier upgrade it is recommended to customize plugin preference settings in <nop>%LOCALSITEPREFS% only. 
    8176 
    8277---+++ Listing Active Plugins 
     
    8479Plugin status macros let you list all active plugins wherever needed. 
    8580 
    86 This site is running TWiki version *%WIKIVERSION%*, plugin API version 
     81This site is running Foswiki version *%WIKIVERSION%*, plugin API version 
    8782*%PLUGINVERSION{}%* 
    8883 
    8984#ActivatedPlugins 
    9085---++++ =%<nop>ACTIVATEDPLUGINS%= 
    91 On this TWiki site, the enabled plugins are: %ACTIVATEDPLUGINS%. 
     86On this Foswiki site, the enabled plugins are: %ACTIVATEDPLUGINS%. 
    9287 
    9388---++++ =%<nop>PLUGINDESCRIPTIONS%= 
     
    9994 
    10095#PluginAPI 
    101 ---++ The TWiki Plugin API 
    102  
    103 The Application Programming Interface (API) for TWiki plugins provides the specifications for hooking into the core TWiki code from your external Perl plugin module. 
     96---++ The Foswiki Plugin API 
     97 
     98The Application Programming Interface (API) for Foswiki plugins provides the specifications for hooking into the core Foswiki code from your external Perl plugin module. 
    10499 
    105100---+++ Available Core Functions 
    106101 
    107 The TWikiFuncDotPm module (=lib/TWiki/Func.pm=) describes *all* the interfaces available to plugins. Plugins should *only* use the interfaces described in this module. 
    108  
    109 __%X% 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. 
     102The FoswikiFuncDotPm module (=lib/Foswiki/Func.pm=) describes *all* the interfaces available to plugins. Plugins should *only* use the interfaces described in this module. 
     103 
     104__%X% 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 Foswiki. 
    110105 
    111106---+++ Predefined Hooks 
    112107 
    113 In addition to TWiki core functions, plugins can use *predefined hooks*, or *callbacks*, as described in the =lib/TWiki/Plugins/EmptyPlugin.pm= module. 
     108In addition to Foswiki core functions, plugins can use *predefined hooks*, or *callbacks*, as described in the =lib/Foswiki/Plugins/EmptyPlugin.pm= module. 
    114109 
    115110   * All but the initPlugin are disabled. To enable a callback, remove =DISABLE_= from the function name. 
    116111 
    117 TWiki:Codev/StepByStepRenderingOrder helps you decide which rendering handler to use. 
     112Foswiki:Codev/StepByStepRenderingOrder helps you decide which rendering handler to use. 
    118113 
    119114#FastPluginHints 
     
    124119        =eval { require IPC::Run }= %BR% 
    125120        =return "&lt;font color=\"red\"&gt;SamplePlugin: Can't load required modules ($@)&lt;/font&gt;" if $@;= 
    126    * 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/=. 
    127    * 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 [[#ConfigSpec][Config.spec]] instead.  
     121   * 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/Foswiki/Plugins/BathPlugin/=. 
     122   * Avoid using preferences in the plugin topic; set =$NO_PREFS_IN_TOPIC= if you possibly can, as that will stop Foswiki from reading the plugin topic for every page. Use [[#ConfigSpec][Config.spec]] instead.  
    128123   * Use registered tag handlers 
    129124   * [[#MeasurePerformance][Measure the performance]] to see the difference 
     
    138133      * The plugin initialization code does not register a plugin that returns 0 (or that has no =initPlugin= handler). 
    139134 
    140    * =$TWiki::Plugins::VERSION= in the =TWiki::Plugins= module contains the TWiki plugin API version, currently *%PLUGINVERSION{}%*. 
     135   * =$Foswiki::Plugins::VERSION= in the =Foswiki::Plugins= module contains the Foswiki plugin API version, currently *%PLUGINVERSION{}%*. 
    141136      * You can also use the =[[VarPLUGINVERSION][%<nop>PLUGINVERSION{}%]]= macro to query the plugin API version or the version of installed plugins. 
    142137 
    143138---+++ Security 
    144139 
    145    * 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. 
    146    * Don't allow sensitive configuration data to be edited by users. it is better to add sensitive configuration options to the =%TWiki::cfg= hash than adding it as preferences in the plugin topic. 
     140   * Badly written plugins can open huge security holes in Foswiki. This is especially true if care isn't taken to prevent execution of arbitrary commands on the server. 
     141   * Don't allow sensitive configuration data to be edited by users. it is better to add sensitive configuration options to the =%Foswiki::cfg= hash than adding it as preferences in the plugin topic. 
    147142      * [[#ConfigSpec][Integrating with <code>configure</code>]] describes the steps 
    148       * TWiki:Plugins.MailInContrib has an example 
    149       * TWiki:Plugins.BuildContrib can help you with this 
    150    * Always use the TWiki::Sandbox to execute commands. 
     143      * Foswiki:Plugins.MailInContrib has an example 
     144      * Foswiki:Plugins.BuildContrib can help you with this 
     145   * Always use the Foswiki::Sandbox to execute commands. 
    151146   * 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. 
    152147 
     
    154149---++ Creating Plugins 
    155150 
    156 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 [[#PluginAPI][TWiki Plugin API]] provides the programming interface for TWiki. 
     151With 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 [[#PluginAPI][Foswiki Plugin API]] provides the programming interface for Foswiki. 
    157152 
    158153---+++ Anatomy of a Plugin 
    159154 
    160 A (very) basic TWiki plugin consists of two files: 
     155A (very) basic Foswiki plugin consists of two files: 
    161156 
    162157   * a Perl module, e.g. =MyFirstPlugin.pm= 
    163158   * a documentation topic, e.g. =MyFirstPlugin.txt= 
    164159 
    165 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. 
    166 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. 
    167  
    168 The plugin API handles the details of connecting your Perl module with main TWiki code. When you're familiar with the [[#PluginAPI][Plugin API]], you're ready to develop plugins. 
    169  
    170 _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_. 
     160The Perl module can be a block of code that talks to with Foswiki alone, or it can include other elements, like other Perl modules (including other plugins), graphics, Foswiki templates, external applications (ex: a Java applet), or just about anything else it can call. 
     161In 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/Foswiki/Plugins/MyFirstPlugin/= directory. 
     162 
     163The plugin API handles the details of connecting your Perl module with main Foswiki code. When you're familiar with the [[#PluginAPI][Plugin API]], you're ready to develop plugins. 
     164 
     165_The Foswiki: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_. 
    171166 
    172167---+++ Creating the Perl Module  
    173168 
    174 Copy file =lib/TWiki/Plugins/EmptyPlugin.pm= to =&lt;name&gt;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 [[#PluginAPI][Plugin API]] specs for more information. 
     169Copy file =lib/Foswiki/Plugins/EmptyPlugin.pm= to =&lt;name&gt;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 [[#PluginAPI][Plugin API]] specs for more information. 
    175170 
    176171If your plugin uses its own modules and objects, you must include the name of the plugin in the package name. For example, write =Package <nop>MyFirstPlugin::Attrs;= instead of just =Package Attrs;=. Then call it using: 
    177172<pre> 
    178 use TWiki::Plugins::MyFirstPlugin::Attrs; 
     173use Foswiki::Plugins::MyFirstPlugin::Attrs; 
    179174$var = MyFirstPlugin::Attrs->new(); 
    180175</pre> 
     
    185180The plugin documentation topic contains usage instructions and version details. It serves the plugin files as %SYSTEMWEB%.FileAttachments for downloading. (The doc topic is also included _in_ the [[#CreatePluginPackage][distribution package]].) To create a documentation topic: 
    186181 
    187    1. *Copy* the plugin topic template from TWiki.org. To copy the text, go to TWiki:Plugins/PluginPackage and: 
     182   1. *Copy* the plugin topic template from Foswiki.org. To copy the text, go to Foswiki:Plugins/PluginPackage and: 
    188183      * enter the plugin name in the "How to Create a Plugin" section 
    189184      * click Create 
     
    194189      * paste &amp; save new plugin topic on your site 
    195190   1. *Customize* your plugin topic. 
    196       * 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/%WIKINAME%. This is important because links should work properly in a plugin topic installed on any TWiki, not just on TWiki.org. 
     191      * Important: In case you plan to publish your plugin on Foswiki.org, use Interwiki names for author names and links to Foswiki.org topics, such as Foswiki:Main/%WIKINAME%. This is important because links should work properly in a plugin topic installed on any Foswiki, not just on Foswiki.org. 
    197192   1. *Document* the performance data you gathered while [[#MeasurePerformance][measuring the performance]] 
    198193   1. *Save* your topic, for use in [[#CreatePluginPackage][packaging]] and [[#PublishPlugin][publishing]] your plugin. 
     
    200195<blockquote style="background-color:#f5f5f5"> 
    201196*OUTLINE: Doc Topic Contents* <br /> 
    202 Check the plugins web on TWiki.org for the latest plugin doc topic template. Here's a quick overview of what's covered: 
     197Check the plugins web on Foswiki.org for the latest plugin doc topic template. Here's a quick overview of what's covered: 
    203198 
    204199*Syntax Rules:* &lt;<i>Describe any special text formatting that will be rendered.</i>&gt;"  
     
    206201*Example:* &lt;<i>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!</i>&gt;" 
    207202 
    208 *Plugin Settings:* &lt;<i>Description and settings for custom plugin settings, and those required by TWiki.</i>&gt;" 
    209  
    210    * *Plugins Preferences* &lt;<i>If user settings are needed, link to [[%SYSTEMWEB%.PreferenceSettings][preference settings]] and explain the role of the plugin name prefix 
     203*Plugin Settings:* &lt;<i>Description and settings for custom plugin settings, and those required by Foswiki.</i>&gt;" 
     204 
     205   * *Plugins Preferences* &lt;<i>If user settings are needed, link to [[%SYSTEMWEB%.PreferenceSettings][preference settings]] and explain the role of the plugin name prefix</i> 
    211206 
    212207*Plugin Installation Instructions:* &lt;<i>Step-by-step set-up guide, user help, whatever it takes to install and run, goes here.</i>&gt;" 
    213208 
    214 *Plugin Info:* &lt;<i>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.</i>&gt;" 
     209*Plugin Info:* &lt;<i>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 Foswiki:Plugins web.</i>&gt; 
    215210</blockquote> 
    216211 
     
    218213---+++ Packaging for Distribution 
    219214 
    220 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! 
     215The Foswiki:Plugins.BuildContrib is a powerful build environment that is used by the Foswiki project to build Foswiki itself, as well as many of the plugins. You don't *have* to use it, but it is highly recommended! 
    221216 
    222217If 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=). 
    223218 
    224    1. Distribute the plugin files in a directory structure that mirrors TWiki. If your plugin uses additional files, include them all: 
    225       * =lib/TWiki/Plugins/MyFirstPlugin.pm= 
    226       * =data/TWiki/MyFirstPlugin.txt= 
    227       * =pub/TWiki/MyFirstPlugin/uparrow.gif= [a required graphic] 
     219   1. Distribute the plugin files in a directory structure that mirrors Foswiki. If your plugin uses additional files, include them all: 
     220      * =lib/Foswiki/Plugins/MyFirstPlugin.pm= 
     221      * =data/Foswiki/MyFirstPlugin.txt= 
     222      * =pub/Foswiki/MyFirstPlugin/uparrow.gif= [a required graphic] 
    228223   2. Create a zip archive with the plugin name (=MyFirstPlugin.zip=) and add the entire directory structure from Step 1. The archive should look like this: 
    229       * =lib/TWiki/Plugins/MyFirstPlugin.pm= 
    230       * =data/TWiki/MyFirstPlugin.txt= 
    231       * =pub/TWiki/MyFirstPlugin/uparrow.gif= 
     224      * =lib/Foswiki/Plugins/MyFirstPlugin.pm= 
     225      * =data/Foswiki/MyFirstPlugin.txt= 
     226      * =pub/Foswiki/MyFirstPlugin/uparrow.gif= 
    232227 
    233228#MeasurePerformance 
    234229---+++ Measuring and Improving the Plugin Performance 
    235230 
    236 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. 
     231A high quality plugin performs well. You can use the Foswiki:Plugins.PluginBenchmarkAddOn to measure your Foswiki:Plugins.PluginBenchmarks. The data is needed as part of the Documentation Topic. 
    237232 
    238233See also [[#FastPluginHints][Hints on Writing Fast Plugins]]. 
     
    241236---+++ Publishing for Public Use 
    242237 
    243 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. 
     238You can release your tested, packaged plugin to the Foswiki community through the Foswiki:Plugins web. All plugins submitted to Foswiki.org are available for download and further development in Foswiki:Plugins/PluginPackage. 
    244239 
    245240Publish your plugin by following these steps: 
    246    1. *Post* the plugin documentation topic in the TWiki:Plugins/PluginPackage: 
     241   1. *Post* the plugin documentation topic in the Foswiki:Plugins/PluginPackage: 
    247242      * enter the plugin name in the "How to Create a Plugin" section, for example =MyFirstPlugin= 
    248243      * paste in the topic text from [[#CreatePluginTopic][Writing the Documentation Topic]] and save 
    249244   1. *Attach* the distribution zip file to the topic, ex: =MyFirstPlugin.zip= 
    250    1. *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.) 
    251    1. *Put* the plugin into the SVN repository, see TWiki:Plugins/ReadmeFirst (optional) 
     245   1. *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 Foswiki:Support.) 
     246   1. *Put* the plugin into the SVN repository, see Foswiki:Plugins/ReadmeFirst (optional) 
    252247 
    253248%N% Once you have done the above steps once, you can use the !BuildContrib to upload updates to your plugin. 
    254249 
    255 Thank you very much for sharing your plugin with the TWiki community :-) 
     250Thank you very much for sharing your plugin with the Foswiki community :-) 
    256251 
    257252#RecommendedStorageOfPluginData 
    258253---++ Recommended Storage of Plugin Specific Data 
    259254 
    260 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. 
     255Plugins 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 FoswikiFuncDotPm functions that support saving and loading of topics and attachments. 
    261256 
    262257---+++ Plugin Internal Data 
    263258 
    264 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. 
     259You can create a plugin "work area" using the =Foswiki::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, =Foswiki::Func::storeFile()= and =Foswiki::Func::readFile()= are provided to persistently store and retrieve simple data in this area. 
    265260 
    266261---+++ Web Accessible Data 
    267262 
    268 __Topic-specific data__ such as generated images can be stored in the topic's attachment area, which is web accessible. Use the =TWiki::Func::saveAttachment()= function to store the data. 
     263__Topic-specific data__ such as generated images can be stored in the topic's attachment area, which is web accessible. Use the =Foswiki::Func::saveAttachment()= function to store the data. 
    269264 
    270265Recommendation for file name: 
     
    274269   * Example: =_GaugePlugin_img123.gif= 
    275270 
    276 __Web specific data__ can be stored in the plugin's attachment area, which is web accessible. Use the =TWiki::Func::saveAttachment()= function to store the data. 
     271__Web specific data__ can be stored in the plugin's attachment area, which is web accessible. Use the =Foswiki::Func::saveAttachment()= function to store the data. 
    277272 
    278273Recommendation for file names in plugin attachment area: 
     
    286281Some extensions have setup requirements that are best integrated into =configure= rather than trying to use [[%SYSTEMWEB%.PreferenceSettings][preference settings]]. These extensions use =Config.spec= files to publish their configuration requirements. 
    287282 
    288 =Config.spec= files are read during 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=. 
     283=Config.spec= files are read during 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/Foswiki/Plugins/BathPlugin/Config.spec=. 
    289284 
    290285---+++ Structure of a <code>Config.spec</code> file 
     
    299294# **SELECT Plastic,Rubber,Metal** 
    300295# Select the plug type 
    301 $TWiki::cfg{BathPlugin}{PlugType} = 'Plastic'; 
     296$Foswiki::cfg{BathPlugin}{PlugType} = 'Plastic'; 
    302297 
    303298# **NUMBER** 
    304299# Enter the chain length in cm 
    305 $TWiki::cfg{BathPlugin}{ChainLength} = '30'; 
     300$Foswiki::cfg{BathPlugin}{ChainLength} = '30'; 
    306301 
    307302# **BOOLEAN EXPERT** 
    308303# Turn this option off to disable the water temperature alarm 
    309 $TWiki::cfg{BathPlugin}{TempSensorEnabled} = '1'; 
     304$Foswiki::cfg{BathPlugin}{TempSensorEnabled} = '1'; 
    310305</verbatim> 
    311 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, 
    312 <verbatim> 
    313 if( $TWiki::cfg{BathPlugin}{TempSensorEnabled} && $curTemperature > 50 ) { 
     306The 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 =$Foswiki::cfg{BathPlugin}{PlugType}=, =$Foswiki::cfg{BathPlugin}{ChainLength}=, and =$Foswiki::cfg{BathPlugin}{TempSensorEnabled}= for use in your plugin. For example, 
     307<verbatim> 
     308if( $Foswiki::cfg{BathPlugin}{TempSensorEnabled} && $curTemperature > 50 ) { 
    314309    die "The bathwater is too hot for comfort"; 
    315310} 
     
    340335| H | means the option is not visible in =configure= | 
    341336 
    342 See =lib/TWiki.spec= for many more examples. 
     337See =lib/Foswiki.spec= for many more examples. 
    343338 
    344339=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. 
    345340 
    346 TWiki:TWiki/SpecifyingConfigurationItemsForExtensions has supplemental documentation on configure settings. 
     341Foswiki:Foswiki/SpecifyingConfigurationItemsForExtensions has supplemental documentation on configure settings. 
    347342 
    348343#MaintainPlugins 
     
    351346---+++ Discussions and Feedback on Plugins 
    352347 
    353 Each published plugin has a plugin development topic on TWiki.org. Plugin development topics are named after your plugin and end in =Dev=, such as =MyFirstPluginDev=. The plugin development topic is a great resource to discuss feature enhancements and to get feedback from the TWiki community. 
    354  
    355 ---+++ Maintaining Compatibility with Earlier TWiki Versions 
    356  
    357 The plugin interface (TWikiFuncDotPm functions and plugin handlers) evolve over time. TWiki introduces new API functions to address the needs of plugin authors. Plugins using unofficial TWiki internal functions may no longer work on a TWiki upgrade. 
    358  
    359 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.  
    360  
    361 __%T% 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.  
    362 Here is an example; the TWiki:Support.PluginsSupplement has more details. 
    363  
    364 <verbatim> 
    365     if( $TWiki::Plugins::VERSION >= 1.1 ) { 
    366         @webs = TWiki::Func::getListOfWebs( 'user,public' ); 
     348Each published plugin has a plugin development topic on Foswiki.org. Plugin development topics are named after your plugin and end in =Dev=, such as =MyFirstPluginDev=. The plugin development topic is a great resource to discuss feature enhancements and to get feedback from the Foswiki community. 
     349 
     350---+++ Maintaining Compatibility with Earlier Foswiki Versions 
     351 
     352The plugin interface (FoswikiFuncDotPm functions and plugin handlers) evolve over time. Foswiki introduces new API functions to address the needs of plugin authors. Plugins using unofficial Foswiki internal functions may no longer work on a Foswiki upgrade. 
     353 
     354Organizations typically do not upgrade to the latest Foswiki for many months. However, many administrators still would like to install the latest versions of a plugin on their older Foswiki installation. This need is fulfilled if plugins are maintained in a compatible manner.  
     355 
     356__%T% Tip:__ Plugins can be written to be compatible with older and newer Foswiki releases. This can be done also for plugins using unofficial Foswiki internal functions of an earlier release that no longer work on the latest Foswiki codebase.  
     357Here is an example; the Foswiki:Support.PluginsSupplement has more details. 
     358 
     359<verbatim> 
     360    if( $Foswiki::Plugins::VERSION >= 1.1 ) { 
     361        @webs = Foswiki::Func::getListOfWebs( 'user,public' ); 
    367362    } else { 
    368         @webs = TWiki::Func::getPublicWebList( ); 
     363        @webs = Foswiki::Func::getPublicWebList( ); 
    369364    } 
    370365</verbatim> 
     
    372367---+++ Handling deprecated functions 
    373368 
    374 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. 
    375  
    376 When a plugin defines deprecated handlers, a warning will be shown in the list generated by %<nop>FAILEDPLUGINS%. Admins who see these warnings should check TWiki.org and if necessary, contact the plugin author, for an updated version of the plugin. 
    377  
    378 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 %<nop>FAILEDPLUGINS%. 
    379  
    380 This is done by defining a map from the handler name to the =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: 
    381  
    382 <verbatim> 
    383 package TWiki::Plugins::SinkPlugin; 
    384 use vars qw( %TWikiCompatibility ); 
    385 $TWikiCompatibility{endRenderingHandler} = 1.1; 
     369From time-to-time, the Foswiki developers will add new functions to the interface (either to FoswikiFuncDotPm, 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 Foswiki release, and probably longer, though this cannot be guaranteed. 
     370 
     371When a plugin defines deprecated handlers, a warning will be shown in the list generated by %<nop>FAILEDPLUGINS%. Admins who see these warnings should check Foswiki.org and if necessary, contact the plugin author, for an updated version of the plugin. 
     372 
     373Updated plugins may still need to define deprecated handlers for compatibility with old Foswiki versions. In this case, the plugin package that defines old handlers can suppress the warnings in %<nop>FAILEDPLUGINS%. 
     374 
     375This is done by defining a map from the handler name to the =Foswiki::Plugins= version _in which the handler was first deprecated_. For example, if we need to define the =endRenderingHandler= for compatibility with =Foswiki::Plugins= versions before 1.1, we would add this to the plugin: 
     376 
     377<verbatim> 
     378package Foswiki::Plugins::SinkPlugin; 
     379use vars qw( %FoswikiCompatibility ); 
     380$FoswikiCompatibility{endRenderingHandler} = 1.1; 
    386381</verbatim> 
    387 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. 
     382If the currently-running Foswiki version is 1.1 _or later_, then the _handler will not be called_ and _the warning will not be issued_. Foswiki with versions of =Foswiki::Plugins= before 1.1 will still call the handler as required. 
    388383 
    389384%STOPINCLUDE% 
    390 __Related Topics:__ DeveloperDocumentationCategory, AdminDocumentationCategory, TWiki:Support.PluginsSupplement 
    391  
     385__Related Topics:__ DeveloperDocumentationCategory, AdminDocumentationCategory, Foswiki:Support.PluginsSupplement 
     386 
Note: See TracChangeset for help on using the changeset viewer.