This is version . It is not the current version, and thus it cannot be edited.
[Back to current version]   [Restore this version]

This Contributed Plugin allows you to execute JavaScript code on the server. Useful for creating pages with dynamic content. This plugin is experimental at this stage; clearly better wiki integration and server safety issues need to be addressed.

The plugin's JavaScript implementation is Mozilla's Rhino. The public discussion for Mozilla's JavaScript implementations is at netscape.public.mozilla.jseng.

For more information please contact Andrew Gilmartin at andrew.gilmartin at ingenta.com.

Building#

To built you will need to

  1. copy the JSPWiki.jar to the project's lib directory. Note that I have only built the plugin against the JSPWiki 2.0.39 source.
  2. copy js.jar from Rhino 1.6R1 at http://www.mozilla.org/rhino/download.html
  3. copy xbrean.jar from at XMLBeans v1.0.3 at http://www.apache.org/dist/xml/xmlbeans/v1.0.3/bin/xmlbeans-1.0.3.tar. Note that this is a tar.gz file dispite the file name.
  4. copy servlet.jar from, for example, your Tomcat installation.

Then run ant

The code does not yet conform to the JSPWIki Coding Standard.

Installing#

Copy the file build/jspwiki-js-plugin.jar, lib/js.jar, and lib/xbean.jar to JSPWiki's WEB-INF/lib directory.

Using#

The plugin is called using

[{com.ingenta.jspwiki.plugin.js.JSPlugin scriptPage='wikiPage' scriptResult='text|xml|wiki' }]

[{com.ingenta.jspwiki.plugin.js.JSPlugin script='javascript' scriptResult='text|xml|wiki' }]

[{com.ingenta.jspwiki.plugin.js.JSPlugin result='text|xml|wiki'

.. javascript body content ..
}]

[{scriptPage result='text|xml|wiki'

.. data body content ..
}]

For most installations you need only refer to the plugin as JSPlugin as the installation will have added com.ingenta.jspwiki.plugin.js to the jspwiki.plugin.searchPath property.

The script and scriptPage parameter or body content selects the JavaScript code to execute. The scriptResult parameter determines how the script's result is further processed; xml result output is sent as is to the browser; text result output is send to the browser after escaping &, <, >, and " characters; wiki result output is send to the browser after first converting to HTML. The default scriptResult value is wiki.

Using the scriptPage as the name of the plugin only works for JSPWiki implementations using the modified com.ecyrd.jspwiki.plugin.PluginManager supporting the jspwiki.plugin.unknownPlugin property. For more information see ScriptedPlugin.

During execution the following global variables are available to the script:

wikiInfo An instance of class JSWikiInfo
wikiPage An instance of class JSWikiInfo for the page containing the plugin
pluginArgs An associative array containing the arguments to the plugin. For example format = pluginArgs[ "scriptResult" ];.
pluginBody The content of the plugin body. This is only set if the body does not contain the script.

See JSPluginScripts for examples of scripts.

Note that the current interpreter is not a safe one. Thus all event, file, socket, and use of Java classes is enabled.

Class and method detail#

class JSWikiPage#

o.name The name of the page.
o.author The author name of the most recient version.
o.created The creation date of the most recient version.
o.modified The last modified date of the most recient version.
o.versionNumber The version number of the most recient version.
o.versions Returns a list of page's versions. See JSWikiPageVersionInfo
o.attachments Returns a list of the page's attachments. See JSWikiPageAttachmentInfo
o.content Returns the content of the page.
o.setContent( pageContent ) Sets the content of the page (and creates a new version)

class JSWikiPageVersionInfo#

o.author The name of the author.
o.modified The last modified date.
o.versionNumber The version number.

class JSWikePageAttachmentInfo#

method description
o.fileName The attachment's file name.
o.fileSize The attachment's file size in bytes.

class JSWikiInfo#

method description
o.pluginVersion The version number of this plugin.
o.pages Returns a list of the pages.
o.hasPage( pageName ) Returns true if the named page exists.
o.getPage( pageName ) Returns the named page. It is an error if the page does not exist.
o.createPage( pageName, pageContent ) Creates a new page with the given name and content. It is an error if the page already exists.
o.deletePage( pageName ) Deletes the named page. It is an error if the page does not exist.

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
txt
DO NOT USE.txt.txt 0.0 kB 1 16-Jan-2009 05:33 Andrew Gilmartin Depricated
jsp
browse.jsp 66.9 kB 1 04-Feb-2006 07:19 148.221.80.109
jar
jspwiki-js-plugin-26Jul2006.ja... 13.5 kB 1 26-Jul-2006 22:47 Nascif Abousalh-Neto
zip
jspwiki-js-plugin-jspwiki-2.8-... 25.0 kB 1 16-Jan-2009 05:21 Andrew Gilmartin Made "info" classes public to work with latest Java, JSPWiki, and Tomcat
zip
jspwiki-js-plugin-src-26Jul200... 9.4 kB 1 26-Jul-2006 22:47 Nascif Abousalh-Neto
jar
jspwiki-js-plugin.jar 13.2 kB 1 03-Mar-2005 23:46 68.9.19.21
gz
jspwiki-js-plugin.tar.gz 6.0 kB 1 21-Feb-2005 21:39 216.41.98.254
« This particular version was published on 22-Feb-2005 02:34 by 68.9.19.21.