472,796 Members | 1,076 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,796 software developers and data experts.

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 2258
> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

54
by: Brandon J. Van Every | last post by:
I'm realizing I didn't frame my question well. What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump up in your chair and scream "Wow! Ruby has *that*? That is SO...
7
by: Andrew Chalk | last post by:
Is this possible? In my CGI app. I display a web page with a link (anchor). When the link is clicked I want to exectute a python script rather than go to an HTML page. Many thanks.
34
by: Erik Johnson | last post by:
This is somewhat a NEWBIE question... My company maintains a small RDBS driven website. We currently generate HTML using PHP. I've hacked a bit in Python, and generally think it is a rather...
8
by: Paul Cochrane | last post by:
Hi all, I've got an application that I'm writing that autogenerates python code which I then execute with exec(). I know that this is not the best way to run things, and I'm not 100% sure as to...
122
by: seberino | last post by:
I'm interested in knowing which Python web framework is most like Ruby on Rails. I've heard of Subway and Django. Are there other Rails clones in Python land I don't know about? Which one...
0
by: venkatbo | last post by:
Hi folks, I'm trying to get lighttpd, fastcgi & python working on a 2.4.21.x i686 linux system. I tried following the steps in: ...
6
by: tatamata | last post by:
Hello. How can I run some Python script within C# program? Thanks, Zlatko
14
by: nicolasg | last post by:
Hi folks, I have accomplished to make a python program that make some image manipulation to bmp files. I now want to provide this program as a web service. A user can visit a site and through a...
10
by: James Stroud | last post by:
Hello All, I am interested in setting up a modest invoicing system for some consulting I am doing. I like the idea of managing this on the web and creating invoices and printing them from a...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.