Wednesday, December 14

Extra Delicious Grog

I was talking with Case yesterday about how we’ve been pretty steady del.icio.us users even when we haven’t been blogging so often. It’s nice to be able to just drop a link and a bit of text without worrying about the clever prose and subversive hyperlinks required of a blog post.

So, I just finished del.icio.usifying the blog. First up, I have FeedBurner burning in my new links every day with their Link Splicer service. Then, for those of you who actually visit this fair website, I have a little JavaScript magic to insert the 5 most recent links right below the latest post.

The list of links is made possible with del.icio.us’s JSON interface to my bookmarks. JSON is a convention for data literals that is used here to get around the cross-domain restrictions of XMLHttpRequest. Instead, the template contains a script tag that points at a dynamically generated JavaScript file on the del.icio.us servers that, when loaded, populates the global Delicious variable with the data from my last n links. Since, in practice, browsers load external JavaScript sequentially, the data from del.icio.us will be in place by the time an inline script expects it and builds the definition list out of it.

I have to credit the JSON example from del.icio.us for the very clever idea of loading favicons into the list. I adapted the rest of the code, using the DOM helpers from (the most excellent) MochiKit. I was a bit disappointed that MochiKit doesn’t include a fold alongside their map, hence the hack to return a span to get a space between the tags.