|
This entire web site is created from a database. The pages are not
created dynamically for each HTTP request, rather a program generates the
static pages that you are currently reading from information it has in a
database. This document describes how this is done.
The technology used in the creation of this site is just about all
freely available on the Internet, and just goes to show what can be done
without paying vast amounts of money for commercial software. (Note: I only
tend to use free software that compiles straight out of the tar(1) file
with little or no configuration on my Solris 2.X machine.)
Software Used...
- Database:
PostgreSQL
PostgreSQL gives me powerfull database technology that easily
interfaces to my programming language of choice.
- Programming Language:
Python
Python is my programming language of choice, and has been for a
number of years now.
- Graphic Tools:
ImageMagick &
The Gimp
I use The Gimp to create the original graphics, and I then transform
them down to GIFs using ImageMagick. I also use ImageMagick to
manipulate the high resolution scanned pictures in TIFF format down
to the various sizes of JPEG image used on the site.
The Program...
The program that performs the generation of the site uses two non
standard Python modules. Firstly there is pg95ext which gives me a simple
to use interface to making SQL queries on the PostgreSQL
database. Secondly I use the HTMLgen module to generate the HTML without
having to mess about with raw HTML tags.
A minimal example of what can be achived using Python and these two
modules is shown below:
import pg95ext
from HTMLgen import *
db = pg95ext.connect (dbname="collection")
manufacturers = db.query ("SELECT full_name,common_name,resource "
"FROM manufacturer")
for (full_name,common_name,resource) in manufacturers:
doc = MinimalDocument ()
doc.title = "Manufacturer - %s"%(full_name)
doc.append (Heading(1,common_name))
# Other HTML goes here...
doc.write (filename = resource+".html")
db.close ()
This code fragment opens a connection to the database, then queries the
manufacturer table to get all the records we have. We then loop through the
records creating a HTML document for each manufacturer.
You can find the full source code of the program that creates these
pages in: generate_collection
Static Pages...
Even these 'static' pages are partly stored in the database. The main
body of the page is stored in a plain text file as it allows me to edit it
using my favourite editor. I then store a reference to this file in the
database along with title, description, keywords etc. I can then bolt on my
standard headers and footers to the pages to give then a consistent
appearance without the headache of keeping them up to date all the time.
The Database...
Someday I will get around to publishing the database schema, but for the
time being let me say...
There is more information stored in the database than is presented in
these web pages. Things that have been left out are who/where I acquire
things from, and their purchase price. This is to save embarrassment for me
How much did you spend on that machine! and to protect my sources
because I wouldn't want to give these away to other collectors and increase
competition :-)
My Pictures...
I don't use anybody elses pictures, so all the pictures you will find on
this site were taken by me. (Yes, I am no expert at photography but I am
learning slowly.) I scanned the original prints into high resolution 24bit
TIFF files. These 'originals' are then converted using ImageMagick
into various size JPEG files, and it is these pictures you see here on the
site.
|