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.
- 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.
- Copy the plugin template [TiddlyWiki.org].
- Paste the template into a new tiddler in a stock TiddlyWiki html (not the one you edited).
- File out the boilerplate stuff like the plugin's name and author.
- Override the functions or objects you noted in step 1 by writing code in !Code section of the tiddler.
- Add "systemConfig" to the tag field of the tiddler and save the tiddler.
- 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:
Post a Comment