[library-web/new-website-style] possibility to rewrite url in html documents



commit 6487d9adc5682676525de2d5dadd07e989c4a51d
Author: Frédéric Péters <fpeters 0d be>
Date:   Wed Mar 30 22:04:55 2011 +0530

    possibility to rewrite url in html documents

 data/overlay.xml.in     |    3 ++-
 data/xslt/html2html.xsl |   14 ++++++++++++++
 2 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/data/overlay.xml.in b/data/overlay.xml.in
index e45cd93..e985472 100644
--- a/data/overlay.xml.in
+++ b/data/overlay.xml.in
@@ -1159,7 +1159,8 @@
       <channel>devel</channel>
       <category>devel-guides</category>
       <href>http://live.gnome.org/DevGnomeOrg</href>
-      <attributes h2hmode="content-id" hidehref="true" extracss="moinmoin.css"/>
+      <attributes h2hmode="content-id" hidehref="true" extracss="moinmoin.css"
+                  rewritebase="http://live.gnome.org"; />
     </extrawikidocs>
 
   </documents>
diff --git a/data/xslt/html2html.xsl b/data/xslt/html2html.xsl
index 10948b2..e552889 100644
--- a/data/xslt/html2html.xsl
+++ b/data/xslt/html2html.xsl
@@ -33,6 +33,7 @@ along with libgo; if not, write to the Free Software Foundation, Inc.,
   <xsl:param name="default.encoding" select="'UTF-8'"/>
 
   <xsl:param name="libgo.extracss"/>
+  <xsl:param name="libgo.rewritebase"/>
   <xsl:param name="libgo.originalhref"/>
   <xsl:param name="libgo.h2hmode" select="'body'"/>
   <xsl:param name="libgo.hidehref" select="'false'"/>
@@ -200,6 +201,19 @@ along with libgo; if not, write to the Free Software Foundation, Inc.,
    </xsl:attribute>
   </xsl:template>
 
+  <xsl:template match="@href">
+   <xsl:attribute name="href">
+    <xsl:choose>
+     <xsl:when test="starts-with(., '/') and $libgo.rewritebase">
+       <xsl:value-of select="concat($libgo.rewritebase, .)"/>
+     </xsl:when>
+     <xsl:otherwise>
+       <xsl:value-of select="."/>
+     </xsl:otherwise>
+    </xsl:choose>
+   </xsl:attribute>
+  </xsl:template>
+
   <xsl:template match="meta[ content='text/html; charset=US-ASCII']">
   </xsl:template>
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]