Gold Plated Blog Posts
Whatev.
Tuesday, October 21, 2008

New to the Pictures Section

This is kind of a two-part post. The first is to just let everyone know that I've finally uploaded pictures of the Portland wedding that my Uncle Steve took. If you were at the wedding, there's a good chance you'll find yourself in one and if you weren't, check it out to see what you missed!

If you've ever used the commenting option at the bottom of each picture, you'll also notice a few new features. I'm sure you know how frustrating it is when you don't enter your name and it inserts "Some anonymous shmoe" as a replacement. My first new feature alleviates that problem to a large extent. Now the first time you enter a comment on a computer, it will remember your name and if you forget to enter your name in a future comment, it will insert the name you used in your last comment. It won't follow you around from computer to computer (that would be impossible) but it will work on any computer you use as long as you don't clear your cookies.

If you like to comment on photos you probably know the feeling you get when you accidentally hit the Enter button after leaving half a comment, or the feeling you get when you leave comments after heavily drinking the night before and wake up to find yourself the laughing stock of the community (the cameronhinkle.com community, that is. ....so basically, me). At your rescue is the new "delete" button. It's in the form of a red X and it will appear at the end of all your future comments. Again, it only works per-computer and will be there as long as you don't clear your cookies. If you don't know what "clear your cookies" means, you'll have some catching up to do. I would start here.

For those of you who care, I'll get a little into the specifics of how I made these possible. The first is easy, I just set a cookie in your browser that contains the name you enter for each comment, then I check for it if you don't enter a name in the future. The delete button is a little tougher. Cameronhinkle.com now keeps a cookie in your browser that holds a pipe-delimited list of comments that you've made. Every time you enter a new comment, it adds the comment id to the cookie. Then whenever you view a picture on CameronHinkle.com, it explodes the list of comment ids into an array and iterates through each comment id to see if it exists in the array of comments that have been submitted for that photo. If a comment is found in the array, it puts the red X inside a form at the end of that comment with the comment id as a hidden field. When the X is clicked, the form posts the comment id to the server and the comment is deleted using my versatile and robust Picasa API. The way that it is deleted is similar to the way it's posted, which you can read about in my article Comments: Enabled. I haven't worked out all the kinks (in fact it just blew up on me a second ago) but it's coming along nicely and I think it will be a really useful addition.

This deleting mechanism obviously opens up a bit of a security risk. All someone would have to do is post a comment id to the page to delete any comment they want. I'm not too concerned about this because I don't know who would care about deleting comments. Also, it would be a little bit of a hassle to find the comment id for a particular comment, especially if you don't know anything about the Picasa API. If I put the X next to every single comment I could definitely see someone clicking all the X's just to be annoying, but it's probably inconvenient enough as it is that no one will bother. If I'm wrong and there is an incident, I'll just encrypt the ids before I store them in the cookie. I would do that now but I wanted to make the page load as fast as possible.

Hopefully this and the Comments: Enabled post has given some people a few creative ideas of what is possible with the API. I've gotten a lot of good feedback on the Pictures section in general and am always trying to come up with ways to improve it. Of course if you don't use it then all my work is in vain, so go comment find your favorite picture and make some comments!

The articles in this blog are authored by Cameron Hinkle, Software Engineer for Nike. The thoughts and opinions expressed are not shared by Nike or any of its affiliates.