Treat with Jermolene

protective, soothing, anti-bacterial

TiddlyBookmarklets

with 6 comments

UPDATE: I’ve now published these bookmarklets to http://www.tiddlywiki.com/#TiddlyBookmarklets

So, I’ve been preparing for the release of TiddlyWiki 2.2 and have just run into a niggling little problem that’s ended up triggering something quite fun.

I’m at the point where I’m preparing the content for the new release, taking the existing tiddlywiki.com content, folding in the new beta documentation and making sure that everything is up to date and cross-references. The problem arises because the new release adds a “changecount” extended field to each tiddler. It tracks how many times that tiddler has been modified since it was created or received from a server. Our current build process will propagate an extended attribute like that all the way from me making some minor edit in my local copy of tiddlywiki.com up to publication on the internet. That’s a problem, because we should be distributing tiddlywiki.com with clean content, with no “changecount” field.

Various more or less terrible solutions occurred to me immediately:

  • Doing a search and replace in the final index.html file to remove all the “changecount” attributes just before publication
  • Modifying the build process to clear out the “changecount” attribute
  • Writing a new macro that presents a button that scrubs “changecount” attributes from every tiddler

The problems with these solutions being “tedium”, “not knowing Ruby” and “inappropriateness” respectively. Inappropriateness being that such a macro would have to form part of the standard distribution/build process, and yet it seems rather a hack that shouldn’t really be needed.

All of which led to the idea of using bookmarklets – the ultimate platform for hacks. A bookmarklet is a browser favourite or bookmark that has a “javascript:” URL containing executable code, instead of a normal “http:” URL. So, when you click on it, rather than navigating to a new page, it executes the JavaScript code – as if it were on the current page. That means that bookmarklets can reach into the internal structure of a page and do almost anything – including things like stripping “changecount” attributes. With most browsers you can pack enough code into the URL to do some quite useful things.

I knocked up a couple of proof of concept TiddlyBookmarklets to explore what can be done:

  • ScrubTiddlyFields – Strips out all the extended fields from a TiddlyWiki document, including that pesky “changecount” field
  • ScrubTiddlyShadows -Restores any overridden shadow tiddlers in the current TiddlyWiki document. Handy when you’ve gone mad with PageTemplate customisations and your TiddlyWiki document won’t display properly
  • TiddlyRescue – Strips out the raw content of a TiddlyWiki document and displays it in a new window. Handy when you’ve inadvertently been editing an online version of TiddlyWiki that isn’t letting you save changes in the usual way.

Here’s how to use them:

  1. Drag one of the links above straight into your browser links bar
  2. Alternatively, right-click on the links and select “Create favourite” or “Create bookmark”
  3. Navigate to a TiddlyWiki document such as http://www.tiddlywiki.com/
  4. Select your new bookmarklet to execute it

PS If you’re interested in writing your own bookmarklets, check out this excellent bookmarklet editor that simplifies packing in all that JavaScript, and some useful tips.

UPDATE: Looks like I don’t know enough about WordPress to make the bookmarklet links work properly (thanks Ace_NoOne). I’m fiddling about to try to get them working…

Advertisements

Written by jermolene

May 5, 2007 at 9:07 am

Posted in development, tiddlywiki

6 Responses

Subscribe to comments with RSS.

  1. Nice idea to use bookmarklets!
    However, ScrubTiddlyFields and ScrubTiddlyShadows are potentially dangerous when using autosave and no backups…

    Also, WordPress seems to mess up the “javascript:” links – you have to manually strip the “https://jermolene.wordpress.com/2007/05/05/tiddlybookmarklets/” …

    Ace_NoOne

    May 5, 2007 at 10:10 am

  2. UPDATE: I can’t get these bookmarklets to work.
    Even after replacing all instances of “%7B” and “%7D” with the respective curly brackets and adding “javascript:” to the beginning, nothing happens…

    Ace_NoOne

    May 5, 2007 at 10:17 am

  3. This may help with editing/sharing/posting bookmarklets: http://xdexavier.googlepages.com/sharebookmarklet.html. It’s like a poor’s man bookmarklet editor but it has the ability to save the code into an url that can be easily posted/mailed.

    Xavier

    May 14, 2007 at 9:28 pm

  4. My guess is it’s the WYSIWYG editor that is breaking the links you posted. Use the html editing option to add the links, and just make sure you never edit the post again. That seems the only viable solution. (Along with keeping a back of the html for the links somewhere). Thought I would share this in case you wanted to give it another go sometime in the future.

    Saq

    October 7, 2007 at 3:20 am

  5. Yeah, I tried that, and still kept getting messed up. I think there might also be some character sequences in the bookmarklets that worry WordPress in some way.

    Anyhow, I ended up moving the bookmarklets to tiddlywiki.com:

    http://www.tiddlywiki.com/#TiddlyBookmarklets

    jermolene

    October 7, 2007 at 9:51 am

  6. […] you will notice that there have been some additions. I have added some new bookmarklets myself, and Jeremy Ruston has graciously allowed me to include his bookmarklets as […]


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: