Improve local menus
All checks were successful
the build was successful

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:
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 # 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 all: localmenuinfo.en.xml
localmenuinfo.en.xml: ./tools/buildmenu.xsl $(MENUSOURCES) localmenuinfo.en.xml: ./tools/buildmenu.xsl $(MENUSOURCES)

View File

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

View File

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

View File

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

View File

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

View File

@@ -30,7 +30,7 @@
</div> </div>
</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> <h1 class="p-name">News Archive for :YYYY:</h1>

View File

@@ -11,28 +11,59 @@
<!-- Only the English files defines the menu structure --> <!-- Only the English files defines the menu structure -->
<xsl:element name="localmenuitems"> <xsl:element name="localmenuitems">
<xsl:for-each select="/localmenuset/menuitem[@language='en']"> <xsl:for-each select="/localmenuset/menuitem[@language='en']">
<xsl:element name="menu"> <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:attribute name="set">
<xsl:choose><xsl:when test="localmenu/@set"> <xsl:choose>
<xsl:value-of select="localmenu/@set" /> <xsl:when test="localmenu/@set">
</xsl:when><xsl:otherwise> <xsl:value-of select="localmenu/@set"/>
<xsl:text>0</xsl:text> </xsl:when>
</xsl:otherwise></xsl:choose> <xsl:otherwise>
<xsl:text>default</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute> </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:attribute name="style">
<xsl:choose><xsl:when test="localmenu/@style"> <xsl:choose>
<xsl:value-of select="localmenu/@style" /> <xsl:when test="localmenu/@style">
</xsl:when><xsl:otherwise> <xsl:value-of select="localmenu/@style"/>
<xsl:text>default</xsl:text> </xsl:when>
</xsl:otherwise></xsl:choose> <xsl:otherwise>
<xsl:text>default</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute> </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:element>
</xsl:for-each> </xsl:for-each>
@@ -43,20 +74,37 @@
<xsl:for-each select="/localmenuset/menuitem"> <xsl:for-each select="/localmenuset/menuitem">
<xsl:element name="lang_part"> <xsl:element name="lang_part">
<xsl:attribute name="dir"><xsl:value-of select="dir" /></xsl:attribute> <xsl:attribute name="dir">
<xsl:choose>
<xsl:attribute name="set"> <xsl:when test="localmenu/@dir">
<xsl:choose><xsl:when test="localmenu/@set"> <xsl:value-of select="localmenu/@dir"/>
<xsl:value-of select="localmenu/@set" /> </xsl:when>
</xsl:when><xsl:otherwise> <xsl:otherwise>
<xsl:text>0</xsl:text> <xsl:value-of select="dir"/>
</xsl:otherwise></xsl:choose> </xsl:otherwise>
</xsl:choose>
</xsl:attribute> </xsl:attribute>
<xsl:attribute name="id"><xsl:value-of select="localmenu/@id" /></xsl:attribute> <xsl:attribute name="set">
<xsl:attribute name="language"><xsl:value-of select="@language" /></xsl:attribute> <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:element>
</xsl:for-each> </xsl:for-each>