July 10, 2005
MarkBernstein.org
 

Another use for Tinderbox rules

A note about an advanced (but useful) Tinderbox technique...

Most often, you use Tinderbox rules to enforce constraints. Things like, "make sure all the urgent things are bright red", or "If we don't know the priority of this change request, and it's part of a bigger package of changes, then use the priority of the whole package."

But you can also use rules to force Tinderbox to be a little bit smarter.

For example, del.icio.us lets you request HTML snippets that you can paste on your web site by putting together a simple URL -- something like this:

http://del.icio.us/html/your_account/?count=5

where your_account is your account name. Easy enough! We can just put our account into the URL of a note, turn on AutoFetch, and we've got today's snippet. Dandy!

But suppose we don't want to edit the URL. We could pick up the account name from another note:

^getFor(/Configuration/del.icio.us,Account)

This means, "go find the del.icio.us note inside the container named Configuration, because we want to know the Account name stored there."

Of course, we can't just paste that into a URL. How would Tinderbox know that ^getFor was an instruction to Tinderbox and not part of the URL?

But I can easily synthesize the URL in a rule:

URL=http://del.icio.us/html/ ^getFor(/Configuration/del.icio.us,Account)^?count=5

The next time the rule runs, it sets the URL. If we change accounts and someone updates the Configuration note, the rule will pick up the change and immediately fix up the URL. Nice!