[uf-rest] New microformat/REST Ruby Parser: mofo

James Stewart jystewart at gmail.com
Wed Mar 14 06:42:07 PST 2007


I think this is my first post here, after lurking for a while.

On Mar 13, 2007, at 3:43 PM, Dr. Ernie Prabhakar wrote:
> Things have been fairly quiet lately (despite many new members  
> who've joined, welcome).  I've been pondering how best to build on  
> the success of getting REST into Rails 1.2.  Fortunately, Chris (cc- 
> ed above) appears to have beaten me to it:
> http://errtheblog.com/post/37
>> What if instead of requesting /posts/1 and posts/1.xml, all you  
>> ever needed was /posts/1? I’m not making this up. We are indeed  
>> seeing the epoch of a world of resources, and in many places we  
>> can take the RESTful design a step further: we can eliminate some  
>> of our our respond_to and params[:format] requirements. Less code...
>> Soon you may not even need to code feeds—either your readers will  
>> understand hAtom and be capable of subscribing to a URL directly  
>> (which NetNewsWire can already do), or you can (now) use an hAtom  
>> to Atom converter. Just point Feedburner at the converted feed and  
>> bam, insta-Atom. No extra code required.
>> And that’s the whole point. Less code. The information is already  
>> there. Help the machines find it.
> What's more intriguing is that he's using Hpricot, the whiz-bang  
> (well, whiz-% :-) Ruby parser, for the (somewhat painfully named)  
> mofo:
>> mofo is a microformat parser for Ruby based on Hpricot. It’s got a  
>> nice little DSL for defining microformats and currently supports  
>> hCard, hCalendar, hReview, hEntry, xoxo, rel-tag, and rel- 
>> bookmark. There may be a few kinks, but hey, it’s new.
> Me thinks it wouldn't be that difficult to hack scaffold_resource  
> to generate XOXO-compatible lists that could be extracted into the  
> equivalent of "to_xml", and then to add that into ActiveResource to  
> create an end-to-end REST-Enabled XHTML solution.

I've been doing a bit of work along similar lines, using mofo to take  
input for an events service I'm currently testing (not public yet,  

Since my service is entirely focussed on events I've been focussing  
on hCalendar and hCard, and my frontend generates them as a matter of  
course. I'm using the mofo head rather than the current release as  
the released version doesn't have support for hCards or addr within  
hCalendar events.

What I wanted to be able to do was to be able to accept my input as  
XML, JSON, microformats or a regular query string. It's quite  
straightforward to add parameter parsers for different types of input  
in Rails 1.2, but distinguishing the microformat input from a  
standard query string was a bit trickier.

I wrote up a few notes on my blog:


I've also written up a longer piece on the process which should  
appear on infoq.com some time soon.


James Stewart

Work: http://jystewart.net/process/
Play: http://james.anthropiccollective.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://microformats.org/discuss/mail/microformats-rest/attachments/20070314/e0e7f81c/attachment.html

More information about the microformats-rest mailing list