You are viewing a plain text version of this content. The canonical link for it is here.
Posted to svn@forrest.apache.org by rg...@apache.org on 2005/10/29 14:13:24 UTC
svn commit: r329402 - in
/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.Daisy:
input.xmap resources/stylesheets/daisy-to-html.xsl
resources/stylesheets/navigation-to-siteSnippet.xsl
Author: rgardler
Date: Sat Oct 29 05:13:16 2005
New Revision: 329402
URL: http://svn.apache.org/viewcvs?rev=329402&view=rev
Log:
don't use absolute paths as this prevents the site being hosted anywhere other than the root of the server
Modified:
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.Daisy/input.xmap
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.Daisy/resources/stylesheets/daisy-to-html.xsl
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.Daisy/resources/stylesheets/navigation-to-siteSnippet.xsl
Modified: forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.Daisy/input.xmap
URL: http://svn.apache.org/viewcvs/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.Daisy/input.xmap?rev=329402&r1=329401&r2=329402&view=diff
==============================================================================
--- forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.Daisy/input.xmap (original)
+++ forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.Daisy/input.xmap Sat Oct 29 05:13:16 2005
@@ -42,7 +42,9 @@
<map:part src="cocoon://{1}.daisy.source" />
<map:part src="{lm:daisy.siteSnippetFor.{1}}" />
</map:aggregate>
- <map:transform src="{lm:daisy.transform.daisy.html}"/>
+ <map:transform src="{lm:daisy.transform.daisy.html}">
+ <map:parameter name="documentPath" value="{0}"/>"/>
+ </map:transform>
<map:transform src="{lm:transform.html.document}"/>
<map:select type="exists">
<map:when test="{project:resources.stylesheets}/daisy/postFilter.xsl">
Modified: forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.Daisy/resources/stylesheets/daisy-to-html.xsl
URL: http://svn.apache.org/viewcvs/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.Daisy/resources/stylesheets/daisy-to-html.xsl?rev=329402&r1=329401&r2=329402&view=diff
==============================================================================
--- forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.Daisy/resources/stylesheets/daisy-to-html.xsl (original)
+++ forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.Daisy/resources/stylesheets/daisy-to-html.xsl Sat Oct 29 05:13:16 2005
@@ -23,6 +23,11 @@
xmlns:nav="http://outerx.org/daisy/1.0#navigationspec"
version="1.0">
+
+ <!-- The path to the current document, used to calculate the path
+ to the site root when working out paths in links -->
+ <xsl:param name="documentPath"/>
+
<!-- The pathPrefix is added to the start of all resolved Daisy links
It must include a trailing slash if it is non-empty -->
<xsl:param name="pathPrefix">/</xsl:param>
@@ -159,6 +164,12 @@
</xsl:template>
<xsl:template match="a">
+ <xsl:variable name="pathToRoot">
+ <xsl:call-template name="dotdots">
+ <xsl:with-param name="path"><xsl:value-of select="$documentPath"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:variable>
+
<xsl:choose>
<xsl:when test="starts-with(@href, 'daisy:')">
<xsl:variable name="docId"><xsl:value-of select="substring-after(@href, 'daisy:')"/></xsl:variable>
@@ -166,7 +177,7 @@
<xsl:value-of select="$pathPrefix"/>
<xsl:for-each select="//daisyDocument/descendant::doc[@id=$docId][1]/ancestor::group|//daisyDocument/descendant::doc[@id=$docId][1]/ancestor::doc[@nodeId]"><xsl:value-of select="@href"/></xsl:for-each>
</xsl:variable>
- <xsl:variable name="url"><xsl:value-of select="$path"/><xsl:value-of select="//node()[@id=$docId]/@href"/></xsl:variable>
+ <xsl:variable name="url"><xsl:value-of select="$pathToRoot"/><xsl:value-of select="$path"/><xsl:value-of select="//doc[@id=$docId]/@href"/></xsl:variable>
<a>
<xsl:choose>
<xsl:when test="contains($url, '#')">
@@ -218,6 +229,27 @@
<xsl:copy>
<xsl:apply-templates select="@*|*|text()|processing-instruction()|comment()"/>
</xsl:copy>
+ </xsl:template>
+
+ <!-- FIXME: this should come from include of dotdots.xsl in forest core -->
+ <xsl:template name="dotdots">
+ <xsl:param name="path"/>
+ <xsl:variable name="dirs" select="normalize-space(translate(concat($path, 'x'), ' /\', '_ '))"/>
+ <!-- The above does the following:
+ o Adds a trailing character to the path. This prevents us having to deal
+ with the special case of ending with '/'
+ o Translates all directory separators to ' ', and normalize spaces,
+ cunningly eliminating duplicate '//'s. We also translate any real
+ spaces into _ to preserve them.
+ -->
+ <xsl:variable name="remainder" select="substring-after($dirs, ' ')"/>
+ <xsl:if test="$remainder">
+ <xsl:text>../</xsl:text>
+ <xsl:call-template name="dotdots">
+ <xsl:with-param name="path" select="translate($remainder, ' ', '/')"/>
+ <!-- Translate back to /'s because that's what the template expects. -->
+ </xsl:call-template>
+ </xsl:if>
</xsl:template>
</xsl:stylesheet>
Modified: forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.Daisy/resources/stylesheets/navigation-to-siteSnippet.xsl
URL: http://svn.apache.org/viewcvs/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.Daisy/resources/stylesheets/navigation-to-siteSnippet.xsl?rev=329402&r1=329401&r2=329402&view=diff
==============================================================================
--- forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.Daisy/resources/stylesheets/navigation-to-siteSnippet.xsl (original)
+++ forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.Daisy/resources/stylesheets/navigation-to-siteSnippet.xsl Sat Oct 29 05:13:16 2005
@@ -37,14 +37,7 @@
<doc>
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
<xsl:attribute name="label">Section Home</xsl:attribute>
- <xsl:choose>
- <xsl:when test="@nodeId">
- <xsl:attribute name="href"><xsl:value-of select="@nodeId"/>.html</xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="href"><xsl:value-of select="@id"/>.html</xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
+ <xsl:attribute name="href">../<xsl:value-of select="@nodeId"/>.html</xsl:attribute>
</doc>
<xsl:apply-templates/>
</group>