![]() |
Introduction to rest2webA Gentle Introduction to the Site BuilderWhat is rest2web ?
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. InternationalizationWith 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
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.
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 Siterest2web 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
Source Distributionrest2web 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 DistributionDownload the executable version of restweb (3.5mb) from rest2web-0.4.0alpha-EXE.zip Subversion RepositoryYou 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. Sourceforgerest2web can also be downloaded from the Sourceforge rest2web Project Page. Installing
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 Heartrest2web 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
Footnotes
Return to Top |
||||||||||||