Move tag list generation to a central template

This commit is contained in:
Reinhard Müller 2020-04-29 11:23:52 +02:00
parent 91e462d237
commit 5bcb9dc9d3
6 changed files with 38 additions and 27 deletions

View File

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:include href="sharebuttons.xsl" />
<xsl:include href="fsfe_sidebar.xsl" />
<xsl:include href="tags.xsl"/>
<xsl:include href="sharebuttons.xsl"/>
<xsl:include href="fsfe_sidebar.xsl"/>
<xsl:template name="fsfe_mainsection">
<xsl:element name="section">
@ -44,11 +45,7 @@
<xsl:with-param name="id" select="'tags'"/>
</xsl:call-template>
</xsl:element>
<ul class="tags">
<xsl:for-each select="/buildinfo/document/tags/tag[not(@key='front-page')]">
<li><a href="/tags/tagged-{@key}.{/buildinfo/@language}.html"><xsl:value-of select="."/></a></li>
</xsl:for-each>
</ul>
<xsl:apply-templates select="/buildinfo/document/tags"/>
</xsl:element>
</xsl:if> <!-- /tags -->

View File

@ -12,15 +12,12 @@
buildinfo/trlist|
buildinfo/fundraising|
buildinfo/localmenuset|
buildinfo/document/tags|
buildinfo/document/legal|
buildinfo/document/author|
buildinfo/document/date|
buildinfo/document/download|
buildinfo/document/followup"/>
<xsl:template match="set | tags | text"/>
<!-- For all other nodes, copy verbatim -->
<xsl:template match="@*|node()" priority="-1">
<xsl:copy>

27
build/xslt/tags.xsl Normal file
View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- ====================================================================== -->
<!-- Display a list of tags (below a news item or event entry) -->
<!-- ====================================================================== -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="tags">
<xsl:element name="ul">
<xsl:attribute name="class">tags</xsl:attribute>
<xsl:for-each select="tag[not(@key='front-page')]">
<xsl:element name="li">
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:text>/tags/tagged-</xsl:text>
<xsl:value-of select="@key"/>
<xsl:text>.</xsl:text>
<xsl:value-of select="/buildinfo/@language"/>
<xsl:text>.html</xsl:text>
</xsl:attribute>
<xsl:value-of select="."/>
</xsl:element><!-- a -->
</xsl:element><!-- li -->
</xsl:for-each>
</xsl:element><!-- ul -->
</xsl:template>
</xsl:stylesheet>

View File

@ -32,12 +32,7 @@
<xsl:apply-templates select="body/node()"/>
<!-- Tags -->
<xsl:element name="ul">
<xsl:attribute name="class">tags</xsl:attribute>
<xsl:for-each select="tags/tag[not(@key='front-page')]">
<li><a href="/tags/tagged-{@key}.{/buildinfo/@language}.html"><xsl:value-of select="."/></a></li>
</xsl:for-each>
</xsl:element>
<xsl:apply-templates select="tags"/>
</xsl:element>

View File

@ -6,11 +6,11 @@
xmlns:str="http://exslt.org/strings"
extension-element-prefixes="str">
<xsl:import href="build/xslt/fsfe_head.xsl" />
<xsl:import href="build/xslt/fsfe_body.xsl" />
<xsl:import href="build/xslt/gettext.xsl" />
<xsl:import href="build/xslt/static-elements.xsl" />
<xsl:import href="build/xslt/tagging.xsl" />
<xsl:include href="build/xslt/fsfe_head.xsl" />
<xsl:include href="build/xslt/fsfe_body.xsl" />
<xsl:include href="build/xslt/gettext.xsl" />
<xsl:include href="build/xslt/static-elements.xsl" />
<xsl:include href="build/xslt/tagging.xsl" />
<!-- HTML 5 compatibility doctype, since our XSLT parser doesn't support disabling output escaping -->
<xsl:output method="html" encoding="utf-8" indent="yes" doctype-system="about:legacy-compat" />

View File

@ -85,12 +85,7 @@
</xsl:element><!-- p -->
<!-- Tags -->
<xsl:element name="ul">
<xsl:attribute name="class">tags</xsl:attribute>
<xsl:for-each select="tags/tag[not(@key='front-page')]">
<li><a href="/tags/tagged-{@key}.{/buildinfo/@language}.html"><xsl:value-of select="."/></a></li>
</xsl:for-each>
</xsl:element>
<xsl:apply-templates select="tags"/>
</xsl:element>