Recently in Projects Category
I'm pleased to present the Flickr Favorites Browser.
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Yes, it's the same thing I had hacked out in perl a while ago. But now I've finished (mostly) the port to PHP. By using the Smarty template system I get caching and a nice separation of logic and presentation. There isn't a single piece of HTMl in my PHP code.
Moving from perl to PHP isn't always easy, especially when you use CPAN modules to get most of the work done. But I had no idea I was digging such a hole with my decision to move to php. The Smarty setup isn't that big of a deal, but it does force you to think about how you want to separate logic from presentation and how to best get HTML out of your code and into your templates. Your code should deal with data, not ever-changing HTML.
Then there is the issue of parsing the xml that you get back from the Flickr REST interface. zeman on the Flickr API group pointed me to miniXML, which is nice since it is pure PHP and requires no additional modules. It did take a while to get used to though, even with the nice docs and samples. I'm just slow that way.
Speaking of slow, I haven't even fully replicated the main feature of the perl version, that is to have the first column be a specified user's favorites and the rest of the row be the favorites of the owner of the picture in the first column. Although, now that I have my head around miniXML and how the Smarty templates are going to be laid out, I should be able to make better progress. I would like to have something I'm not embarrassed to post the code for by tonight.
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
A quick peek at the debug html comments shows that some of my problems are that people don't have that many favorites. It's like getting into Dave Gorman's Googlewhack Adventure, where every new turn leads into a dead end...only, it's not funny. Maybe I'll just give up on perl and port the thing over to PHP so I can at least feel like I'm doing something.
It is still far from being anywhere close to being ready for "prime time," but I am moving forward. There are no user interaction features as of yet, hence me posting static HTML and not a nice web interface for you to use. The originating username is still hard coded. I have somewhat solved the problem where a person does not have enough favorites to complete a row. I have a quick hack to prevent two rows in a row from having the same owner, although this is a cheap hack. I need to make sure there are no duplicate rows in the whole square. I can do this by either grabbing another batch of favorites for the same owner or skipping an owner after they have gotten a row. I would like to add some visual styling to show which photos are which as I always run into problems explaining the concept to people.
Every decision I make revolves around keeping the number of API calls to a bare minimum. I also want to keep the size of the calls as small as possible. I try to only ask for the number of favorites that I actually need to make a square instead of the default 50. XML is verbose and the less the API has to send back the better. Of course, that means more logic and data structure fu on my end and boy, is my perl rusty!
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
So I made my first foray into the land of Flickr programming. I'm using the perl Flickr::API module and it was quite easy to use once I found the Linux Gazette Flickr and Perl article by Jimmy O'Regan to help me get past the perl XPath stuff. The hardest part was coming up with an idea of what to do with it. So this is what I came up with:
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
What is it? I'm glad you asked. It's a small sample of my Favorites Browser. The basics structure is that pictures in the first column are ones that I have marked as a favorite. The pictures that extend out in the row are the favorites from the person who took the picture that I marked as a favorite.
So the first picture in the table was taken by bopuc and the next three are his first three public favorites. Go one down, rinse, lather and repeat. Obviously this is a very static view and I plan to add more interaction. Some ideas that I'm tossing around are dynamically rebuilding the square when you click on an image, being able to enter a username or e-mail address for a starting point and maybe some kind of DHTML-fu where I use the XMLHttpRequest object to pull in favorites and build some kind of Boogle™ like game board without having to reload the page.
Anyway, this is how far I got last night before I went out to watch movies with "the guys." I can't spend all Friday night geeking out...
Update:
Some issues that I need to deal with:
- If the first column contains two favorites from the same person, the rows will be the same. I should pull more photos to make sure that doesn't happen.
- If the person doesn't have enough favorites to complete the row, the square effect is botched.
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
The Washington Post allows you to e-mail full text copies of articles to people. I will often send myself articles to my gmail account so I can have a searchable archive of articles that I've read, or at least wanted to read. Well, this became a tedious process and what do Mac users use for automation? That's right, AppleScript.
tell application "Safari"
set theUrl to the URL of document 1
set theArticle to do shell script "wapo.pl " & theUrl
end tell
That's it! Oh...except for that little perl script. What does it do? Everything.
First, put wapo.pl in you path. It takes a URL from the AppleScript, which needs to be a Washington Post article, grabs the article ID from the URL and then posts all the right info to the Post's mailto cgi. So what's the big deal? Well, WaPo is a registration only site...so the perl script has to talk to it and be you. How does it do that? It uses your browsers cookies. As long as you use a cookie file from a browser that you've already authenticated with, it should work just fine.
If you try and use it and run into problems, you're probably better off not contacting me. This is crappy code, but like all good code it works for me.












































































































