Skip to content

Commit

Permalink
Add parameter to leave out index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
kthoden committed Aug 27, 2021
1 parent d30fd7e commit dda70ac
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
6 changes: 5 additions & 1 deletion src/stylesheets/tei2html/tei2html_publ_frontpage_utils.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@
<xsl:text>link link--green</xsl:text>
</xsl:attribute>
<xsl:attribute name="href">
<xsl:text>./1/index.html</xsl:text>
<xsl:for-each select="//tei:body//tei:div[@type = 'chapter'][1]">
<xsl:call-template name="uri_from_frontpage">
<xsl:with-param name="with_index" select="false()"/>
</xsl:call-template>
</xsl:for-each>
</xsl:attribute>
<span class="link__label">READ ONLINE</span>
</xsl:element>
Expand Down
27 changes: 18 additions & 9 deletions src/stylesheets/tei2html/utils/numbering.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -245,45 +245,54 @@
</xsl:template>

<xsl:template name="uri_from_frontpage" as="xs:string">
<xsl:param name="with_index" as="xs:boolean" select="false()"/>
<xsl:variable name="chapter" select="ancestor-or-self::tei:div[@type = 'chapter']"/>
<xsl:variable name="chapter_nr" select="count($chapter/preceding-sibling::*) + 1"/>
<xsl:variable name="chapter_nr" select="count($chapter/preceding-sibling::*)"/>
<xsl:choose>
<xsl:when test="self::tei:div[@type ='chapter']">
<xsl:value-of select="concat('./', $chapter_nr , '/index.html')"/>
<xsl:value-of select="concat('./', $chapter_nr , if ($with_index) then '/index.html' else ())"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="container_id" as="xs:string"><xsl:call-template name="container_id"/></xsl:variable>
<xsl:value-of select="concat('./', $chapter_nr , '/index.html#', $container_id)"/>
<xsl:variable name="container_id" as="xs:string">
<xsl:call-template name="container_id"/>
</xsl:variable>
<xsl:value-of select="concat('./', $chapter_nr , if ($with_index) then '/index.html#' else '#' , $container_id)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template name="uri_from_chapter" as="xs:string">
<xsl:param name="with_index" as="xs:boolean" select="false()"/>
<xsl:variable name="chapter" select="ancestor-or-self::tei:div[@type = 'chapter']"/>
<xsl:variable name="chapter_nr" select="count($chapter/preceding-sibling::*)"/>
<xsl:choose>
<xsl:when test="self::tei:div[@type ='chapter']">
<xsl:value-of select="concat('../', $chapter_nr , '/index.html')"/>
<xsl:value-of select="concat('../', $chapter_nr , if ($with_index) then '/index.html' else ())"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="container_id" as="xs:string"><xsl:call-template name="container_id"/></xsl:variable>
<xsl:value-of select="concat('../', $chapter_nr , '/index.html#', $container_id)"/>
<xsl:variable name="container_id" as="xs:string">
<xsl:call-template name="container_id"/>
</xsl:variable>
<xsl:value-of select="concat('../', $chapter_nr , if ($with_index) then '/index.html#' else '#' , $container_id)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template name="full_uri_from_chapter" as="xs:string">
<xsl:param name="with_index" as="xs:boolean" select="false()"/>
<xsl:choose>
<xsl:when test="$platform_uri != ''">
<xsl:variable name="chapter" select="ancestor-or-self::tei:div[@type = 'chapter']"/>
<xsl:variable name="chapter_nr" select="count($chapter/preceding-sibling::*)"/>
<xsl:variable name="uri" select="concat($platform_uri, '/', $series, '/', $publication_number, '/', $chapter_nr , '/index.html')"/>
<xsl:variable name="uri" select="concat($platform_uri, '/', $series, '/', $publication_number, '/', $chapter_nr , if ($with_index) then '/index.html' else ())"/>
<xsl:choose>
<xsl:when test="self::tei:div[@type ='chapter']">
<xsl:value-of select="$uri"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="container_id" as="xs:string"><xsl:call-template name="container_id"/></xsl:variable>
<xsl:variable name="container_id" as="xs:string">
<xsl:call-template name="container_id"/>
</xsl:variable>
<xsl:value-of select="concat($uri, '#', $container_id)"/>
</xsl:otherwise>
</xsl:choose>
Expand Down

0 comments on commit dda70ac

Please sign in to comment.