Python script to generate static site?

has has.temp2 at virgin.net
Thu Aug 12 08:16:04 EDT 2004


Fred <fred at acme.com> wrote in message news:<hl5lh0pb3u4m47f2bsatc9vigrv7pc7v07 at 4ax.com>...

> I'd just like a script that would 
> 1. look in a directory for articles in raw HTML,
> 2. generate a cooked output for each page (ie. add header and footer,
> CSS link in HEAD, etc.),
> 3. regenerate the homepage with "Last modified" bit following each
> article's title,
> 4. ready to be uploaded by FTP to a web server that only handles
> static web pages.

This should be close to what you want:
<http://freespace.virgin.net/hamish.sanderson/DocGen.zip>. (See
<http://freespace.virgin.net/hamish.sanderson/htmltemplate.html>.)

To add 'last modified' dates, replace the second-last line of
write_docs.py with:

import time
index = '<ol>\n%s</ol>' % ''.join(['\t<li><a href="%s">%s</a>
%s</li>\n' % (href, name, time.strftime('(last modified: %I:%M:%S %p
on %Y-%m-%d)', time.localtime(os.stat(src + href).st_mtime))) for
name, href in chapterNames])



More information about the Python-list mailing list