summaryrefslogtreecommitdiff
path: root/xslt
diff options
context:
space:
mode:
authorShaun McCance <shaunm@redhat.com>2018-10-20 11:01:31 -0400
committerShaun McCance <shaunm@redhat.com>2018-10-20 11:01:31 -0400
commitb34a615ff6c04c638805d73de26ecf195852bbd8 (patch)
tree1ef4586007697fab473529f56c16c614f64bf573 /xslt
parent30a542d15625fc76495d4b50d1e896460c22a6cb (diff)
downloadyelp-xsl-b34a615ff6c04c638805d73de26ecf195852bbd8.tar.gz
Initial work on Mallard stacks
Diffstat (limited to 'xslt')
-rw-r--r--xslt/mallard/cache/mal-cache.xsl24
-rw-r--r--xslt/mallard/html/mal2html-links.xsl90
-rw-r--r--xslt/mallard/html/mal2html-page.xsl12
3 files changed, 113 insertions, 13 deletions
diff --git a/xslt/mallard/cache/mal-cache.xsl b/xslt/mallard/cache/mal-cache.xsl
index 3439f705..6305e0b9 100644
--- a/xslt/mallard/cache/mal-cache.xsl
+++ b/xslt/mallard/cache/mal-cache.xsl
@@ -56,8 +56,20 @@ mal.cache.info
<xsl:param name="node_in"/>
<info>
<xsl:for-each select="$info/*">
- <xsl:copy-of select="."/>
+ <xsl:choose>
+ <xsl:when test="$node/parent::mal:stack[@type = 'series'] and
+ self::mal:link[@type = 'next']"/>
+ <xsl:otherwise>
+ <xsl:copy-of select="."/>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:for-each>
+ <xsl:if test="$node/parent::mal:stack[@type = 'series']">
+ <xsl:variable name="next" select="$node/following-sibling::mal:page[1]"/>
+ <xsl:if test="$next">
+ <link type="next" xref="{$next/@id}"/>
+ </xsl:if>
+ </xsl:if>
</info>
</xsl:template>
@@ -67,7 +79,7 @@ mal.cache.info
<!-- = /cache:cache = -->
<xsl:template match='/cache:cache'>
<cache:cache>
- <xsl:for-each select="mal:page">
+ <xsl:for-each select="mal:page | mal:stack">
<xsl:apply-templates select="document(@cache:href)/*">
<xsl:with-param name="node_in" select="."/>
</xsl:apply-templates>
@@ -75,6 +87,14 @@ mal.cache.info
</cache:cache>
</xsl:template>
+<!-- = mal:stack = -->
+<xsl:template match="mal:stack">
+ <xsl:param name="node_in"/>
+ <xsl:apply-templates select="mal:page">
+ <xsl:with-param name="node_in" select="$node_in"/>
+ </xsl:apply-templates>
+</xsl:template>
+
<!-- = mal:page = -->
<xsl:template match="mal:page">
<xsl:param name="node_in"/>
diff --git a/xslt/mallard/html/mal2html-links.xsl b/xslt/mallard/html/mal2html-links.xsl
index 09b23e5f..7b63b4db 100644
--- a/xslt/mallard/html/mal2html-links.xsl
+++ b/xslt/mallard/html/mal2html-links.xsl
@@ -422,7 +422,7 @@ the links itself. They must be passed in with the $links parameter.
<!--**==========================================================================
mal2html.links.prevnext
Output links to the previous and next pages.
-@revision[version=1.0 date=2011-06-15 status=final]
+@revision[version=3.32 date=2018-10-20 status=final]
[xsl:params]
$node: A `links` or `page` element to link from.
@@ -432,6 +432,11 @@ if they exist. The block containing the links is end-floated by default. The
links use the text "Previous" and "Next", although the actual page titles are
used for tooltips.
+If $node is part of a series-type stack, this template uses the previous and
+next pages in the stack. Otherwise, the previous page is a page with a next-type
+link to $node, and the next page is whatever is pointed to by the next-type link
+in $node.
+
If the `links` element has the style hint `top`, it will be inserted before
the page title, instead of in its position on the page. This is handled by the
calling functions in {mal2html-page}.
@@ -445,9 +450,11 @@ calling functions in {mal2html-page}.
</xsl:call-template>
</xsl:variable>
<xsl:variable name="next" select="$page/mal:info/mal:link[@type='next']"/>
+ <xsl:variable name="stacknext"
+ select="$page[parent::mal:stack[@type='series']]/following-sibling::mal:page[1]"/>
<xsl:for-each select="$mal.cache">
<xsl:variable name="prev" select="key('mal.cache.link.key', concat('next:', $linkid))"/>
- <xsl:if test="$prev or $next">
+ <xsl:if test="$prev or $next or $stacknext">
<nav class="prevnext pagewide"><div class="inner">
<xsl:if test="$prev">
<a>
@@ -471,6 +478,27 @@ calling functions in {mal2html-page}.
</a>
</xsl:if>
<xsl:choose>
+ <xsl:when test="$stacknext">
+ <a>
+ <xsl:attribute name="href">
+ <xsl:call-template name="mal.link.target">
+ <xsl:with-param name="node" select="$stacknext"/>
+ <xsl:with-param name="xref" select="$stacknext/@id"/>
+ </xsl:call-template>
+ </xsl:attribute>
+ <xsl:attribute name="title">
+ <xsl:call-template name="mal.link.tooltip">
+ <xsl:with-param name="node" select="$stacknext"/>
+ <xsl:with-param name="xref" select="$stacknext/@id"/>
+ </xsl:call-template>
+ </xsl:attribute>
+ <xsl:for-each select="$page">
+ <xsl:call-template name="l10n.gettext">
+ <xsl:with-param name="msgid" select="'Next'"/>
+ </xsl:call-template>
+ </xsl:for-each>
+ </a>
+ </xsl:when>
<xsl:when test="$next">
<a>
<xsl:attribute name="href">
@@ -660,6 +688,8 @@ This template calls {mal2html.links.series.prev} and
<xsl:param name="node" select="."/>
<xsl:variable name="page" select="$node/ancestor-or-self::mal:page[last()]"/>
<xsl:variable name="title" select="$node/self::mal:links/mal:title"/>
+ <xsl:variable name="stitle"
+ select="$node/ancestor::mal:stack/mal:info/mal:title[@type='series']"/>
<xsl:variable name="style" select="concat(' ', $node/@style, ' ')"/>
<xsl:variable name="role" select="$node/self::mal:links/@role"/>
<div>
@@ -681,15 +711,22 @@ This template calls {mal2html.links.series.prev} and
</xsl:choose>
<xsl:call-template name="mal2html.ui.expander.class">
<xsl:with-param name="node" select="$node"/>
- <xsl:with-param name="hastitle" select="count($title) > 0"/>
+ <xsl:with-param name="hastitle" select="count($title) + count($stitle) > 0"/>
</xsl:call-template>
</xsl:attribute>
<xsl:call-template name="mal2html.ui.expander.data">
<xsl:with-param name="node" select="$node"/>
- <xsl:with-param name="hastitle" select="count($title) > 0"/>
+ <xsl:with-param name="hastitle" select="count($title) + count($stitle) > 0"/>
</xsl:call-template>
<div class="inner">
- <xsl:apply-templates mode="mal2html.block.mode" select="$title"/>
+ <xsl:choose>
+ <xsl:when test="count($title) > 0">
+ <xsl:apply-templates mode="mal2html.block.mode" select="$title[1]"/>
+ </xsl:when>
+ <xsl:when test="count($stitle) > 0">
+ <xsl:apply-templates mode="mal2html.block.mode" select="$stitle[1]"/>
+ </xsl:when>
+ </xsl:choose>
<div class="region">
<ul>
<xsl:call-template name="mal2html.links.series.prev">
@@ -774,7 +811,7 @@ to it.
<!--**==========================================================================
mal2html.links.series.next
Output following links to pages in a series.
-@revision[version=1.0 date=2011-06-15 status=final]
+@revision[version=3.32 date=2018-10-20 status=final]
[xsl:params]
$node: The current `page` element.
@@ -784,6 +821,9 @@ This template is called by {mal2html.links.series} to output the pages after
the starting page in the series. This template finds the next page for the page
$node. It outputs a link to that page, then calls itself recursively on that
page.
+
+If $node is part of a series-type stack, this template uses the next page in
+the stack. Otherwise, it looks for a next-type link in $node.
-->
<xsl:template name="mal2html.links.series.next">
<xsl:param name="node" select="."/>
@@ -795,7 +835,40 @@ page.
</xsl:call-template>
</xsl:variable>
<xsl:variable name="next" select="$node/mal:info/mal:link[@type='next']"/>
- <xsl:if test="$next">
+ <xsl:variable name="stacknext"
+ select="$node[parent::mal:stack[@type='series']]/following-sibling::mal:page[1]"/>
+ <xsl:choose>
+ <xsl:when test="$stacknext">
+ <xsl:for-each select="$mal.cache">
+ <li class="links">
+ <a>
+ <xsl:attribute name="href">
+ <xsl:call-template name="mal.link.target">
+ <xsl:with-param name="node" select="$stacknext"/>
+ <xsl:with-param name="xref" select="$stacknext/@id"/>
+ </xsl:call-template>
+ </xsl:attribute>
+ <xsl:attribute name="title">
+ <xsl:call-template name="mal.link.tooltip">
+ <xsl:with-param name="node" select="$stacknext"/>
+ <xsl:with-param name="xref" select="$stacknext/@id"/>
+ <xsl:with-param name="role" select="concat($role, ' series')"/>
+ </xsl:call-template>
+ </xsl:attribute>
+ <xsl:call-template name="mal.link.content">
+ <xsl:with-param name="node" select="$stacknext"/>
+ <xsl:with-param name="xref" select="$stacknext/@id"/>
+ <xsl:with-param name="role" select="concat($role, ' series')"/>
+ </xsl:call-template>
+ </a>
+ </li>
+ <xsl:call-template name="mal2html.links.series.next">
+ <xsl:with-param name="node" select="key('mal.cache.key', $stacknext/@id)"/>
+ <xsl:with-param name="links" select="$links"/>
+ </xsl:call-template>
+ </xsl:for-each>
+ </xsl:when>
+ <xsl:when test="$next">
<xsl:for-each select="$mal.cache">
<li class="links">
<a>
@@ -824,7 +897,8 @@ page.
<xsl:with-param name="links" select="$links"/>
</xsl:call-template>
</xsl:for-each>
- </xsl:if>
+ </xsl:when>
+ </xsl:choose>
</xsl:template>
diff --git a/xslt/mallard/html/mal2html-page.xsl b/xslt/mallard/html/mal2html-page.xsl
index f2ce208e..f673d1f3 100644
--- a/xslt/mallard/html/mal2html-page.xsl
+++ b/xslt/mallard/html/mal2html-page.xsl
@@ -35,6 +35,11 @@ This stylesheet contains templates to process Mallard `page` and `section`
elements, including implementations of the interfaces provided by the common
{html} stylesheet.
-->
+<xsl:template match="/">
+ <xsl:for-each select="mal:page | mal:stack/mal:page">
+ <xsl:call-template name="html.output"/>
+ </xsl:for-each>
+</xsl:template>
<!--@@==========================================================================
@@ -63,7 +68,8 @@ the `page` element. Information is extracted from the `info` element of $node.
-->
<xsl:template name="mal2html.page.about">
<xsl:param name="node" select="."/>
- <xsl:if test="$node/mal:info/mal:credit or $node/mal:info/mal:license">
+ <xsl:variable name="infos" select="$node/mal:info | $node/parent::mal:stack/mal:info"/>
+ <xsl:if test="$infos/mal:credit or $infos/mal:license">
<footer class="about ui-expander" role="contentinfo">
<div class="yelp-data yelp-data-ui-expander" data-yelp-expanded="false"/>
<div class="inner">
@@ -78,7 +84,7 @@ the `page` element. Information is extracted from the `info` element of $node.
</div>
<div class="region">
<div class="contents">
- <xsl:variable name="credits" select="$node/mal:info/mal:credit"/>
+ <xsl:variable name="credits" select="$infos/mal:credit"/>
<xsl:variable name="copyrights"
select="$credits[contains(concat(' ', @type, ' '), ' copyright ')]
[mal:years]"/>
@@ -147,7 +153,7 @@ the `page` element. Information is extracted from the `info` element of $node.
<div class="credits-blank"></div>
</div>
</xsl:if>
- <xsl:for-each select="$node/mal:info/mal:license">
+ <xsl:for-each select="$infos/mal:license">
<div class="license">
<div class="title">
<span class="title">