Thursday, 3 May 2007

TiddlyLockPlugin - the multi-user TiddlyWiki Plugin

When I wrote (i.e. hacked) TiddlyLock, I didn't realise just how simple plugins for TiddlyWiki were to write. All the examples I had seen looked really complicated and had lots of /*** ***/ !!! and //{{{ characters in them and I couldn't tell what was required and what wasn't. See my previous post for an example of how simple plugin are, and how quickly they can become difficult to read!

Anyway, the first version of TiddlyLock was a JavaScript hack - I modified the core code directly.
<smackhand>ouch
I'm a reformed citizen now and have re-coded TiddlyLock into TiddlyLockPlugin, the self-contained, easy-to-install, set-and-forget plugin that allows multiple people to access and edit the same TiddlyWiki file on a shared drive, but prevents users from overwriting each other's changes.

Simply use the ImportTiddlers tiddler in your TiddlyWiki (look for it on the Shadowed tiddlers tab) and point it to http://www.minormania.com/tiddlylock/tiddlylock.html. Select TiddlyLockPlugin and import it.

Reload your TiddlyWiki and set the Username and Password options in the OptionsPanel or in the GettingStarted tiddler.

Now, every time you click Edit the TiddlyWiki will be locked by you. Any other user who tries to edit the same TiddlyWiki will be told that you are locking it. They will have to wait until you are finished and refresh their browser before they can edit it.

It's not foolproof, and 'passwords' are visible and unencrypted, so don't expect enterprise-level security.

To Do:

  • Obfuscate passwords
  • Encrypt lock file

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!