Feeds for Free
And money for nothing. Or something like that? Sorry, Mark Knopfler. I’ll pay more attention next time.
Anyways, let us be painfully aware that we can get Atom feeds for free. Not as in beer or speech, but as in ‘zero lines of code.’ How? Microformats.
You and meFormats
Almost a year has past since we last spoke of microformats, and way more than a year since our first encounter. Seems like only yesterday.
Remember hAtom? It’s like Atom, only embedded into your existing content’s HTML pages. The mofo site references the following example:
A normal, typical blog post:
Went to a show last night. Megadeth. It was alright.
The same post with hAtom superpowers:
Megadeth Show Last Night
Posted by on June 4thWent to a show last night. Megadeth. It was alright.
To you and I, eagerly searching for a review of last summer’s Megadeth show, there is no difference between the two. Our browsers render them the same. To a machine, however, the second post is chock full of semantic goodness.
This semantic goodness represents, in our HTML, the same information an Atom feed would provide. This leaves us with two paths of action for gettin’ our feed on: we can wait for feed readers to start speaking hAtom fluently, or we can have someone translate hAtom to Atom for us.
Subtlely Free Feeds
One year ago today Subtlety was released. Today it is re-released with a new feature: it can convert a page containing hAtom entries into an Atom feed. This means your feeds are now officially free.
We’ve actually been doing this for a while right here on Err. Our Feedburner feed points to this url: http://subtlety.errtheblog.com/O_o/29f.xml. It’s an Atom feed generated by Subtlety after parsing the hAtom elements on this site. On Err the Blog.
My ozmm blog is a static blog with no special RSS code. Instead, I point the Feedburner URL at a Subtlety Atom feed which is generated from the hAtom in the posts. Our Dynamite blog uses the same trick. See the pattern?
There’s no reason to ever write your own Atom feeds anymore. Sorry.
But what if I don’t want you hosting my feeds?
That’s fine, and acceptable. How about I just hand you the technology to do this on your own?
It goes like this:
$ gem install mofo $ cd rails_app/vendor/plugins $ gem unpack mofo
Then, here’s your controller:
class PostsController < ApplicationController def index @posts = Post.find(:all) end def atom target = url_for(:action => :index) render :xml => hEntry.find(target).to_atom(:title => 'whatever') end end
You can use this trick for dynamically generated feeds (changelogs or activity feeds, perhaps) or whatever else. Thanks, mofo.
Last Step: Cut the Code
Now go through your app and remove all the Atom code. Drop those extra plugins, remove those xml templates, cut out all the special logic, and enjoy simple Subtlety or profound mofo.
Have fun.
- Company:
- Person:
- Programming Language:
- Technology:



Recent comments
1 year 23 weeks ago
1 year 23 weeks ago
1 year 25 weeks ago
1 year 27 weeks ago
1 year 42 weeks ago
1 year 45 weeks ago
1 year 45 weeks ago
1 year 45 weeks ago
1 year 46 weeks ago
1 year 48 weeks ago