Return to Top
Page last modified <% modtime %>.
rest2web-0.5.2~alpha+svn-r248.orig/ 0000700 0001750 0001750 00000000000 10644674645 016525 5 ustar madduck madduck rest2web-0.5.2~alpha+svn-r248.orig/docs/ 0000700 0001750 0001750 00000000000 10644674642 017452 5 ustar madduck madduck rest2web-0.5.2~alpha+svn-r248.orig/docs/special_files.txt 0000600 0001750 0001750 00000004702 10327117674 023015 0 ustar madduck madduck restindex crumb: Special Files page-description: A list of all the *special filenames* that **rest2web** uses - and what they are for. /description /restindex =============== Special Files =============== ---------------------------------------- Filenames With Particular Significance ---------------------------------------- .. contents:: **rest2web** works by scanning files in the directories it is working with. Some files have particular significance. This page lists all the *special files* used by rest2web - and what they do. index.txt ========= A directory will only be processed if it has an 'index.txt' file. This file needn't contain the contents of the index page, but it must exist. At the least it should contain the keyword ``index-file`` which tells **rest2web** which file *does* contain the index page contents. If the restindex for 'index.txt' does have an ``index-file`` keyword, then this is the only value that is read. All other values will be read from the real index file. template.txt ============ If the index file doesn't specify a template file, using the ``template`` keyword in the restindex, but a file called 'template.txt' does exist - then it will be used as the template for that page and directory. If you wanted to include a page of contents called 'template.txt' then you would need to include a ``template`` keyword explicitly pointing to the real template file. restindex.txt ============= If you are only using **rest2web** to generate part of a website then you may want to include in your indexes pages that rest2web isn't building. You may also want to reproduce your website structure (including whole sections that rest2web isn't building), so that the navigation links are built correctly. In this situation you may have several pages that **rest2web** isn't building in a section. Rather than having to include a separate file for each one, you can combine several restindexes in one file called 'restindex.txt'. You don't need to explicitly set the ``build`` keyword to 'No' - that's assumed. Each restindex *must* have a target value though (unless you want a link pointing to 'restindex.html' !). __prune__ ========== If a directory has a file called ``__prune__`` in it, then **rest2web** won't attempt to build the files in that directory or below. This is useful if you are testing minor changes to a site, and don't want **rest2web** to rebuild the whole site every time you make a change. rest2web-0.5.2~alpha+svn-r248.orig/docs/macros.txt 0000600 0001750 0001750 00000050460 10513540211 021461 0 ustar madduck madduck restindex crumb: Macros page-description: The text macro system used by **rest2web**. Includes documentation on all the example macros. /description /restindex ==================== Macros in rest2web ==================== -------------- Using Macros -------------- .. contents:: Macros About macros ============ Macros allow you to use a shorthand for often-used text or HTML. As a simple example, let's say that I use a certain link a lot. I don't want to type it over and over again. I can define a macro foo to include this link every time I type ``{foo}``: .. class:: ex foo = 'My link' In this case, the "macro definition" is simply a string that contains the HTML we want to substitute. We can use more sophisticated macros, though. Let's assume that I use acronyms a lot, and I'm getting tired of having to type that tag again and again. It would be nice if I could type something like ``{curlyl}acronym;IMO;In My Opinion{curlyr}`` which expands to {acronym;IMO;In My Opinion}. (Move your mouse over the "IMO" to see the effect. Not all browsers may support this.) To achieve this, we define a simple Python function: .. raw:: html {+coloring} def acronym(acronym, meaning): return '%s' % ( meaning, acronym) {-coloring} {curlyl}acronym;IMO;In My Opinion{curlyr} is equivalent to the function call ``acronym("IMO", "In My Opinion")``. These macros can also be used to do more complex things, like insert pictures, include whole files etc. .. note:: Macros pass through the ReST processing untouched (unless you include characters that ReStructured text normal escapes, like '<'). This means that macros on a line of their own will be processed as a paragraph. The generated HTML will be between paragraph tags: ``
...
``. Where are Macros Defined? ========================= As of **rest2web 0.5.0** all the macros described here are built-in to rest2web. That means you can use them without supplying a macros file. Two of the built in macros require paths to operate properly. You can do this using the `config file' tag, which breaks my layout - have I mentioned that before ? {sm;:wink:}
For example ``{cl}include;r2w.ini;True{cr}`` escapes the *r2w.ini* file and inserts it into the page :
.. raw:: html
{include;r2w.ini;True}
You can use ``inc`` as a shorter alias for ``include``.
To include HTML files (without escaping), use ``{cl}include;some_file.html{cr}``.
colorize
--------
This macro takes a file and applies Python syntax highlighting to it. You need the right rules in your CSS file for the coloring to be visible. See the rules that start *py* in ``test.css``.
``{cl}colorize;docs/example_function.txt{cr}`` becomes :
{colorize;docs/example_function.txt}
You can use ``col`` as a shorter alias for ``colorize``.
To use the colorize macro, you need the right definitions in your CSS. Something like : ::
.pysrc {
border: #c0c0ff 2px dotted; padding:10px;
font-weight: normal; background: #e0e0ff; margin: 20px;
padding:10px;
}
.pykeyword {
font-weight: bold;
color: orange;
}
.pystring {
color: green
}
.pycomment {
color: red
}
.pynumber {
color:purple;
}
.pyoperator {
color:purple;
}
.pytext {
color:black;
}
.pyerror {
font-weight: bold;
color: red;
}
Change the color definitions to alter the appearance.
+/- coloring
------------
This is the only example of an advanced macro included. It does the same job as the ``colorize`` macro, but instead of passing it a filename - it works on the text it encloses. This : ::
.. raw:: html
{cl}+coloring{cr}
class coloring:
"""A Macro for coloring chunks of text."""
def open(self, data):
p = color.Parser(data)
p.format(None, None)
src = p.getvalue()
src = src.replace('\n', '
\n')
return src.replace(' ', ' ')
def close(self, *args):
pass
{cl}-coloring{cr}
Becomes :
.. raw:: html
{+coloring}
class coloring:
"""A Macro for coloring chunks of text."""
def open(self, data):
p = color.Parser(data)
p.format(None, None)
src = p.getvalue()
return src.replace('\n', '
\n').replace(' ', ' ')
def close(self, *args):
pass
{-coloring}
small
-----
This macro puts the enclosed text between .... tags. This is a
feature missing from docutils.
``.
You link to it using the HTML - ``Link to Anchor``.
title
-----
This is a shortcut for inserting headlines. You pass in the text and the size
(which defaults to an ``h3`` headline).
{cl}title;A Headline{cr} becomes : ::
.. raw:: html
{title;A Headline}
{cl}title;Another Headline;1{cr} becomes : ::
.. raw:: html
{title;Another Headline;1}
Including Macros in ReST Pages
==============================
Macros are just treated as ordinary text by docutils_. That means that they
must fit into the reST syntax. If they don't, then you should escape them using
the raw role or the raw directive.
The Raw Role
------------
The raw role can only be used if it is declared at the start of the document.
You must include the following declaration : ::
.. role:: raw-html(raw)
:format: html
From then on you can pass anything through docutils untouched, like this :
``:raw-html:`{cl}small;Something to be made small{cr}```
In the above example it's not very useful. However, macros return HTML. If you
tried to include HTML in your macro - docutils would escape the *<* tags, and
they would be included as text (or break your macro).
So ``{cl}small;Something to be made small{cr}`` *doesn't work* in reST
documents. Try it if you don't believe me. {sm;:-)}
Instead you can do ``:raw-html:`{cl}small;Something to be made small{cr}```,
which does work.
The Raw Directive
-----------------
If you use the `Advanced Macros`_ then you almost certainly want to include a
passage of text to transform it. That transformation will be done *after*
docutils has seen the text. Usually you will want the *macro* to transform your
text verbatim - and have docutils leave it alone. In this case you need to use
the raw directive.
The classic example of this is the Python source coloring macro : ::
.. raw:: html
{cl}+coloring{cr}
section = sections['section-name']
pages = section['pages']
{cl}-coloring{cr}
If you didn't include the raw directive, docutils would do strange things to the
chunk of code - and the macro wouldn't be able to process it.
Paragraphs
----------
Docutils treats macros as ordinary text. That means if it comes across one on
its own it will treat it as a paragraph. That may not be what you intend.
For example - the {cl}title{cr} macro is used to create headlines. If you put
this in your document on it's own, then docutils will encase it in paragraph
tags. The following : ::
{cl}title;Some Heading{cr}
Produces this HTML : ::
Some Heading
This is neither valid, nor what you intended. The way round it, is to use the
raw directive : ::
.. raw:: html
{cl}title;Some Heading{cr}
namespace and uservalues
========================
The ``macros.py`` file that comes with rest2web has a ``set_uservalues`` function. This is used to set the global values ``namespace`` and ``uservalues``.
That means that you can use access the uservalues and namespace for each page from your macros.
Credits
=======
The example macro file uses various Python modules. These are included in the ``modules`` directory that comes with the **rest2web** distribution. If you don't use the macros, you don't need this folder.
The various modules come from the following people and places :
* A lot of the text in this page comes from the document `Firedrop macros`_ by Hans Nowak
* The macros module [#]_ comes from Firedrop_ by Hans Nowak
* The smilies use *smiley.py* by `Mark Andrews`_.
* *smiley.py* depends on *path.py* by `Jason Orendorff`_.
* *smiley.py* uses smiley sets that follow the phpbb_ convention, you can download alternative sets from stylesdb_.
* The smiley set included with **rest2web** is by a gentleman called Spider_.
* The colorize macro uses a module called *colorize.py*. It originated as part of the MoinMoin_ project. The version we use is the one from the `Python Cookbook`_.
----------
Footnotes
=========
.. [#] And the filename must only consist of alphanumerics and the underscore character. It should start with a letter, not a number, and is case sensitive, got all that ? {sm;:?:}
.. [#] Assuming the page is in {acro;reST} format of course.
.. [#] *textmacros.py* - in the rest2web folder.
.. _rest2web config file: config_file.html
.. _Jason Orendorff: http://www.jorendorff.com/articles/python/path
.. _Mark Andrews: http://www.la-la.com
.. _phpbb: http://www.phpbb.com/
.. _stylesdb: http://www.stylesdb.com/smilies_styles.html
.. _Spider: http://web.spidercode.de/smilies
.. _smilies page: reference/smilies.html
.. _Firedrop Macros: http://zephyrfalcon.org/labs/firedrop_macros.html
.. _Firedrop: http://zephyrfalcon.org/labs/
.. _moinmoin: http://moinmoin.wikiwikiweb.de
.. _Python Cookbook: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52298
.. _docutils: http://docutils.sourceforge.net
rest2web-0.5.2~alpha+svn-r248.orig/docs/translation/ 0000700 0001750 0001750 00000000000 10644674642 022010 5 ustar madduck madduck rest2web-0.5.2~alpha+svn-r248.orig/docs/translation/de/ 0000700 0001750 0001750 00000000000 10644674642 022400 5 ustar madduck madduck rest2web-0.5.2~alpha+svn-r248.orig/docs/translation/de/index.txt 0000600 0001750 0001750 00000000403 10311246051 024223 0 ustar madduck madduck restindex
crumb: German Index
format: html
page-title: The German Index
/restindex
uservalues
body: ../template/_index.txt
greeting: Guten Tag - Wilkommen
para1: Something in German
index_title: Index Title in German
/uservalues
rest2web-0.5.2~alpha+svn-r248.orig/docs/translation/de/page.txt 0000600 0001750 0001750 00000000214 10311246051 024030 0 ustar madduck madduck restindex
crumb: German Rest
/restindex
uservalues
body: ../template/page.txt
para1: Having a **reST** in German.
/uservalues
rest2web-0.5.2~alpha+svn-r248.orig/docs/translation/en/ 0000700 0001750 0001750 00000000000 10644674642 022412 5 ustar madduck madduck rest2web-0.5.2~alpha+svn-r248.orig/docs/translation/en/index.txt 0000600 0001750 0001750 00000000433 10311246051 024240 0 ustar madduck madduck restindex
crumb: English Index
format: html
page-title: The English Index
/restindex
uservalues
body: ../template/_index.txt
greeting: Hello and Welcome
para1: We are here... maybe we wish we weren't.
index_title: Index Title in English
/uservalues
rest2web-0.5.2~alpha+svn-r248.orig/docs/translation/en/page.txt 0000600 0001750 0001750 00000000216 10311246051 024044 0 ustar madduck madduck restindex
crumb: English Rest
/restindex
uservalues
body: ../template/page.txt
para1: Having a **reST** in English.
/uservalues
rest2web-0.5.2~alpha+svn-r248.orig/docs/translation/index.txt 0000600 0001750 0001750 00000001200 10335344157 023643 0 ustar madduck madduck restindex
page-title: The Translation Index
crumb: Translation
link-title: Translation Example
format: html
page-description:
A very basic example of a website with multiple translations.
/description
/restindex
rest2web-0.5.2~alpha+svn-r248.orig/docs/translation/template/ 0000700 0001750 0001750 00000000000 10644674642 023623 5 ustar madduck madduck rest2web-0.5.2~alpha+svn-r248.orig/docs/translation/template/_index.txt 0000600 0001750 0001750 00000001403 10425411107 025610 0 ustar madduck madduck
<* greeting *>
<* index_title *>
<#
import urllib
pageblock = '''\
- %s
%s
'''
pages = sections[None]['pages'] # everything is in the
# default section in this index
subsections = []
for page in pages:
print pageblock % (page['target'], page['link-title'], page['page-description'])
#>
<% para1 %>
<% Processor.dir_as_list %> rest2web-0.5.2~alpha+svn-r248.orig/docs/translation/template/page.txt 0000600 0001750 0001750 00000000013 10425411107 025252 0 ustar madduck madduck <* para1 *> rest2web-0.5.2~alpha+svn-r248.orig/docs/translation/fr/ 0000700 0001750 0001750 00000000000 10644674642 022417 5 ustar madduck madduck rest2web-0.5.2~alpha+svn-r248.orig/docs/translation/fr/index.txt 0000600 0001750 0001750 00000000376 10311246051 024253 0 ustar madduck madduck restindex
crumb: French Index
format: html
page-title: The French Index
/restindex
uservalues
body: ../template/_index.txt
greeting: Bonjour et Bievenue
para1: Nous sommes ici.
index_title: Index Title in French
/uservalues
rest2web-0.5.2~alpha+svn-r248.orig/docs/translation/fr/page.txt 0000600 0001750 0001750 00000000214 10311246051 024047 0 ustar madduck madduck restindex
crumb: French Rest
/restindex
uservalues
body: ../template/page.txt
para1: Having a **reST** in French.
/uservalues
rest2web-0.5.2~alpha+svn-r248.orig/docs/template.txt 0000600 0001750 0001750 00000012720 10516441366 022023 0 ustar madduck madduck
<% title %>
<#
if 'gallery' in plugins:
print ''
#>
<# print_crumbs(breadcrumbs) #>

-
Index Page
<#
minibar(sections, displayval="crumb", liststart='', listend='',
intro='- Pages
',
subintro='- Sub Sections
')
#>
rest2web-0.5.2~alpha+svn-r248.orig/docs/tutorial.txt 0000600 0001750 0001750 00000057677 10464644405 022100 0 ustar madduck madduck restindex
tags: tutorial, introduction, beginners, site builder, website, basics, guide, basic guide
crumb: Tutorial
link-title: Tutorial
page-description:
An tutorial showing how to use **rest2web** to create a simple website.
/description
/restindex
==========================
Introduction to rest2web
==========================
----------------------------------
Creating a Website With rest2web
----------------------------------
.. contents:: rest2web Tutorial
Introduction
============
{emo;paper} Creating a website with **rest2web** is easy. Looking at the
bewildering array of options in the restindex_ can make it seem very complex.
In fact, you can build a simple website in a few minutues - using only a few
features. You can then add things as you need them. If you look in the source
files for the `example site`_ [#]_, you can see that most of the pages have
only two or three items in the ``restindex``.
This tutorial explains the basics of creating a website - and shows you an
example.
.. note::
This tutorial assumes you are basically familiar with {acro;HTML} and
creating/editing text files.
A Basic Site
============
The principles of **rest2web** are simple. A rest2web site has at least the
following elements :
1) `Config file`_ - this tells rest2web where to read files from (the start
directory), and where to put the files it creates (the target directory).
2) template.txt_ - This is the {acro;HTML} template for your website.
3) **index.txt** - This is the source file (content) for your main index page.
Each directory *must* have this file.
4) Optionally other text files for your other pages.
5) Subdirectories with more content.
We'll briefly look at these things, and then create a basic site.
The Config File
---------------
**rest2web** goes through all the files in your source directory (and
subdirectories). It builds the contents, indexes, etc - puts them into the
templates, and then saves the results in the target directory.
So at the minimum, rest2web needs to know the source directory and target
directory. It gets these from the config file.
You tell **rest2web** the name of your config file at the command line : ::
python r2w.py config_file.ini
If you *don't* specify a config file, then rest2web will look for one called
``r2w.ini`` in the current directory. On Windoze, this means you can just
double click on *r2w.py* and it will do it's magic.
There are several other options in the config file- but the source and target
directories are the two options you must specify for each site.
Look at the example ``r2w.ini`` that comes with rest2web, or the
`Config file`_ page, for full details.
The Template File
-----------------
The template file is the HTML framework for your website. Special values that
you put in your template determine where the content, title, and navigation
elements go.
The name ``template.txt`` is just the default filename. You can change the name
and location of this file through the ``restindex``. You can also use more than
one template in your website.
If you are only using one template in your website (as many will) then you can
do this by just having one file (``template.txt``) in the top level of your
source directory.
The Index File
--------------
Every *directory* must have a file called ``index.txt`` in it - or rest2web
will ignore it. {sm;:-)}
*Every* rest2web page *must* start with a restindex_. This is a set of options
that tells rest2web how to build the page.
The index page is important. Some of the options you set in the ``restindex``
of your index page apply to the whole directory.
The index page also has some extra information available to it (about the other
pages in the directory). This allows you to have in your index page, links to
each of the pages in that directory along with descriptions (including any
subdirectories).
Other Pages
-----------
In order to be a **rest2web** source file, a file must be a text file
(``.txt``) and start with a ``restindex``. There are over twenty different
options you can set in the restindex - but you will probably only need to use a
couple on most pages. Some of these options are only relevant to index pages
anyway.
A restindex looks like this : ::
restindex
format: html
page-title: This is the Page Title
crumb: Short Title
page-description:
This is a description of the page.
It can be more than one line long.
/description
/restindex
Immediately after the restindex comes the page contents. If this is in ReST_
format then docutils_ will be used to turn it into html.
The page contents is then put into the template - and any special values are
converted. This allows for things like sidebars and navigation trails [#]_ to
be added to your site.
After all the files in a directory have been processed, rest2web moves on and
processes any subdirectories.
Subdirectories
--------------
Subdirectories will also get rendered. Each subdirectory should have it's own
index page. This index page can be automatically linked to in the index page of
their parent directory.
Creating an Example Site
========================
{acro;Ok;What Does Ok Stand For ?} - so let's see how this works in practise.
{sm;:biggrin:}
.. note::
The simple site we create here can be seen in the tutorial_site_ [#]_ folder
of the docs.
The first thing we'll do is create a config file.
Config File
-----------
If you were to create an example site from scratch you would need to create a
directory for it all to go in. In this tutorial our source directory will be
``docs/tutorial_site``, and the html will be put in ``docs_html/tutorial_site``.
In our example we won't use any macros, so you can create a text file called
``r2w.ini`` with the following values : ::
# these values are all left at the default
psyco = True
pause = False
log_file = 'log.txt'
DEBUG = False
compare_directory = ''
# these values we have edited for our site
start_directory = 'docs/tutorial_site'
target_directory = 'docs_html/tutorial_site'
macros = ''
.. raw:: html
{small;This config file is actually called 'tutorial_site.ini' in the distribution.}
HTML Template
-------------
.. sidebar:: Embedded Code
Special values are enclosed in either ``<% ... %>`` tags (for single
values) or ``<# ... #>`` tags for multiple statements.
Multiple statements are actually Python_ code. You can embed chunks of code
into your pages and templates. This allows *unlimited expressiveness* in
how dynamic you make your pages and templates.
If you wanted you could use your template to fetch information form the web
and include it in your pages. You can do anything that Python can do.
The HTML template has the basic framework of our website. We put special values
into the template - so that **rest2web** knows where to put things like the
page title, the page content, etc.
A website can use as many different templates as you want - for different parts
of the website, or even a different one for each page. {sm;:-o} Most websites
will only need a single template though.
The full `doc page for templating`_ gives you a list of all the special values
we can use in our templates. (We can also use these in our page content). Last
count there were about twenty five of these values. Like the restindex, we can
create our basic site by only using a few of these.
We use these values in two different ways. For single values we surround the
values in ``<% ... %>`` tags. For chunks of code, we use ``<# ... #>``.
We only need to use special values for things that are different in each page.
We save the template as ``template.txt`` and put it in the root directory of
our site. Because it doesn't start with a restindex, rest2web won't attempt to
process it as a page.
Here's our simple HTML template : ::
<% title %>
<% body %>
Return to Top
Page last modified <% modtime %>.
It's actually {acro;XHTML}, so it starts with the proper DOCTYPE [#]_. The rest
is a pretty simple document, with no real content.
.. note::
We use two stylesheets in the template.
One is ``test.css``, which contains the styles for our page [#]_.
The other is ``rest.css``, which has the styles for docutils generates HTML.
You can see the special values in the template. Let's look at the ones we have
used :
Special Values
~~~~~~~~~~~~~~
#. ``<% title %>``
#. ``<% final_encoding %>``
#. ``<% path_to_root %>``
#. ``<# print_crumbs(breadcrumbs) #>``
#. ``<% body %>``
#. ``<% modtime %>``
title
#####
``<% title %>`` will be replaced with the title for each page. For index pages,
and pages in html format, you must specify the title in the restindex.
For pages in ``reST`` format, your top heading becomes the page title.
final_encoding
##############
``<% final_encoding %>`` is the character encoding used for the page. This can
vary from page to page *or* you can set it for the whole site in your main
page.
In order to be valid html you **must** specify an encoding. If you don't know
about encodings then **rest2web** will attempt to work them all out for you -
and do the right thing. By default it will output the page using the same
encoding as the content.
To learn more about how rest2web handles encodings - read the `Text Encodings`_
page.
path_to_root
############
``<% path_to_root %>`` is the path from the page being created to the root
directory (always ending in a ``/`` unless the page is in the root directory).
You might be used to specifying the location of stylesheets using the form
``/stylesheets/styles.css``. This gives the absolute location of the stylesheet -
but means that the file cannot be viewed correctly from the filesystem.
Using *path_to_root* for stylesheets and images (etc) puts the correct relative
path in - meaning that the site can be viewed from the filesystem.
print_crumbs
############
You can see that ``<# print_crumbs(breadcrumbs) #>`` uses the second style of
tags - ``<# ... #>``. That's because it's a function call not a value - and we
use it's output.
``print_crumbs`` is one of the built in functions_. It prints the navigation
trails that are known by the weird name *breadcrumbs*. Tradition puts them at
the top of the page.
print_crumbs prints them as a list of items - so we put the function call
between unordered list tags `` ...
``. There are some {acro;css} rules
that cause them to be dispayed properly.
body
####
``<% body %>`` is the contents of the page. {sm;:-p}
modtime
#######
``<% modtime %>`` is the date (and time) that the source file was last modified.
The Index Page
--------------
When you run **rest2web** it scans the start directory, processing every text
file with a restindex. From each text file it creates a corresponding output
HTML file. By default, the filename of the output file will be the same as the
source file - except ending in ``.html`` instead of ``.txt``. Having completed
all the files in a directory, rest2web then does any subdirectories.
.. caution::
**rest2web** will overwrite files in the target directory, creating all
necessary subdirectories.
So by default ``index.txt`` in the source directory becomes ``index.html`` in
the target directory. If you don't want your index page to be called
'index.html' then there are a couple of ways you can affect that. You can
either use the ``target`` keyword (in the restindex of course) to specify an
explicit target name for the target file, or you can use the ``index-file``
keyword. 'index-file' tells rest2web that this file isn't the real index page -
but another one is instead. rest2web will then read that file and treat it as
the index page for the directory. Whichever you choose *every* directory must
have a file called ``index.txt``, with a restindex, or rest2web will ignore
that directory.
Our file ``index.txt`` starts with a restindex. We're going to make it as
simple as possible.
Our index page is going to be a short introduction to the site, and have links
to all the other pages, with descriptions of them. For our main index page
we'll use HTML rather than ReST : ::
restindex
crumb: Home
format: html
page-title: rest2web Tutorial Website
/restindex
rest2web Tutorial Website
An Example Index Page
<#
print_details(default_section)
#>
This is the index for the rest2web Tutorial
website. It's not got much on it - other than this paragraph and
links to our other pages.
The page is divided into two parts - the restindex, and the content.
The restindex
~~~~~~~~~~~~~
Every **rest2web** source page starts with a restindex. The restindex has
sensible defaults, so we only need to include values that we're changing. For
details of *all* the restindex options, read the restindex_ page.
.. sidebar:: Empty restindex
It's entirely possible that you might be happy with *all* the default
values in a restindex.
In this case you still need to start your page with an empty restindex : ::
restindex
/restindex
We are using navigation trails in our template. That means each page should
have a ``crumb``. Because this is the index page, we use the *traditional*
value **Home**.
Our page is html. The default format is html - this is **rest2web** after all
{sm;:-)} - so we need include the ``format: html`` argument.
Because the page is html (and also because it is an index page [#]_) it needs a
``page-title``.
And that's all we need in our restindex. Wasn't that easy. {sm;:-p}
We are relying on lots of default values - we don't define any sections for our
directory, we're ging to let rest2web handle all our encodings, and so on. The
restindex_ page will tell you all the default values for the restindex options.
The Content
~~~~~~~~~~~
The content is nice and standard html *except*, we can see one of our special
values turning up again. This time it's a call to one of the
`standard functions`_ - ``print_details``.
**print_details** displays a nice list of links to all the pages in a
*section*. Your index page can be divided up into several *sections*. This
enables you to have one directory with pages on several different topics. Each
page then has a declaration in the restindex as to which section it is in.
(The ``section`` keyword in the restindex). You have to declare your list of
sections in the index page.
As you can see we **haven't** done that {sm;:lol:} - so all the pages in our
directory will go into the default section.
You access a lot of data about *all* the pages in a directory using the
``sections`` special value. You can read about that in the templating_ page
(along with all the other special values you can include in your pages).
You access information about the default section through ``sections[None]``
*or* ``default_section``. ``default_section`` is just an easier way to access
the same information.
.. note::
``sections`` is a Python_ object called a dictionary. You access members
through their keys. In the ``sections`` data structure each member is a
section. Each section is also a dictionary. Each section includes a list of
all the pages in that section.
.. raw:: html
{+coloring}
section = sections['section-name']
pages = section['pages']
{-coloring}
Every directory has all the sections you define in the index page *and* the
default section. This has the key ``None``. You can also access the default
section through the special value ``default_section``.
You can use dictionaries to build quite complex data structures. You can
learn more about dictionaries in the `Python Tutorial`_ or in the Python
docs about `Mapping Types`_.
**print_details** takes an individual section to display all the pages in a
section. Any subdirectories in a directory can also be displayed as
'sub-sections'. Because all our pages will be in the default directory we
call print_details with the default section -
``<# print_details(default_section) #>``.
Other Pages
-----------
We've created our main page. The main page acts as an index to all the pages in
the directory.
So we need some content. Because this is **rest2web**, we'll create the page in
{acro;reST} format. ::
restindex
crumb: A Page
link-title: An Example Page
page-description:
This description is for the index page.
You can use **reST** markup if you want.
/description
/restindex
==============
A ReST Title
==============
--------------
The Subtitle
--------------
..
This is a comment. To use the 'raw-role', we have to define it
*first*.
.. role:: raw-html(raw)
:format: html
This page is written in ReStructured Text markup. That's
why it looks like *plain text*.
This page lives at :raw-html:`<% pagepath %>` [#]_. This tutorial
isn't a tutorial on ReStructuredText though. If you're looking for one, you
might be better off with the `docutils documentation`_.
.. [#] The file path is dynamically inserted by rest2web.
.. _docutils documentation: http://docutils.sourceforge.net
The restindex for this page is a bit different to the one for the index page.
ReST is the default markup, so we don't need to declare it explicitly in the
restindex. Additionally, docutils will automatically generate a page title for
us from the top level heading.
If we don't specify a crumb, the page title will be used [#]_. This is too
long, so we specify a short one.
We want this page to appear in the index page. It's entry will appear as a link
with a brief description. If we don't specify a link title, the page title will
be used. Often this will be ok - but here we've specified a different one [#]_.
So the text used for the link is the ``link-title`` value and the text used for
the description is the ``page-description`` value. This is a multi-line value
and can contain ReST markup.
reST Content
~~~~~~~~~~~~
.. sidebar:: Embedded Code With reST
If you want to include multi-line chunks in rest documents, then you can
use the raw directive : ::
.. raw:: html
<#
big = '%s'
print big % 'Hello World'
#>
Unlike the raw role, this doesn't need to be declared before you use it.
The content is straightforward reStructuredText. If you want an introduction
to ReST, `A ReStructuredText Primer`_ is a good place to start.
Notice the use of the raw role : ``:raw-html:`<% pagepath %>```. This
allows us to insert **rest2web** special values into the page (without docutils
escaping the *<* symbols). You can only use the raw role if you declare it
first.
Subdirectories
--------------
Directories can have subdirectories. These appear in the index page as
'Subsections'.
The subdirectory must have an 'index.txt' file. The 'link-title' and
'page-description' specified here are what appear in the index page of the
directory above.
We'll create a subdirectory - imaginatively called 'subdirectory'. We'll create
the following file, and save it as 'index.txt' : ::
restindex
crumb: Subdirectory
target: subdirectory.html
page-description:
A subdirectory - with pages of it's own.
/description
/restindex
=========================
Subdirectory Index Page
=========================
--------------
The Subtitle
--------------
.. role:: raw-html(raw)
:format: html
.. raw:: html
<#
if not default_section['pages']:
print 'No Pages Yet
'
else:
print_details(default_section)
#>
.. class:: intro
This page lives at :raw-html:`<% pagepath %>`. The ``class``
directive applies a style to this paragraph.
I didn't want this page to be called ``index.html``. I *could* have used the
``index-file`` option to specify another file as being the index page. Instead
I stuck with keeping the source file as *index.txt*, but specifying an
alternative target filename. That's the ``target`` keyword.
This page is also in rest format. This means that we don't need to specify a
format in the restindex.
The content prints an index using ``print_details`` - but *only* if there are
any pages. It checks first (``if not default_section['pages']:``), and if there
aren't any it prints the **No Pages Yet** heading.
It also uses the ``class`` directive to apply a class to the paragraph - so
that it can be styled with CSS.
More Advanced Topics
====================
In this tutorial we haven't used any macros_, or sidebars. Macros allow you to
easily insert smilies, python source coloring, and lots more into your pages.
The functions to create sidebars are described in the `standard functions`_
page. There are many options in the restindex that we haven't explored here -
and also lots of special values that we haven't looked at.
Despite what it doesn't show, this tutorial does give you a good overview as to
how to create a website using **rest2web**. For further examples you can look
at the source files in the ``docs`` folder. These use most of the features of
**rest2web** - and you can see the results in the finished documentation.
----------
Footnotes
=========
.. [#] In the docs folder of the distribution.
.. [#] For some bizarre reason known as *breadcrumbs*.
.. [#] The only difference is that the main index page has the ``include: No``
option set - so that it doesn't go into the main index. {sm;:-p}
.. [#] Purists might note that I *haven't* included the {acro;xml} declaration.
This is because it puts {acro;IE} into quirks mode.
.. [#] I've just re-used the main stylesheet for the rest2web docs. This is
easier for me - but it means there are a few extra values in there.
.. [#] Index pages need a ``page-title`` in the restindex. This is so that **rest2web**
doesn't have to build the page (for reST content) when examining the
index pages of it's subdirectories.
.. [#] For index pages the filename is used as the default crumb.
.. [#] The link title can also be used by sidebars.
.. _A ReStructuredText Primer: http://docutils.sourceforge.net/user/rst/quickstart.html
.. _macros page: macros.html
.. _restindex: restindex.html
.. _config file: config_file.html
.. _macros: macros.html
.. _tutorial_site:
.. _example site: tutorial_site/index.html
.. _doc page for templating:
.. _template.txt:
.. _templating: templating.html
.. _text encodings: reference/encodings.html
.. _standard functions:
.. _functions: functions.html
.. _python tutorial: http://docs.python.org/tut/node7.html#SECTION007500000000000000000
.. _Mapping Types: http://docs.python.org/lib/typesmapping.html
.. _docutils:
.. _rest: http://docutils.sourceforge.net
.. _Python: http://www.python.org
rest2web-0.5.2~alpha+svn-r248.orig/docs/reference/ 0000700 0001750 0001750 00000000000 10644674642 021410 5 ustar madduck madduck rest2web-0.5.2~alpha+svn-r248.orig/docs/reference/todo.txt 0000600 0001750 0001750 00000021371 10514020175 023102 0 ustar madduck madduck restindex
crumb: TODO/ISSUES
page-description:
The TODO and ISSUES list for **rest2web**.
/description
/restindex
=============
TODO/ISSUES
=============
TODO
====
This is the **TODO** and **Wish List** for `rest2web`_. It includes things that
need to be done as well as things that are only included because they could be
done.
They are not listed in any order of priority or even desirability.
Obviously bug-fixes are the highest priority. If you have any suggestions for
this list, or opinions as to the priority of items on this list, or wish to
implement any of the ideas yourself, then please get in touch.
Some of the items have (?) at the end of them. This means we are not sure if it
desirable to implement the suggestion at all. There is a constant tension
between adding more flexibility (extra options) and keeping things simple. Your
input is wanted - if it matters to you whether we do this or not then let us
know.
For bug reports or feature requests you can use the `rest2web Mailing List`_.
* Add an extra level of verbosity, errors only.
* Remove the 'unicode' encoding option - this defaults to an output encoding
of template encoding; which is arbitrary.
* Allow overriding of default index and template used with 'force mode'. (And
provide a simpler default template.)
* ``<% path_to_root %>`` doesn't work in gallery files, need a workaround in
plugin if possible. Could sllow path_to_root in the uservalue 'body', or
some other mechanism.
* Better error messages from rendering templates - proper line numbers.
* CSS error in new template for long page titles (squashed in minibar).
* Implement next and previous. (By giving pages access to the section order lists.)
* Add rest2web version to the namespace.
* Provide a better default title for the index pages (using
``self._top_level_name``).
* Handle encodings for dicts (subsections) and list values, when supplied as
uservalues in config file.
* Add a 'guess' option (the default) for encodings supplied in a config file ?
* Ability to set the lineendings of the output. ('``\\n``' or '``\\r\\n``')
* Build a more up to date executable.
* Add test examples of the new ``include`` functions.
* Allow source and target directories to be provided as command line options.
* A standard function to automatically copy (and link to) the text source for
a page.
* Add a 'Generated by rest2web' comment into the HTML of each page.
* Duplicate entries in ``section_pages`` gives an unhelpful error message.
* Get plugins and macro support complete in the executable version.
* The example translation file, links to the same pages in the other languages.
Standard function to do this, or restindex keyword ?
* Allow setting of docutils options in the config file.
* Render macros in section descriptions.
* Allow easy adding of user functions ? (like macros, currently doable through
normal imports in templates)
* markup format - could allow additional markups, like sextile and textile.
* template engines - support for other templating engines like Cheetah
* Better support for multiline and nested macros.
* description format - we might want to allow different markups for the
description. (Currently reST *only* - could allow html easily)
* can we extract the page description from the reST format ? (as meta
information)
* Use filename as default page title/link title/crumb ? (where none is supplied)
* Build a plugin to use the tags for navigation - so a site needn't just be
represented as a tree. Also build a data structure (probably XML) that can be
used by a CGI script for dynamically searching for pages with tag
combinations.
* Should we allow comments inline with values in the restindex ? (or even
multiline comments ?) - this would require a better parser.
* Should be a standard function to generate a table of links to the sections in
a page, for use in the index page - which could have several pages in each
section. See the example table in the test site.
* Should 'format' or 'encoding' be a default value, when specified in the index
file ? (any others ?)
* At the moment you can only have sections you have declared in your restindex
'sectionlist'. Should you be able to assign pages to sections without having
to declare them ? FIXME: check this is true
* Develop the index generation stuff so that it can generate 'blue arrows'
style Python documentation, including up. (Difficult without support in docutils)
* Contents for a section, or for the whole site.
* Single index page for the whole site (sitemap plus indexes from within pages).
* Unittests or doctests. (Probably requires a lot of refactoring to make
rest2web testable.)
* A way of adding a set of standard links to all reST pages.
* Implement more of the config file values as command line options.
* Automatic FTP facility.
* Integrate with Tidy for checking of HTML.
* [madduck] More flexible parsing for restindex. Ideally, it should be
possible to have the restindex anywhere within the document, including
comments. Also, it should be completely removed from the document after
processing.
ISSUES
======
Following is a list of 'unresolved issues' with **rest2web**. They aren't
necessarily all bugs, so they may not be fixed. It's probably worth being aware
of them.
* Unfortunately, the ``guess_encoding`` function can recognise ``cp1252`` [#]_
as ``ISO-8859``. In this case docutils can choke on some of the characters.
We probably have to special case the ``cp1252`` and ``ISO-8859`` encodings -
but I wonder if this problem applies to other encodings ?
* If you set ``include: No`` for an index page, it works fine *except* when you
are viewing that index page or subpages. In these cases it *is* included.
* If no crumb is provided, the page-title is supposed to be used instead. Each
page needs it's index page in it's list of crumbs (as the 'crumb before' it).
In order to work out the title for the index page, we would need to render the
body of the page. But to render the body of an index page, you need to render
all the other pages *first*. This means **index pages need crumbs**. Either
that or you can supply an explicit ``page-title`` value !
* You probably can't set a target that is outside the current directory tree.
(test !) Allow for a way of specifying that the target is an absolute URL (if
build is 'No')
* It would be nice for every page to have access to the whole structure of the
site [#]_. This would allow a sidebar to have links to every page in every
section. The only way of doing this is to generate the site in two passes.
First pass create the structure. Second pass, render the pages with the pages
having access to the index structure. This means parsing the restindex - which
also extracts page contents. Unless we are going to parse the restindex twice
we would end up with the entire contents in memory. Is this feasible ?
(or worthwhile - would anyone use it ?) XXXX Note that because of the data
structures we create - it's likely that *currently* the whole site is being
kept in memory *anyway*.
* Currently a '.txt' file without a restindex won't be built. It's *possible*
that *all* the defaults are what you want. Should we let a file without a
restindex be processed ? (That means if you don't want a text file to be
processed you must give it a restindex and set build and include to ``No`` -
maybe make it an option ?).
* It would be nice to make `Firedrop `_
a graphical frontend to **rest2web**. It would need to be able to handle
trees of pages, instead of a list, and effectively have a 'build.ini' file
per page (the restindex) rather than for the whole site.
* For a page that has 'include' set to 'No', the indexpage value is ``None``.
This is because the current page doesn't have an entry in the indextree
structure. This could require some care if you use 'thispage' in your
template. Is their some other sensible value it can have ? You can still use
indextree without problem.
* I'm not sure if filename encodings are an issue or not. I don't always decode
filenames - so where we are comparing them from the filesystem etc. it's *possible*
we'll have problems.
* Sidebars contain links to pages in sections above. This means that changing one
page can affect other pages - so when you change something we have to rebuild
the whole site, not just the changed part.
----------
Footnotes
=========
.. [#] The default windows encoding.
.. [#] Currently through indextree, a site has access to the whole structure
*above* the current page - but not the *whole* structure.
.. _rest2web: http://www.voidspace.org.uk/python/rest2web
.. _rest2web Mailing List: http://lists.sourceforge.net/lists/listinfo/rest2web-develop
rest2web-0.5.2~alpha+svn-r248.orig/docs/reference/uservalues.txt 0000600 0001750 0001750 00000023337 10513540211 024334 0 ustar madduck madduck restindex
crumb: uservalues
page-description:
A description of the uservalues system. This can be used to communicate
with plugins, or for providing alternative translations of sites.
/description
/restindex
==================
The User Values
==================
---------------------------------
Extra Values in Your Templates
---------------------------------
.. contents::
Introduction
=============
**rest2web** generates pages by inserting special values into your web page
templates. These values include the body of the page, the title and so on. You can
see from the templates_ page, all the values that you can use in your templates.
*uservalues* are a way of inserting extra values into your template. As you
might guess, you specify the names and values.
One obvious use of this is to provide several different translations [#]_ of
your website.
The uservalues can be in HTML *or* in ReST format. They use two slightly
different syntaxes so that rest2web knows whether to render the uservalue into
HTML or not.
Uservalues can be put into your pages (via your content or your templates),
using the `templating system <../templating.html>`_.
uservalues
==========
*uservalues* can be specified in three ways :
1) In each page. These *uservalues* are local to the page.
2) At the `command line <../command_line.html>`_.
3) In the `config file <../config_file.html>`_.
Uservalues are effectively new variables (or names) you can use in your templates.
For example, if you create a uservalue 'site_wide_title', you can use it in your
templates like this :
``<% site_wide_title %>``
or :
``<# print site_wide_title #>``
For global values (available to every page), the most convenient thing to do is
to define them in your config file.
.. note::
Changes to uservalues (in embedded code, through ``{lt}$ ... $>`` tags)
are *not* propagated to the main namespace.
uservalues in Pages
-------------------
*uservalues* can be specified in each page in a similar way to the restindex.
uservalues are specified *immediately after* the restindex. : ::
restindex
crumb: A Page
/restindex
uservalues
value1: Some Value
heading: A Heading
long_value: """
A multi line value
which spreads across
several lines.
"""
another_long_value:"""
This one
has a big indent
in front of it ! """
/uservalues
An addition to the restindex syntax, is that multiline values use triple quotes.
.. caution::
Indentation is not removed from multi line values. The text between the
triple quotes is inserted literally wherever you use the value. You can use
single or double quote marks.
There is one special value, the ``body`` value discussed below.
uservalues at the Command Line
------------------------------
It is also possible to pass uservalues to **rest2web** at the command line.
These will be available in *every* page.
uservalues in the config file
-----------------------------
You can specify uservalues in the ``uservalues`` section of the config file.
These are also available in every page.
To do this, you need to add something like the following to the bottom of
your site config (``r2w.ini``) file : ::
[uservalues]
site_wide_title = 'Some Title'
site_wide_subtitle = 'Some Subtitle'
Reserved Names
--------------
You can't use any name that shadows a name already used by the templating
system. This means that the following names are all reserved. Trying to use
them will cause a ``SyntaxError``. :
.. raw:: html
{+coloring}
reserved_names = [
'title', 'breadcrumbs', 'sections', 'pagename', 'pagepath',
'encoding', 'output_encoding', 'final_encoding', 'path_to_root',
'sectionlist', 'rest_dict', 'doc', 'stdout', 'modified', 'modtime',
'template_file', 'template_encoding', 'indexpage', 'indextree',
'thispage', 'sidebar', 'minibar', 'print_crumbs', 'Processor', 'tags',
'default_section', 'modtime', 'modtimeiso'
]
{-coloring}
.. note::
See that ``title`` is a reserved name. If you want to set the page title, you should use the ``page-title`` keyword in your *restindex*.
The body Value
=================
The *body* value is special. This lets you specify a file that is the content for this page. Any content following the uservalues is ignored - and the specified file is used instead.
If that file has template tags that use the uservalues - then they will be substituted when the template is processed.
The file specified can be an absolute path, or a path relative to the page it is bein used in.
For example, say we have the following for our uservalues : ::
uservalues
body: ../templates/a_page.txt
greeting: Howdy
/uservalues
**rest2web** will use the file ``../templates/a_page.txt`` as the body of this page. If it contains a tag that looks like ``<% greeting %>``, then it will be replaced with ``Howdy
`` when the template is processed.
.. warning::
Using the *body* value you separate your content from your file containing the restindex/uservalues. You **must** store them with the *same* encoding.
Translations
--------------
A good example of using the *body* value is for multiple translations of websites. A typical example is where you have several pages of content that you want to mirror in different languages. That is, you want the same pages, with the same structure, just key sections swapping over.
The *body* value lets you keep your page frameworks all in one place. The framework should use the uservalues - and then just have several directories of pages which point to the framework... but have the right values set for the uservalues.
There is an example in the example site - the translation_ pages. See the *source* of these pages for a clear illustration how of how it works.
Now I'll attempt to explain it in words {sm;:razz:}.
Suppose you want three translations for your site. You'll put the english files in a directory called **en**, the French ones in a directory called **fr**, and the German ones in a directory called **de**. The HTML framework of each page is going to be identical in each directory - it's just the viewable words that will be different.
To achieve this we add a fourth directory called templates. It's in here that we are going to put our HTML frameworks. Everywhere we want some text to appear we will put a uservalue placeholder instead.
We have our usual *template.txt* which contains the outline of the page. We'll create a file in the ``template`` directory called ``index_page.txt`` [#]_. It might look something like : ::
<% greeting %>
<% para1 %>
This page body has a placeholder for the headline and the paragraph.
In *index.txt* in your ``en`` folder you would then put : ::
restindex
format: html
crumb: English Index
page-title: English Index
/restindex
uservalues
body: ../templates/index_page.txt
greeting: Hello and Welcome
para1: """This is the body text,
with some HTML in it."""
/uservalues
When rendered, it fetches the ``index_page.txt`` as the body, and inserts the English values into it.
In *index.txt* in your ``fr`` folder you would then put : ::
restindex
format: html
crumb: French Index
page-title: French Index
/restindex
uservalues
body: ../templates/index_page.txt
greeting: Bonjour et Bienvenue
para1: """Du Francais ici,
avec du HTML."""
/uservalues
When rendered, this creates the French page.
You create your basic directory structure in the ``templates`` directory. You mirror this in your other directories; but your files are all basically identical and you only need to edit the uservalues.
With a little trickery in the body or the templates it ought to be simple to include links between pages in one language and the other ones.
The Order of Processing
=======================
There are two ways of inserting values into pages using the template system.
The first way allows you to put *ReST* values into your pages before they are
turned into HTML. The second way puts html into your pages when the template is
processed.
If your pages are in HTML, then the difference doesn't matter.
If your page is in ReST format, then it allows you to have uservalues in ReST;
which then get rendered along with the rest of your page.
For the full details, see the `templating system`_.
It basically boils down to this, the following template tags will be resolved
*before* the ReST is processed :
``{lt}$ ... $>``
``{lt}* ... *>``
and the following template tags will be resolved *after* the ReST is processed
(and so should contain html values) :
``{lt}# ... #>``
``{lt}% ... %>``
Don't forget that in order to put HTML tags inside a ReST document, you will
need to use the raw directive [#]_ : ::
.. raw:: html
{lt}# print 'hello' #>
---------
Footnotes
===========
.. [#] This footnote is just so that the words internationalization (i18n), and localization (l10n) appear somewhere on this page {sm;:-)}.
.. [#] We won't call it *index.txt*, which is a `special file`_ in **rest2web**. The example site uses *_index.txt*.
.. [#] ``<% value %>`` will become ``<% value %>``; which doesn't work {sm;:sad:}. If you do need to do this (by the way) you could also use the raw role.
.. _templates: ../templating.html
.. _docutils: http://docutils.sourceforge.net
.. _special file: ../special_files.html
.. _translation: ../translation/index.html
.. _let me know: fuzzyman@voidspace.org.uk
rest2web-0.5.2~alpha+svn-r248.orig/docs/reference/encodings.txt 0000600 0001750 0001750 00000015645 10414273736 024131 0 ustar madduck madduck restindex
crumb: Encodings
page-description:
How to handle different character encodings in **rest2web**.
/description
/restindex
================
Text Encodings
================
-------------------------
Encodings with rest2web
-------------------------
.. contents::
Fun With Encodings
==================
{emo;dove} **rest2web** handles text encodings in ways that are hopefully sensible and simple.
Whenever you are dealing with text you **should** *know and specify the encoding used* [#]_. If you disagree with me (or haven't a clue what I'm on about), read `The Minimum Every Developer Must Know About Unicode`_, by Joel Spolsky.
**rest2web** allows you to specify what encodings your content is (source files) and what encoding to write the output as. In order to achieve this, **rest2web** is almost entirely ``Unicode`` internally.
If all of this is gobbledygook, then don't worry **rest2web** will guess what encoding your files are, and write them out using the same encoding. If you're not 'encoding aware', this is usually going to be what you want.
Summary
=======
In a nutshell you use **'encoding'** to specify the encoding of a contents, file **'template-encoding'** to specify the encoding of your templates, and **'output-encoding'** to specify the encoding the file should be saved with. 'output-encoding' used in an 'index file' sets the output encoding for all the files in that directory and below.
Input Encodings
===============
As usual, the way we handle encodings is through the restindex_.
The first thing we can specify is the encoding of a page of content. We do this with the ``encoding`` keyword. If this keyword is set for a file [#]_, it is used to read and decode the file. If no encoding is specified, **rest2web** will attempt to guess the encoding. It tries a few standard encodings *and* retrieves information from the *locale* [#]_ about the standard encoding for the system. If the page is successfully decoded then it stores the encoding used [#]_, otherwise an error is raised.
From this point on the page content is stores as Unicode inside **rest2web**.
Whichever encoding was used to decode the page, it is available as the variable ``encoding`` inside the templates.
Template Encodings
==================
In the restindex you can also specify the encoding of the template file. This is the value ``template-encoding``. It is only used if you are also specifying a template file. If you specify a template file without specifying an encoding, our friend ``guess_encoding`` will be used to work out what it is.
This value is available as the variable ``template_encoding``.
Output Encodings
=================
When the page is rendered you can specify what encoding should be used. This is done with the ``output-encoding`` keyword. If you specify an 'output-encoding' in an 'index file' then that encoding will be used for all the files in that directory, and any sub-directories. That means you can specify it once, in your top level index file, and have it apply to the whole site.
The encoding you specify applies to *all values passed to the template*. This means the variables ``body``, ``title``, ``crumb``, ``sectionlist``, etc.
As well as the standard Python encodings, there are a couple of special values that ``output-encoding`` can have. These are ``Unicode`` and ``none``.
If you specify a value of **none** for 'output-encoding', then all string are re-encoded using the original encoding.
If you specify a value of **Unicode** for 'output-encoding' then strings are *not encoded*, but are passed to the template as Unicode strings. Your template will also be decoded to Unicode. The output will be re-encoded using the 'template-encoding', but will be processed in the template as Unicode.
The value for 'output-encoding' is available in your template as the variable ``output_encoding``. Because of the special values of 'output-encdoing' there is an additional variable called ``final_encoding``. ``final_encoding`` contains the actual encoding used to encode the strings. If the value of ``output_encoding`` was **none**, then it will contain the original encoding. If the value of ``output_encoding`` was **unicode**, then it will contain the ``None`` object.
Encodings and the Templating System
===================================
The templating system makes several variables available to you to use. These include ``indextree``, ``thispage``, and ``sections``. These contain information about the current page - and other pages as well. The information contained in these data structures allows you to create simple or complex navigation aids for your website.
See the templating_ page for the details of how these data structures are constructed.
Because these values contain information taken from other pages you can't be certain of their *original encoding*. This isn't a problem though, rest2web will convert these appropriately to the ``final_encoding`` of the current page. (It also converts all target URLs to be relative to the current page).
The slight exception to this is part of the ``sections`` value. This value is a dictionary containing all the pages in the current directory, divided into sections. Each section has information about the section, as well as a list of pages in the section. Each page is itself a dictionary with various members containing information about the page.
One of these members is ``namespace``, which is the namespace the page will be rendered in. This means that the values in the namespace are encoding with the appropriate encoding for *that* page. You can always tell what encoding that is by looking at ``final_encoding`` in the namespace. To be fair you're unlikely to dig that far into ``sections`` from the template - but I thought you ought to know {sm;:roll:}
Problem
=======
Note the following problem_.
* Unfortunately, the ``guess_encoding`` function can recognise ``cp1252`` [#]_ as ``ISO-8859``. In this case docutils can choke on some of the characters. We probably have to special case the ``cp1252`` and ``ISO-8859`` encodings - but I wonder if this problem applies to other encodings ?
--------
Footnotes
=========
.. [#] The bottom line being, that if you don't know what encoding is used - you don't have text, you have random binary data.
.. [#] It must be an encoding that Python recognises. See the Python `Standard Encodings`_
.. [#] See the python `Locale module`_ documentation.
.. [#] The only exception is if the page successfully decodes using the ``ascii`` codec. In this case we store ``ISO8859-1`` as the encoding. This is a more flexible ascii compatible encoding.
.. [#] The standard windows encoding.
.. _The Minimum Every Developer Must Know About Unicode: http://www.joelonsoftware.com/articles/Unicode.html
.. _restindex: ../restindex.html
.. _Standard Encodings: http://docs.python.org/lib/standard-encodings.html
.. _Locale Module: http://docs.python.org/lib/module-locale.html
.. _templating: ../templating.html
.. _problem: todo.html#ISSUES rest2web-0.5.2~alpha+svn-r248.orig/docs/reference/indextree.txt 0000600 0001750 0001750 00000015116 10465432422 024133 0 ustar madduck madduck restindex
crumb: indextree
page-description:
Reference to the weird and wonderful data-structure *indextree*.
/description
/restindex
=========================
indextree and thispage
=========================
-------------------------------
Representing Site Structure
-------------------------------
**rest2web** provides your templates with three variables that give you information about the site structure. The first is called **sections**. This gives you information about all the pages in the same directory as the one that is being rendered. See the templating_ page for the description of that data structure.
The other two variables are called **indextree** and **thispage**. **indextree** is a data structure that represents more of the whole site than **sections**. **thispage** is a pointer to a specific part of **indextree**.
**indextree** itself represents the top level page. It has members representing the pages inside the top level directory. Any index pages for sub-directories will be represented here, and will themselves have pages.
Because of the order that sites are processed in, any page can know that every directory above it will have been *fully* processed. This means that **indextree** can be used to construct 'sidebar' type links that look a bit like the following : ::
(root directory)
index page <- indextree
|
|
section1
| (a sub-directory)
|
section 2 - Index Page
| |
| |
section 3 |
| sub-section 1
| |
section 4 sub-section 2 (another sub-directory)
|
sub-section 3 - Index Page
|
|
**This Page** <- thispage
|
Another Page
|
And Another One
This allows a sidebar that is a set of links to all the sections above the current page. It doesn't yet allow you to know what pages might be in ``section 3`` or ``section 4`` of the root directory - but it would be unusual to need to put that amount of links just in a sidebar [#]_ !
You can see an example of using **sections** for sidebar information in the `rest2web docs`_. The `test site`_ is an example of a site using **indextree** for the sidebar. You can use the `standard function`_ ``sidebar`` to generate these sidebars from indextree.
The actual data structure **indextree** is a dictionary that represents the index page for the top level directory. The dictionary contains links to dictionaries that represent the other pages and indexes. ``indextree`` is actually just part of the whole tree - it only contains the branches needed to get from the root directory to the current page that is being rendered.
The dictionaries in **indextree** all follow the same pattern [#]_ and contain the following members :
#. **parent** : a reference to the parent directory (also a dictionary like this).
If this is the top level directory, then this member is ``None``.
#. **sectionlist** : a list of sections for this directory. This retains the order that the sections are listed in the ``sectionlist`` value of the restindex.
#. **sections** : this is actually a dictionary keyed by section name. Each value is a tuple ``(section_title, section_description)``
#. **pages** : a *list* of pages that are in this section. For pages that don't represent subsections this will be the value ``None``. For pages that do represent subsections, this list will only be populated if our page is somewhere down this tree.
If the page currently being rendered (**thispage**) is not further down this branch, then this will be an empty list ``[]``.
Each *page* in this list is also a dictionary like this one.
#. **subdir** : This will be ``True`` for pages that are index pages (i.e. represent sub-directories). It is ``False`` for pages that aren't index pages for sections.
#. **target** : A relative link from the current page to the one that this dictionary represents.
#. **section** : What section this page is in. For an index page, this section will refer to what section in the *directory above* this index belongs to.
#. **link-title**
#. **crumb**
#. **page-description**
#. **thispage** : ``True`` if this page represents the one currently being rendered, ``False`` otherwise.
#. **uservalues** : The uservalues for this page.
#. **restindex** : The restindex for the page.
#. *current_dir* - The directory the page was rendered in, relative to the top level directory. You can turn this into an absolute path using ``os.path.join(os.getcwd(), current_dir)``.
#. *source_file* - The source filepath for the page.
#. *target_dir* - The target file directory (as an absolute file path) being rendered into. Note: if the file has a target specified it may not be put in this directory. Use ``os.path.dirname(target_file)`` instead.
#. *full_page_url* - The full url (starting with '/') for the page. Using this means that your pages may not work from the filesystem. {sm;:-)}
#. *target_file* - The full output filepath of the page.
As well as **indextree**, templates also have access to a value called **thispage**. **thispage** is an entry in the **indextree** structure, but it points to the current page. If you like **indextree** is the top of the tree, and **thispage** is the bottom.
.. note::
Pages that have 'include' set to 'No' aren't in indextree. For those pages the value *thispage* will be ``None``.
All string values in the **indextree** structure are encoded using the appropriate encoding for the page being rendered (as determined by the value ``final_encoding``).
.. [#] It would be possible to do this by generating the site in two passes. On the first pass we'd generate the link structure and on the second pass actually render the pages. This would take longer, mean keeping the whole site in memory, and mean parsing the whole site before basic errors in the template are discovered !
.. [#] They follow as closely as possible the pattern for pages in the *sections* variable that is also passed to templates. See *sections* in the templating_ page.
.. _templating: ../templating.html
.. _rest2web docs: ../index.html
.. _test site: ../test_site/index.html
.. _standard function: ../functions.html
rest2web-0.5.2~alpha+svn-r248.orig/docs/reference/changelog.txt 0000600 0001750 0001750 00000027072 10632630076 024100 0 ustar madduck madduck restindex
crumb: changelog
page-description:
**CHANGELOG** for the released versions of rest2web..
/description
tags: changelog, changes, improvements, diffs
/restindex
============
Changelog
============
.. contents::
Rest2web Releases
=================
This records the different releases to **rest2web**, with most of the major
changes. The individual source files have more fine grained changelogs if
you have a hankering to know the details. {sm;:-)}
Version 0.5.2 alpha
-------------------
Fixed bug where 'force' in the config file was required to be spelt 'Force' by mistake.
'template.txt' files (without a restindex) will not be processed in force mode.
In force mode, directories *will* use the templates of their parent directories.
Added optional compare function (for sorting pages) to the ``sidebar`` function. (Thanks to Gael Varoquaux.)
'initialheaderlevel' is now inherited by all pages in a directory, if set in an index page.
Version 0.5.1 2006/12/16
------------------------
Added some extra debugging info to syntax errors in the templates.
Fixed odict and pathutils for Python 2.5 compatibility.
Added the 'promote_headers' option to the `config file <../config_file.html>`_.
Added the ``sortpages`` method to the ``sections``. This sorts the pages in a section (or all sections) alphabetically. You can also pass in a custom sort function.
Version 0.5.0 Final 2006/10/11
------------------------------
Paths in the ``file`` keyword and in the config file now have '~' expanded. This
means they can use paths relative to the user directory. (Plus the 'colorize' and
'include' macros.)
Added 'skiperrors' config file / command line option. Errors in processing a file can now be
ignored and rest2web will attempt to continue processing.
Fixed bug where non-ascii uservalues would blow up.
There was a bug in handling tabs in embedded code. This has been fixed.
The macro system has been revamped. All the standard macros are now built in
as default macros. The modules needed by the default macros are also now built
into rest2web. You can still add your own macros, or override the default ones,
by supplying an additional macros file.
``Macro Paths`` section added to the config file for configuring the default
macros ``smiley`` and ``emoticon``.
The initial message printed by rest2web has been changed to ``INFO`` level, so
that it is not displayed by the ``-a`` and ``-w`` verbosity levels.
The namespace and uservalues for each page are now available to the macros,
using global variables ``uservalues`` and ``namespace`` (dictionaries). This
means you can write macros that are customised for individual pages.
A config file is no longer required in force mode. (The current directory is
used as the source directory and html output is put into a subdirectory called
'html'.)
The restindex and uservalues block may now be in a ReST comment. This means
that rest2web source documents with a restindex can still be valid ReStructured
Text documents.
Fixed imports in the gallery plugin. (Thanks to Steve Bethard.)
Changed over to use the latest version of
`StandOut `_.
rest2web now exits with an error code corresponding to the number of warnings and errors generated.
Errors and warnings are now output on ``sys.stderr``.
Version 0.5.0 beta 1 2006/08/05
-------------------------------
Updated docs.
Moved 'pythonutils' distribution into the 'rest2web' directory for ease of
packaging.
Added a ``#!`` line to ``r2w.py``.
All rest2web imports now absolute imports.
Added 'quickstart.txt' thanks to Andrew Ittner.
Added an ``include`` standard function, this can be used to nest templates or
customise sections. (It will walk up the directory tree looking for the
file you specify and takes an optional argument if the file doesn't exist -
useful for templates that allow subdirectories to add to the template, or
even wrap the body.)
``make_dist.py`` now takes ``nopause`` as a command line argument (``make_dist.py``
is in `Subversion`_ for creating distributions.)
Default breadcrumb divider is now '>'. Breadcrumbs are also output in HTML
on separate lines for readability.
Fixed bug when ``final_encoding`` is ``None``.
Default config file is now called ``r2w.ini``. ``rest2web.ini`` will still be
supported until the next release.
Fixed bug with ``standerr`` where no logfile is used.
``print_crumbs`` can now take ``None`` for the dividers.
Added 'globalValues' to the namespace. (Available in templates and pages for
storing values which can be accessed across all pages.)
Added 'uservalues' and 'restindex' into each page in the indextree.
A new command line 'nopause' option to override the config file.
Change so that variables (and functions etc) defined in templates can be used
in single code blocks (like ``<% new_name %>``).
Added more information about pages to the namespace and indextree. The new
values are :
'source_file': The source file for the page
'current_dir': The current directory being processed - this can be turned
into an absolute filepath by doing ``os.path.join(os.getcwd(), current_dir)``
'target_dir': The target file directory (as an absolute file path) being
rendered into. Note if the file has a target specified it may
not be put in this directory. Use ``os.path.dirname(target_file)``
instead.
'full_page_url': The full url (starting with '/') for the current page
'target_file': The full filename of the page being rendered
Fixed bug where 'thispage' wasn't set on pages in the indextree. (Value should
be ``True`` for the current page.)
Fixed bug where 'thispage' (in the namespace) would sometimes be incorrectly
``None``.
Cached template files for faster execution.
Special thanks to Martin Krafft for bugfixes and suggestions.
Version 0.5.0 alpha 2006/05/01
------------------------------
**rest2web** can now build a site with no index pages, no template and no
restindexes. This is the `force <../force_mode.html>`_ command line option. It can
be used to automatically build a site from a collection of ReST documents, and
use default templates.
``uservalues`` can be passed at the `command line <../command_line.html>`_
and in the config file. (Command line `uservalues `_ override
config file ones.) These uservalues are now available in every page. The
encoding of uservalues in the config file is specified by the ``__encoding__``
value.
A ``--template-file`` (or ``-t``) command line option. (Will override the top
level ``template`` keyword specified in the restindex.) This allows you to have
alternative templates for a site; for example one for an online version and
another for distributed documentation.
New website template, created by `Fuchsiashock Design `_.
``final_encoding`` should never be ``utf8`` - should be ``utf-8`` instead. This
is because ``utf8`` is not recognised by browsers. (This is now automatically
handled.)
Added ``initialheaderlevel`` a new restindex keyword. It sets the size of
headers used in ReST documents. Can be set per page.
The ``file`` keyword has been bugfixed. It now only operates if the target file
doesn't exist or is different to the source file. It copies the timestamp along
with the file.
The `gallery plugin `_ now ignores non-image files. It also skips
image files it can't handle (currently only animated jpgs.
**rest2web** now has three levels of verbosity, controlled from the command
line :
* ``-v`` : Verbose, the default.
* ``-a`` : Warnings and actions.
* ``-w`` : Warnings only.
``uservalues`` can now be inserted in pages using a new syntax. Where this is
used, the uservalues are inserted *before* the page is rendered from ReST to
HTML. This means uservalues can be in ReST format. The syntax for single values
is ``{lt}* ... *>``. For multiple lines of code it is ``{lt}$ ... $>``.
Added ``modtimeiso`` value to the namespace and the ``formattime``
`standard function <../functions.html>`_.
The ``namespace`` and ``uservalues`` are both now available (as dictionaries)
to the macros and the standard functions.
Removed the two ``
`` from ``listend`` in the standard function
``minibar`` and added ``wrapper_class`` to ``print_details``.
Added ``os`` and ``sys`` to the namespace for every page.
The default crumb for index pages (if no ``page-title`` specified) is the
filename, minus the extension and turned to title case.
Removed ``urlpath`` from rest2web, because it is now in pythonutils.
It won't run in the distribution directory - need to run "make_dist.py". (This
only applies if fetched from `subversion `_).
Version 0.4.0 alpha 2005/11/11
------------------------------
There were a lot of changes between the 0.3.0 and the 0.4.0 release. This is a
summary :
Documentation refactored and improved, including the `tutorial <../tutorial.html>`_.
Changes for compatibility with `Pythonutils `_
0.2.3 and docutils 3.10.
Added ``page_description`` to namespace.
Added ``file`` keyword (reserved word in namespace).
Added ``tags`` keyword.
Added ``section-pages`` keyword (a way of specifying the order of pages in sections).
Added ``__prune__`` (document in special files).
The plugins system and the gallery.
Changes to config file (psyco, pause, DEBUG).
Interactive debug mode.
Added ``section_contents`` and ``print_details`` functions.
Three extra standard macros.
Bugfix (and change) to the 'print_crumbs' function. It now takes an 'item'
value - this means the last item is also a list item.
Fixed bug where restindex options from one section could leak into another.
Fixed bug where having ``include: No`` for an index page would cause a crash.
Bugfix to ``thispage`` (not broken anymore).
Fixed bug where subsections with a different 'file-extension' were broken.
Fixed bug where not building an index page would cause a crash.
Some changes for compatibility with py2exe (including addition of a ``py2exe-setup.py``).
Version 0.3.0 2005/06/27
------------------------------
Code refactored and better commented. (Thanks to Nicola Larosa for input).
Minor bugfix - an encoding was missing.
Added stylesheet to docutils options override.
Version 0.2.3 2005/06/25
------------------------------
Code style cleanup with help from Nicola Larosa.
Start of the refactoring (some code is simpler internally)
``uservalues`` now compatible with reST.
docs updated appropriately.
Version 0.2.2 2005/06/12
------------------------------
Added support for ``uservalues``.
Version 0.2.1 2005/06/06
------------------------------
Removed extraneous print statement from ``embedded_code.py``
Version 0.2.0 2005/06/01
------------------------------
Various minor changes - especially additions to the namespace pages are
rendered in.
Sites are rendered a whole section at a time. This means pages have index data
for that section available. This is the ``sections`` variable in the namespace.
Added the ``output-encoding`` and ``final_encoding`` values to the restindex.
Added the ``template-encoding`` value to the restindex. (rest2web is now
entirely unicode internally).
It's now possible to specify title and description for the default section.
Added indextree and thispage, allows building of sidebars.
Added standard functions.
Added macros.
Started using subversion repository.
Changed all line endings to 'LF'.
Version 0.1.0 2005/05/08
------------------------------
First version released.
Thanks to Andrew Ittner for testing on Linux.
rest2web-0.5.2~alpha+svn-r248.orig/docs/reference/smilies.txt 0000600 0001750 0001750 00000007470 10414273736 023622 0 ustar madduck madduck restindex
crumb: Smilies
page-description:
The full set of smilies - for use in the ``smiley`` `macro <../macros.html>`_.
/description
/restindex
======================
The Smilies Macro
======================
------------------
Smilies
------------------
.. contents::
Introduction
==============
Included in the example macros file is a function called ``smiley``. This uses a modified version of *smiley.py* by `Mark Andrews`_. It also requires the *path module*. These are both included as part of the **rest2web** distribution in the *modules* directory. If you move them elsewhere you should make sure they are on the *Python search path* [#]_. If you don't know what I'm on about then leave them where they are {sm;:lol:}
The Smilies
===============
To use the smilies you use the *smiley macro*. This can be either ``{curlyl}smiley;SMILEY{curlyr}`` or the shorter form ``{curlyl}sm;SMILEY{curlyr}``. Replace ``SMILEY`` with the symbols for the the smiley you want to display. For example ``{curlyl}smiley;8){curlyr}`` becomes {sm;8)}.
Here is the full smiley set :
* ``{sm;:doubt:}`` -- ``:doubt:``
* ``{sm;:-?}`` -- ``:-?``
* ``{sm;:!:}`` -- ``:!:``
* ``{sm;:lol:}`` -- ``:lol:``
* ``{sm;8)}`` -- ``8)``
* ``{sm;:(}`` -- ``:(``
* ``{sm;:)}`` -- ``:)``
* ``{sm;:eek:}`` -- ``:eek:``
* ``{sm;:-D}`` -- ``:-D``
* ``{sm;:cry:}`` -- ``:cry:``
* ``{sm;:-X}`` -- ``:-X``
* ``{sm;:?}`` -- ``:?``
* ``{sm;:evil:}`` -- ``:evil:``
* ``{sm;:-o}`` -- ``:-o``
* ``{sm;:mad:}`` -- ``:mad:``
* ``{sm;:oops:}`` -- ``:oops:``
* ``{sm;:grin:}`` -- ``:grin:``
* ``{sm;:-|}`` -- ``:-|``
* ``{sm;:-p}`` -- ``:-p``
* ``{sm;:biggrin:}`` -- ``:biggrin:``
* ``{sm;:idea:}`` -- ``:idea:``
* ``{sm;:shock:}`` -- ``:shock:``
* ``{sm;:o}`` -- ``:o``
* ``{sm;:?:}`` -- ``:?:``
* ``{sm;:badgrin:}`` -- ``:badgrin:``
* ``{sm;:roll:}`` -- ``:roll:``
* ``{sm;:arrow:}`` -- ``:arrow:``
* ``{sm;:|}`` -- ``:|``
* ``{sm;:smile:}`` -- ``:smile:``
* ``{sm;:p}`` -- ``:p``
* ``{sm;:razz:}`` -- ``:razz:``
* ``{sm;:wink:}`` -- ``:wink:``
* ``{sm;:-)}`` -- ``:-)``
* ``{sm;8-)}`` -- ``8-)``
* ``{sm;:cool:}`` -- ``:cool:``
* ``{sm;:D}`` -- ``:D``
* ``{sm;:neutral:}`` -- ``:neutral:``
* ``{sm;:sad:}`` -- ``:sad:``
* ``{sm;:???:}`` -- ``:???:``
The Missing Smilies
=====================
{emo;exclaim} We can't use the following smilies. ``;-)`` and ``;)``.
Because they contain a **";"** [#]_, we can't yet use these smilies. They both represent the same smiley. You have to use it in its other form; ``:wink:`` -- ``{sm;:wink:}``.
Alternative Smiley Sets
========================
The nice thing about *smiley.py* is that it supports any smile sets with a **.pak** file. This is the standard for smiley sets that is used by phpbb_. You can find alternative sets of smilies at the stylesdb_ website.
Simply replace the *docs_html/images/smilies* directory with an alternative set to use them. *smiley.py* will automatically create the right links by reading the **.pak** file.
You will need to edit the ``smiley`` function in *macros.py* to have the right path to the smilies directory (to read it) and the right final path to the smilies for your site.
Credits
========
* The *smilies* come from a gentleman called Spider_.
* *smiley.py* is written by `Mark Andrews`_. It is licensed under the BSD license, which is the same one as the `Voidspace License`_ .
* *path.py* (needed by *smiley.py*) is written by `Jason Orendorff`_. He has placed it in the public domain.
.. [#] ``sys.path``
.. [#] This is a limitation of the macros_ system.
.. _macros: ../macros.html
.. _Jason Orendorff: http://www.jorendorff.com/articles/python/path
.. _Voidspace License: http://www.voidspace.org.uk/python/license.shtml
.. _Mark Andrews: http://www.la-la.com
.. _phpbb: http://www.phpbb.com/
.. _stylesdb: http://www.stylesdb.com/smilies_styles.html
.. _Spider: http://web.spidercode.de/smilies
rest2web-0.5.2~alpha+svn-r248.orig/docs/reference/index.txt 0000600 0001750 0001750 00000000604 10414273736 023254 0 ustar madduck madduck restindex
crumb: Reference
link-title: Reference Section
page-description:
Documentation and reference for **rest2web**.
/description
/restindex
==============================
rest2web - Reference Section
==============================
.. raw:: html
<#
print_details(sections[None])
#>
rest2web-0.5.2~alpha+svn-r248.orig/docs/reference/plugins.txt 0000600 0001750 0001750 00000012702 10414273736 023630 0 ustar madduck madduck restindex
crumb: Plugins
page-description:
A description of the **rest2web** plugin system. A manual on how to
write your own plugins.
/description
/restindex
============================
The rest2web plugin System
============================
------------------------
Roll Your Own Features
------------------------
Plugins
=======
.. note::
The plugin system is not yet production ready.
The main problem is that plugins currently have to return encoded byte
strings in the same encoding as the content. This is fine so long as you
can gurantee that the output of your plugin can always be expressed in the
encoding of your content !
I also haven't implemented support for global plugins.
* XXXX __init__ should call start !
* XXXX document that changes to uservalues will have inconsistent results - don't do it !
The plugin system allows you to integrate your own functionality into rest2web. You can use this to implement plugins that process pages or generate their output in ways too complex for the templates.
Plugins can either be global, or just applied to individual pages.
You create plugins by writing a class that inherits from ``rest2web.PluginClass.PluginClass``, place it in a module in the plugins directory, and configure your pages/site to use it.
An example of a plugin that works for individual pages would be a gallery_ - creating pages from directories of images.
An example of a global plugin could be a sitemap generator or a search engine that indexes every page.
The Basic Principle
-------------------
Your plugin name is the module name. So ``gallery.py`` is the ``gallery`` plugin. You module must contain a class called ``Plugin`` - this will be imported when it is first used.
Your plugin class only needs to implement the relevant methods. For a global plugin this will include the ``start`` and ``end`` methods. For a normal plugin you might only need to implement the ``page`` method.
.. note::
You shouldn't override the ``__init__`` method. Use ``start`` instead.
Each page specifies which normal plugins are being used (in the restindex). Each of the plugins (which may not be any of course), plus all the global ones, are called for every page.
What this means is that the ``page`` method of your ``Plugin`` class is called - and passed the parameters : ::
page(self, content, encoding, filepath, targetr, estindex, uservalues)
This means that if you want to pass values or settings from the page to the plugin, they can be specified in the *uservalues*.
The page method (when it has done it's work) should return a tuple of : ::
(content, encoding, newvalues)
*newvalues* is a dictionary that is used to update the uservalues. The values you return here can be used as variables in your page.
When it is first initialised, *every* plugin is given a reference to the processor object and the original config file. You can access this from within your plugin methods using :
.. raw:: html
{+coloring}
processor = self.processor
config = self.config
#
# config is a dictionary like object
value = config['value']
{-coloring}
This means two things :
1) Global plugins can have universal settings in the site config file.
2) You can access the processor attributes like ``dir``, ``dir_as_url``, etc. ::
dir = self.processor.dir
Global Plugins
--------------
When you run rest2web, global plugins are initialised (and their ``start`` method is called). They are then called for every page.
A global plugin can implement any of the ``start``, ``page``, and ``end`` methods. You only need to implement the methods you are using.
.. raw:: html
{+coloring}
from rest2web.PluginClass import PluginClass
class Plugin(PluginClass):
def start(self):
"""
Called when the plugin is initialised.
For global plugins, this is when rest2web starts up.
"""
pass
def end(self):
"""
Called after the last page has been rendered.
Only for global plugins.
"""
pass
def page(self, content, filepath, target, encoding, restindex, uservalues):
"""
Called for every page with globals.
"""
newvalues = {}
return (content, encoding, newvalues)
{-coloring}
Normal Plugins
--------------
A normal plugin will only be used for individual pages. You specify plugins to use on a page with the ``plugins`` keyword in the restindex : ::
plugins: gallery, plugin2
Normal plugins can implement the ``start`` and ``page`` methods.
.. raw:: html
{+coloring}
from rest2web.PluginClass import PluginClass
class Plugin(PluginClass):
def start(self):
"""
Called when the plugin is initialised.
For normal plugins, this is when they are first used.
"""
pass
def page(self, content, encoding, filepath, target, restindex, uservalues):
"""
Called only for pages using the plugin.
"""
newvalues = {}
return (content, encoding, newvalues)
{-coloring}
For an example of this kind of plugin, have a look at the gallery_ plugin.
The Page Method
===============
Todo....
Encoding Issues
===============
Todo...
.. _gallery: http://www.voidspace.org.uk/python/rest2web/reference/gallery.html
rest2web-0.5.2~alpha+svn-r248.orig/docs/reference/gallery.txt 0000600 0001750 0001750 00000032451 10462725010 023577 0 ustar madduck madduck restindex
crumb: Gallery
page-description:
Reference for the gallery plugin.
/description
/restindex
==============================
Picture Galleries and Beyond
==============================
--------------------
The Gallery Plugin
--------------------
:Author: Fuzzyman_
:Date: 2005/08/12
:Version: 0.2.0
:Homepage: `Gallery Page`_
.. contents:: Galleries of Images
Introduction
============
The gallery acts as a plugin to rest2web_. (It can also fuction as a `standalone program`_). It generates an html gallery page from a directory of images, an html template, and a few settings.
It creates a single main gallery page, with thumbnails that act as links to each image. The images themselves appear on their own page, with a title and optional description. Each page has links to the next and previous images, and back to the main gallery.
You can see the sort of output it generates with the `online example`_, which acts as the gallery test site in the rest2web_ distribution.
If you are viewing this from the test docs, you can build the test gallery by running [#]_ : ::
r2w.py gallery_test.ini
You can then view the gallery at `gallery index`_.
Downloading
===========
At some point I will package the gallery on it's own. Currently it's only available bundled with **rest2web**.
Using Gallery With rest2web
===========================
In order to use it with rest2web, ``gallery.py`` needs to be available in the ``plugins`` subdirectory of rest2web - and also PIL_ must be installed.
In order to use the gallery in a page, you must have 'gallery' in your list of plugins for the page. This is done in the restindex, with a line like : ::
plugins: gallery
Next you must specify a set of values that tell the gallery what to do. When run as a plugin you specify these as ``uservalues``.
uservalues Settings
===================
The settings control the gallery program, they specify which directory to read the images from, which templates to use to generate the output pages, and so on.
All the settings must be present, or the gallery will raise an error. Assuming you have no other ``uservalues``, the settings look like : ::
uservalues
thumb_size = 150, 150
gallery_dir = ../../FTP Mirror/gallery
gallery_url = gallery
data_file = gallery_data.ini
page_template = page.html
entry_template = entry.html
gallery_mode = 1
/uservalues
See `the settings`_ section for an explanation of what they all mean.
Standalone Program
==================
*gallery.py* will work as a standalone program as well as a plugin to rest2web. It uses the same settings, but gets them from a config file instead of uservalues.
One of the main reasons to make gallery.py run in this way, was so that Aidan could use it for his online `Pages of Computer Imagery`_.
In order to use gallery.py as a standalone program, you will need Python_ 2.3 or later and a recent version of PIL_. You will also need either pythonutils_ 0.20 *and* rest2web_ installed [#]_ ; or just version 0.2.0 (or higher) of pythonutils [#]_.
By default the gallery looks for a config file called ``gallery.ini``. You can also specify an alternative config file at the command line [#]_.
All the settings need to be present or the gallery will raise an error. The complete settings are : ::
thumb_size = 150, 150
gallery_dir = ../../FTP Mirror/gallery
gallery_url = gallery
data_file = gallery_data.ini
page_template = page.html
entry_template = entry.html
gallery_template = gallery.html
gallery_mode = 1
gallery_page = gallery_page.html
See `the settings`_ for what they mean.
The Settings
============
Most of the settings have the same meaning however you use gallery.
* ``thumb_size`` -> ``width, height``
e.g. *150, 150*
This is the *maximum* size of the generated thumbnails. It keeps the proportions of the original image.
* ``gallery_dir`` -> ``path to directory``
e.g. *../../FTP Mirror/gallery*
This is the path from the file to the directory of images.
* ``gallery_url`` -> ``url path``
e.g. *gallery*
The final url path from the gallery to the image directory. This path is used to make paths for all the images/thumbnails/pages.
.. note::
When run as a standalone program, the image directory should be in a single subdirectory from the main gallery. Hopefully this limitation will be removed soon.
* ``data_file`` -> ``filepath``
e.g. *gallery_data.ini*
This is the data file that stores details of all the image files and thumbnails. See the `Gallery Data File`_ section for details.
* ``page_template`` -> ``filepath``
e.g. *page.html*
The path to the template file for the individual pages. See `The Templates`_ for details.
* ``entry_template`` -> ``filepath``
e.g. *entry.html*
The path to the template file for every thumbnail on the main page. See `The Templates`_ for details.
* ``gallery_mode`` -> ``1`` or ``2``
e.g. *1*
Whether gallery should scan all the images (1), or just use the stored data file to generate the pages (2). See the `Gallery Data File`_ section for details.
Standalone Specific Settings
----------------------------
These next two settings are only used when gallery.py is run as a standalone program.
* ``gallery_template`` -> ``filepath``
e.g. *gallery.html*
This is the template file used to create the main gallery page.
* ``gallery_page`` -> ``filepath``
e.g. *gallery_page.html*
This is the filename to save the main gallery page as. See `The Templates`_ for details.
Gallery Data File
=================
The gallery data file won't exist until the first time you run gallery.
When *gallery.py* runs it scans the image directory and stores the details of each image. It puts all the thumbnails in a 'thumbnail' subdirectory of the image directory. It puts all the html pages it creates in an 'html' subdirectory of the image directory. If these directories don't exist, it will create them.
The datafile it creates is effectively a config file with sections [#]_ - one section per image !
If you have pythonutils 0.3.0 [#]_ (or more recent) then the order of these sections will be the order that images appear in the gallery. This means you can cut and paste to edit the order.
.. warning::
If you run gallery (in mode 1) after removing any images from the image directory - it will remove their entry from the data file.
There are two other entries that you can edit per image :
1) *Title* - by default gallery generates a title for the image based on the filename. It replaces '_' with spaces and capitalizes words.
2) *Description* - You can put an optional description for the image here. This will appear below the image, on it's page.
.. note::
Entering a description with several lines is only possible with pythonutils 0.3.0 or higher (or configobj 4).
If you have pythonutils 0.3.0, you should surround entries with multiple lines between triple quotes - ``'''like this'''``.
Gallery Mode
------------
The details it stores in the data file are sufficient to generate the main gallery page and all the individual pages, without having to scan the image directory again.
If ``gallery_mode`` is set to *2* (see `The Settings`_), then gallery *won't* scan the image directory. Not only is this quicker - but it can be useful when you have finalised the contents of a gallery and want to move the images.
If you *do* want gallery to scan the image directory, set ``gallery_mode`` to *1*. This won't overwrite any titles or descriptions, but it will add new images and remove entries for ones you've deleted. You can also use it to regenerate thumbnails if you change their size.
The Templates
=============
*gallery.py* generates it's output from html templates that you supply. It fills in values in the template with things like the path to the image or thumbnail, it's height, width, or title, and so on.
If you are using gallery from rest2web there are two templates. If you are running it on it's own there are three. You need to supply the path to each of these files in the settings.
Obviously a good place to start is by looking at the example ones provided.
The three templates are :
* *entry_template*
This is a small template. It is used for every thumbnail and link in the main gallery page.
* *page_template*
This is the template used to make each page (the ones containing the individual images).
* *gallery_template*
This is only used when running as a `standalone program`_. It is used to make the main page with all the thumbnails on.
The templates have various entries in them, that gallery replaces with the right values for the pages it is building. They all look like ``**some name**``. When you edit the templates, you must keep these for the page to work.
.. note::
In fact it won't cause an error to remove any of the special entries from the templates - that value will just be missing from the final pages. You can use this to further customize the appearance of your galleries.
entry_template
--------------
This template is used for every thumbnail and link in the main gallery page.
The special values are :
* ``**link**``
Link to the image page.
* ``**thumb**``
Path to the thumbnail (for the ``img`` tag).
* ``**width**``
Thumbnail width.
* ``**height**``
Thumbnail height.
* ``**title**``
Image title.
page_template
-------------
This is the template used to make each page (the ones containing the individual images).
The special values are :
* ``**title**``
The image title. Used as the page title, and as a heading above the image.
* ````
* ````
In the template the 'previous image' and 'next image' are commented out. If they are needed in the page, the comment markers are removed.
Obviously, the first image doesn't have a previous (left) image, and the last doesn't have a next (right).
* ``**linkleft**``
* ``**linkright**``
These are the links to the previous and next image pages.
* ``**thumbleft**``
* ``**thumbright**``
These are the paths to the thumbnails for the previous and next images.
* ``**widthleft**``
* ``**heightleft**``
* ``**widthright**``
* ``**heightright**``
The widths and heights for the next/previous thumbnails.
* ``**titleleft**``
* ``**titleright**``
The image titles for the next/previous thumbnails.
* ``**linkgallery**``
The link back to the main gallery page.
* ``**image**``
The path to the actual image.
* ``**widthmain**``
* ``**heightmain**``
The width and height of the actual image.
* ``**description**``
Guess what !
gallery_template
----------------
This template is only needed (or used) when running gallery.py as a standalone program. It is used to make the main page with all the thumbnails on.
The only special value is :
* ``**gallery**``
This is replaced with the html containing all the thumnail images and links.
Using the Output
================
..note::
This section is only relevant when the gallery is used from rest2web.
Using the output from the gallery in your page is very easy. It creates an extra value ``gallery`` to use in your page.
If the page format is {acro;reST;reStructured Text}, the ouput is indented and put inside a ``.. raw:: html`` directive [#]_.
The output for the main page contains thumbnails with links to the individual pages. It is made up from the *entry* template - with the value
filled in for each image. You would normally use it with something like : ::
<% gallery %>
TODO
====
The gallery is still experimental ('alpha' quality). I need to check the following things.
* XXXX Does it delete thumbnails and html pages for deleted images ?
* XXXX Sort html for multi-line descriptions.
* XXXX check "file_error" works
* XXXX If the page format is reST, the ouput is indented and put inside a ``.. raw:: html`` directive.
* XXXX *except* - shouldn't use plugins with reST
-------
Footnotes
=========
.. [#] On Windoze you can just double click on ``gallery_test.bat``.
.. [#] Installed means somewhere on your normal PYTHONPATH.
.. [#] Version 0.2.0 was the first to include *urlpath*, which gallery.py needs in order to run.
.. [#] Or by creating a ``bat`` file if you use windoze and are unfamiliar with the command line. To run gallery.py with *gallery.ini*, create a text file called *gallery.bat* - with ``python gallery.py gallery.ini``. Double clicking on *gallery.bat* should then run gallery.py with the correct config file.
.. [#] It uses ConfigObj_ to read/write the 'INI' style config files.
.. [#] Which has ConfigObj 4 - this retains the order of entries in config files.
.. [#] Except currently plugins are not compatible with pages in reST format. That will be fixed soon.
.. _gallery index: ../gallery_test/index.html
.. _rest2web: http://www.voidspace.org.uk/python/rest2web/
.. _PIL: http://www.pythonware.com/products/pil
.. _python: http://www.python.org
.. _pythonutils: http://www.voidspace.org.uk/python/pythonutils.html
.. _Configobj: http://www.voidspace.org.uk/python/configobj.html
.. _Pages of Computer Imagery: http://www.nebulae.org.uk
.. _fuzzyman: fuzzyman@voidspace.org.uk
.. _gallery page: http://www.voidspace.org.uk/python/rest2web/reference/gallery.html
.. _online example: http://www.voidspace.org.uk/python/rest2web/gallery_test/index.html
rest2web-0.5.2~alpha+svn-r248.orig/docs/tutorial_site/ 0000700 0001750 0001750 00000000000 10644674642 022341 5 ustar madduck madduck rest2web-0.5.2~alpha+svn-r248.orig/docs/tutorial_site/subdirectory/ 0000700 0001750 0001750 00000000000 10644674642 025057 5 ustar madduck madduck rest2web-0.5.2~alpha+svn-r248.orig/docs/tutorial_site/subdirectory/index.txt 0000600 0001750 0001750 00000001242 10414273736 026722 0 ustar madduck madduck restindex
crumb: Subdirectory
target: subdirectory.html
page-description:
A subdirectory - with pages of it's own.
/description
/restindex
=========================
Subdirectory Index Page
=========================
--------------
The Subtitle
--------------
.. role:: raw-html(raw)
:format: html
.. raw:: html
<#
if not default_section['pages']:
print 'No Pages Yet
'
else:
print_details(default_section)
#>
.. class:: intro
This page lives at :raw-html:`<% pagepath %>`. The ``class`` directive applies a style to this paragraph.
rest2web-0.5.2~alpha+svn-r248.orig/docs/tutorial_site/template.txt 0000600 0001750 0001750 00000001675 10414273736 024722 0 ustar madduck madduck
<% title %>
<% body %>
Return to Top
Page last modified <% modtime %>.
rest2web-0.5.2~alpha+svn-r248.orig/docs/tutorial_site/index.txt 0000600 0001750 0001750 00000000734 10414273736 024211 0 ustar madduck madduck restindex
crumb: Home
format: html
page-title: rest2web Tutorial Website
include: No
/restindex
rest2web Tutorial Website
An Example Index Page
<#
print_details(default_section)
#>
This is the index page for the rest2web Tutorial website.
It's not got much on it - other than this paragraph and links to our other
pages.
rest2web-0.5.2~alpha+svn-r248.orig/docs/tutorial_site/example.txt 0000600 0001750 0001750 00000001521 10414273736 024530 0 ustar madduck madduck restindex
crumb: A Page
link-title: An Example Page
page-description:
This description is for the index page.
You can use **reST** markup if you want.
/description
/restindex
==============
A ReST Title
==============
--------------
The Subtitle
--------------
..
This is a comment. To use the 'raw-role', we have to define it *first*.
.. role:: raw-html(raw)
:format: html
This page is written in {acro;reST;ReStructured Text} markup. That's why it looks like *plain text*.
This page lives at :raw-html:`<% pagepath %>` [#]_. This tutorial isn't a tutorial on ReStructuredText though. If you're looking for one, you might be better off with the `docutils documentation`_.
.. [#] The file path is dynamically inserted by rest2web.
.. _docutils documentation: http://docutils.sourceforge.net
rest2web-0.5.2~alpha+svn-r248.orig/docs/index.txt 0000600 0001750 0001750 00000010623 10542017106 021305 0 ustar madduck madduck restindex
crumb: rest2web
tags: index, main page, sourceforge, mailing list, svn, svn repository
output-encoding: utf8
template-encoding: utf8
section-pages: , introduction, quickstart, config_file, tutorial, command_line, force_mode, templating, the_restindex, functions, macros, special_files, reference/index, test_site/index, translation/index
link-title: rest2web Home
/restindex
=============================
rest2web - The Site Builder
=============================
---------------------------------------
Autogenerating Websites with Docutils
---------------------------------------
:Author: Michael Foord {sm;8)}
:Contact: fuzzyman@voidspace.org.uk
:Version: 0.5.1
:Date: 2006/12/16
:License: BSD-License_
:Home Page: rest2web_
:Quick Download: `rest2web-0.5.1.zip `_
:Tarball: `rest2web-0.5.1.tar.gz `_
:Sourceforge: `rest2web Project Page`_
:Development: `SVN Repository`_
:Support: `rest2web Mailing List`_
.. image:: images/logos/rest2web200x80.gif
:height: 80
:width: 200
:alt: Site Built with rest2web
:align: center
.. image:: images/screenshot.jpg
:height: 308
:width: 410
:alt: Building with rest2web
:class: image
:align: center
:target: images/screenshot_big.jpg
rest2web - The Website Builder
==============================
{emo;html} Maintaining websites or project documentation in {acro;HTML} is a pain.
**rest2web** takes out the pain, and brings back the joy. {sm;:wink:}
**rest2web** is a simple tool that lets you build your website from a single
template (or as many as you want), and keep the contents in `ReStructured Text `_ [#]_.
(You can still keep pages in HTML if needed.)
It can also aid in having multiple translations of your site ({acro;i18n;Internationalization})
and a *host* of other features. {sm;:-)}
Below is an index to all the rest2web documentation, but for more information
check out the `introduction `_.
Alternatively, browse the following websites. They are *all* built with **rest2web**
and show the range of different styles it is capable of creating [#]_ :
* `Voidspace `_
* `Project Pipe `_
* `Martin Krafft's PHD Pages `_
* `HP Linux Imaging and Printing `_
* `Live Off Grid `_
* `CRSR `_
* `Civitas `_
* `German Website on Text Based Tools `_
* `The Python Academy (English) `_
* `The Python Academy (Deutsch) `_
* `Creatext `_
* `Tibet.net `_
* `Homesite of Marius Soutier `_
* `Homesite of Paul Bartletts `_
* `Homesite of Peter Brett `_
* `Homepage of Gal Varoquaux `_
* `The Rhyming Panda `_
* `Aikido Club Website `_
* `Introduction to Scott Mcdermott `_
It also builds the documentation for the following projects :
* rest2web_
* `PyGeo `_
* `Movable Python `_
* `Firedrop2 `_
To see recent changes, visit the `Changelog `_.
.. raw:: html
<#
print_details(default_section, wrapper_class="displaybox")
#>
---------------------
.. [#] {acro;ReST;ReStructuredText} is a plain text {acro;WYSIWYG} markup. It's
a great way of keeping documents in a readable and editable form.
.. [#] If your site is built with **rest2web**, then `Contact Me `_
to get it added to this list.
.. _BSD-License: http://www.voidspace.org.uk/python/license.shtml
.. _rest2web: http://www.voidspace.org.uk/python/rest2web/
.. _Rest2web Mailing List: http://lists.sourceforge.net/lists/listinfo/rest2web-develop
.. _SVN Repository: https://svn.rest2web.python-hosting.com/trunk/
.. _rest2web Project Page: http://sourceforge.net/projects/rest2web
rest2web-0.5.2~alpha+svn-r248.orig/docs/introduction.txt 0000600 0001750 0001750 00000027572 10541054604 022735 0 ustar madduck madduck restindex
crumb: Introduction
tags: introduction, site, website
page-description:
A gentle introduction to **rest2web**.
/description
/restindex
==========================
Introduction to rest2web
==========================
-------------------------------------------
A Gentle Introduction to the Site Builder
-------------------------------------------
.. contents::
What is rest2web ?
==================
{emo;python} **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
{acro;breadcrumbs;Weird name for navigation links ?}).
* 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. {sm;:-p}
* 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 {acro;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. {sm;:-)}
{acro;ReST} is a {acro;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 [#]_.
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
---------------------
{emo;html} 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 {acro;XHTML} and {acro;CSS;Cascading Style Sheets}.
{sm;:grin:} 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. {sm;8-)}
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. [#]_
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
===========
{emo;file1} 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`_. [#]_
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/`` [#]_
.. 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
==========
{emo;eyeballz} If you are running the source version of **rest2web**, you need docutils_ installed. It works best with the latest version [#]_.
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 [#]_ 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. {sm;:cool:}
* webgen_ - A ruby_ project that does a similar thing to **rest2web**. It is *scarily* similar in the way it works. {sm;:lol:} It doesn't work with ReST_ markup however.
* Tahchee_ - an alternative to *rest2web* that uses the cheetah_ templating system.
---------------
Footnotes
=========
.. [#] Many websites will only need a single template file.
`Voidspace `_ actually uses two for *all* the
parts of the site built by rest2web.
.. [#] 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.
.. [#] Many thanks to the decent folks over at `python-hosting.com `_.
.. [#] For Windoze users, I recommend the SVN client TortoiseSVN_.
.. [#] Version 0.3.9 or later.
.. [#] And **Kaa**, the predecessor to firedrop.
.. _rst-ht2html: http://www.rutherfurd.net/articles/rst-ht2html.html
.. _ht2html: http://ht2html.sourceforge.net/
.. _Python:
.. _python.org: http://www.python.org
.. _jython.org: http://www.jython.org
.. _docutils: http://docutils.sourceforge.net
.. _Hans Nowak: http://zephyrfalcon.org
.. _Firedrop:
.. _firedrop2: http://www.voidspace.org.uk/python/firedrop2/index.shtml
.. _rest: http://docutils.sourceforge.net/rst.html
.. _Voidspace Manifesto: http://www.voidspace.org.uk/documents/voidspace_manifesto.html
.. _pythonutils module: http://www.voidspace.org.uk/python/pythonutils.html
.. _restindex: restindex.html
.. _Creating a site: tutorial.html
.. _rest2web: http://www.voidspace.org.uk/python/rest2web
.. _BSD-License: http://www.voidspace.org.uk/python/license.shtml
.. _Rest2web Mailing List: http://lists.sourceforge.net/lists/listinfo/rest2web-develop
.. _SVN Repository: https://svn.rest2web.python-hosting.com/trunk/
.. _templates: templating.html
.. _macros: macros.html
.. _Test Site: test_site/index.html
.. _rest2web Project Page: http://sourceforge.net/projects/rest2web
.. _uservalues: reference/uservalues.html
.. _TortoiseSVN: http://tortoisesvn.tigris.org/
.. _webgen: http://webgen.rubyforge.org/
.. _ruby: http://www.ruby-lang.org/en/
.. _tahchee: http://www.ivy.fr/tahchee/
.. _cheetah: http://www.cheetahtemplate.org/
rest2web-0.5.2~alpha+svn-r248.orig/docs/quickstart.txt 0000600 0001750 0001750 00000022234 10447605110 022373 0 ustar madduck madduck restindex
tags: quickstart, introduction, beginners, site builder, website, basics, guide, basic guide
crumb: Quickstart
link-title: Quickstart
page-description:
An quick start guide showing how to use **rest2web** to create a simple website.
/description
/restindex
.. role:: raw-html(raw)
:format: html
======================
Rest2Web Quick start
======================
This document shows how to create a very simple site with rest2web_.
.. contents::
Files and Directories
----------------------
You need:
- a config file (simple text file)
- an input directory (the directory that rest2web_ will process - your site's source)
- an output directory (where rest2web_ will place the new HTML files)
- content!
Do this
=============
Make the following directory structure, with empty text files (**directories**, *files*).
- **quickstart**
- *quickstart.ini*
- **input**
- *index.txt*
- *template.txt*
- *somecontent.txt*
- **subdir1**
- *index.txt*
- **subdir2**
- **output**
Things to note
===============
- rest2web_ will build all the directories and files under ``input/``. If a directory does not have an ``index.txt`` file in it, **the directory will not be processed**.
Configuration
-------------
Do this
============
Add the following to ``quickstart.ini``::
psyco = False
pause = False
log_file = '/home/user/quickstart/qs_log.txt'
DEBUG = False
compare_directory = ''
# these values we have edited for our site
start_directory = '/home/user/quickstart/input'
target_directory = '/home/user/quickstart/output'
macros = ''
Change the ``/home/user/`` prefix to a suitable location. For windows users, simply use the appropriate syntax (e.g. ``C:\data\quickstart\``).
Explanation
============
log_file
where to write the log file
start_directory
the root directory of the source files
target_directory
where to write the HTML files
.. note:: You may use any location for the start and target directories; they do **not** have to be siblings, **nor** do they have to reside underneath the same directory as the ini file.
Source files
-------------
Each source file corresponds to a content file, except under special circumstances (like telling rest2web_ **not** to process a directory, which we will cover later). Every source file needs a ``restindex`` block at the very top. The ``restindex`` can contain multiple options.
Do this
==========
Add the following to ``quickstart/input/index.txt``::
restindex
crumb: quickstart root
format: rest
page-title: the quickstart root!
encoding: utf-8
output-encoding: None
/restindex
restindex format
=================
* Must be at the very top of the file
* Must start with ``restindex`` and end with ``/restindex``
* Each option must be indented by a consistent amount
* An option with values must be in this format: ``option: value``
* A block of options must start with ``option`` (indented) and end with ``/option`` (same indentation)
What it means
==============
crumb
what should be shown on the breadcrumb trail for this page.
format
the two most common formats are ``rest`` for ReStructuredText; and html for HTML
page-title
The name of the page. You do not need this if you specify a title in-line.
encoding
The encoding that *the source file* is in. ``iso-8859-1`` and ``utf-8`` are common.
output-encoding
The encoding for the *output file*. ``None`` means "use the same encoding as the input file."
Do this
===========
Add a restindex block to each ``index.txt`` file in the ``input/`` tree, and also to any text files you want included in the build. The easiest way is copy the example, or modify what you placed in the ``input/index.txt`` root source file, and add it to each.
Remember to customize the ``crumb`` and ``page-title`` options!
Oh, and **add some content to each page**. That *is* the whole point, right?
Templates
----------
The template controls how your site looks, what navigation features to include - basically anything outside of the content. We will use `the same template`__ as in the tutorial_, and add the ``print_details(default_section)`` macro.
__ ./tutorial.html#html-template
Do this
===========
Add the following to ``quickstart/template.txt``::
<% title %>
<% body %>
Return to Top
Page last modified <% modtime %>.
Build your site
------------------
Run the following at the command line::
python /path/to/rest2web/r2w.py /path/to/quickstart/quickstart.ini -w
This builds your site, and display any warnings (``-w``). If you see any errors, read them from the bottom up (especially if they are Python_ errors like ``traceback``) and fix them. If you cannot resolve an error, many helpful people on `the rest2web mailing list`__ are happy to help.
__ http://lists.sourceforge.net/lists/listinfo/rest2web-develop
Ignoring and including files
------------------------------
rest2web_ normally builds the entire site, ignoring any files not ending in "``.txt``" This can be a problem if you have pre-existing content, perhaps built by another process, that you simply want rest2web_ to link to.
How to not overwrite a directory
=================================
Assume we already have ``subdir2`` in the ``output/`` directory, and rest2web_ should not overwrite that directory or the index.html file within it.
Do this
=========
Create ``quickstart/input/subdir2/index.txt`` and add the following::
restindex
# NOTE: the files listed here must reside in the OUTPUT directory; r2w will NOT copy them over
crumb: subdir2
format: html
page-title: subdir2's index
encoding: utf-8
output-encoding: None
target: index.html
# "build: no" prevents this page from overwriting the existing subdir2/index.html page!
build: no
/restindex
Then rebuild the site.
As you may have guessed, the relevant option in the ``restindex`` block is ``build: no``. This tells rest2web_ that there is a ``output/subdir2/index.html`` file, so **do not overwrite it**. The ``crumb`` and ``page-title`` options mean that rest2web_ will include those values in any site maps or sections. The section of your site that rest2web_ did *not* build will still be connected to the part that rest2web_ *did* build.
.. note:: rest2web_ will not create ``subdir2/`` or ``subdir2/index.html``, so make sure you create it yourself.
How to include a file
======================
Have files that you want to include but do not want them to get built? Or files that rest2web_ skips over, like ``.py`` text files or ``.png`` image files? Never fear! ``file:`` is here!
Do this
========
- Create a new file and save it to ``quickstart/input/somefile.abc``.
- In ``quickstart/input/index.txt``, add this option to the ``restindex`` block: ``file: somefile.abc``
- Save `index.txt`.
- Build your site.
Result: ``quickstart/output/`` now has ``somefile.abc``!
Some reasons to use rest2web_ to handle files that it does not build:
- rest2web_ will never overwrite it in the ``output/`` directory, because it already knows about it.
- The modification times will remain the same.
- The file will *only* get copied over if it is newer than what is already in ``output/``.
Congratulations
-----------------
You finished the rest2web_ quickstart!
Next steps
------------
- Templates_ are powerful ways to customize your site's look and navigation.
- The stylesheets are probably not connected correctly. Make new ones and use the ``file:`` keyword to have rest2web process them.
- Macros_ are powerful ways to customize your site's look and naviga - oh wait, I already said that. Well, they are *different* powerful ways.
- The tutorial_ gives much more detail about creating your site using rest2web_.
Author and copyright
----------------------
Written by `Andrew Ittner`__, :raw-html:`©` 2006. Licensed under the same license as rest2web_.
__ http://www.rhymingpanda.com/
.. _rest2web: http://www.voidspace.org.uk/python/rest2web/
.. _Python: http://www.python.org/
.. _templates: ./templating.html
.. _macros: ./macros.html
.. _tutorial: ./tutorial.html
rest2web-0.5.2~alpha+svn-r248.orig/docs/force_mode.txt 0000600 0001750 0001750 00000005515 10513302450 022301 0 ustar madduck madduck restindex
crumb: Force Mode
page-description:
A special mode (set from the command line) allows **rest2web** to build
a website from a collection of ReST documents. In this mode templates,
index pages and restindexes are optional.
/description
tags: website, force, automatic, quick, shortcut
/restindex
================================
Building Websites the Easy Way
================================
----------------
The Force Mode
----------------
.. contents::
Introduction
============
Sometimes you just want to throw some ReST documents together as HTML. Or
perhaps you need to keep your documents in normal ReST syntax, and you don't
want to add a ``restindex``.
In this case, you want the *force mode*. {sm;:-)}
In essence the force mode makes templates, restindexes and index pages
optional. It does this by supplying defaults where they are missing.
The default template (complete with sidebar) and default index page are stored
in the ``rest2web/defaults/`` directory. You are of course free to edit them.
.. note::
This functionality is new, and needs to mature. For example, at the moment
you will probably want to edit the supplied defaults.
An obvious feature to add would be to allow the overriding of the defaults
at the command line.
If you have any opinions about how this feature should develop, then please
comment on the `rest2web-develop mailing list `_.
Files in your site can still be contained in a directory tree. rest2web will
create an index page for each directory, and link between them via the index
pages, sidebar and breadcrumbs.
Using Force Mode
================
You activate force mode through the command line, with either the ``-f`` or
``--force`` option.
When force is on and no template is specified, then the default one
(``restweb/defaults/template.txt``) is used.
If a template is specified in the restindex of any index page, then that will
be used for that directory (and all subdirectories) in the usual way.
Every directory that has no ``index.txt`` will use the default one.
(``restweb/defaults/index.txt``)
Every text file without a restindex will be assumed to be in ReST format. It
will use the normal defaults for a restindex.
The index page for the top level will have the title *Index for Site*.
Other index pages will have *Site* replaced with the directory name.
The page title will be used as the crumb and link-title for all pages.
Force Mode and Config File
==========================
If you are in force mode, the config file is also optional.
In this case, the current directory is used as the source directory.
The output is put into a subdirectory called 'html'. This directory will be created if it doesn't exist, it will also not be scanned for source text files.
rest2web-0.5.2~alpha+svn-r248.orig/docs/gallery_test/ 0000700 0001750 0001750 00000000000 10644674642 022150 5 ustar madduck madduck rest2web-0.5.2~alpha+svn-r248.orig/docs/gallery_test/index.txt 0000600 0001750 0001750 00000000363 10414273736 024016 0 ustar madduck madduck restindex
build: No
crumb: Gallery
link-title: Example Gallery
page-description:
Example gallery from the `gallery plugin `_.
(Only present if you build it).
/description
/restindex
rest2web-0.5.2~alpha+svn-r248.orig/docs/command_line.txt 0000600 0001750 0001750 00000012617 10514020430 022621 0 ustar madduck madduck restindex
crumb: Command Line
page-description:
The different command line options for **rest2web**. This includes
passing *uservalues* for use in your pages and templates.
/description
/restindex
======================
Command Line Options
======================
--------------------------------------------
Configuring Rest2web from the Command Line
--------------------------------------------
.. contents::
Introduction
============
Most **rest2web** configuration is done through the config file. It is
generally easier to edit a single text file than to have to remember lots of
arcane command line options. {sm;:-)}
There are several things you can control from the command line. These include :
* The `Config File `_
* The verbosity level (how much information rest2web outputs as it runs
* Override the template file
* Go into force mode
* Specify global `uservalues `_
Basic Usage
===========
If you type ``r2w.py --help`` at the command line, this is the message it
*should* print :
::
usage: r2w.py [options] config_file
options:
--version show program's version number and exit
-h, --help show this help message and exit
-v Verbose output (default).
-a Display warnings & actions only.
-w Display warnings only.
-t TEMPLATE, --template-file=TEMPLATE
Specify a template file. (Overrides first template.)
-u USERVALUES, --uservalues=USERVALUES
Global uservalues for the site, in the form
"name=value".
-f, --force Force site without indexes, restindexes or template.
-n, --nopause Do not pause after processing (overrides setting in config file).
-s, --skiperrors Skip errors (continue processing).
.. note::
Command line options are processed using `optparse `_.
This only comes with Python 2.3 and more recent. On Python 2.2 you will
only be able to pass the config file at the command line.
The Config File
===============
If you run ``r2w.py`` *without* any command line options, it looks for a file
called ``r2w.ini`` in the current working directory.
Alternatively you can specify a `config file`_ as the last argument to ``r2w.py``.
Verbosity Level
===============
By default rest2web outputs a lot of information about what it does. This
includes which directories and files it is processing, as well any errors
raised along the way.
This may be too much information. There are three different verbosity levels :
* ``-v`` - Verbose, the default level. Information, actions and errors.
* ``-a`` - Action level. Actions and errors only.
* ``-w`` - Warning level. Warnings only.
Template File
=============
rest2web uses template files to generate the output pages. See `Templating `_
for the details of this.
Often you will only use a single template, specified in the `restindex `_
of your top level index page. Sometimes you may want to use alternative templates
for the same site. For example one for the online version and one for the
distributed documentation.
You can override the top level template from the command line, using either :
``r2w.py -t path/to/template.txt``
``r2w.py --template-file=path/to/template.txt``
Uservalues
==========
`The Uservalues `_ are a way of providing values to
use in your content and templates. They can be useful for multiple translations,
or for values that you want to specify at the time you build your site.
You can specify uservalues in the restindex of each page. You can also specify
*global* uservalues (available in every page) in the config file, or at the
command line.
If you specify the same values in your config file *and* at the command line,
the command line takes higher priority.
A uservalue needs a name (this is how you refer to it in pages/templates) and
a value. The name and value should be separated by an equals sign.
This means that you can specify uservalues at the command line using either :
``r2w.py -u "name=value"``
``r2w.py --uservalues="name=value"``
The double quotes are optional, but useful if the value has spaces.
Uservalues in pages will override global uservalues specified in either the
config file or at the command line.
Force Mode
==========
`force mode `__ allows you to build websites without specifying
a template, providing indexes, or having restindexes in the ReST documents that
form your pages.
You can supply any of these that you want, but where they are missing rest2web
will supply defaults.
To switch force mode onfrom the command line, use :
``r2w.py -f``
``r2w.py --force``
No Pause
========
This overrides the 'pause' option in the config file, and forces 'r2w.py' to
*not pause* after running.
skiperrors
==========
This option determines how rest2web will handle exceptions (like our old friend ``UnicodeDecodeError``) that happen when processing pages.
If set, rest2web will display the error and move to the next file. The default is off.
.. note::
If an error occurs whilst trying to process an index file, it will have to skip building the directory.
This feature is still 'experimental' and may need refining.
rest2web-0.5.2~alpha+svn-r248.orig/docs/test_site/ 0000700 0001750 0001750 00000000000 10644674642 021455 5 ustar madduck madduck rest2web-0.5.2~alpha+svn-r248.orig/docs/test_site/section4/ 0000700 0001750 0001750 00000000000 10644674642 023205 5 ustar madduck madduck rest2web-0.5.2~alpha+svn-r248.orig/docs/test_site/section4/notincluded.txt 0000600 0001750 0001750 00000000212 10414273736 026245 0 ustar madduck madduck restindex
include: no
crumb: Not Included
/restindex
==============
Not Included
==============
This page just isn't included.
rest2web-0.5.2~alpha+svn-r248.orig/docs/test_site/section4/empty/ 0000700 0001750 0001750 00000000000 10644674642 024343 5 ustar madduck madduck rest2web-0.5.2~alpha+svn-r248.orig/docs/test_site/section4/empty/somewhere/ 0000700 0001750 0001750 00000000000 10644674642 026341 5 ustar madduck madduck rest2web-0.5.2~alpha+svn-r248.orig/docs/test_site/section4/empty/somewhere/index.txt 0000600 0001750 0001750 00000000270 10246051200 030163 0 ustar madduck madduck restindex
page-title: This is an Orphaned Page
crumb: Orphan
/restindex
=================
A Poor Orphan
=================
rest2web will render whole orphaned sections. rest2web-0.5.2~alpha+svn-r248.orig/docs/test_site/section4/index.txt 0000600 0001750 0001750 00000000101 10246051200 025020 0 ustar madduck madduck restindex
index-file: ../archive/strangeindex2.txt
/restindex rest2web-0.5.2~alpha+svn-r248.orig/docs/test_site/archive/ 0000700 0001750 0001750 00000000000 10644674642 023076 5 ustar madduck madduck rest2web-0.5.2~alpha+svn-r248.orig/docs/test_site/archive/strangeindex1.txt 0000600 0001750 0001750 00000007447 10247534203 026414 0 ustar madduck madduck restindex
format: html
page-title: Welcome to Section 3
crumb: Thirdy
link-title: Come and Explore Section 3
page-description:
This section comes directly before the fourth section, and directly after the second section. That makes it section 3.
/description
sectionlist: topic 1, topic 2, topic 3, Not Real,
section-title: , The Default Section
section-description:
I haven't included any links in the default section, but if you look in the source for this index page (if you can find it) - you will see how to include the default section in the ``sectionlist``, and give it a title and description.
This also makes the template more interesting - when it is handling ``sectionlist`` it has to cope with the fact that ``None`` is in it.
/description
section-description: topic 1
This is a description of the articles in topic 1.
/description
section-description: topic 2
This is a description of the articles in topic 2.
/description
section-description: topic 3
This is a description of the articles in topic 3.
/description
section-description: Not Real
This section only contains files that don't really exist. You ought to get **404** errors when you click on the links.
They are all pulled in from the file *restindex.txt* and illustrate how you can use **rest2web** to build indexes for content that it isn't actually building. Of course normally you'd set the target to be files that *do really exist*.
/description
/restindex
Section Number Three
Welcome to something.
These Are More Articles
A feature of this section is that the index page is in a different directory to the content. You probably wouldn't use it like this - but it has possibilities when using rest2web to only build part of a website. This is more of a test that the link logic works.
Funky Stuff Hey
<#
import urllib
blank = ' '
row = '%s %s '
entry = '%s'
sectlist = [(urllib.quote(section), section.title()) for section in sectionlist if section is not None]
if None in sectionlist:
sectlist.append(('Default', 'Default'))
index = 0
while index < len(sectlist):
entry_1 = entry % sectlist[index]
if index == len(sectlist)-1:
entry_2 = blank
else:
entry_2 = entry % sectlist[index+1]
print row % (entry_1, entry_2)
index += 2
#>
<#
indexblock = '''\
%s
%s
%s
'''
pageblock = '''\
%s
%s
'''
for section in sectionlist:
thepages = []
for page in sections[section]['pages']:
a_page = pageblock % (page['target'], page['link-title'], page['page-description'])
if type(a_page) is unicode:
a_page = a_page.encode('utf8')
thepages.append(a_page)
thepages = '\n'.join(thepages)
if section is None:
id = 'default'
else:
id = urllib.quote(section)
sect_title = sections[section]['title']
desc = sections[section]['description']
this_sect = indexblock % ( id, id, sect_title, desc, thepages)
print this_sect
#> rest2web-0.5.2~alpha+svn-r248.orig/docs/test_site/archive/strangeindex2.txt 0000600 0001750 0001750 00000001271 10307776104 026407 0 ustar madduck madduck restindex
target: ../section4/index.html
page-title: This is the Famous Section 4
crumb: Fourth of Course
page-description:
This really is the Famous Section 4.
/description
/restindex
==========================
An Index in reST Format
==========================
If this works properly `this is a link to a hidden section`__. Again, it illustrates a not so useful feature of rest2web. This is the fact that rest2web will continue to render subdirectories, even if the directories above had no content. Not only that, but the 'crumbs' still work.
This is a link to a page that isn't included__ in the index.
__ empty/somewhere/index.html
__ notincluded.html rest2web-0.5.2~alpha+svn-r248.orig/docs/test_site/section3/ 0000700 0001750 0001750 00000000000 10644674642 023204 5 ustar madduck madduck rest2web-0.5.2~alpha+svn-r248.orig/docs/test_site/section3/article3.txt 0000600 0001750 0001750 00000000622 10246051200 025426 0 ustar madduck madduck restindex
section: topic 3
/restindex
=============
Article 3
=============
This article has nearly the smallest restindex possible ! If it was in the 'default' section [#]_, it would have the smallest one possible.
.. [#] The *default section* is where articles without a section specified are put. In your index page template, you access the articles in this section using ``pages[None]``. rest2web-0.5.2~alpha+svn-r248.orig/docs/test_site/section3/index.txt 0000600 0001750 0001750 00000000101 10246051200 025017 0 ustar madduck madduck restindex
index-file: ../archive/strangeindex1.txt
/restindex rest2web-0.5.2~alpha+svn-r248.orig/docs/test_site/section3/restindex.txt 0000600 0001750 0001750 00000000605 10311246051 025731 0 ustar madduck madduck restindex
section: Not Real
target: not_real_1.html
crumb: The First
/restindex
restindex
section: Not Real
target: not_real_2.html
crumb: The Second
/restindex
restindex
section: Not Real
target: somewhere_else/not_real.html
crumb: The Third
/restindex
restindex
section: Not Real
target: ../not_real_at_all.html
crumb: The Last
/restindex
rest2web-0.5.2~alpha+svn-r248.orig/docs/test_site/section3/article2.txt 0000600 0001750 0001750 00000000250 10246051200 025422 0 ustar madduck madduck restindex
link-title: Another Article
section: topic 2
/restindex
=============
Article 2
=============
This is another article about nothing in particular. rest2web-0.5.2~alpha+svn-r248.orig/docs/test_site/section3/article1.txt 0000600 0001750 0001750 00000000237 10246051200 025426 0 ustar madduck madduck restindex
link-title: An Article
section: topic 1
/restindex
=============
An Article
=============
This is an article about nothing in particular. rest2web-0.5.2~alpha+svn-r248.orig/docs/test_site/section1/ 0000700 0001750 0001750 00000000000 10644674642 023202 5 ustar madduck madduck rest2web-0.5.2~alpha+svn-r248.orig/docs/test_site/section1/internet_article.txt 0000600 0001750 0001750 00000000647 10246051200 027260 0 ustar madduck madduck restindex
section: internet
link-title: Click here to be whisked away from it all.
page-description:
A very, very short article on the internet [#]_.
.. [#] Testing footnotes in page descriptions.
/description
crumb: Internet Article
/restindex
======================
Internet Article
======================
This is an article about the internet. Or at least it *could be*. rest2web-0.5.2~alpha+svn-r248.orig/docs/test_site/section1/index.txt 0000600 0001750 0001750 00000006357 10246051200 025040 0 ustar madduck madduck restindex
format: html
page-title: The Science Index Page
crumb: Science
link-title: Science, Computers, and Technology
page-description:
This section contains books and articles about the wonderful worlds of Science, Computing, and Technology.
/description
sectionlist: science, computers, internet
section-description: science
This is a description of the articles on science.
This description is written using **reST**. That means it can include links__.
__ http://docutils.sourceforge.net
/description
section-description: computers
This is also a description. It would be easy to extend the range of text markups that *rest2web* supported. If there was any demand we could allow html in the descriptions, and even extend the range of supported markups to include *sextile* and *textile*. This would make the name **rest2web** [#]_ less appropriate of course.
.. [#] Obviously reST is my preferred markup...
/description
section-description: internet
This is also a description.
/description
/restindex
The Science Index Page
Welcome to something.
These Are the Sections
So enjoy....
The Voidspace Science Sections
<#
import urllib
blank = ' '
row = '%s %s '
entry = '%s'
sectlist = [(urllib.quote(section), section.title()) for section in sectionlist if section is not None]
# note we use the variable sectionlist - to loop over the sections in the same order they appear
# in 'sectionlist' in the restindex. We also exclude ``None`` - the default section.
index = 0
while index < len(sectlist):
entry_1 = entry % sectlist[index]
if index == len(sectlist)-1:
entry_2 = blank
else:
entry_2 = entry % sectlist[index+1]
print row % (entry_1, entry_2)
index += 2
#>
<#
indexblock = '''\
%s
%s
%s
'''
pageblock = '''\
%s
%s
'''
for section in sections:
if section is None:
continue
thepages = []
for page in sections[section]['pages']:
a_page = pageblock % (page['target'], page['link-title'], page['page-description'])
if type(a_page) is unicode:
a_page = a_page.encode('utf8')
thepages.append(a_page)
thepages = '\n'.join(thepages)
id = urllib.quote(section)
sect_title = sections[section]['title']
desc = sections[section]['description']
this_sect = indexblock % ( id, id, sect_title, desc, thepages)
print this_sect
#>