Monday 25 February 2008

Google AJAX Feeds API

This weekend I was planning to do some coding work on my home page. I wanted to add an RSS/Atom feed from my blog to the front page of blue sky workshop. To do this, you just need a simple proxy script to grab feeds from the web and cache them. Then write some AJAX code to request the feed and pull it down to your web page. Of course being lazy in the Larry Wall sense, I first tried find someone else's code to perform this task. I couldn't really find anything suitable and had pretty much settled on writing my own code.



However on Saturday by accident, I stumbled across the Google AJAX Feeds API:

http://code.google.com/apis/ajaxfeeds/.



Basically, Google has gone and written the whole thing for me already. Thank you Google! It took me about half an hour to modify their code and get it working on my home page. To see the code, just do a "view source" on the Blue Sky Workshop home page. The AJAX code is all in the head section of the page.



Since I'm using an Atom feed, the HTML markup I put in my posts is sent for each of my entries. So if I added the post description as a text node, the HTML is ignored and just shows up as text on my home page. But by setting description.innerHTML = entry.content, the HTML is incorporated just fine.



Very slick Google. For any future projects, I plan to check your site first to see if there is any other code I can steal... I mean use for my site. :)

No comments:

Post a Comment