Date: 2005-03-23 01:24:00
Tags: rant, web
broken paradigm
You know what I hate about Gallery? It breaks the Back button. For example, go here. Then select page 2 (right above the date). Then hit the Back button. You would expect that you would go back to page 1, right? Nope, you're left staring at page 2 wondering why the Back button didn't work.

(Note: For the same reason that this is broken, going here might take you directly to page 2. If that's the case, select page 1 then hit the Back button.)

This is, of course, just one of the many things I hate about Gallery.
Couldn't that be fixed pretty easily?
You'd think so, yes. But the design decision that produces this behaviour appears to be quite deliberate. At first the link is ".../gallery/sxsw2005". When you go to page 2, it changes to ".../gallery/sxsw2005?page=2". This appears to set your "current" page for the sxsw2005 gallery to page 2. When you go back to ".../gallery/sxsw2005", gallery just shows you the "current" page as last set. Which isn't page 1 anymore, but page 2. Surely they could have come up with a better design that didn't rely on server-side state for remembering which page was your "current" page. That sort of thing is supposed to be handled by the content of the URL.

An easy way to fix this would be to change Gallery to send an HTTP temporary redirect response when accessing the unqualified ".../gallery/sxsw2005" to the url for the current page, ie. ".../gallery/sxsw2005?page=1". That would preserve functionality and not end up breaking the Back button, because the browser wouldn't store the unqualified ".../gallery/sxsw2005" in its history.
I've found the people that write the software to be pretty responsive on the gallery message board. Perhaps a note about it there would be in order. Worst that could happen is that they adopt the all-to-typical "our software is fine, the user is wrong" attitude. :)
They also seem to be without clue. For example, how on earth do you write exploits into a picture gallery?

Greg needs to add some gallery-like features to his photo gallery and release it on freshmeat or the like.
Not being a programmer, I don't know how exploits can happen in any software. But it happens, even to the best of software packages.
Isn't that controlled by a cookie? If I don't let a site running Gallery set cookies, it doesn't "remember" which page I'm on like that. Maybe they could add (if it isn't already there) an option to disable this setting of cookies server-side?

Sometimes I like that behavior, sometimes I don't. It's not enough to make me disable cookies on all sites running gallery, even thought that would take almost no work since my browser prompts me about cookies anyway... And I suspect disabling cookies on a Gallery site where I login would prevent me from logging in.
Yes, it appears the current page is stored in server-side state where the user is identified by a cookie. I haven't tested this with gallery, but usually PHP will embed the session ID in the URL if it finds that it can't set a cookie. All this might be configurable and up to the admin, I don't know.
Gallery is wonderful. :)
For the same reason that this is broken, going here might take you directly to page 2

For the same reason? I was under the impression that this would only happen if the last time you visited the page you were on page 2 and then you clicked on the album link again. I don't think first time visitors ever are shown any page other than page 2 first. This has been my experience at least.

And yes, that "feature" of Gallery can be annoying. I think JWZ ranted about it once. But it's never bothered me enough to try and fix it :)

Yeah, I mentioned the note about the page 2 thing because I suspect that many of the readers here will have already visited the nucleartacos gallery in the recent past, and may have last viewed page 2. :)
Oh, good point. :)
your browser is broken =)

opera does the right thing. perhaps that is why i still tolerate gallery--i only ever use it in opera.
It might also be that Opera is caching the album pages too aggressively, and the server would say "yes I have new content for that page" if only the browser would ask. :)
oh, quite likely. i do hit reload more often than one might think would be necessary when i'm polling my LJ friends page for example. however, in this particular case it's a win =)
It works for me. I have cookies disabled. It doesn't seem to embed a cookie in the URL; I'm pretty sure that PHP only will do that if some effort is taken by the page author to make it use the URL when cookies are disabled.
Clarification: by "it works" I mean "the back button works, and does not display the broken behaviour you describe".
Greg Hewgill <>