1 |
commit: 55104cea1b44b11984723dd3f61c06e823cbd7f5 |
2 |
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Feb 23 20:36:27 2020 +0000 |
4 |
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Feb 28 06:59:06 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=55104cea |
7 |
|
8 |
devbook.xsl: List sections in navigation dropdown. |
9 |
|
10 |
This aims at improving navigation by also listing the sections of the |
11 |
current chapter in the dropdown list. |
12 |
|
13 |
As before, list any first-level sub-documents (below a divider line). |
14 |
|
15 |
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org> |
16 |
|
17 |
devbook.xsl | 37 ++++++++++++++++++++++++++++++------- |
18 |
1 file changed, 30 insertions(+), 7 deletions(-) |
19 |
|
20 |
diff --git a/devbook.xsl b/devbook.xsl |
21 |
index 69a3b9a..ae25acb 100644 |
22 |
--- a/devbook.xsl |
23 |
+++ b/devbook.xsl |
24 |
@@ -358,7 +358,6 @@ |
25 |
<!-- TOC Tree --> |
26 |
<xsl:template match="contentsTree" name="contentsTree"> |
27 |
<xsl:param name="depth" select="0"/> |
28 |
- <xsl:param name="ulclass"/> |
29 |
<xsl:param name="maxdepth"> |
30 |
<xsl:choose> |
31 |
<xsl:when test="@maxdepth"><xsl:value-of select="@maxdepth"/></xsl:when> |
32 |
@@ -400,7 +399,7 @@ |
33 |
</xsl:for-each> |
34 |
</xsl:when> |
35 |
<xsl:otherwise> |
36 |
- <ul class="{$ulclass}"> |
37 |
+ <ul> |
38 |
<xsl:for-each select="document($doc_self)/guide/include"> |
39 |
<xsl:variable name="extraction_counter_node"> |
40 |
<xsl:call-template name="contentsTree"> |
41 |
@@ -531,11 +530,35 @@ |
42 |
<ul class="nav navbar-nav"> |
43 |
<li><a href="{concat($relative_path_depth_recursion, substring-after(substring-before(@link, '##'), '::'), 'index.html', substring-after(@link, '##'))}"><span class="fa fa-home"/>  Home</a></li> |
44 |
<li class="dropdown"> |
45 |
- <a href="#" class="dropdown-toggle" data-toggle="dropdown"><xsl:value-of select="/guide/chapter[1]/title"/> <span class="caret"></span></a> |
46 |
- <xsl:call-template name="contentsTree"> |
47 |
- <xsl:with-param name="maxdepth" select="1"/> |
48 |
- <xsl:with-param name="ulclass">dropdown-menu</xsl:with-param> |
49 |
- </xsl:call-template> |
50 |
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown"> |
51 |
+ <xsl:value-of select="/guide/chapter[1]/title"/> <span class="caret"></span> |
52 |
+ </a> |
53 |
+ <xsl:if test="/guide/chapter[1]/section or //contentsTree"> |
54 |
+ <ul class="dropdown-menu"> |
55 |
+ <!-- List sections of this chapter first. --> |
56 |
+ <xsl:for-each select="/guide/chapter[1]/section"> |
57 |
+ <xsl:variable name="anchor"> |
58 |
+ <xsl:call-template name="convert-to-anchor"> |
59 |
+ <xsl:with-param name="data" select="title"/> |
60 |
+ </xsl:call-template> |
61 |
+ </xsl:variable> |
62 |
+ <li><a class="reference" href="#{$anchor}"><xsl:value-of select="title"/></a></li> |
63 |
+ </xsl:for-each> |
64 |
+ <xsl:if test="//contentsTree"> |
65 |
+ <li class="divider"></li> |
66 |
+ <!-- List any sub-documents included at first level. |
67 |
+ We cannot call "contentsTree" directly, because it would |
68 |
+ insert another "ul" element. So, assign it to a variable, |
69 |
+ then copy only the "li" nodes. --> |
70 |
+ <xsl:variable name="contents"> |
71 |
+ <xsl:call-template name="contentsTree"> |
72 |
+ <xsl:with-param name="maxdepth" select="1"/> |
73 |
+ </xsl:call-template> |
74 |
+ </xsl:variable> |
75 |
+ <xsl:copy-of select="exslt:node-set($contents)/ul/li"/> |
76 |
+ </xsl:if> |
77 |
+ </ul> |
78 |
+ </xsl:if> |
79 |
</li> |
80 |
<li><xsl:call-template name="findPrevious"/></li> |
81 |
<li><xsl:call-template name="findNext"/></li> |