rest2web: Building Websites Across the Known Universe

- rest2web
- >
- Introduction

# Introduction to rest2web

## A Gentle Introduction to the Site Builder

Contents

- What is rest2web ?
  - Internationalization
  - Static Versus Dynamic
  - Why rest2web ?
- A rest2web Site
- Downloading
  - Source Distribution
  - Executable Distribution
  - Subversion Repository
  - Sourceforge
- Installing
  - At the Heart
- Useful Links
- Footnotes

# What is rest2web ?

rest2web is a tool for autogenerating wesites, or parts of websites. It's main features are :

- Integrated with docutils.
- Automatically builds index pages and navigation links (sidebars and breadcrumbs).
- Embedded code in templates for unlimited expressiveness.
- Flexible macro system.
- Uses relative links, so sites can be viewed from the filesystem.
- Unicode internally - so you don't have to be.
- Includes features for multiple translations of sites.
- Built-in gallery creator plugin.
- The basic system is very easy to use.
- Lots of powerful (optional) features.

The content can be stored as HTML, or in ReST format; in which case the HTML will be generated using docutils. rest2web inserts each page into a template, and automatically creates index pages for sections, and navigation links.

ReST is a WYSIWYG text markup format. It is simpler than HTML - but very flexible. A document marked up with reST is still readable as text. This means that maintaining article contents in reST is a lot easier than maintaining them in HTML.

Adding new pages is as easy as dropping a text file into the right folder. rest2web builds the new page and adds a link to it in the index (optionally with a description as well). Removing a page is just as easy. Delete the file, and when you run rest2web again it removes the entry.

rest2web includes standard functions to build a sidebar, with links to the other pages in the directory, or to the other sections in the website.

Another advantage is that a website can be easily restyled by only changing template files. It is likely that only a few template files will be needed for most websites [1].

Because rest2web generates sites using relative paths, the results can be viewed from the filesystem. This means that it is an effective way of bundling documentation.

## Internationalization

With uservalues you can use rest2web to create versions of a website in different languages. Simply create the framework once with your uservalues as place markers - then create your files with different translations. rest2web will build the website and can handle linking the sites together.

An example of a site that uses this feature is, the Website of Marius Soutier.

## Static Versus Dynamic

rest2web is a dynamic website generation tool - that generates static (HTML) pages. The rationale of creating static content, is that most pages will only change occasionally - serving static HTML content is quicker than generating pages dynamically. Not only that, but static content can be served by a lot cheaper hosting account!

Distributing HTML documentation is another reason for wanting static pages.

## Why rest2web ?

rest2web comes about from a need for me to restyle a whole website from badly marked up HTML 4, into beautiful XHTML and CSS. See the Voidspace Manifesto for a discussion of my aims and objectives in the restyle.

An added challenge is that part of the website is already restyled - and the blog pages are built using a different tool (Firedrop2, which also uses ReST incidentally). All this means that rest2web needs to be able to handle generating just part of a website, and indexes for the existing parts where necessary.

# A rest2web Site

rest2web is optimized for creating websites with a particular structure. It is aimed at the sort of sites that have sections and subsections. The basic structure is closely related to the directory structure on disk. It is based on having an index page in each directory. Files in that directory are listed in the index page, which can be divided into various sections.

Subdirectories have their own index page - that index page will be link to from the 'directory' above. Your website structure is modelled on the directory structure. This is the hierarchy of sections and subsections.

Every text file ('.txt' extension) in a directory will be scanned. If the file starts with a restindex, then it will be processed.

If you want links to some prebuilt files on an index page, then you can put a relevant text file in the directory with the details (target name, link title, page description, etc) and set `build: No`. This allows you to use rest2web to just build part of a website - but still include in the index pages that it doesn't build. [2]

For a good introduction, read the tutorial - Creating a Site. You can also peruse the Test Site included with this documentation. It illustrates most features of rest2web.

Every page can also have a set of uservalues that will be inserted into the template. This is another way of putting dynamic values into a template. An obvious use of this system is for providing a website in several different languages.

If you just want to get up and running, you may want to checkout the Quick Start Guide by Andrew Ittner.

# Downloading

