I decided to rewrite my webpage, and this time to create scripts that will create all the html from a template file and some .content files. The basics work great. However, now I'm considering how to handle "special case" pages, like my screenshots page nad my random pictures page. On those pages I want to take a dir of images with one file that contains captions and automagically create an index page containing thumbnails that link to pages with the actual pictures (or the image files themselves, in the screenshot page). Right now, my main script looks for all the .content files in the main dir and creates .html files from those. I also have a couple of scripts that will create the "special" pages on their own. I'm trying to see if I can come up with a way of having one script do it all for me, and whether that will just be nasty (do i have a .pages file that tells my script which pages are "special"....
I know that there are 10,000 packages out there that will do exactly what I'm doing now for me much more elegantly and better than anything I can write, but writing this crap is helping me with the depression I've been struggling with for the last several days. sigh
I of course realized that i was being an idiot. All I have to do is create the custom .content files seperately, and then my script can create the html from those. So the main body of my script looks like:
inside the make_pixcontent and make_sscontent subs I create
a .content page that, when parsed, creates an index page of
all the images thumbnailed, and then a bunch of .content
files that parse to have the full sized image on the page.
The first thing was that no one knew exactly where the
project lived. OK, no
problem. I looked through the cgi-bin dir, hey look,
survey.cgi. Looks like
it calls a survey.py script that does all the work. Uhoh.
I've never looked
at python before in my life. Ok, let's run the cgi and
start tracking errors.
First error is a syntax error in the script. Hrm, better hit
google. Tracked it down
to a change in
python since we seem to be running a newer version of
python than the
script was written for. Evidently, python made the way args
are defined a bit stricter--no problem.
The script wants to make a connection to a
MySQL database. Oops, python can't find the MySQL
module. OK, this is
a debian box, no problem. apt-cache search mysql | grep
python-mysqldb - A Python interface for MySQL. Neat.
apt-get install. Hrm,
the script still can't seem to find the module. Oh, it's
MySQLdb, not MySQL.
Hmm, i wonder what is different...
OK, pretty much everything is different. Different syntax on how to make a db connection. Different syntax on executing SQL commands. I did some nasty ad hackery (think ad hoc) and voila! It seems to work. Yay me! Sometimes I don't feel like such a moron...
New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.
Keep up with the latest Advogato features by reading the Advogato status blog.
If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!