reStructWeb is a small piece of software written in Python language. I wrote it to manage my personal web site. The most important features that I wished when I decided to write it are :
I took as a starting point the the Wiki system to update my Web site. The pages are created in text format using the reStructuredText format. Look for example at the source of this document clicking on the Source link in bottom of this page.
reStructWeb is based on the following tools:
At present reStructWeb makes hardly more than 300 lines of code. Largest of work (the management of the reStructuredText format) is made by Docutils.
reStructWeb was tested on the following environments :
The program should work on any system supporting Python 2.2 (or more) and docutils
The system used is very powerful. The majority of time, the pages are sent to the navigator directly by Apache (static pages). Two cases of figures will lead Apache to return the request on reStructWeb script:
reStructWeb script will ask you to create a page in case it don't exist or will ask you for the modification of an existing page. It generates thereafter html pages in the various languages and Apache will be able to send them in a traditional way.
Apache requires a small configuration to redirect the requests towards reStructWeb. You can however configure to use reStructWeb in a traditional way like a cgi, for example:
With Apache settings
http://www.test.com/index.html.en
Without Apache setting
http://www.test.com/rstweb.cgi/index.html.en
reStructWeb is a small script which I wrote for my needs only. It was not thought and not designed at all for a system having to be managed by several people. There is no management of users, no modifications history and the safety options are non-existent : The permission of modification of the site is based on a single password, the magicWord: -)
Attention!
Do not let anonymous users modify the contents of your website. reStructWeb is not a Wiki. An badly-attentive user can divert the use of the reStructuredText to try to compromise the system. Example :
.. include:: /etc/passwd
It is thus possible to include the contents in the page of any file on the system (for which the user of apache as the rights for reading).
This said, it is very fast 1 , very light, very simple to implement (a single file and four parameters)
[1] | It is not the reStructWeb script which is fast, but the Apache sending of static pages. What is practically always the case on my site. |
In this mode, there is no Apache configuration. You only need to to copy the script in the directory cgi-bin.
proceed as for the standalone mode and to configure Apache in the following way :
Script GET /cgi-bin/rstgen.py Script POST /cgi-bin/rstgen.py ErrorDocument 404 /cgi-bin/rstgen.py
On my computer, the working directory is /home/web/david/pages, rstgen.py is copied in the /home/web/david/cgi-bin directory.
Here is my Apache configuration :
<Directory "/home/web/david/pages"> Options FollowSymLinks MultiViews +Includes Script GET /drobert/admin Script POST /drobert/admin ErrorDocument 404 /drobert/admin AddDefaultCharset UTF-8 </Directory> <Directory "/home/web/david/pages/st"> Options Indexes FollowSymLinks MultiViews +Includes AddDefaultCharset ISO-8859-1 </Directory> <VirtualHost *> ServerAdmin webmaster@ombrepixel.com DocumentRoot /var/www/ombrepixel.com ServerName www.ombrepixel.com ServerAlias ombrepixel.com ErrorLog logs/www.ombrepixel.com-error_log CustomLog logs/www.ombrepixel.com-access_log combined ScriptAlias /drobert/admin /home/web/david/cgi-bin/rstgen.py Alias /drobert /home/web/david/pages/ </VirtualHost>
The appearance of each page can be completely customized because the system uses templates. It is completely possible to make a really nice website by using reStructWeb (not like this one).
The templates are files with the .tmpl extension located in the working directory. You need a default template for each language your website support, thus,on my site, two files are present on the working directory :
They are the default templates for all the pages, in French and English.
You can create templates specific to each page with the filename page_name.tmpl.en. For example if I want a customized template for the reStructWeb page, you just have to create the files restructweb.tmpl.en and restructweb.tmpl.fr``.
The template file is a pure html file in which a certain number of variables are replaced by dynamic contents. Currently, reStructWeb makes it possible to use the following variables :
Variables | Replaced by |
---|---|
$title | Title 2 of the page |
$body | Body of the page |
$sourceUrl | Page source url |
$editUrl | Page edit url |
$enUrl | English version url |
$frUrl | French version url |
$lastModified | Last modified date |
[2] | Title is defined in the reStructuredText (name of first section) |