Buildindex : automatic generation of an HTML page from a list a subdirectories

Christophe Pallier

As my web site grew in size and complexity, it became more and more difficult to navigate. That is why I decided to have a web page that would index all the ressources available on the site (research or technical articles, software packages, list of links...) . As I have little time to maintain the site and edit web pages, I wanted to be able to easily add new ressources and have the index page generated automatically.

I might have used a MySQL database and PHP, but this seemed overkill and I tend to prefer static HTML (not all web hosting companies prive MySQL+PHP). So, here is my solution:

All ressources are stored in as many subdirectories of the site's root directory (1 ressource=1 subdirectory). Each subdirectory must contain a text file 'desc.txt' which describes the ressource. Here is an example:

name sound_tools

type software

date 2002-10-08

desc A toolbox to amplify, mix and concatenate sound files.
(based on libsndfile)

files <a href="sound_tools/sound_tools-1.0.tar.gz">sound_tools-1.0.tar.gz</a>

links <a href="www.libsndfile.org">www.libsndfile.org</a>

status 1 (alpha)

The fields (name, type, date, desc, files,links, status) are written in this file, separated by empty lines.

From the list of subdirectories, a small Perl script (source code) produces an HTML page. It is possible to specify on which field the list of ressources should be sorted (the sort order is reversed).

Here is a shell script that can be used to generate the indexes:

#! /bin/sh 
find . -type d -maxdepth 1 | sed 1d | xargs buildindex2 -s type >bytype.html
find . -type d -maxdepth 1 | sed 1d | xargs buildindex2 -s date >bydate.html
find . -type d -maxdepth 1 | sed 1d | xargs buildindex2 -s name >byname.html

The perl script can easily be modified to modify the list of field, or the appearance of the generated html pages.




File translated from TEX by TTH, version 3.01.
On 4 Nov 2002, 10:57.