Articles tagged “projects”
Implementing an image gallery using facebox and will_paginate
On VisitaCSA we’re using defunkt’s facebox to show places images at large. Facebox is a great general-purpose lightbox, because it is fast, stable, is based on jQuery and has got a really clean API.
But we needed more than a simple display lightbox, because we wanted our users to navigate easily between all images, possibly without modifying facebox at all. The solution turned out to be pretty simple, thanks also to the will_paginate plugin we were already using. It all burns out to have:
- A Photo model, instrumented with the
has_attachmentmethod - Resource routes for photos (
map.resources :photos, :only => :showinconfig/routes.rb) - A
showcontroller method in thePhotosControllerthat calls.paginatewith a:per_pageargument of 1 - An HTML view for the photo resource, that has pagination controls using the
will_paginatehelper - Some jQuery code hooks onto the pagination links and make the browser load via AJAX the next photo directly into the facebox.
A permalink_fu improvement: allow modification of permalinks and send HTTP redirects on-the-fly
Another spin-off from the www.visitacsa.it website: a permalink_fu improvement that allows dynamic permalinks. I know it is an oximoron, because permalinks should be .. well .. permanent! And because search engines index them, they should never change. But what happens when you publish something, your permalink is generated with permalink_fu using the title of your post, and after a couple of days you want to change the title, and the permalink under which the post is accessible as well?
Following the specification, your app should send out a 301 moved permanently HTTP status when accessing the old permalink and redirect the client to the new Uniform Resource Locator. That’s quite the same thing what my modification to permalink_fu does: whenever your post attributes are changed, the former and new permalinks are saved to the database, and you can enable your controller to generate 302 moved temporarily redirects when needed. In other words, it checks whether the requested URL is an old permalink, and automagically redirects the client to the new one.
The jQuery ajax-upload-fu plugin
I recently wrote jQuery plug-in, that allows AJAX file uploads without using a fixed file input button. It achieves its goals by installing an OnMouseMove handler over the selected elements, and moving the input button under the mouse cursor.
The quote that inspired this code is: “If Muhammad won’t go to the the mountain, the mountain will come to Muhammad”,the opposite of the more known proverb :).
It has been spinned off from the Visita CSA application JavaScript codebase, see the gist for more information, and have a look onto the live app code for an example of its usage.
Here is the source code:
myousica.com was born today
Today we released the output of 9 months of hard work: myousica.com, a social networking site for musicians. Have a look at the promo video and check out the site. Have fun! :)
UPDATE 2009/02/23: The site is now paused.


