buildrelease
[openafs-wiki.git] / TWiki / TWikiPlugins.mdwn
1 <div>
2   <ul>
3     <li><a href="#TWiki Plugins"> TWiki Plugins</a><ul>
4         <li><a href="#Overview"> Overview</a></li>
5         <li><a href="#Installing Plugins"> Installing Plugins</a><ul>
6             <li><a href="#On-Site Pretesting"> On-Site Pretesting</a></li>
7             <li><a href="#Some Notes on Plugin Performance"> Some Notes on Plugin Performance</a></li>
8           </ul>
9         </li>
10         <li><a href="#Managing Installed Plugins"> Managing Installed Plugins</a><ul>
11             <li><a href="#Enabling Plugins"> Enabling Plugins</a></li>
12             <li><a href="#Plugin Evaluation Order"> Plugin Evaluation Order</a></li>
13             <li><a href="#Plugin-Specific Settings"> Plugin-Specific Settings</a></li>
14             <li><a href="#Listing Active Plugins"> Listing Active Plugins</a><ul>
15                 <li><a href="#=%ACTIVATEDPLUGINS%="> %ACTIVATEDPLUGINS%</a></li>
16                 <li><a href="#=%PLUGINDESCRIPTIONS%="> %PLUGINDESCRIPTIONS%</a></li>
17                 <li><a href="#=%FAILEDPLUGINS%="> %FAILEDPLUGINS%</a></li>
18               </ul>
19             </li>
20           </ul>
21         </li>
22         <li><a href="#The TWiki Plugin API"> The TWiki Plugin API</a><ul>
23             <li><a href="#Available Core Functions"> Available Core Functions</a></li>
24             <li><a href="#Predefined Hooks"> Predefined Hooks</a></li>
25             <li><a href="#Hints on Writing Fast Plugins"> Hints on Writing Fast Plugins</a></li>
26             <li><a href="#Plugin Version Detection"> Plugin Version Detection</a></li>
27             <li><a href="#Security"> Security</a></li>
28           </ul>
29         </li>
30         <li><a href="#Creating Plugins"> Creating Plugins</a><ul>
31             <li><a href="#Anatomy of a Plugin"> Anatomy of a Plugin</a></li>
32             <li><a href="#Creating the Perl Module"> Creating the Perl Module </a></li>
33             <li><a href="#Measuring and Improving the Plug"> Measuring and Improving the Plugin Performance</a></li>
34             <li><a href="#Writing the Documentation Topic"> Writing the Documentation Topic</a></li>
35             <li><a href="#Packaging for Distribution"> Packaging for Distribution</a></li>
36             <li><a href="#Publishing for Public Use"> Publishing for Public Use</a></li>
37           </ul>
38         </li>
39         <li><a href="#Recommended Storage of Plugin Sp"> Recommended Storage of Plugin Specific Data</a><ul>
40             <li><a href="#Plugin Internal Data"> Plugin Internal Data</a></li>
41             <li><a href="#Web Accessible Data"> Web Accessible Data</a></li>
42           </ul>
43         </li>
44         <li><a href="#Maintaining Plugins"> Maintaining Plugins</a><ul>
45             <li><a href="#Discussions and Feedback on Plug"> Discussions and Feedback on Plugins</a></li>
46             <li><a href="#Maintaining Compatibility with E"> Maintaining Compatibility with Earlier TWiki Versions</a></li>
47             <li><a href="#Handling deprecated functions"> Handling deprecated functions</a></li>
48           </ul>
49         </li>
50       </ul>
51     </li>
52   </ul>
53 </div>
54
55 # <a name="TWiki Plugins"></a> TWiki Plugins
56
57 _Add functionality to TWiki with readily available Plugins; create Plugins based on APIs_
58
59 ## <a name="Overview"></a> Overview
60
61 You can add Plugins to extend TWiki functionality, without altering the core code. A plug-in approach lets you:
62
63 - add virtually unlimited features while keeping the main TWiki code compact and efficient;
64 - heavily customize an installation and still do clean updates to new versions of TWiki;
65 - rapidly develop new TWiki functions in Perl using the Plugin API.
66
67 Everything to do with TWiki Plugins - demos, new releases, downloads, development, general discussion - is available at TWiki.org, in the ** TWiki:Plugins ** web.
68
69 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.
70
71 **_Relevant links on TWiki.org:_**
72
73 - TWiki:TWiki.TWikiPluginsSupplement - **_%T% tip:_** supplemental documentation on TWiki plugins
74 - TWiki:Plugins.PluginPackage - list of all contributed plugin packages
75 - TWiki:Plugins.PluginDevelopment - discussion and feedback on contributed plugins
76 - TWiki:Plugins.PluginBrainstorming - open forum for new plugin ideas
77 - TWiki:Plugins.PluginPackageHowTo - template to create a new plugin package
78
79 **_See other types of extensions:_** [[TWikiAddOns]], [[TWikiContribs]], [[TWikiSkins]]
80
81 <a name="InstallPlugin"></a>
82
83 ## <a name="Installing Plugins"></a> Installing Plugins
84
85 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.
86
87 **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.
88
89 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.
90
91 <a name="PreTesting"></a>
92
93 ### <a name="On-Site Pretesting"></a> On-Site Pretesting
94
95 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.
96
97 [[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 <code>[[%FAILEDPLUGINS%|Main/VarFAILEDPLUGINS]]</code> variable can be used to debug failures. You may also want to check your webserver error log and the various TWiki log files.
98
99 ### <a name="Some Notes on Plugin Performance"></a> Some Notes on Plugin Performance
100
101 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 http://www.dementia.org/twiki/view/TWiki/AbcPlugin`
102
103 %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 %DISABLEDPLUGINS% TWiki variable.
104
105 Define `DISABLEDPLUGINS` to be a comma-separated list of names of plugins to disable. Define it in Main.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,
106
107        * Set DISABLEDPLUGINS = SpreadSheetPlugin, EditTablePlugin
108
109 <a name="ManagingPlugins"></a>
110
111 ## <a name="Managing Installed Plugins"></a> Managing Installed Plugins
112
113 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:
114
115 ### <a name="Enabling Plugins"></a> Enabling Plugins
116
117 Plugins can be enabled and disabled with the [configure](http://www.dementia.org/twiki/configure) script. An installed Plugin needs to be enabled before it can be used.
118
119 ### <a name="Plugin Evaluation Order"></a> Plugin Evaluation Order
120
121 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](http://www.dementia.org/twiki/configure).
122
123 ### <a name="Plugin-Specific Settings"></a> Plugin-Specific Settings
124
125 Plugins are usually configured by variables accessible though the [configure](http://www.dementia.org/twiki/configure) interface, but in some cases (usually older plugins) TWiki preferences are used. If a TWiki variable is defined in a Plugin topic e.g:
126
127 - Set SETTING = Create dynamic foo bar reports
128
129 Then these settings can be retrieved as preferences variables like `%<pluginname>_<var>%`. For example, `%RUBBERPLUGIN_SETTING%` shows the value of SETTING in the RubberPlugin topic.
130
131 ### <a name="Listing Active Plugins"></a> Listing Active Plugins
132
133 Plugin status variables let you list all active Plugins wherever needed.
134
135 #### <a name="=%ACTIVATEDPLUGINS%="></a> `%ACTIVATEDPLUGINS%`
136
137 On this TWiki site, the enabled Plugins are: [[SpreadSheetPlugin]], [[CommentPlugin]], [[EditTablePlugin]], [[InterwikiPlugin]], [[PreferencesPlugin]], [[SlideShowPlugin]], [[SmiliesPlugin]], [[TablePlugin]], [[TwistyPlugin]].
138
139 #### <a name="=%PLUGINDESCRIPTIONS%="></a> `%PLUGINDESCRIPTIONS%`
140
141 - [[SpreadSheetPlugin]] <span>(any TWiki, 10197)</span>:
142 - [[CommentPlugin]] <span>(Dakar, 11359)</span>: Allows users to quickly post comments to a page without an edit/preview/save cycle
143 - [[EditTablePlugin]] <span>(any TWiki, 11646)</span>:
144 - [[InterwikiPlugin]] <span>(Dakar, $Rev: 11935$)</span>:
145 - [[PreferencesPlugin]] <span>(Dakar, 9839)</span>:
146 - [[SlideShowPlugin]] <span>(Any TWiki, $Rev: 12847$)</span>:
147 - [[SmiliesPlugin]] <span>(Dakar, 8154)</span>:
148 - [[TablePlugin]] <span>(1.020, 12339)</span>:
149 - [[TwistyPlugin]] <span>(1.2.0, $Rev: 12154$)</span>:
150
151 #### <a name="=%FAILEDPLUGINS%="></a> `%FAILEDPLUGINS%`
152
153 <table border="1">
154   <tr>
155     <th>Plugin</th>
156     <th>Errors</th>
157   </tr>
158   <tr valign="top">
159     <td>[[TWiki/SpreadSheetPlugin]]</td>
160     <td><pre>
161 Plugins: could not fully register SpreadSheetPlugin, no plugin topic
162 </pre></td>
163   </tr>
164   <tr valign="top">
165     <td>[[TWiki/CommentPlugin]]</td>
166     <td><pre>
167 Plugins: could not fully register CommentPlugin, no plugin topic
168 </pre></td>
169   </tr>
170   <tr valign="top">
171     <td>[[TWiki/EditTablePlugin]]</td>
172     <td><pre>
173 Plugins: could not fully register EditTablePlugin, no plugin topic
174 </pre></td>
175   </tr>
176   <tr valign="top">
177     <td>[[TWiki/InterwikiPlugin]]</td>
178     <td><pre>
179 Plugins: could not fully register InterwikiPlugin, no plugin topic
180 </pre></td>
181   </tr>
182   <tr valign="top">
183     <td>[[TWiki/PreferencesPlugin]]</td>
184     <td><pre>
185 Plugins: could not fully register PreferencesPlugin, no plugin topic
186 </pre></td>
187   </tr>
188   <tr valign="top">
189     <td>[[TWiki/SlideShowPlugin]]</td>
190     <td><pre>
191 Plugins: could not fully register SlideShowPlugin, no plugin topic
192 </pre></td>
193   </tr>
194   <tr valign="top">
195     <td>[[TWiki/SmiliesPlugin]]</td>
196     <td><pre>
197 Plugins: could not fully register SmiliesPlugin, no plugin topic
198 </pre></td>
199   </tr>
200   <tr valign="top">
201     <td>[[TWiki/TablePlugin]]</td>
202     <td><pre>
203 Plugins: could not fully register TablePlugin, no plugin topic
204 </pre></td>
205   </tr>
206   <tr valign="top">
207     <td>[[TWiki/TwistyPlugin]]</td>
208     <td><pre>
209 Plugins: could not fully register TwistyPlugin, no plugin topic
210 </pre></td>
211   </tr>
212 </table>
213 <table border="1">
214   <tr>
215     <th>Handler</th>
216     <th>Plugins</th>
217   </tr>
218   <tr valign="top">
219     <td>beforeCommonTagsHandler</td>
220     <td>PreferencesPlugin<br />TwistyPlugin</td>
221   </tr>
222   <tr valign="top">
223     <td>beforeSaveHandler</td>
224     <td>CommentPlugin</td>
225   </tr>
226   <tr valign="top">
227     <td>commonTagsHandler</td>
228     <td>SpreadSheetPlugin<br />CommentPlugin<br />EditTablePlugin<br />SlideShowPlugin<br />SmiliesPlugin</td>
229   </tr>
230   <tr valign="top">
231     <td>initPlugin</td>
232     <td>SpreadSheetPlugin<br />CommentPlugin<br />EditTablePlugin<br />InterwikiPlugin<br />PreferencesPlugin<br />SlideShowPlugin<br />SmiliesPlugin<br />TablePlugin<br />TwistyPlugin</td>
233   </tr>
234   <tr valign="top">
235     <td>postRenderingHandler</td>
236     <td>EditTablePlugin<br />PreferencesPlugin<br />TwistyPlugin</td>
237   </tr>
238   <tr valign="top">
239     <td>preRenderingHandler</td>
240     <td>InterwikiPlugin<br />SmiliesPlugin<br />TablePlugin</td>
241   </tr>
242 </table>
243
244 **9 plugins**
245
246 <a name="PluginAPI"></a>
247
248 ## <a name="The TWiki Plugin API"></a> The TWiki Plugin API
249
250 The Application Programming Interface (API) for TWiki Plugins provides the specifications for hooking into the core TWiki code from your external Perl Plugin module.
251
252 ### <a name="Available Core Functions"></a> Available Core Functions
253
254 The [[TWikiFuncDotPm]] module (`lib/TWiki/Func.pm`) describes **all** the interfaces available to Plugins. Plugins should **only** use the interfaces described in this module.
255
256 **_%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.
257
258 ### <a name="Predefined Hooks"></a> Predefined Hooks
259
260 In addition to TWiki core functions, Plugins can use **predefined hooks**, or **callbacks**, as described in the `lib/TWiki/Plugins/EmptyPlugin.pm` module.
261
262 - All but the initPlugin are disabled. To enable a callback, remove `DISABLE_` from the function name.
263
264 TWiki:Codev/StepByStepRenderingOrder helps you decide which rendering handler to use.
265
266 <a name="FastPluginHints"></a>
267
268 ### <a name="Hints on Writing Fast Plugins"></a> Hints on Writing Fast Plugins
269
270 - 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.
271 - For example, use an `eval` block like this:%BR% `eval { require IPC::Run }` %BR% `return "<font color=\"red\">SamplePlugin: Can't load required modules ($@)</font>" if $@;`
272 - You can use a flag to avoid running the initialization twice
273 - The TWiki:Plugins.PluginBenchmarkAddOn comes in handy to measure and fine-tune the performance of your Plugin
274
275 ### <a name="Plugin Version Detection"></a> Plugin Version Detection
276
277 To eliminate the incompatibility problems bound to arise from active open Plugin development, a Plugin versioning system is provided for automatic compatibility checking.
278
279 - All modules require a `$VERSION='0.000'` variable, beginning at `1.000`.
280
281 - The `initPlugin` handler should check all dependencies and return TRUE if the initialization is OK or FALSE if something went wrong.
282   - The Plugin initialization code does not register a Plugin that returns FALSE (or that has no `initPlugin` handler).
283
284 - `$TWiki::Plugins::VERSION` in the `TWiki::Plugins` module contains the TWiki Plugin API version, currently **1\.11**.
285   - You can also use the <code>[[%PLUGINVERSION{}%|Main/VarPLUGINVERSION]]</code> variable to query the Plugin API version or the version of installed Plugins.
286
287 ### <a name="Security"></a> Security
288
289 - 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.
290 - 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
291   - See TWiki:Plugins.MailInContrib for an example of this
292   - TWiki:Plugins.BuildContrib can help you with this
293 - Always use the TWiki::Sandbox to execute commands.
294 - 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.
295
296 <a name="CreatePlugins"></a>
297
298 ## <a name="Creating Plugins"></a> Creating Plugins
299
300 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|Main/WebHome#PluginAPI]] Plugins by providing a programming interface for TWiki.
301
302 ### <a name="Anatomy of a Plugin"></a> Anatomy of a Plugin
303
304 A basic TWiki Plugin consists of two elements:
305
306 - a Perl module, ex: `MyFirstPlugin.pm`
307 - a documentation topic, ex: `MyFirstPlugin.txt`
308
309 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. 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.
310
311 The Plugin API handles the details of connecting your Perl module with main TWiki code. When you're familiar with the [[Plugin API|Main/WebHome#PluginAPI]], you're ready to develop Plugins.
312
313 ### <a name="Creating the Perl Module"></a> Creating the Perl Module
314
315 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|Main/WebHome#PluginAPI]] specs for more information.
316
317 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:
318
319     use TWiki::Plugins::MyFirstPlugin::Attrs;
320     $var = MyFirstPlugin::Attrs->new();
321
322 <a name="MeasurePerformance"></a>
323
324 ### <a name="Measuring and Improving the Plug"></a> Measuring and Improving the Plugin Performance
325
326 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.
327
328 See also [[Hints on Writing Fast Plugins|Main/WebHome#FastPluginHints]].
329
330 <a name="CreatePluginTopic"></a>
331
332 ### <a name="Writing the Documentation Topic"></a> Writing the Documentation Topic
333
334 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|Main/WebHome#CreatePluginPackage]].) To create a documentation topic:
335
336 1. **Copy** the Plugin topic template from TWiki.org. To copy the text, go to TWiki:Plugins/PluginPackage and:
337   - enter the Plugin name in the "How to Create a Plugin" section
338   - click Create
339   - select all in the Edit box &amp; copy
340   - Cancel the edit
341   - go back to your site to the TWiki web
342   - In the [[GoBox]] enter your Plugin name, for example `MyFirstPlugin`, press enter and create the new topic
343   - paste &amp; save new Plugin topic on your site
344 2. **Customize** your Plugin topic.
345   - 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/admin. This is important because links should work properly in a Plugin topic installed on any TWiki, not just on TWiki.org.
346 3. **Document** the performance data you gathered while [[measuring the performance|Main/WebHome#MeasurePerformance]]
347 4. **Save** your topic, for use in [[packaging|Main/WebHome#CreatePluginPackage]] and [[publishing|Main/WebHome#PublishPlugin]] your Plugin.
348
349 > **OUTLINE: Doc Topic Contents**
350 >
351 > <br />
352 >
353 > Check the Plugins web on TWiki.org for the latest Plugin doc topic template. Here's a quick overview of what's covered:
354 >
355 > **Syntax Rules:** &lt;_Describe any special text formatting that will be rendered._&gt;"
356 >
357 > **Example:** &lt;_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!_&gt;"
358 >
359 > **Plugin Settings:** &lt;_Description and settings for custom Plugin %VARIABLES%, and those required by TWiki._&gt;"
360 >
361 > - **Plugins Preferences** &lt;_If user settings are needed, explain... Entering values works exactly like [[TWikiPreferences]] and [[WebPreferences]]: six (6) spaces and then:_&gt;"
362 >   - **Set &lt;_EXAMPLE = value added_&gt;**
363 >
364 > **Plugin Installation Instructions:** &lt;_Step-by-step set-up guide, user help, whatever it takes to install and run, goes here._&gt;"
365 >
366 > **Plugin Info:** &lt;_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._&gt;"
367
368 <a name="CreatePluginPackage"></a>
369
370 ### <a name="Packaging for Distribution"></a> Packaging for Distribution
371
372 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!
373
374 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`).
375
376 1. Distribute the Plugin files in a directory structure that mirrors TWiki. If your Plugin uses additional files, include them all:
377   - `lib/TWiki/Plugins/MyFirstPlugin.pm`
378   - `data/TWiki/MyFirstPlugin.txt`
379   - `pub/TWiki/MyFirstPlugin/uparrow.gif` [a required graphic]
380 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:
381   - `lib/TWiki/Plugins/MyFirstPlugin.pm`
382   - `data/TWiki/MyFirstPlugin.txt`
383   - `pub/TWiki/MyFirstPlugin/uparrow.gif`
384
385 <a name="PublishPlugin"></a>
386
387 ### <a name="Publishing for Public Use"></a> Publishing for Public Use
388
389 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.
390
391 Publish your Plugin by following these steps:
392
393 1. **Post** the Plugin documentation topic in the TWiki:Plugins/PluginPackage:
394   - enter the Plugin name in the "How to Create a Plugin" section, for example `MyFirstPlugin`
395   - paste in the topic text from [[Writing the Documentation Topic|Main/WebHome#CreatePluginTopic]] and save
396 2. **Attach** the distribution zip file to the topic, ex: `MyFirstPlugin.zip`
397 3. **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.)
398 4. **Put** the Plugin into the SVN repository, see TWiki:Plugins/ReadmeFirst (optional)
399
400 %N% Once you have done the above steps once, you can use the BuildContrib to upload updates to your Plugin.
401
402 Thank you very much for sharing your Plugin with the TWiki community :-)
403
404 <a name="RecommendedStorageOfPluginData"></a>
405
406 ## <a name="Recommended Storage of Plugin Sp"></a> Recommended Storage of Plugin Specific Data
407
408 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.
409
410 ### <a name="Plugin Internal Data"></a> Plugin Internal Data
411
412 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.
413
414 ### <a name="Web Accessible Data"></a> Web Accessible Data
415
416 **_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.
417
418 Recommendation for file name:
419
420 - Prefix the filename with an underscore (the leading underscore avoids a nameclash with files attached to the same topic)
421 - Identify where the attachment originated from, typically by including the Plugin name in the file name
422 - Use only alphanumeric characters, underscores, dashes and periods to avoid platform dependency issues and URL issues
423 - Example: `_FooBarPlugin_img123.gif`
424
425 **_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.
426
427 Recommendation for file names in Plugin attachment area:
428
429 - Prefix the filename with an underscore
430 - Include the name of the web in the filename
431 - Use only alphanumeric characters, underscores, dashes and periods to avoid platform dependency issues and URL issues
432 - Example: `_Main_roundedge-ul.gif`
433
434 <a name="MaintainPlugins"></a>
435
436 ## <a name="Maintaining Plugins"></a> Maintaining Plugins
437
438 ### <a name="Discussions and Feedback on Plug"></a> Discussions and Feedback on Plugins
439
440 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.
441
442 ### <a name="Maintaining Compatibility with E"></a> Maintaining Compatibility with Earlier TWiki Versions
443
444 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.
445
446 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.
447
448 **_%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. TWiki:TWiki.TWikiPluginsSupplement#MaintainPlugins has more.
449
450 ### <a name="Handling deprecated functions"></a> Handling deprecated functions
451
452 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.
453
454 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.
455
456 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%.
457
458 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:
459
460     package TWiki::Plugins::SinkPlugin;
461     use vars qw( %TWikiCompatibility );
462     $TWikiCompatibility{endRenderingHandler} = 1.1;
463
464 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.
465
466 **_Related Topics:_** [[DeveloperDocumentationCategory]], [[AdminDocumentationCategory]], TWiki:TWiki.TWikiPluginsSupplement
467
468 -- **_Contributors:_** TWiki:Main.PeterThoeny, TWiki:Main.AndreaSterbini, TWiki:MainMikeMannix, TWiki:CrawfordCurrie