A number of posts are currently in stasis waiting for me to actually finish them, but I thought it was worth mentioning the selection of my most recent Flickr photos that now graces my homepage. While the rest of that page awaits serious styling and content work, I’ve dilly-dallied by creating this bit of eye-candy.
The loveliness of this slightly hackish system is that it uses AJAX (with help from MochiKit) to fetch an RSS 2.0 feed, so it doesn’t require an understanding of Flickr’s huge quasi-REST API. Also, because one can guarantee the RSS feed is good XML, the responseXML property of the XMLHTTPRequest object can be trusted. This means you don’t need to do any string-based munging of the returned data to transform it into the HTML seen on the page: there’s an XML DOM already set up for you. It also means that the method could be adapted to other RSS feeds, in principle.
The major difficulty was getting the Javascript to request a URL from a different server from the one that the current page was on (quick summary: you can’t, because of Javascript’s security rules). But it took two minutes, one and a half of which were googling, to set up a proxy of this feed in Perl using LWP::Agent.
There’s other minor problems to be overcome—the first paragraph of the RSS description feed is a rather trite “username posted a photo:” so naturally I got rid of that, and the images are actually shown half-size because it’s easier to change the <img /> tag’s width and height than it is to try and work out the dimensions and locations of the real thumbnails—but it works. And all in under an hour’s programming.