diff options
author | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2006-01-09 20:44:25 +0000 |
---|---|---|
committer | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2006-01-09 20:44:25 +0000 |
commit | d77fdfef70e08114f57cbef5d91707df8717ea9f (patch) | |
tree | 49444e3486c0c333cb7b33dfa721296c08ee4ece /sandbox/gschwant/htmlnav | |
parent | 53cd16ca6ca5f638cbe5956988e88f9339e355cf (diff) | |
parent | 3993c4097756e9885bcfbd07cb1cc1e4e95e50e4 (diff) | |
download | docutils-0.4.tar.gz |
Release 0.4: tagging released revisiondocutils-0.4
git-svn-id: http://svn.code.sf.net/p/docutils/code/tags/docutils-0.4@4268 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'sandbox/gschwant/htmlnav')
-rw-r--r-- | sandbox/gschwant/htmlnav/README.txt | 183 | ||||
-rw-r--r-- | sandbox/gschwant/htmlnav/rst2htmlnav.py | 19 | ||||
-rw-r--r-- | sandbox/gschwant/htmlnav/setup.py | 21 | ||||
-rw-r--r-- | sandbox/gschwant/htmlnav/writer/htmlnav.py | 193 |
4 files changed, 0 insertions, 416 deletions
diff --git a/sandbox/gschwant/htmlnav/README.txt b/sandbox/gschwant/htmlnav/README.txt deleted file mode 100644 index 370a8991f..000000000 --- a/sandbox/gschwant/htmlnav/README.txt +++ /dev/null @@ -1,183 +0,0 @@ -================== - README: htmlnav_ -================== - ----------------------------------------------------------- -An HTML writer for docutils which supports navigation-bars ----------------------------------------------------------- - -:Author: Gunnar Schwant -:Contact: g.schwant@gmx.de -:Date: $Date$ - -.. contents:: - -Introduction -============ - -This is the writer which I use to build my homepage: http://schwant.gmxhome.de. -[#]_ The name **htmlnav** is a short term for *HTML with navigation-bars*. - -System Requirements -=================== - -Docutils and everything needed to use docutils has to be -installed. - -Installation -============ - -Perform the usual ``setup.py install`` procedure. - -Usage -===== - -Most parts of the writer are inherited from David Goodger's ``html4css1``. -In fact, if no ``.nav``-files do exist in the destination directory, it -produces the same output as David's writer. - -Short example -------------- - -1. Go to docutils' "``tools``"-directory and create a file called - "``left.nav``" with the following contents:: - - colors | #000000 | #8E8E8E - section | Home - link | Python | http://www.python.org - link | Docutils | http://docutils.sf.net - raw | <br> - raw | © 2003 MyCompany - -2. Process "``test.txt``" to HTML using "``rst2htmlnav.py``":: - - rst2htmlnav.py test.txt test.html - - Open "``test.html``" in your browser. You will notice the left - navigation-bar. - -3. Create a file called "``right.nav``" in docutils' "``tools``"-directory. - This time the contents are:: - - colors | #000000 | #8E8E8E - section | Contact - link | me@MyCompany.org | mailto:me@mycompany.org - -4. Now perform step 2 again and open "``test.html``" in your browser. - You will notice that there is a right navigation-bar now. - -5. Create a file called "``top.nav``" in docutils' "``tools``"-directory - with the following contents:: - - color | #C8DBEB - cornerpic | ../docs/rst/images/ball1.gif - link | Home | test.html - link | Python | http://www.python.org - link | Docutils | http://docutils.sf.net - link | Search | http://www.google.com - -6. Once again perform step 2 and open "``test.html``" in your browser. - Now a top navigation-bar is there, too. - -.nav-files ----------- - -In order to get navigation-bars in the output-page you have to create -``.nav``-files in the destination directory. There are 4 types of -``.nav``-files: - -[file].nav - This defines the left navigation-bar of the output-file ``[file].html``. - (``[file]`` is the name of the output-file without extension.) - -left.nav - This defines the left navigation-bar of all output-files for which - no ``[file].nav``-file is present. - -right.nav - This defines the right navigation-bar of all output-files. - -top.nav - This defines the top navigation-bar of all output-files. - -.. important:: At least one of the files ``[file].nav`` and ``left.nav`` - has to be present. Otherwise no navigation-bars will be - added to the output file. - -.nav-file-entries ------------------ - -``.nav``-files contain a one-liner for each navigation-bar-entry. -In general such a one-liner is of the form - -:: - - parameter | value 1 | value 2 - -These are the different types of parameters: - -color -~~~~~ - -:Used in: ``top.nav`` -:Value 1: Background-color of all navigation-bars. -:Value 2: Not used. -:Example: ``color | #8E8E8E`` sets the navigation-bars' background-color - to ``#8E8E8E``. (The default color is white.) - -colors -~~~~~~ - -:Used in: ``[file].nav``, ``left.nav``, ``right.nav`` -:Value 1: Background-color of section entries. -:Value 2: Background-color of any other (non-section) entry. -:Example: ``colors | #000000 | #8E8E8E`` sets the background-color to be - ``#000000`` (black) for sections to be ``#8E8E8E`` (gray) for - any other entry. - -cornerpic -~~~~~~~~~ - -:Used in: ``top.nav`` -:Value 1: Path to the graphics file which will be displayed in the upper - left corner of the top navigation-bar. (The *width* of a - corner-picture should be 150 pixel.) -:Value 2: Not used. -:Example: ``cornerpic | pics/home.png`` sets the path of the corner-picture - to ``pics/home.png``. - -raw -~~~ - -:Used in: ``[file].nav``, ``left.nav``, ``right.nav`` -:Value 1: Any kind of text. -:Value 2: Not used. -:Example: ``raw | <br>`` will create an empty cell (a spacer) in - the navigation-bar. - -section -~~~~~~~ - -:Used in: ``[file].nav``, ``left.nav``, ``right.nav`` -:Value 1: Title of the section. -:Value 2: Not used. -:Example: ``section | Home`` will create a section with title *Home* in - the navigation-bar. - -link -~~~~ - -:Used in: ``[file].nav``, ``left.nav``, ``right.nav``, ``top.nav`` -:Value 1: Text to be displayed. -:Value 2: URL -:Example: ``link | Docutils | http://docutils.sf.net`` creates a link to - Docutils' homepage in the navigation-bar. - -Footnotes -========= - -.. [#] Sorry, my homepage is in german language. However, even if you - don't understand what the text says, you'll get an impression of the - writers output. - -.. _htmlnav: writer/htmlnav.py
\ No newline at end of file diff --git a/sandbox/gschwant/htmlnav/rst2htmlnav.py b/sandbox/gschwant/htmlnav/rst2htmlnav.py deleted file mode 100644 index 7d68bfce8..000000000 --- a/sandbox/gschwant/htmlnav/rst2htmlnav.py +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env python - -# Author: Gunnar Schwant -# Contact: g.schwant@gmx.de -# Revision: $Revision$ -# Date: $Date$ -# Copyright: This module has been placed in the public domain. - -import locale -try: - locale.setlocale(locale.LC_ALL, '') -except: - pass - -from docutils.core import publish_cmdline, default_description - -description = (default_description) - -publish_cmdline(writer_name='htmlnav', description=description) diff --git a/sandbox/gschwant/htmlnav/setup.py b/sandbox/gschwant/htmlnav/setup.py deleted file mode 100644 index 22a200ce7..000000000 --- a/sandbox/gschwant/htmlnav/setup.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python - -from distutils.core import setup - -def do_setup(): - dist = setup( - name='html-with-navigation-bars-writer', - description='A HTML writer for Docutils which supports navigation bars', - url='http://docutils.sourceforg.net/sandbox/gschwant/htmlwnav/', - version='0.1', - author='Gunnar Schwant', - author_email='g.schwant@gmx.de', - license='Public Domain', - packages=['docutils.writers'], - package_dir={'docutils.writers':'writer'}, - scripts=['rst2htmlnav.py'] - ) - return dist - -if __name__ == '__main__': - do_setup() diff --git a/sandbox/gschwant/htmlnav/writer/htmlnav.py b/sandbox/gschwant/htmlnav/writer/htmlnav.py deleted file mode 100644 index 40b17b778..000000000 --- a/sandbox/gschwant/htmlnav/writer/htmlnav.py +++ /dev/null @@ -1,193 +0,0 @@ -# Author: Gunnar Schwant -# Contact: g.schwant@gmx.de -# Revision: $Revision$ -# Date: $Date$ -# Copyright: This module has been placed in the public domain. - -from docutils import writers, nodes, languages -import docutils, html4css1, os - -class Writer(html4css1.Writer): - - def __init__(self): - writers.Writer.__init__(self) - self.translator_class = HTMLTranslator - -class HTMLTranslator(html4css1.HTMLTranslator): - - def __init__(self, document): - html4css1.HTMLTranslator.__init__(self, document) - self.navigation_bgcolor = '#FFFFFF' - self.body_prefix = [self.get_body_prefix()] - self.body_suffix = [self.get_body_suffix()] - - def get_body_prefix(self): - navtop = os.path.join(os.path.split(self.settings._destination)[0], - 'top.nav') - navright = os.path.join(os.path.split(self.settings._destination)[0], - 'right.nav') - if os.path.exists(navright): - colspan = 3 - width = '70%' - else: - colspan = 2 - width = '85%' - navleft = '%s%s' % (os.path.splitext(self.settings._destination)[0], - '.nav') - bgcolor = color1 = color2 = self.navigation_bgcolor - cornerpic = None - if not os.path.exists(navleft): - navleft = os.path.join(os.path.split(self.settings._destination)[0], - 'left.nav') - if os.path.exists(navleft): - if os.path.exists(navtop): - f = open(navtop, 'rt') - lines = f.readlines() - f.close() - for line in lines: - val = line.split('|') - for i in range(len(val)): - val[i] = val[i].strip() - if val[0] == 'color': - bgcolor = color1 = color2 = val[1] - self.navigation_bgcolor = bgcolor - if val[0] == 'cornerpic': - cornerpic = val[1] - body_prefix = '<style type="text/css"><!--\n' \ - 'a.navigation, a.navigation-top { ' \ - 'text-decoration: none ; color: #000000 }\n' \ - 'a.navigation-top { font-weight: bold }\n' \ - 'a.navigation:hover, a.navigation-top:hover { ' \ - 'text-decoration: underline }\n' \ - 'table.navigation { font-size: 10pt ; ' \ - 'border-collapse: collapse ; border-width: 0pt ' \ - '; border-color: #FFFFFF }\n' \ - 'td.navigation { font-size: 8pt ; padding-left: ' \ - '0em ; padding-right: 0em }\n' \ - '--></style>\n</head>\n<body>\n<table width="100%" ' \ - 'class="navigation" border="0" cellspacing="0" ' \ - 'cellpadding="0">' - if os.path.exists(navtop): - body_prefix = body_prefix + '\n<tr><td width="15%" ' - body_prefix = '%s class="navigation" bgcolor="%s">' \ - % (body_prefix, bgcolor) - if cornerpic != None: - body_prefix = '%s\n<center><img src="%s"></center>' \ - % (body_prefix, cornerpic) - body_prefix = '%s\n</td><td bgcolor="%s" ' \ - 'class="navigation"> </td>' \ - '<td bgcolor="%s" colspan="%d" ' \ - 'class="navigation">' % (body_prefix, - bgcolor, bgcolor, - colspan) - body_prefix = body_prefix + '\n<table class="navigation" ' \ - 'width="100%" border="0" cellspacing="0" ' \ - 'cellpadding="0">' - body_prefix = '%s\n<tr align="left">' % body_prefix - for line in lines: - val = line.split('|') - for i in range(len(val)): - val[i] = val[i].strip() - if val[0] == 'link': - body_prefix = '%s\n<td class="navigation"><ul><li>' \ - '<a href="%s" class="navigation-top">' \ - '%s</a></li></ul></td>' \ - % (body_prefix, val[2], val[1]) - elif val[0] == 'raw': - body_prefix = '%s\n<td class="navigation">%s</td>' \ - % (body_prefix, val[1]) - body_prefix = '%s\n</tr></table></td></tr>' % body_prefix - f = open(navleft, 'rt') - lines = f.readlines() - f.close() - body_prefix = '%s\n<tr><td class="navigation" bgcolor="%s" ' \ - % (body_prefix, bgcolor) - body_prefix = body_prefix + ' width="15%" valign="top">' - body_prefix = body_prefix + '\n<table class="navigation" ' \ - 'width="100%" border="0" cellspacing="0" ' \ - 'cellpadding="3">' - for line in lines: - val = line.split('|') - for i in range(len(val)): - val[i] = val[i].strip() - if val[0] == 'colors': - (color1, color2) = (val[1], val[2]) - elif val[0] == 'link': - body_prefix = '%s\n<tr><td bgcolor="%s" ' \ - 'class="navigation"> <a href="%s" ' \ - 'class="navigation">%s</a></td></tr>' \ - % (body_prefix, color2, val[2], val[1]) - elif val[0] == 'section': - body_prefix = '%s\n<tr><td bgcolor="%s" ' \ - 'class="navigation"> <b>' \ - % (body_prefix, color1) - if color1 != bgcolor: - body_prefix = '%s<font color="#FFFFFF">%s</font>' \ - '</b></td></tr>' \ - % (body_prefix, val[1]) - else: - body_prefix = '%s%s</b></td></tr>' \ - % (body_prefix, val[1]) - elif val[0] == 'raw': - body_prefix = '%s\n<tr><td bgcolor="%s" ' \ - 'class="navigation"> %s</td></tr>' \ - % (body_prefix, color2, val[1]) - body_prefix = '%s\n</table>\n</td>\n<td ' \ - 'width="15"> </td>\n<td width="%s">' \ - % (body_prefix, width) - else: - body_prefix = '</head>\n<body>\n' - return body_prefix - - def get_body_suffix(self): - bgcolor = color1 = color2 = self.navigation_bgcolor - navleft = '%s%s' % (os.path.splitext(self.settings._destination)[0], - '.nav') - if not os.path.exists(navleft): - navleft = os.path.join(os.path.split(self.settings._destination)[0], - 'left.nav') - navright = os.path.join(os.path.split(self.settings._destination)[0], - 'right.nav') - if os.path.exists(navleft) and os.path.exists(navright): - f = open(navright, 'rt') - lines = f.readlines() - f.close() - body_suffix = '</td><td width="15"> </td>\n<td ' \ - 'class="navigation" width="15%" valign="top" ' - body_suffix = '%s bgcolor="%s">' % (body_suffix, bgcolor) - body_suffix = body_suffix + '\n<table class="navigation" ' \ - 'width="100%" border="0" cellspacing="0" ' \ - 'cellpadding="3">' - for line in lines: - val = line.split('|') - for i in range(len(val)): - val[i] = val[i].strip() - if val[0] == 'link': - body_suffix = '%s\n<tr><td bgcolor="%s" ' \ - 'class="navigation"> <a href="%s" ' \ - 'class="navigation">%s</a></td></tr>' \ - % (body_suffix, color2, val[2], val[1]) - elif val[0] == 'colors': - (color1, color2) = (val[1], val[2]) - elif val[0] == 'section': - body_suffix = '%s\n<tr><td bgcolor="%s" ' \ - 'class="navigation"> <b>' \ - % (body_suffix, color1) - if color1 != bgcolor: - body_suffix = '%s<font color="#FFFFFF">%s</font>' \ - '</b></td></tr>' \ - % (body_suffix, val[1]) - else: - body_suffix = '%s%s</b></td></tr>' % (body_suffix, - val[1]) - elif val[0] == 'raw': - body_suffix = '%s\n<tr><td bgcolor="%s" ' \ - 'class="navigation"> %s</td></tr>' \ - % (body_suffix, color2, val[1]) - body_suffix = '%s\n</table>\n</td></tr></table>\n</head>\n' \ - '</body>\n' % body_suffix - elif os.path.exists(navleft): - body_suffix = '</td></tr></table>\n</head>\n</body>\n' - else: - body_suffix = '</head>\n</body>\n' - return body_suffix |