Improve local menus
the build was successful Details

They now look much better (using a bootstrap navbar), allow for files
from multiple directories being included in a single menu (needed by the
news archive), and exclude all files name "*-template" (also needed by
the news archive).
This commit is contained in:
Reinhard Müller 2019-03-12 11:31:39 +01:00
parent 40f9044019
commit e6821ed35a
7 changed files with 135 additions and 70 deletions

View File

@ -25,7 +25,7 @@ $(SUBDIRS): .FORCE
# Handle local menus
# -----------------------------------------------------------------------------
MENUSOURCES := $(shell find -name '*.xhtml' | xargs grep -l '<localmenu.*</localmenu>' )
MENUSOURCES := $(shell find -name '*.xhtml' -not -name "*-template.*" | xargs grep -l '<localmenu.*</localmenu>' | sort)
all: localmenuinfo.en.xml
localmenuinfo.en.xml: ./tools/buildmenu.xsl $(MENUSOURCES)

View File

@ -5,60 +5,74 @@
<!-- Insert local menu -->
<xsl:template match="localmenu">
<xsl:variable name="set">
<xsl:choose><xsl:when test="@set">
<xsl:value-of select="@set"/>
</xsl:when><xsl:otherwise>
<xsl:text>0</xsl:text>
</xsl:otherwise></xsl:choose>
<xsl:variable name="dir">
<xsl:choose>
<xsl:when test="@dir">
<xsl:value-of select="@dir"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="/buildinfo/@dirname"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="dir"><xsl:value-of select="/buildinfo/@dirname"/></xsl:variable>
<xsl:variable name="language"><xsl:value-of select="/buildinfo/@language"/></xsl:variable>
<xsl:variable name="set">
<xsl:choose>
<xsl:when test="@set">
<xsl:value-of select="@set"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>default</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:element name="div">
<xsl:attribute name="class">localmenu</xsl:attribute>
<xsl:element name="p">
<xsl:text>[ </xsl:text>
<xsl:variable name="own_id">
<xsl:value-of select="@id"/>
</xsl:variable>
<xsl:for-each select="/buildinfo/document/set/localmenuitems/menu[@dir=$dir and @set=$set]">
<xsl:sort select="@id"/>
<xsl:variable name="language">
<xsl:value-of select="/buildinfo/@language"/>
</xsl:variable>
<xsl:variable name="style"><xsl:value-of select="@style"/></xsl:variable>
<xsl:variable name="id"><xsl:value-of select="@id"/></xsl:variable>
<xsl:variable name="localmenutext">
<xsl:choose><xsl:when test="/buildinfo/document/set/translate/lang_part[@dir=$dir and @id=$id and @language=$language]">
<xsl:element name="ul">
<xsl:attribute name="class">nav nav-tabs</xsl:attribute>
<xsl:for-each select="/buildinfo/document/set/localmenuitems/menu[@dir=$dir and @set=$set]">
<xsl:sort select="@id"/>
<xsl:variable name="id">
<xsl:value-of select="@id"/>
</xsl:variable>
<xsl:variable name="localmenutext">
<xsl:choose>
<xsl:when test="/buildinfo/document/set/translate/lang_part[@dir=$dir and @id=$id and @language=$language]">
<xsl:value-of select="/buildinfo/document/set/translate/lang_part[@dir=$dir and @id=$id and @language=$language]"/>
</xsl:when><xsl:otherwise>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="/buildinfo/document/set/translate/lang_part[@dir=$dir and @id=$id and @language='en']"/>
</xsl:otherwise></xsl:choose>
</xsl:variable>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:element name="span">
<xsl:attribute name="class">local_menu_item</xsl:attribute>
<xsl:choose> <xsl:when test="not(substring-before(concat(/buildinfo/@filename ,'.html'), string(.)))">
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="."/></xsl:attribute>
<xsl:value-of select="$localmenutext"/>
</xsl:element>
</xsl:when><xsl:otherwise>
<xsl:attribute name="href">bamboo</xsl:attribute>
<xsl:value-of select="$localmenutext"/>
</xsl:otherwise></xsl:choose>
</xsl:element>
<xsl:element name="li">
<xsl:attribute name="role">presentation</xsl:attribute>
<xsl:if test="position()!=last()">
<xsl:choose><xsl:when test="$style='number'">
<xsl:text> | </xsl:text>
</xsl:when><xsl:otherwise>
<xsl:text> ] [ </xsl:text>
</xsl:otherwise></xsl:choose>
<xsl:if test="$id=$own_id">
<xsl:attribute name="class">active</xsl:attribute>
</xsl:if>
</xsl:for-each>
<xsl:text> ]</xsl:text>
</xsl:element><!--end wrapper-->
</xsl:element>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="@dir"/>
<xsl:value-of select="."/>
</xsl:attribute>
<xsl:value-of select="$localmenutext"/>
</xsl:element>
</xsl:element><!-- /li -->
</xsl:for-each>
</xsl:element><!-- /ul -->
</xsl:template>
</xsl:stylesheet>

