Reminder Plugin for TiddlyWiki

23:35 Thu 01 Feb 2007. Updated: 18:31 03 Feb 2007
[, , , ]

I created a very hacky plugin for TiddlyWiki that will place a node titled with the date at the top of the page if you open the page on that date. In other words, you can create a node with a specific date, and when you open TiddlyWiki on that date you’ll see that node.

On days when you have nodes with that date, it will look something like this:

Hacky Calendar Reminder Plugin in Action

It’s a primitive reminder plugin. I think there’s a more sophisticated reminder plugin out there, but I wanted to get something that did exactly what I wanted.

It’s hacky for a few reasons. The first is that you can’t just add the plugin to your TiddlyWiki and tag it with “systemConfig” and save and reload the page (which is the standard method for installing plugins). With this, you have to do all that and then also add the plugin node to your DefaultTiddlers. Once you do that, however, the hackiness is then invisible to the end user, who won’t see anything other than the reminder nodes when they’re supposed to show up.

Behind the scenes, though, when you open TiddlyWiki, it will open the plugin node and then hide it immediately. I couldn’t see another way to do it while keeping the code inside a plugin (it started out as raw JavaScript in the TiddlyWiki file, but that was a bad approach).

When you load plugin code in TiddlyWiki, it executes before the page is fully finished loading. So if you try to display a node at that point, you’ll get an error. There might be hooks you can add to run things when everything else is done, but I couldn’t find them.

The way most plugins seem to work is to assign a macro handler, which can then be invoked with <<this syntax>> in a node—that is, when a node with that syntax in it is loaded, or when you click on something with that syntax, the handler is called and the macro is run.

So I needed to open a node with that syntax in it every time the page started. TiddlyWiki has a DefaultTiddlers node that lets you do this. But I didn’t want to actually open a node that contained nothing but that code, and I didn’t want to stuff that code into one of the nodes I open by default, either.

I thought I’d put it in the MainMenu node, which is always open in my setup. However, that’s a systemConfig node, and apparently they’re treated differently, because it didn’t work.

I then decided I’d open a node in DefaultTiddlers and have it hide itself when it opened. That’s what I’ve done, and that’s why a reference to the plugin has to be in DefaultTiddlers for it to work.

Installing it should take about three minutes, using the following steps:

* Copy the code below into a new node (tiddler—I don’t like that name, so I call them nodes. But all the docs call them tiddlers).
* Name the node HackyCalendarReminderPlugin.
* Tag it with systemConfig.
* Put a reference to HackyCalendarReminderPlugin into your DefaultTiddlers node.
* Save your TiddlyWiki.
* Reload your TiddlyWiki.

That should do it! To test it, create a node titled with the current date (must be in the DD/MM/YYYY format!), save your TiddlyWiki, and reload it. The new node should be at the top.

I use it with CalendarPlugin, which you may find to your liking.

The contents of the plugin:

|''Description:''|Puts Tiddlers named with the current date on top of the TiddlyWiki at load time|
|''Date:''|23:23 Thu 01/02/2007|
|''Author:''|Tadhg O'Higgins http://www.tadhg.com/|
|''License:''|[[BSD open source license]]|
|''Browser:''|Firefox 1.0.4+; Firefox 1.5; InternetExplorer 6.0|
|''Notes:''|This is rather Hacky. To make it work, you have to include HackyCalendarReminderPlugin in your DefaultTiddlers.|
|~|It will close itself the first time it's opened, making the assumption that you don't really want the plugin open, just the reminder. After that, you can open it normally.|
|~|It has this weird behavior because if you open a tiddler while loadPlugins() is running, you haven't loaded enough of the structure to put the tiddler somewhere, and you'll get an error.|
|~|Therefore you need to run a macro from a tiddler, and that only happens when you open a tiddler, and systemTiddlers apparently don't count for this.|
|~|So I had to open a tiddler and then make it close itself. Might as well put that in the plugin itself.|


config.macros.hackyCalendarReminder = {};
config.macros.hackyCalendarReminder.handler = function(place, marcoName, params) {
    var todayDate = new Date;
    var todayNum = todayDate.getDate();
    var monthString = (todayDate.getMonth() +1);
    if (monthString < 10) {
        monthString = "0" + monthString;
    if (todayNum < 10) {
        todayNum = "0" + todayNum;
    var dateString = todayNum + "/" + monthString + "/" + todayDate.getFullYear();
    if (store.tiddlerExists(dateString)) {
        story.displayTiddler("top", dateString,1);
    if (typeof alreadyClosed=="undefined") {
        story.closeTiddler("HackyCalendarReminderPlugin", false, false);
        alreadyClosed = true;
(next) »

Leave a Reply