The goal of efficiency is more slack.

Thursday, June 10, 2010

Writing a TiddlyWiki plugin

It was easier than I thought to write a simple TiddlyWiki plugin. I wanted to create a shortcut for the "Close all" button on the sidebar.
  1. Hack (a backup of) the core TiddlyWiki html or javascript to make it do what you want. Take note of the functions or objects you edited.
  2. Copy the plugin template [TiddlyWiki.org].
  3. Paste the template into a new tiddler in a stock TiddlyWiki html (not the one you edited).
  4. File out the boilerplate stuff like the plugin's name and author.
  5. Override the functions or objects you noted in step 1 by writing code in !Code section of the tiddler.
  6. Add "systemConfig" to the tag field of the tiddler and save the tiddler.
  7. Save changes to the TiddlyWiki and refresh.
For your convenience, here's the plugin template. Be sure to replace SamplePlugin with the name of your plugin.

/***
|''Name''|SamplePlugin|
|''Description''|<...>|
|''Icon''|<...>|
|''Author''|<...>|
|''Contributors''|<...>|
|''Version''|<...>|
|''Date''|<...>|
|''Status''||
|''Source''|<...>|
|''CodeRepository''|<...>|
|''Copyright''|<...>|
|''License''|<...>|
|''CoreVersion''|<...>|
|''Requires''|<...>|
|''Overrides''|<...>|
|''Feedback''|<...>|
|''Documentation''|<...>|
|''Keywords''|<...>|
!Description
<...>
!Notes
<...>
!Usage
{{{
<>
}}}
!!Parameters
<...>
!!Examples
<>
!Configuration Options
<...>
!Revision History
!!v<#.#> ()
* <...>
!To Do
<...>
!Code
***/
//{{{
if(!version.extensions.SamplePlugin) { //# ensure that the plugin is only installed once
version.extensions.SamplePlugin = { installed: true };

if(!config.extensions) { config.extensions = {}; } //# obsolete from v2.4.2

config.extensions.SamplePlugin = {
sampleFunction: function() {
/* ... */
}
};

config.macros.SampleMacro = {
handler: function(place, macroName, params, wikifier, paramString, tiddler) {
/* ... */
}
};

} //# end of "install only once"
//}}}

0 comments:

Popular Posts

Recent Posts

Unordered List

Text Widget

Pages

Powered by Blogger.
Scroll To Top