I (Andrew Gilmartin) have been working on the TclPlugin. A useful pattern I have discovered is to place the script in one page and call it with data from another page. For example, a general purpose script might produce a index of project pages. This script needs to know the name of the project and it can generate the index content from the list of all pages. To use this today I would enter

[{TclPlugin scriptPage='ProjectPagesIndexScript' prefix='Glass'}]

What would be preferable would be to have the user enter

[{ProjectPagesIndexScript prefix='Glass'}]

Now, when com.ecyrd.jspwiki.plugin.PluginManager can't find the plugin it first checks if there is a page with the name and then invokes the scripting plugin ("jspwiki.plugin.scriptPlugin") with the additional parameter indicating the name of the script (for example "_script" à la "_body").

Perhaps the JSPWiki support should be more generic. An "unknown plugin" plugin would be specified via jspwiki.plugin.unknownPlugin property. When a plugin can't be found the unknown plugin is called with name of the missing plugin passed in via the "_name" parameter (along with the other parameter). A scripting plugin might do as above. A database plugin might use the _name as the name of a stored procedure and so execute it and return the results to the wiki page. -- Andrew Gilmartin

What happens when you have two or more scripting tools? For example I have a lot of Judoscript via my Judoscript plugin and have added the Tcl Plugin. How will it figure out which scripting language to use? -- Foster Schucker

Lets assume you have three scripting plugins. Each would register itself for use in handling unknown plugin requests. When JSPWiki needs to execute the unknown name it would ask each in turn until one agrees to handle the execution. The scripting plugins would implement something like boolean canExecute( String name, Map parameters ). (Note that this would allow you to replace the existing plugin path searching code with another plugin.)

How each plugin knows whether can handle the request is another matter. I think this needs to be independent of scripting plugin. For example, the Coffee International site might choose to require that the first line of each script page name the plugin to be used. For example, the MilestonesScript page has as its first line #!com.ingenta.jspwiki.plugin.TclPlugin. While the Local Tea site might require all script pages to be listed on a page specific to each plugin. For example, the MilestonesScript would be listed on the JudoscriptScripts page. And the Soda World site requires script pages to use a plugin specific prefix so that MilestonesScript would need to be called MilestonesTclScript.

The main point to take away is that plugin authors should abide by the site preference and not invent their own. I would be happy to design something with you to get this moving forward. -- Andrew Gilmartin

The attached patch "unknownPlugin.patch" to the PluginManager.java (~JSPWIki 2.0.52) implements the simpler unknown plugin feature. When a wiki page contains an unknown plugin the plugin specified by the ~jspwiki.plugin.unknownPlugin property is used. (The plugin's class name must be fully qualified.) When the plugin is called the name of unknown plugin is passed as "_name" in the parameters. -- Andrew Gilmartin
Attached my current PluginManager.java (from ~JSPWiki 2.0.39). The patch works but having the actual file sometimes is more helpful. -- Andrew Gilmartin
It would be enough to just use something like the standard Unix #! directive to select the plugin to use. For example, "#!TclPlugin" or "//!com.ingenta.jspwiki.plugins.js.JSPlugin". It might also be useful to provide default parameters, eg "//!JSPlugin scriptResult='xml' foo='bar'". But perhaps the simpler the better. -- Andrew Gilmartin
I implemented something simpler still. I modified the PluginManager to match the start of the page's content with a shebang-like token and then to use the token's corresponding plugin class as the handler for the page. In the jspwiki.properties I added
jspwiki.plugin.shebangPluginMap= \
    //!javascript com.ingenta.jspwiki.plugin.js.JSPlugin \
    /*!javascript com.ingenta.jspwiki.plugin.js.JSPlugin \
    #!tcl com.ingenta.jspwiki.plugin.TclPlugin \

So now if you want a script page to help handled by JSPlugin you would add to //!javascript to the top of the page, eg



-- Andrew Gilmartin

Add new attachment

Only authorized users are allowed to upload new attachments.

List of attachments

Kind Attachment Name Size Version Date Modified Author Change note
PluginManager.java 16.6 kB 1 22-Feb-2005 02:38
unknownPlugin.patch 3.2 kB 1 01-Sep-2004 00:28 AndrewGilmartin
« This page (revision-17) was last changed on 10-Mar-2005 23:56 by