Tuesday, 1 May 2007

TiddlyWiki - How to Write a Plugin

There are lots of plugins available for TiddlyWiki, but documentation on how to actally write a plugin is scarce. I understand the concept - plugins are just tiddlers that contain JavaScript and are tagged with "systemConfig" - but I couln't find any explanation of the syntax of a plugin and simple instructions on how to get it to work.

So, here it is. And it's really simple.

  • Create a New Tiddler by clicking on the "new tiddler" link in your TiddlyWiki
  • Choose a name for your plugin (tiddler) - standards say you should end the name with the word "Plugin". e.g. TiddlyLockPlugin
  • The body of the tiddler at it's simplest is just straight JavaScript
e.g.
alert('Hello, World');
  • You can add standard TiddlyWiki content as well to provide some comments, usage info and other supporting documentation. This text must be 'commented out' using the standard JavaScript commenting characters // or /* ... */ remember, the content of the tiddler is interpreted as JavaScript
  • You should also surround your JavaScript code with {{{ and }}} to allow it to be displayed by TiddlyWiki without being interpreted by the browser.
e.g.
/***
this is the Hello, World plugin
|Hello, World|a simple sample plugin|
!!! here comes the code ...
***/
{{{
alert('Hello,World');
}}}

  • Include "systemConfig" as one of the tags for the tiddler.
  • Save your tiddler and reload the TiddlyWiki. The 'Hello, World' alert box should appear.
And that's it!

1 comment:

Unknown said...

Extremely simple. Thanks Bud, nothing could be easier than this.