Psychologists say that shame is the most powerful human emotion. Well, I wouldn't be too quick to write off spite. During last month's del.icio.us upgrade, a valuable means of tapping into the hivemind of taggers was inexplicably turned off. I vowed revenge and today has seen the generic JSON feed return, with all the elegance, robustness and civic-mindedness of a dodgy third world electricity hookup.
First, the backstory. Perhaps the most important part of "social bookmarking" is the "social" bit. This means you can access the whole community's bookmarks, for example:
Note that no particular account is specified - here I'm asking for all pages tagged "blogger" by anyone. (Hence the term "generic".) Delicious, in their wisdom, allowed users to get at this information by publishing it as a JSON feed.
This feed format is a super-lightweight replacement for XML, like RSS without the trimmings. It's also what FreshTags uses to support in-blog navigation. This opened up a raft of novel and experimental uses of tag-driven content to enhance boring static pages. Freed from the restrictions of nominating a target delicious account or a pre-ordained set of tags, users could serve up a sidebar full of fresh links based on inbound search queries or free-form text entry by readers. We were just getting started and more exciting and disruptive possibilities were open.
But then Black Sunday fell. Delicious "upgraded" to Yahoo! machines, went up and down for days and eventually stabilised. From the wreckage, it was apparent that the generic JSON feeds had stopped working. Oh no! (Yet, strangely, they were still happily serving up generic queries as HTML and RSS.) A lone, plaintive voice spoke up in defence of JSON, but Joshua denied that it had ever worked at all. Inflamed, I stuck out my bottom lip, let it quiver, stamped my feet but to no avail: they were gone, weren't coming back and no one seemed to care. After sulking for a few weeks, I decided to take it back.
Step Two. Write a suitable callback function. What's this? Well, it's a function that gets wrapped around your JSON object before being sent back to your page by ejohn's app. I called mine delify() since its job is to take the ejohn-style JSON object and convert it into the delicious-style JSON object. This just involved mangling things around and renaming. For example, "link" becomes "u", "title" becomes "d" etc.
Now that the resulting JSON object is indistinguishable from what delicious used to return, FreshTags can quite happily tear it apart, put it back together and render it nicely on your page. Check it out:
Or, tag-fixed to "blogger"
Or, to try tag-grabbing, select a tag from the left on this blog and then visit my homepage.
Astute readers will notice that you can enter whatever text you like in the field and FreshTags will process it (via delicious and ejohn) asynchronously. That's right, no more reloading the page each time you change tags! This is a sneak preview of what's coming up in the next release. NB: I probably haven't done it quite right, so advice from seasoned AJAXians would be appreciated (privately please; no need to publicly run me down :-)
Sadly, I have to point out that I won't be incorporating ejohn's hosted rss2json hack into the next release of FreshTags, owing to the unfair burden on his servers and link. So this one-off implementation remains on my homepage as a form of silent protest, as well as a proof-of-concept. If you'd like to see this generic mode return to FreshTags, please lobby delicious to turn feeds/json/tag/* back on, or persuade your favourite bookmarker to go JSON, or even offer to host ejohn's rss2json yourself!
That said, it is reassuring to know that such a service is in principle available (John Ressig's code is released under a Creative Commons licence). This is especially important given the rise of a range of social bookmarking services offering RSS feeds - but not JSON.
Perhaps this finally frees FreshTag users from the hegemony of delicious ...
Update: John "ejohn" Resig wrote to inform us that his service sometimes gets temporarily banned by delicious, for making too many hits. Also, it doesn't seem to handle tag intersections too well. So best use one tag at a time and if it's down, try again the next day.
Filed in: freshtags, tags, feeds, json, rss, blogger-hacks, delicious