468,471 Members | 1,653 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,471 developers. It's quick & easy.

Python script to generate static site?

Hi,

I'm sure there are a bunch of them, but googling just returned
full-fledged CMS that require a DBMS and generate dynamic pages.

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.

Considering Python's wealth of libraries, it's most likely only a
couple hours' work, but since I'm pretty much a Python newbie...

Thank you
Fred.
Jul 18 '05 #1
9 1947
> Considering Python's wealth of libraries, it's most likely only a
couple hours' work, but since I'm pretty much a Python newbie...


I recommend ht2html; this is used to generate python.org.

Regards,
Martin
Jul 18 '05 #2
Fred <fr**@acme.com> writes:
Hi,

I'm sure there are a bunch of them, but googling just returned
full-fledged CMS that require a DBMS and generate dynamic pages.

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.

Considering Python's wealth of libraries, it's most likely only a
couple hours' work, but since I'm pretty much a Python newbie...

Thank you
Fred.


My Pdx package can do this:
manual: http://www.seanet.com/~hgg9140/comp/...oc/manual.html
download: http://www.seanet.com/~hgg9140/comp/

You do a template, then do "=include_for html" for the basic datafile
you want to wrap. Or write directly in Pdx (less verbose than raw
html).

--
ha************@boeing.com
6-6M21 BCA CompArch Design Engineering
Phone: (425) 342-0007
Jul 18 '05 #3
Fred <fr**@acme.com> wrote in message news:<hl********************************@4ax.com>. ..
Hi,

I'm sure there are a bunch of them, but googling just returned
full-fledged CMS that require a DBMS and generate dynamic pages.

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.

Considering Python's wealth of libraries, it's most likely only a
couple hours' work, but since I'm pretty much a Python newbie...

If I may humbly plug my own project, you might try HRL:

http://www.aerojockey.com/software/hrl

In fact, the example on the home page pretty much does exactly what
you ask. It's very versatile for generating static pages, I'd say.
Maybe too versatile. If you'd like to be able to use the power of
Python to automate various tasks that come along, this might be what
you want. If you just want 1, 2, 3, and 4 for all eternity, you might
prefer something less deep.

Also, it supports Unicode, if you need that.
--
CARL BANKS
Jul 18 '05 #4
has
Fred <fr**@acme.com> wrote in message news:<hl********************************@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])
Jul 18 '05 #5
>>>>> "Fred" == Fred <fr**@acme.com> writes:

Fred> Hi, I'm sure there are a bunch of them, but googling just
Fred> returned full-fledged CMS that require a DBMS and generate
Fred> dynamic pages.

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

Fred> Considering Python's wealth of libraries, it's most likely
Fred> only a couple hours' work, but since I'm pretty much a
Fred> Python newbie...

yaptu is python templating code (79 lines long!). I use it to
(statically) generate the entire matplotlib web site -
http://matplotlib.sourceforge.net. This includes parsing pydoc output
to embed it into the web site navigation tables, adding headers /
footers, etc. I think it's great - it's really easy to mix python &
html
see http://aspn.activestate.com/ASPN/Coo...n/Recipe/52305. If
you want more extensive examples, look in the *.html.template files of
the htdocs subdirectory of a matplotlib cvs checkout.

JDH
Jul 18 '05 #6
>>>>> "Fred" == Fred <fr**@acme.com> writes:

Fred> Hi, I'm sure there are a bunch of them, but googling just
Fred> returned full-fledged CMS that require a DBMS and generate
Fred> dynamic pages.

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

Fred> Considering Python's wealth of libraries, it's most likely
Fred> only a couple hours' work, but since I'm pretty much a
Fred> Python newbie...

yaptu is python templating code (79 lines long!). I use it to
(statically) generate the entire matplotlib web site -
http://matplotlib.sourceforge.net. This includes parsing pydoc output
to embed it into the web site navigation tables, adding headers /
footers, etc. I think it's great - it's really easy to mix python &
html
see http://aspn.activestate.com/ASPN/Coo...n/Recipe/52305. If
you want more extensive examples, look in the *.html.template files of
the htdocs subdirectory of a matplotlib cvs checkout.

JDH
Jul 18 '05 #7
Fred wrote:
Hi,

I'm sure there are a bunch of them, but googling just returned
full-fledged CMS that require a DBMS and generate dynamic pages.

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.

Considering Python's wealth of libraries, it's most likely only a
couple hours' work, but since I'm pretty much a Python newbie...


You could try XIST (http://www.livinglogic.de/Python/xist/).

The source for this page can be found here:
http://www.livinglogic.de/Python/xist/index.htmlxsc

XIST supports Unicode, XHTML, SVG, XSL-FO, WML etc.

Bye,
Walter Dörwald
Jul 18 '05 #8
On Thu, 12 Aug 2004 18:20:04 +0200, Walter Dörwald
<wa****@livinglogic.de> wrote:
(snip)

Thx a bunch everyone. I'll check all those out.

Fred.
Jul 18 '05 #9
I like PubTal because it produces static pages from Zope Page
Templates (ZPT), which I like as an approach:

<http://www.owlfish.com/software/PubTal/>

Recent versions have intelligent FTP upload too.

ZPT has a learning curve, but is quite nice (and scalable upwards to a
fully dynamic solution in future if you need that).

--Phil.
Jul 18 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

54 posts views Thread by Brandon J. Van Every | last post: by
7 posts views Thread by Andrew Chalk | last post: by
34 posts views Thread by Erik Johnson | last post: by
8 posts views Thread by Paul Cochrane | last post: by
6 posts views Thread by tatamata | last post: by
14 posts views Thread by nicolasg | last post: by
10 posts views Thread by James Stroud | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by kmladenovski | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.