All distributions include all the documentation and the example site.

## Source Distribution

rest2web is a pure Python programme. If you have Python installed you don't need to compile anything to use the source distribution.

Download restweb (2.49mb) from rest2web-0.5.1.zip, or rest2web-0.5.1.tar.gz.

## Executable Distribution

Download the executable version of restweb (3.5mb) from rest2web-0.4.0alpha-EXE.zip

## Subversion Repository

You can browse (or download using SVN) the latest development version over at the SVN Repository. [3]

The version in SVN is often more up to date than the latest release version - and I try not to break the version in SVN (but no guarantees).

The full command is : `svn co https://svn.rest2web.python-hosting.com/trunk/` [4]

Note

If you obtain rest2web from subversion, it won't run from its own distribution directory unless you delete the `__dist__` file.

## Sourceforge

rest2web can also be downloaded from the Sourceforge rest2web Project Page.

# Installing

If you are running the source version of rest2web, you need docutils installed. It works best with the latest version [5].

rest2web itself shouldn't actually need installing. You can place the 'rest2web' directory in your 'site-packages' folder if you want to. You should then be able to run 'r2w.py' from anywhere.

You can test rest2web by just double clicking on it. This should build the docs and example site as html, in the docs_html directory. It will generate a log of the process in 'log.txt'. If there are any problems then they will be recorded in the log. Please report any bugs to the rest2web Mailing List.

The files in the 'modules' folder are used by macros. They will also need to be somewhere on `sys.path` (e.g. in 'site-packages'.) Alternatively, if the modules directory is in the same directory as 'r2w.py' when you run it, it will automatically be added to the path.

## At the Heart

rest2web and docutils are both projects written in a language called Python. In order to use the source version you will need Python installed.

Hint

If you don't want to (or can't) install Python, then you can use the pre-built executable version instead.

This does limit slightly what you can do with macros and embedded code in the templates. (Basically you can only use the modules that come included or that you create yourself).

The templates and macros are also done using Python code. If you've never used Python before, don't let this put you off. It's a very easy language to learn and you can learn the basics very quickly. The main Python website has distributions for most platforms available for download, as well as links to tutorials and resources for learning Python.

# Useful Links

- rst-ht2html - This is a project with a similar aim, the automatic creation of websites from restructured text. It uses ht2html, the scripts that generate sites like Python.org, and Jython.org. rest2web is more flexible with the templating it allows. It should be possible to generate a much wider range of sites with rest2web.

- docutils - this is the Python project that turns reStructuredText into nice XHTML.

- Firedrop2 - the blog client originally created by Hans Nowak.

  This project [6] produced `embedded_code.py` and `textmacros.py` which are used by rest2web. `embedded_code.py` is the templating engine used by rest2web. `textmacros.py` adds a simple system of macros into rest2web.

  Firedrop2 also supports alternative text markups sextile and textile. rest2web may be enhanced to support these (if there is any demand).

  > Note

  > I now maintain Firedrop2. You can download the latest distribution, and browse the docs over at : http://www.voidspace.org.uk/python/firedrop2/index.shtml.

- webgen - A ruby project that does a similar thing to rest2web. It is scarily similar in the way it works. It doesn't work with ReST markup however.

- Tahchee - an alternative to rest2web that uses the cheetah templating system.

# Footnotes

[1] | Many websites will only need a single template file. Voidspace actually uses two for all the parts of the site built by rest2web.

[2] | It's possible to include details of several of these pages in a single file called 'restindex.txt'. It is basically a series of restindexes in a single file.

[3] | Many thanks to the decent folks over at python-hosting.com.

[4] | For Windoze users, I recommend the SVN client TortoiseSVN.

[5] | Version 0.3.9 or later.

[6] | And Kaa, the predecessor to firedrop.

Return to Top
Part of the rest2web Docs
Page last modified Sat Dec 16 20:39:32 2006.

- Index Page
- Pages
- Introduction
- Quickstart
- Config File
- Tutorial
- Command Line
- Force Mode
- Templates
- restindex
- Functions
- Macros
- Special Files
- Sub Sections
- Reference
- Test Site
- Translation
- Gallery