Monday, June 25, 2007

They're Baaaack!

The old blog photos, that is. All 3,000 of them!

Well, almost all. There were few images that were incompatible with Blogger (mainly animated GIFs). But everything else is there!

Geek Alert! Do not continue reading if you are not a geek...

It has taken me exactly one month of spare-time programming and diddling and tweaking to get there, but I have finally succeeded in transforming my old blog (which ran on Pebble, on a Tomcat platform) to the Blogger platform. With minor exceptions, everything is back the way it was. Here's what it took:
  1. I wrote a program that converted the Pebble posts (each in an XML file) to Blogger posts. I used JDOM to read the Pebble XML files, and the Blogger API to post them to my blog. The main challenge in this program was to convert the non-HTML markups in Pebble to HTML for consumption by Blogger. This involved porting a bunch of classes called "Decorators" in Pebble to my conversion program, and making a style sheet that rendered the posts properly in Blogger. The Blogger API is very easy to use; the only real problem I ran into there was that Google initially limited me to importing 50 posts per day. After I begged for a break, they raised the limit to 500. This code took me three days to write and debug, and then it took a week to get all the posts on Blogger.

  2. Next I wrote a program that transferred all the images on the old blog to Picasa, using the Picasa API. This was necessary because the Blogger API doesn't provide any means of posting images. The main challenge for this step was the need to convert all image file types to JPG files; to do this I had to learn the ImageIO API in Java, including a series of quirks related to "transcoding" from one file type to another. Trust me, it was a pain in the neck! This program also built a database that kept track of the image URLs as they appeared in the old blog and the new Picasa URL. I ran this program over the past weekend; it took 11 hours over a high-bandwidth connection to transfer the 3,004 images from the old blog to Picasa.

  3. Next I wrote a progam that munged all the old posts on Blogger, changing the href and src references to point to Picasa instead. I used the Blogger API again for this program. The main challenge in this program was identifying and correctly tranforming the many variations of IMG and A tags my blog had accumulated over the years.

  4. Finally, I wrote a popup viewer (in JavaScript) to more elegantly handle the display of a large image when a thumbnail is clicked. Picasa serves up any image in up to 17 different sizes; my viewer attempts to pick the most appropriate size, taking into account screen resolution, window size, etc.
This is one project I'm very glad to have behind me!

No comments:

Post a Comment