Tuesday, December 19, 2006

Picture Rotator (and, Blogger Sucks)

UPDATE 3/14/2007: I've changed the picture rotator to a different implementation than the one I'm talking about here. So none of this really applies anymore, but read it if you want to.

If you're reading this on my website, instead of through an RSS aggregator, you might notice a new feature. In the upper right there's a rotating image pulled from my SmugMug account.

This is actually something I've been meaning to do for a while - namely add a feature on my site based off of what I'm doing at work. What finally got me to do it? Well, for one thing Karyn did it. Then earlier today John stopped by to ask about a bit of picture rotator code he just added. I took a look at John's implementation, and it's nice and all, but it has some problems. For instance, the names of the pictures are hardcoded into the page, so he needs to go edit that every time he adds or removes a photo. Even worse than that, it in now way uses RSS or Private Label!

So I whipped up a quick replacement, based on SmugMug's built in RSS feeds and the Buzz framework. Basically his pictures are published as RSS feed based on SmugMug photo tags. Newsgator picks that up and makes it available using the Buzz framework. Then a couple lines of Javascript grab the enclosures from those posts and render out his rotator. It only takes about 5 lines of HTML and Javascript.

At this point I was going to post those 5 lines of code. Why not? Well, it turns out that Blogger is UNBELIEVABLY PAINFUL to deal with for scripting. It took me about 10 minutes to write and debug the code in a dummy HTML page. I then spent about 90 minutes trying to make it work in my blog template, most of it dealing with Blogger's wonderful habit of silently mangling whatever markup I put into the page.
It turns out the same great editing abilities apply to my posts, and at this point I may just demolish my laptop if I have to try it. No, at this point what I need is not more HTML, but rather a nice glass of bourbon.

And with that, I bid you good night.

UPDATE 12/20/06: It's been pointed out to me that the rotator doesn't work in IE. I'm not that surprised, as I always develop in Firefox because I love me some Firebug. I was planning on validating it in IE, but after wrestling with Blogger I was in no mood. I'll try to get to it tomorrow, since I will likely be sitting in the airport all day.

2 comments:

kmgerman said...

And, trust me, if I was able to figure this out on my TypePad account, Beaker HAD to figure it out on his blog. :'}

Carlo said...

Good Job! :)