The idea is quite simple and intuitive. An extension file contains functions. Each function returns a HTML document that contains a
<tail> element. For example, output of a function might look like this:
<tail> element is empty for this example. Its use is similar to
<tail> element is only run after the page has fully loaded. When Deki Wiki receives this output, it merges the
<tail> elements from each function invocation. It also replaces the function call with the contents of the
<body> element. Once all functions have been invoked, the page is sent to the browser. Simple and elegant!
Let’s create an XML file that describes the extension and its functions. The following example describes an extension with one function called “instant”. The function takes no parameters and simply returns the above document as a result.
So far, our output is constant, which isn’t really interesting. This is where DekiScript comes into play. Instead, of returning a static document, we can use the same mechanism used by Deki Wiki to generate pages dynamically. To make this work seamlessly, we take advantage of XML namespaces to mark parts of the document we wish to evaluate.
First, we need to declare the DekiScript namespace by adding
xmlns:eval="http://mindtouch.com/2007/dekiscript" to the
<html> element. Next, we need to declare that our function takes four parameters: the image URI, shadow opacity, frame color, and tilt direction. Finally, we need to replace the hard-coded values with DekiScript expressions. To access the function arguments, we prefix their names with
Here is the final version of our sample extension:
DekiScript allows you to evaluate attributes and elements. When an attribute is evaluated, the attribute prefix is automatically stripped, and the attribute value becomes the result of the DekiScript expression. For elements, it’s a little more varied. There are three kinds of elements that can be evaluated:
<eval:if test="true">Hello</eval:if><eval:if test="false">Bye</eval:if>
Last, but not least, we need to add our extension to Deki Wiki. This is done in the usual manner.
- Go into the Control Panel
- Click on Service Management
- Click on “Local”
- Select “Extension”
- Enter a description for your service (like sample)
- Enter the DekiScript SID: http://services.mindtouch.com/deki/draft/2007/12/dekiscript
- Add the config the key manifest
- Set the value for the config key to the location of the XML extension file. The location can either be a disk path or a URI. (e.g. /root/sample.xml or c:filessample.xml or http://server/sample.xml)
That’s it! You’re now ready to use the XML extension.
I’ve uploaded a couple of extensions already (AccuWeather and Scratch) to wet your appetite, but you can expect a lot more in the comming months. The DekiScript service is included in Deki Wiki 1.8.3 RC2, which should go out tomorrow. Share your thoughts, suggestions, and questions on the forums.