Parse Picasa XML with Rails

Here’s a helper I just wrote for a site of mine. I use it with my picasa XML albums to generate the appropriate links for Lokesh Dhakar’s lightbox image viewer trick. You can change it to use your own image views by simply changing the "slideshow" method in the helper.

It is also a good example of parsing an XML resource in ruby. I am parsing most of the metadata so you should be able to do a lot more with this.

In the controller, you need to add the following:

  helper :picasa_album

In your .rhtml file, add the lightbox tags:

  <%= stylesheet_link_tag 'lightbox' %>
  <%= javascript_include_tag 'lightbox' %>

  <div class="slideshow" style="margin: 2em 10em">
    <%= slideshow( "",
    url_for( "/path/to/album/index.xml") ) %>

Finally, add picasa_album_helper.rb to the helpers directory.

Let me know of your experiences with this.

Have fun! 

Update 06/23/2006: I got a patch for this not too long ago. Still waiting for confirmation before submitting it but I did add it to the subversion – see the repository browser for a version history.

technorati tags: , , ,