Archive for the ‘mybooklist’ Category

Book Collection Managment for Linux

Friday, September 26th, 2008

Once upon a time, the options available to Linux users interested in managing their book collections were limited. The situation was so bleak that I attempted to create my own web-based application. That app was fine until I tried to host it on my 64MB VPS and failed (RoR had a footprint of 60MB all by itself)!

Lately, I have been missing the ability to browse through my books. I started thinking about having another attempt at a book collection manger. Maybe this time I would try and write a desktop application. I could use python or even try out mono. So today I did a bit of googling and stumbled upon Alexandria, a book collection manager for GNOME.

This application is brilliant! It is almost the perfect application. All I needed to do was get a list of books in my old app:

echo "select isbn from books;" | sqlite3 mybooklist_production.sqlite > import-list.txt

I was then able to import all my old books into Alexandria using the import ISBN list feature. I would like to recommend this app to anyone who is looking for a book collection manger for Linux. The site also has deb packages for those who use Debian or Ubuntu.

Caching the book cover images

Saturday, December 2nd, 2006

In my “mybooklist” application I deal with lots of images! My current method has been to store the uploaded book covers in public/images/bookcovers/isbnnumber.png” and creating thumbnails on the fly in the list and grid views!

Of course this is a very bad thing to do! The load on my server was going crazy with all the CPU intensive image manipulation going on! I had to do something.

The task required to different solutions. The first was client side caching to prevent the browser downloading the image multiple times! to achieve this I modified the show browser function like so:

# 2. we see if we need to send the file or not
        lastmod = File.stat(filepath).mtime
        minTime = Time.rfc2822(@request.env["HTTP_IF_MODIFIED_SINCE"]) rescue nil
        if minTime and lastmod < = minTime
            # use cached version
            render_text '', '304 Not Modified'
        else
            # send image

now I only send the image to the client only in I need to!

The second area of improvement was the thumbnail creation on the fly! I first tried the rails

caches_page :show_cover

but I found myself in a situation where I was sending the image to the client every time because rails was sending the cached image without ever running the show_cover function (and my browser cache code)!

I guess I am just going to generate the thumbnails in the create and update functions. The app should feel a lot different and the load on the server should stay low!