PDA

View Full Version : smlatest.pl - hack to set featured gallery -> 4 last updated galleries


darryl
Oct-13-2007, 11:13 PM
STOP! THIS HACK IS NO LONGER NECESSARY. You should use this hack instead, which uses Javascript hackery to dynamically replace your Featured Galleries with the last X (you can have more than 4!) galleries updated (per your RSS feed). Unless of course you think Javascript hacks are nasty. In which case, feel free to continue to use this hack. :-}

Hiya: I hacked together a Perl script w/ LWP and XML::Simple to grab a list of all the galleries, sort them in reverse chronological order, and then sets the 4 most recent ones to be your featured galleries.

That last bit isn't through the API, because the API doesn't support it. Instead, I use LWP to login on my behalf, and then using that cookie, fire off the HTTP POST command used to set a featured gallery.

It's pretty slow, so I just have a cron job set to run it nightly.

Feel free to have a gander:

http://www.darryl.com/smlatest/

After finding out how to set the title of "featured galleries" to "last updated galleries", I realized that *maybe* there's a way to do this with JavaScript? I was thinking that even if you're listing galleries by Category, perhaps the gallery of all galleries, sorted by last updated, might still be accessible using JavaScript magic?

And maybe you could just display just the top 4 galleries? Or heck, any number if you had them all. I guess I'm envisioning a bit of JS like this niftyness.

Well, I don't know enough JavaScript, but since others have asked for a "last updated galleries" feature before, it'd be nifty of somebody else coded it. :-}

--Darryl

darryl
Oct-13-2007, 11:16 PM
In retrospect, the figuring out which galleries are most recent is probably much more easily accomplished by hitting the RSS feed. GAH!

--Darryl

darryl
Oct-14-2007, 01:38 AM
I'm an idiot. So now the script uses RSS, and only updates Featured Galleries with the latest four if they've actually changed. Hooray.

Added bonus (?) -- no API calls needed and it's tons faster.