forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephan E. Schlierf" <stephan.schli...@vsa.de>
Subject FYI: Beautifying the output of cvs keywords in generated sites
Date Mon, 03 Nov 2003 12:01:35 GMT
Hi,

a couple of weeks ago I asked how one can get at it that generated sites 
(html, pdf) show cvs keywords.
At the first step I maneged it to get them shown but I was unsatisfied 
with the output; it looked something like "$Revision: 1.9" or "$Date: 
2003/11/01 10:17:23$"
So I tried to beautify it and after soem testing (more or less trial and 
error ;-)) I found the following solution:
Given you have a <version>-element in your document that looks like this:
<version>$Revision$ vom $Date$</version> ("vom" is just a filler)

For HTML pages (I use the krysalis skin and Forrest 0.5):

In document2html.xsl:

After
<xsl:if test="header/authors">
...
</xsl:if>
add the following lines to document2html.xsl:

<xsl:if test="header/version">
   <xsl:variable name="cvs_string" select="header/version"/>
   <xsl:variable name="cvs_revision"
        select="substring-before($cvs_string, 'vom')"/>
   <xsl:variable name="cvs_datum"
        select="substring-after($cvs_string, 'vom')"/>
   <xsl:variable name="cvs_revision"
        select="translate($cvs_revision, '$Revision:', '')"/>
   <xsl:variable name="cvs_revision"
        select="translate($cvs_revision, '$', '')"/>
   <xsl:variable name="cvs_datum"
        select="translate($cvs_datum, '$Date:', '')"/>
   <xsl:variable name="cvs_datum"
        select="translate($cvs_datum, '$', '')"/>
   <xsl:variable name="cvs_datum"
        select="normalize-space($cvs_datum)"/>
   <xsl:variable name="cvs_datum"
        select="concat(substring($cvs_datum, 9, 2), '.',
                substring($cvs_datum, 6, 2), '.',
                substring($cvs_datum, 1, 4), ', ',
                substring($cvs_datum, 12, 2), ':',
                substring($cvs_datum, 14, 2), ' Uhr')"/>
   <p align="right">
     <font size="-2">
       <xsl:for-each select="header/version">
         <xsl:value-of select="concat('Version ', $cvs_revision, ' vom ',
                                      $cvs_datum)"/>
       </xsl:for-each>
     </font>
   </p>
</xsl:if>

At the end of document2html.xsl add (just before </xsl:stylesheet>
<xsl:template match="version">
   <xsl:apply-imports/>
</xsl:template>

This gives you something like "Version 1.9 vom 01.11.2003, 10:17 Uhr"

For PDF-pages I decided to have the cvs keywords just after the title of 
the document and at every footer.
So for the footer I modified footerinfo.xls as follows:

<xsl:variable name="cvs_string" select="header/version"/>
<xsl:variable name="cvs_revision"
      select="substring-before($cvs_string, 'vom')"/>
<xsl:variable name="cvs_datum"
      select="substring-after($cvs_string, 'vom')"/>
<xsl:variable name="cvs_revision"
      select="translate($cvs_revision, '$Revision:', '')"/>
<xsl:variable name="cvs_revision"
      select="translate($cvs_revision, '$', '')"/>
<xsl:variable name="cvs_datum"
      select="translate($cvs_datum, '$Date:', '')"/>
<xsl:variable name="cvs_datum" select="translate($cvs_datum, '$', '')"/>
<xsl:variable name="cvs_datum" select="normalize-space($cvs_datum)"/>
<xsl:variable name="cvs_datum"
      select="concat(substring($cvs_datum, 9, 2), '.',
        substring($cvs_datum, 6, 2), '.', substring($cvs_datum, 1, 4))"/>
just before the
<xsl:variable name="url" select="$pdfcredit/url"/> declaration.

And in
<xsl:if test="not($url)">
...
</xsl:if>
I added the following block:
<fo:block font-size="8pt" text-align="center" color="lightgrey">
   <xsl:value-of select="concat('Version ', $cvs_revision, ' vom ',
                         $cvs_datum)"/>
</fo:block>
just after
<fo:block text-align="center" color="lightgrey">
   <xsl:value-of select="$text"/>
</fo:block>

For the title is was a little bit more tricky: my document2fo.xsl now 
looks like this:

[...]

<xsl:template match="document">
   <xsl:variable name="cvs_string" select="header/version"/>
   <xsl:variable name="cvs_revision"
     select="substring-before($cvs_string, 'vom')"/>
   <xsl:variable name="cvs_datum"
     select="substring-after($cvs_string, 'vom')"/>
   <xsl:variable name="cvs_revision"
     select="translate($cvs_revision, '$Revision:', '')"/>
   <xsl:variable name="cvs_revision"
     select="translate($cvs_revision, '$', '')"/>
   <xsl:variable name="cvs_datum"
     select="translate($cvs_datum, '$Date:', '')"/>
   <xsl:variable name="cvs_datum"
     select="translate($cvs_datum, '$', '')"/>
   <xsl:variable name="cvs_datum"
     select="normalize-space($cvs_datum)"/>
   <xsl:variable name="cvs_datum"
     select="concat(substring($cvs_datum, 9, 2), '.',
       substring($cvs_datum, 6, 2), '.', substring($cvs_datum, 1, 4))"/>

   [...]

   <fo:flow flow-name="xsl-region-body">
     <fo:block
         padding-before="20pt"
         padding-after="20pt"
         font-size="24pt"
         font-weight="bold"
         id="{generate-id()}">
       <xsl:value-of select="header/title"/>
     </fo:block>

     <fo:block
         text-align="justify"
         padding-before="18pt"
         padding-after="18pt">
       <xsl:value-of select="concat('Version ', $cvs_revision, ' vom ',
                                     $cvs_datum)"/>
     </fo:block>
     <xsl:apply-templates/>
   </fo:flow>
</xsl:template>


If someone is interested: Feel free to beautfiy my code ;-)

Stephan


Mime
View raw message