… or When Your Customer Doesn’t Share Your Framework’s Opinion

Lately, I’ve been writing a lot of syndication APIs. It’s all about formats, and I happen to agree with Rails that ATOM is the primary XML-based syndication container I want to support. Recently, I had a customer who did not share Rails’ enthusiasm for ATOM, and asked for RSS.

Now clearly, I really didn’t relish making one show.rss.builder for every show.atom.builder I had. Since I’d already used Rails’ atom_feed helper everywhere I had a feed, and since the mappings between ATOM and RSS are reasonably close, I set about trying to make an RSS-ified version of atom_feed.

There are a few issues with this approach - chief amongst which, ATOM has concepts which RSS does not. For these, I've adopted a similar approach to .NET's SyndicationItem class: drop into the ATOM namespace when you've reached the limits of RSS's capabilities.

All you need to do is make sure this helper is required somewhere. The easiest no-code solution is to drop it into /app/helpers. Wherever you require an RSS representation, use

    atom_feed :rssify => true

and continue to refer to ATOM tags and concepts as you would normally. Whistle loudly to yourself while doing this. See? You can almost pretend RSS doesn't exist.

© 2014 ZephyrBlog Suffusion theme by Sayontan Sinha