diff options
-rw-r--r-- | additions/content.css | 9 | ||||
-rw-r--r-- | additions/layout.css | 119 | ||||
-rwxr-xr-x | doit.sh | 1 | ||||
-rw-r--r-- | templates/du2html.xsl | 106 | ||||
-rw-r--r-- | templates/reST.xsl | 234 |
5 files changed, 350 insertions, 119 deletions
diff --git a/additions/content.css b/additions/content.css index 321a2d8..47b7742 100644 --- a/additions/content.css +++ b/additions/content.css @@ -1 +1,8 @@ -div.literal-block { white-space: pre } +div.footnote { + border-left: solid 1px black; + margin-left: 1px; +} + +div.caption { + font-style: italic; +} diff --git a/additions/layout.css b/additions/layout.css index b25faf7..4ae46d7 100644 --- a/additions/layout.css +++ b/additions/layout.css @@ -1,22 +1,117 @@ -body { font: normal 100% Times, Times New Roman, serif; } +div { + border: thin solid green; +} -h1 { font-family: Georgia, serif; font-size: 2em; margin: 0.5em; } -#title { max-width: 60em; margin: 0.2em auto;} +/* sticky footer */ -div { border: thin solid green; margin: 0.3em } +div { + margin: 0; + padding: 0; +} -span.title { font-size: 0.3em; display: block; float: right} +body { + font: normal 100%/1.375 Times, Times New Roman, serif; +} + +html, body { + height: 100%; +} + +#wrapper { + min-height: 100%; + margin: 0 auto -4em auto; +} + +#push { + height: 4em; +} + +#push { + clear: both; +} + +#footer { + margin: 0 auto; + height: 4em; + max-width: 58em; +} + +#wrapper { + max-width: 60em; /* leave "air" at the sides */ +} + +/* columns */ + +#main-col { + float: left; + width: 70%; +} + +#sidebar { + float: right; + width: 25%; +} + +/* title */ + +#title { + max-width: 60em; + margin: 0.2em auto; +} + +h1 { + font-family: Georgia, serif; + font-size: 2em; + line-height: 1.15; + margin: 0.5em; +} + +/* top boxes */ + +#tags, #alt-langs { + position: relative; + text-align: center; + width: 70%; + min-height: 1.5em; + margin: 0 auto; +} + +#tags ul, #tags li { + display: inline; + margin: 0.3em; + padding: 0; + border: none; + list-style: none +} -#tags { position: relative; text-align: center; max-width: 40em; float: left; } -#tags ul, #tags li { display: inline; margin: 0.3em; padding: 0; border: none; list-style: none } #tags li:before { content: '-' } #tags li:after { content: '-' } -#nav-links { position: relative; max-width: 15em; float: right; margin: 0 0 0.5em 0.5em; } -#nav-links dt, #nav-links dd { display: inline } +/* main content */ -#content { clear: left; max-width: 60em; margin: 2em auto 0 auto; } +#content { + width: 100%; + line-height: 1.35; +} + +#dates { + position: relative; + width: 80%; + margin: 0 auto; +} + +/* sidebar */ + +#nav-links, #nav-tags { + position: relative; +} + +#nav-links dt, #nav-links dd { display: inline } -#dates { position: relative; max-width: 60em; margin: 0 auto; } +/* boxes, misc */ -#nav-tags { position: absolute; max-width: 15em; right: 0; top :0; } +span.title { + font-size: 0.3em; + display: block; + float: right +} @@ -14,6 +14,7 @@ fi if [[ "$*" != '--clean' ]]; then rsync -r output/ /var/www/localhost/htdocs/ rsync -r additions/ /var/www/localhost/htdocs/ + rsync /usr/share/doc/docutils-*/html/html4css1.css /var/www/localhost/htdocs/ fi diff --git a/templates/du2html.xsl b/templates/du2html.xsl index 07521a6..6d30510 100644 --- a/templates/du2html.xsl +++ b/templates/du2html.xsl @@ -60,6 +60,15 @@ <t t="navlinks" l="it">Documenti correlati</t> <t t="navlinks" l="en">Related documents</t> <t t="navtags" l="it">Alcuni tag</t> <t t="navtags" l="en">Some tags</t> <t t="alltags" l="it">Tutti i tag</t> <t t="alltags" l="en">All tags</t> +<t t="attention" l="it">Attenzione!</t> <t t="attention" l="en">Attention!</t> +<t t="caution" l="it">Cautela!</t> <t t="caution" l="en">Caution!</t> +<t t="danger" l="it">!PERICOLO!</t> <t t="danger" l="en">!DANGER!</t> +<t t="error" l="it">Errore</t> <t t="error" l="en">Error</t> +<t t="hint" l="it">Suggerimento</t> <t t="hint" l="en">Hint</t> +<t t="important" l="it">Importante</t> <t t="important" l="en">Important</t> +<t t="note" l="it">Nota</t> <t t="note" l="en">Note</t> +<t t="tip" l="it">Trucco</t> <t t="tip" l="en">Tip</t> +<t t="warning" l="it">Avvertenza</t> <t t="warning" l="en">Warning</t> </x:variable> <x:variable name="const-tr" select="e:node-set($const-tr-rtf)/node()" /> @@ -95,7 +104,7 @@ <x:choose> <x:when test="@refuri and string(.)=string(@refuri)"> - <x:apply-templates select="wc:title-for($langs,ancestor::document/@source,@refuri)"/> + <x:apply-templates select="wc:title-for($langs,ancestor::document/@source,@refuri)/node()"/> </x:when> <x:otherwise> <x:apply-templates /> @@ -105,15 +114,30 @@ </x:template> <x:template match="target[@refid and not(@refuri)]"> - <a name="{@refid}"/> + <a name="{@refid}"> + <x:apply-templates/> + </a> </x:template> - <x:template match="target[@names and not(@refuri)]"> - <x:for-each select="s:split(@names,' ')/token"> - <a name="{.}"/> + <x:template match="target[@ids and not(@refuri)]"> + <x:variable name="this" select="."/> + <x:for-each select="s:split(@ids,' ')/token"> + <a name="{.}"> + <x:apply-templates select="$this/node()"/> + </a> </x:for-each> </x:template> + <x:template match="wc:title/title"> + <x:copy-of select="parent::node()"/> + <x:apply-templates/> + </x:template> + + <x:template match="*" mode="admonition-title"> + <x:variable name="n" select="local-name()"/> + <x:value-of select="$const-tr[@t=$n and @l=$language]"/> + </x:template> + <!-- qui ce ne freghiamo del @source, tanto viene usata solo per i documenti stand-alone --> @@ -122,6 +146,7 @@ <head> <title><x:value-of select="title"/></title> <link rel="stylesheet" type="text/css" href="/layout.css" /> + <link rel="stylesheet" type="text/css" href="/html4css1.css" /> <link rel="stylesheet" type="text/css" href="/content.css" /> <x:for-each select="docinfo/field[field_name='css']/field_body/*/list_item|docinfo/field[field_name='css']/field_body/paragraph"> <link rel="stylesheet" type="text/css" href="{normalize-space(.)}" /> @@ -134,30 +159,45 @@ <x:apply-templates select="docinfo" mode="nav-links" /> </head> <body> - <div id="title"> - <h1> - <x:apply-templates select="title/node()"/> - </h1> - <x:apply-templates select="docinfo" mode="tags" /> - <x:call-template name="alternate-langs" /> - <x:apply-templates select="docinfo" mode="nav-block" /> - </div> - <div id="content"> - <x:apply-templates/> - </div> - <x:call-template name="dates" /> - <div class="nav" id="nav-tags"> - <span class="title"><x:value-of select="$const-tr[@t='navtags' and @l=$language]" /></span> - <ul> - <li><x:call-template name="taglink"><x:with-param name="tag">software</x:with-param></x:call-template></li> - <x:if test="$language = 'it'"> <!-- non ci sono racconti in inglese, per ora --> - <li><x:call-template name="taglink"><x:with-param name="tag">racconti</x:with-param></x:call-template></li> + <div id="wrapper"> + <div id="title"> + <h1 class="title"> + <x:apply-templates select="title/node()"/> + </h1> + <x:if test="subtitle"> + <h2 class="subtitle"> + <x:apply-templates select="subtitle/node()"/> + </h2> </x:if> - <li><x:call-template name="taglink"><x:with-param name="tag">viaggi</x:with-param></x:call-template></li> - </ul> - <a href="{wc:dst-uri-for('/tags/')}"><x:value-of select="$const-tr[@t='alltags' and @l=$language]"/></a> - <hr /> - <a href="{wc:dst-uri-for('/contacts/')}"><x:value-of select="wc:title-for($language,$filename,'/contacts/')" /></a> + </div> + <div id="main-col"> + <x:apply-templates select="docinfo" mode="tags" /> + <x:call-template name="alternate-langs" /> + <div id="content"> + <x:apply-templates/> + </div> + <x:call-template name="dates" /> + </div> + <div id="sidebar"> + <x:apply-templates select="docinfo" mode="nav-block" /> + <div class="nav" id="nav-tags"> + <span class="title"><x:value-of select="$const-tr[@t='navtags' and @l=$language]" /></span> + <ul> + <li><x:call-template name="taglink"><x:with-param name="tag">software</x:with-param></x:call-template></li> + <x:if test="$language = 'it'"> <!-- non ci sono racconti in inglese, per ora --> + <li><x:call-template name="taglink"><x:with-param name="tag">racconti</x:with-param></x:call-template></li> + </x:if> + <li><x:call-template name="taglink"><x:with-param name="tag">viaggi</x:with-param></x:call-template></li> + </ul> + <a href="{wc:dst-uri-for('/tags/')}"><x:value-of select="$const-tr[@t='alltags' and @l=$language]"/></a> + <hr /> + <a href="{wc:dst-uri-for('/contacts/')}"><x:apply-templates select="wc:title-for($language,$filename,'/contacts/')/node()" /></a> + </div> + </div> + <div id="push"></div> + </div> + <div id="footer"> + blah blah blah blah </div> </body> </html> @@ -166,7 +206,7 @@ <x:template name="taglink"> <x:param name="tag"/> <a href="{wc:dst-uri-for(concat('/tags/',$tag,'/'))}"> - <x:value-of select="wc:title-for($language,$filename,concat('/tags/',$tag,'/'))"/> + <x:apply-templates select="wc:title-for($language,$filename,concat('/tags/',$tag,'/'))/node()"/> </a> </x:template> @@ -216,7 +256,7 @@ <dt> <span class="tag title"> <a href="{concat('/tags/',@name,'/')}"> - <x:apply-templates select="wc:title-for($language,$filename,concat('/tags/',@name,'/'))"/> + <x:apply-templates select="wc:title-for($language,$filename,concat('/tags/',@name,'/'))/node()"/> </a> </span> </dt> @@ -229,7 +269,7 @@ <x:template match="wc:doc"> <li> - <a class="tag doc" href="{@uri}"><x:apply-templates select="wc:title-for($language,$filename,@uri)"/></a> + <a class="tag doc" href="{@uri}"><x:apply-templates select="wc:title-for($language,$filename,@uri)/node()"/></a> (<span class="tag doc langs"><x:apply-templates/></span>) </li> </x:template> @@ -265,7 +305,7 @@ <li> <span class="tag"> <a href="{concat('/tags/',$tag-name,'/')}"> - <x:apply-templates select="wc:title-for($language,$filename,concat('/tags/',$tag-name,'/'))"/> + <x:apply-templates select="wc:title-for($language,$filename,concat('/tags/',$tag-name,'/'))/node()"/> </a> </span> </li> @@ -298,7 +338,7 @@ </dt> <dd class="nav-link-{$rel}"> <a class="nav-link-{$rel}" href="{normalize-space(.)}"> - <x:apply-templates select="wc:title-for($langs,ancestor::document/@source,normalize-space(.))"/> + <x:apply-templates select="wc:title-for($langs,ancestor::document/@source,normalize-space(.))/node()"/> </a> </dd> </x:template> diff --git a/templates/reST.xsl b/templates/reST.xsl index ecf3bd5..db6e93b 100644 --- a/templates/reST.xsl +++ b/templates/reST.xsl @@ -1,6 +1,8 @@ <!-- Copyright (c) 2006, Michael Alyn Miller <malyn@strangeGizmo.com>. All rights reserved. + + Modified by Gianni Ceccarelli <dakkar@thenautilus.net> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -35,18 +37,24 @@ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" - xmlns="http://www.w3.org/1999/xhtml"> + xmlns:e="http://exslt.org/common" + xmlns:s="http://exslt.org/strings" + xmlns="http://www.w3.org/1999/xhtml" + exclude-result-prefixes="e s" + > <xsl:template match="@classes"> - <xsl:attribute name="class"><xsl:value-of select="."/></xsl:attribute> + <xsl:param name="add" select="/.."/> + <xsl:if test=".|$add"> + <xsl:attribute name="class"><xsl:value-of select="."/> <xsl:value-of select="$add"/></xsl:attribute> + </xsl:if> </xsl:template> -<!-- Suppress the reST document title, information, and topic name. +<!-- Suppress the reST document title and information. These values should be pulled in by the main XSL template. --> <xsl:template match="/document/title" /> <xsl:template match="/document/docinfo" /> -<xsl:template match="/document/topic" /> <!-- Suppress all field lists. These are only used for 'special features' implemented by the author of the site-specific reST @@ -64,7 +72,19 @@ </xsl:template> <xsl:template match="literal"> - <tt><xsl:apply-templates /></tt> + <tt class="docutils literal"><span class="pre"><xsl:apply-templates /></span></tt> +</xsl:template> + +<xsl:template match="title_reference"> + <cite><xsl:apply-templates/></cite> +</xsl:template> + +<xsl:template match="superscript"> + <sup><xsl:apply-templates/></sup> +</xsl:template> + +<xsl:template match="subscript"> + <sub><xsl:apply-templates/></sub> </xsl:template> <xsl:template match="reference"> @@ -132,18 +152,22 @@ </xsl:template> <xsl:template match="line_block/line"> - <xsl:apply-templates /><br /> + <div class="line"><xsl:apply-templates /></div> </xsl:template> <xsl:template match="literal_block"> - <div class="literal-block {@classes}"><xsl:apply-templates /></div> + <pre class="literal-block {@classes}"><xsl:apply-templates /></pre> </xsl:template> <xsl:template match="literal_block/br"> <br /> </xsl:template> +<xsl:template match="doctest_block"> + <pre class="doctest-block {@classes}"><xsl:apply-templates /></pre> +</xsl:template> + <xsl:template match="paragraph"> <p><xsl:apply-templates select="@classes"/><xsl:apply-templates /></p> @@ -162,38 +186,23 @@ <xsl:apply-templates select="@classes"/> <xsl:apply-templates/> </blockquote> - - <xsl:if test="./attribution"> - <div class="cite {@classes}"> - <span class="cite_label {@classes}">Source: </span> - <cite class="{attribution/@classes}"><xsl:apply-templates select="attribution/*|attribution/text()" /></cite> - </div> - </xsl:if> </xsl:template> -<!-- Suppress block_quote/attribution elements since we grab the text of - the attribution from the block_quote template. --> -<xsl:template match="block_quote/attribution" /> - +<xsl:template match="block_quote/attribution" > + <p class="attribution {@classes}"> + <xsl:text>— </xsl:text> + <xsl:apply-templates /> + </p> +</xsl:template> <!-- Footnote references are wrapped in brackets ([..]) and enclosed in an anchor tag with the class "footnoteref". --> <xsl:template match="footnote_reference"> - <xsl:element name="a"> - <xsl:attribute name="class">footnoteref</xsl:attribute> - <xsl:attribute name="id"> - <xsl:text>footnote-backref-</xsl:text> - <xsl:value-of select="@ids" /> - </xsl:attribute> - <xsl:attribute name="href"> - <xsl:text>#footnote-</xsl:text> - <xsl:value-of select="@refid" /> - </xsl:attribute> - - <xsl:text>[</xsl:text> - <xsl:apply-templates /> - <xsl:text>]</xsl:text> - </xsl:element> + <a class="footnote-reference" id="{@ids}" href="#{@refid}"> + <xsl:text>[</xsl:text> + <xsl:apply-templates /> + <xsl:text>]</xsl:text> + </a> </xsl:template> <!-- The footnote itself is wrapped in a div tag with a class of @@ -201,41 +210,55 @@ "footnotereturn") that links back to the part of the document where the footnote appeared. --> <xsl:template match="footnote"> - <xsl:element name="div"> - <xsl:attribute name="class">footnote <xsl:value-of select="@classes"/></xsl:attribute> - <xsl:attribute name="id"> - <xsl:text>footnote-</xsl:text> - <xsl:value-of select="@ids" /> - </xsl:attribute> - - <xsl:element name="a"> - <xsl:attribute name="class">footnotereturn</xsl:attribute> - <xsl:attribute name="href"> - <xsl:text>#footnote-backref-</xsl:text> - <xsl:value-of select="@backrefs" /> - </xsl:attribute> - <xsl:attribute name="title"> - <xsl:text>return to content</xsl:text> - </xsl:attribute> - - <xsl:text>#</xsl:text> - <xsl:value-of select="label" /> - <xsl:text>: </xsl:text> - </xsl:element> - - <xsl:apply-templates /> - </xsl:element> + <xsl:variable name="label" select="label"/> + <xsl:variable name="backrefs" select="s:split(@backrefs,' ')/token"/> + <div class="footnote {@classes}" id="{@ids}"> + <xsl:choose> + <xsl:when test="count($backrefs) <= 1"> + <span class="label"><a class="fn-backref" href="$backrefs">[<xsl:value-of select="$label"/>]</a></span> + </xsl:when> + <xsl:otherwise> + <span class="label">[<xsl:value-of select="$label"/>]</span> + <em><xsl:text> (</xsl:text> + <xsl:for-each select="$backrefs"> + <a class="fn-backref" href="{.}" title="return to content"> + <xsl:value-of select="position()" /> + </a> + <xsl:if test="following-sibling::token">, </xsl:if> + </xsl:for-each> + <xsl:text>)</xsl:text></em> + </xsl:otherwise> + </xsl:choose> + <xsl:text> </xsl:text> + <xsl:apply-templates /> + </div> </xsl:template> <xsl:template match="footnote/label" /> <!-- Basic lists. --> +<xsl:template name="list-class"> + <xsl:attribute name="class"> + <xsl:value-of select="@enumtype"/> + <xsl:value-of select="@classes"/> + </xsl:attribute> +</xsl:template> + <xsl:template match="bullet_list"> - <ul><xsl:apply-templates select="@classes"/><xsl:apply-templates /></ul> + <ul> + <xsl:call-template name="list-class"/> + <xsl:apply-templates /> + </ul> </xsl:template> <xsl:template match="enumerated_list"> - <ol><xsl:apply-templates select="@classes"/><xsl:apply-templates /></ol> + <ol> + <xsl:call-template name="list-class"/> + <xsl:if test="@start"> + <xsl:attribute name="start"><xsl:value-of select="@start"/></xsl:attribute> + </xsl:if> + <xsl:apply-templates /> + </ol> </xsl:template> <!-- Basic list items. --> @@ -260,24 +283,29 @@ <dl><xsl:apply-templates select="@classes"/><xsl:apply-templates /></dl> </xsl:template> +<xsl:template match="definition_list_item"> + <xsl:apply-templates select="term|definition"/> +</xsl:template> + <xsl:template match="definition_list_item/term"> - <dt><xsl:apply-templates select="@classes"/><xsl:apply-templates /></dt> + <dt><xsl:apply-templates select="@classes"/><xsl:apply-templates /> <xsl:apply-templates select="../classifier"/></dt> </xsl:template> <xsl:template match="definition_list_item/definition"> <dd><xsl:apply-templates select="@classes"/><xsl:apply-templates /></dd> </xsl:template> +<xsl:template match="definition_list_item/classifier"> + <span class="classifier-delimiter">:</span> + <xsl:text> </xsl:text> + <span class="classifier"><xsl:apply-templates/></span> +</xsl:template> <!-- Option lists. --> <xsl:template match="option_list"> - <table class="option-list {@classes}" cellpadding="0" cellspacing="0"> - <tr> - <th>Option</th> - <th>Description</th> - </tr> - - <xsl:apply-templates /> + <table class="docutils option-list {@classes}" cellpadding="0" cellspacing="0"> + <col class="option" /><col class="description" /> + <xsl:apply-templates /> </table> </xsl:template> @@ -286,19 +314,21 @@ </xsl:template> <xsl:template match="option_group"> - <td> + <td class="option-group {@classes}"> <xsl:for-each select="option"> - <xsl:apply-templates select="." /><br /> + <xsl:apply-templates select="." /> + <xsl:if test="following-sibling::option">, </xsl:if> </xsl:for-each> </td> </xsl:template> <xsl:template match="option_group/option"> - <span class="option-string"><xsl:value-of select="option_string" /></span> + <kbd><span class="option"><xsl:value-of select="option_string" /></span> <xsl:if test="option_argument"> <span class="option-delimiter"><xsl:value-of select="option_argument/@delimiter" /></span> - <span class="option-argument"><xsl:value-of select="option_argument" /></span> + <var><span class="option-argument"><xsl:value-of select="option_argument" /></span></var> </xsl:if> + </kbd> </xsl:template> <xsl:template match="option_list_item/description"> @@ -326,6 +356,62 @@ </xsl:element> </xsl:template> +<xsl:template match="title" priority="-1"> + <h1 class="{@classes}"> + <xsl:apply-templates/> + </h1> +</xsl:template> + +<xsl:template match="subtitle" priority="-1"> + <h2 class="{@classes}"> + <xsl:apply-templates/> + </h2> +</xsl:template> + +<!-- admonitions --> + +<xsl:template match="attention|caution|danger|error|hint|important|note|tip|warning"> + <div class="{local-name()} {@classes}"> + <p class="admonition-title"><xsl:apply-templates select="." mode="admonition-title"/></p> + <xsl:apply-templates/> + </div> +</xsl:template> + +<xsl:template match="*" mode="admonition-title"><!-- to be overridden --> + <xsl:value-of select="local-name()"/> +</xsl:template> + +<xsl:template match="admonition"> + <div class="admonition {@classes}"> + <xsl:apply-templates/> + </div> +</xsl:template> + +<xsl:template match="admonition/title"> + <p class="admonition-title"><xsl:apply-templates/></p> +</xsl:template> + +<!-- other directives --> + +<xsl:template match="topic|sidebar"> + <div class="{local-name()} {@classes}"> + <xsl:if test="@ids"> + <xsl:attribute name="id"><xsl:value-of select="@ids"/></xsl:attribute> + <a name="{@ids}" /> + </xsl:if> + <xsl:apply-templates /> + </div> +</xsl:template> + +<xsl:template match="sidebar/title|sidebar/subtitle|topic/title|topic/subtitle"> + <p class="{local-name(parent::*)}-{local-name()} {@classes}"> + <xsl:apply-templates/> + </p> +</xsl:template> + +<xsl:template match="rubric"> + <p class="rubric {@classes}"><xsl:apply-templates/></p> +</xsl:template> <!-- Tables. @@ -341,8 +427,7 @@ A similar field exists for specifying the valign value. This field is called ":table-cell-valign:". --> <xsl:template match="table"> - <table> - <xsl:if test="@classes"><xsl:attribute name="class"><xsl:value-of select="@classes"/></xsl:attribute></xsl:if> + <table class="docutils {@classes}" border="1"> <xsl:apply-templates /> </table> </xsl:template> @@ -407,5 +492,8 @@ </xsl:element> </xsl:template> +<xsl:template match="transition"> + <hr /> +</xsl:template> </xsl:stylesheet> |