View File

@ -1,2 +1,3 @@
activities/*/project:[]
campaigns/*/project:[]
localmenuinfo:[]

View File

@ -1,2 +1,3 @@
activities/*/project:[]
campaigns/*/project:[]
localmenuinfo:[]

View File

@ -1,2 +1,3 @@
activities/*/project:[]
campaigns/*/project:[]
localmenuinfo:[]

View File

@ -30,7 +30,7 @@
</div>
</div>
<localmenu set="year" style="number" id=":YYYY:">:YYYY:</localmenu>
<localmenu dir="/news/" set="year" id=":YYYY:" link=":YYYY:/:YYYY:">:YYYY:</localmenu>
<h1 class="p-name">News Archive for :YYYY:</h1>

View File

@ -11,28 +11,59 @@
<!-- Only the English files defines the menu structure -->
<xsl:element name="localmenuitems">
<xsl:for-each select="/localmenuset/menuitem[@language='en']">
<xsl:element name="menu">
<xsl:attribute name="dir"><xsl:value-of select="dir" /></xsl:attribute>
<!-- Directory can be explicitly defined in the source file -->
<!-- and defaults to the directory the source file is in. -->
<xsl:attribute name="dir">
<xsl:choose>
<xsl:when test="localmenu/@dir">
<xsl:value-of select="localmenu/@dir"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="dir"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="set">
<xsl:choose><xsl:when test="localmenu/@set">
<xsl:value-of select="localmenu/@set" />
</xsl:when><xsl:otherwise>
<xsl:text>0</xsl:text>
</xsl:otherwise></xsl:choose>
<xsl:choose>
<xsl:when test="localmenu/@set">
<xsl:value-of select="localmenu/@set"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>default</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="id"><xsl:value-of select="localmenu/@id" /></xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="localmenu/@id"/>
</xsl:attribute>
<xsl:attribute name="style">
<xsl:choose><xsl:when test="localmenu/@style">
<xsl:value-of select="localmenu/@style" />
</xsl:when><xsl:otherwise>
<xsl:text>default</xsl:text>
</xsl:otherwise></xsl:choose>
<xsl:choose>
<xsl:when test="localmenu/@style">
<xsl:value-of select="localmenu/@style"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>default</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:value-of select="link" />
<!-- The content of the localmenuitem/menu element is the link, -->
<!-- relative to the directory given in the dir attribute. It -->
<!-- defaults to the filename of the source file without any -->
<!-- directory prefix, passed in as <link> element. -->
<xsl:choose>
<xsl:when test="localmenu/@link">
<xsl:value-of select="localmenu/@link"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="link"/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:for-each>
@ -43,20 +74,37 @@
<xsl:for-each select="/localmenuset/menuitem">
<xsl:element name="lang_part">
<xsl:attribute name="dir"><xsl:value-of select="dir" /></xsl:attribute>
<xsl:attribute name="set">
<xsl:choose><xsl:when test="localmenu/@set">
<xsl:value-of select="localmenu/@set" />
</xsl:when><xsl:otherwise>
<xsl:text>0</xsl:text>
</xsl:otherwise></xsl:choose>
<xsl:attribute name="dir">
<xsl:choose>
<xsl:when test="localmenu/@dir">
<xsl:value-of select="localmenu/@dir"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="dir"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="id"><xsl:value-of select="localmenu/@id" /></xsl:attribute>
<xsl:attribute name="language"><xsl:value-of select="@language" /></xsl:attribute>
<xsl:attribute name="set">
<xsl:choose>
<xsl:when test="localmenu/@set">
<xsl:value-of select="localmenu/@set"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>default</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:value-of select="localmenu" />
<xsl:attribute name="id">
<xsl:value-of select="localmenu/@id"/>
</xsl:attribute>
<xsl:attribute name="language">
<xsl:value-of select="@language"/>
</xsl:attribute>
<xsl:value-of select="localmenu"/>
</xsl:element>
</xsl:for-each>