#coding   #OpenSource   #ruby

Beef up your RSS2 template for consumption with the Google Feed API Slide Show Control

May 31, 2007

There can be no doubt about it, RSS Feeds became the connecting backplane for the internet. Like Yahoo Pipes a while ago, the new Google Feed API is building its functionallity on top off standartized RSS feeds. For the feeds API, just providing a standardized RSS feed is enough to offer you a free ride. And a jolly good ride it is. The Slide Show Control is rich in features. Most major photo banks are supported and the actual controls allows for fine grained control of timings and sizes. The funny thing is, the API pretty much covers most of what we discussed at work on the friday before the weekend the API was released.

For the public timeline of our all-online-in-browser-photobooth-application foto-foo at /i-d media we wanted to add RSS feeds from which to build slide show like applications displaying a constant stream of fresh images. I decided to give it try and found this RSS2 rxml template on dzone.com which i filled with my data.

Various things happend, but no image was to be seen and the browser stalled a couple of times. First thing i found out was, “standard” Feed actually means it uses the Media RSS extension. This means the feed header has include the Media RSS namespace:

        xmlns:media="http://search.yahoo.com/mrss/" 
xmlns:dc="http://purl.org/dc/elements/1.1/">

which in rxml looks like:

xml.rss "version" => "2.0", 
"xmlns:dc" => "http://purl.org/dc/elements/1.1/",
"xmlns:media" => "http://search.yahoo.com/mrss/" do

Next thing to do is adding a <media:group> to all the feed items:

      <media:group>
<media:title>"#{img.title}"</media:title>
<media:content type="#{img.type}" medium="image" url="#{img.url}"/>
<media:credit role="#{img.credit.role">#{img.credit.txt}</media:credit>
<media:description type="plain">"#{img.desc}"</media:description>
<media:keywords>"#{img.keywords}"</media:keywords>
<media:thumbnail
width="#{img.thumbnail.width" height="#{img.thumbnail.height"
url="#{img.thumbnail.url}"/>
</media:group>

your media group attributes/elements may vary but there is one nasty surprise lurking which you should be aware of. The Feeds API seems to ignore the actual image URL and chooses the the thumbnail URL instead: no thumbnail, no slideshow! This was kind of driving me mad not beeing able to spot the difference between my none working feed and the working one.

Bonus: feed reader compliance

handling images in RSS feeds is part of the vaguely borderline of rich media feeds where things like the Media RSS extension are actually made for. For Atom it seems media handling is defined a little better but the Feed API depends on RSS2. All this variations are hard to grok for some feedreaders but I wanted to have my foto-foo RSS stream also in my Reader, but the did just not show up. I checked out Riding with robots feed which brings fresh views from outer space directly to my desk. It turns out that they just include a little encode HTML in the decscription tag:

<description>&lt;a href='#{img.link}'&gt;&lt;img src='#{img.url}'/&gt;&lt;/a&gt;</description>

and voila, your Slide Show complient rss image feed works equally well in your normal feed reader.

i know this is all rough and dirty, but it works for me, might help you a bit, and i dont like to drown in spec reading for to long today. Find my RSS2 rxml code snippet on dzone and mess it up in any way you like.

have fun.

Technorati Tags: , , , , , ,

share this: