Menu Close

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: , , ,


  1. Pat

    Hey David,

    I found your class while looking for a way to parse the xml from Picasa and write an html template-based generator. I already had a working proof-of-concept written in ruby, so I kind’a had to restructure it heavily. I did modify the class to add some missing tags that I needed, but the biggest change was to add a hash with each tag. I use the hash to substitute the tokens in the html templates for the data in the xml. I stil lleft your class vaiables just in case I ever need them. I wish there was a cleaner structure for this; it’s raw but works.
    I put the scripts in my homepage under Linux/Projects if you’d like to peek. I’m new to ruby, being this one of my first scripts, so I appreciate any critic. I feel like I learned some more exciting things of ruby in practice, by studying and using your class. Thanks! It was most refreshing.


  2. Hackerdude

    Hola Pato!

    Thanks for your comments. This is why we write open source, to know it was useful to others, and when you get comments from people you know your efforts aren’t in vain.

    I’m pretty new to ruby myself (although have been using scripting languages on and off as support code for more “format” languages for years).

    Now that Google has released picasa for linux, I’ll probably get a lot more input from the script than I would have under the Windows days. Someone already submitted a few changes to it (I’m waiting for confirmation from him before I change the one in version control).

    Anyway, thanks again for the comments and I’m glad it’s been useful for you – muy buenas fotos, por cierto.

  3. Mauvre

    Hi David,

    can you help me with an example to the “url_for( “/path/to/album/index.xml”)” … has picasa changed something … I can not find this index.xml-Link !!!

    Knd Rgds!!!

Comments are closed.