aboutsummaryrefslogtreecommitdiff
path: root/source/02_meta
diff options
context:
space:
mode:
authorAdrian Kummerlaender2014-12-09 19:03:28 +0100
committerAdrian Kummerlaender2014-12-09 19:03:28 +0100
commit299dbbb58f9b6c6c85563bba4d1e43ae514a7949 (patch)
tree30a77680fb5d015648c1be639312cfb8f2a9bcfe /source/02_meta
parent1b9a49bacf15c72c093b7e6de79b408c28e5b904 (diff)
downloadblog.kummerlaender.eu-299dbbb58f9b6c6c85563bba4d1e43ae514a7949.tar
blog.kummerlaender.eu-299dbbb58f9b6c6c85563bba4d1e43ae514a7949.tar.gz
blog.kummerlaender.eu-299dbbb58f9b6c6c85563bba4d1e43ae514a7949.tar.bz2
blog.kummerlaender.eu-299dbbb58f9b6c6c85563bba4d1e43ae514a7949.tar.lz
blog.kummerlaender.eu-299dbbb58f9b6c6c85563bba4d1e43ae514a7949.tar.xz
blog.kummerlaender.eu-299dbbb58f9b6c6c85563bba4d1e43ae514a7949.tar.zst
blog.kummerlaender.eu-299dbbb58f9b6c6c85563bba4d1e43ae514a7949.zip
Replaced function-like data resolution with template applications
* e.g. article and tag support data is now fetched through direct _XPath_ template applications ** this required the introduction of a special `resolve` mode to prevent interaction between support and main content resolution ** in most cases arguments had to be wrapped inside helper constants to enable selection of e.g. article support data via the `@handle` attribute using the current elements `@handle` attribute * analogously to the recent changes in _StaticXSLT_ this commit aims to improve the XSLT code style used in generating this static website
Diffstat (limited to 'source/02_meta')
-rw-r--r--source/02_meta/articles.xsl34
-rw-r--r--source/02_meta/categories.xsl20
-rw-r--r--source/02_meta/tags.xsl28
3 files changed, 35 insertions, 47 deletions
diff --git a/source/02_meta/articles.xsl b/source/02_meta/articles.xsl
index 1a8b8fa..f91ff1e 100644
--- a/source/02_meta/articles.xsl
+++ b/source/02_meta/articles.xsl
@@ -11,31 +11,27 @@
<target mode="plain" value="articles.xml"/>
</xsl:variable>
-<xsl:key name="years" match="datasource/articles/entry/date/year/text()" use="." />
+<xsl:key name="years" match="datasource/articles/entry/date/year/text()" use="."/>
+
+<xsl:template match="articles/entry" mode="resolve">
+ <article handle="{@handle}">
+ <title>
+ <xsl:value-of select="title"/>
+ </title>
+ <date>
+ <xsl:value-of select="date/full"/>
+ </date>
+ </article>
+</xsl:template>
<xsl:template match="articles">
<xsl:for-each select="entry/date/year/text()[generate-id() = generate-id(key('years',.)[1])]">
+ <xsl:variable name="year" select="."/>
+
<entry handle="{.}">
- <xsl:call-template name="get_articles">
- <xsl:with-param name="year" select="."/>
- </xsl:call-template>
+ <xsl:apply-templates select="$root/articles/entry[./date/year = $year]" mode="resolve"/>
</entry>
</xsl:for-each>
</xsl:template>
-<xsl:template name="get_articles">
- <xsl:param name="year"/>
-
- <xsl:for-each select="/datasource/articles/entry[date/year = $year]">
- <article handle="{@handle}">
- <title>
- <xsl:value-of select="title"/>
- </title>
- <date>
- <xsl:value-of select="date/full"/>
- </date>
- </article>
- </xsl:for-each>
-</xsl:template>
-
</xsl:stylesheet>
diff --git a/source/02_meta/categories.xsl b/source/02_meta/categories.xsl
index 1a06aa1..ea8593b 100644
--- a/source/02_meta/categories.xsl
+++ b/source/02_meta/categories.xsl
@@ -15,17 +15,13 @@
<target mode="plain" value="categories.xml"/>
</xsl:variable>
-<xsl:template name="get_page_data">
- <xsl:param name="handle"/>
-
- <xsl:variable name="page" select="$root/pages/entry[@handle = $handle]"/>
-
- <page handle="{$handle}">
+<xsl:template match="pages/entry" mode="resolve">
+ <page handle="{@handle}">
<title>
- <xsl:value-of select="$page/title"/>
+ <xsl:value-of select="title"/>
</title>
- <digest size="{string-length($page/content/p[1])}">
- <xsl:copy-of select="$page/content/p[1]/node()"/>
+ <digest size="{string-length(content/p[1])}">
+ <xsl:copy-of select="content/p[1]/node()"/>
</digest>
</page>
</xsl:template>
@@ -37,9 +33,9 @@
</xsl:template>
<xsl:template match="files/directory[@name = 'pages']/*/file[@extension = '.md']">
- <xsl:call-template name="get_page_data">
- <xsl:with-param name="handle" select="@name"/>
- </xsl:call-template>
+ <xsl:variable name="handle" select="@name"/>
+
+ <xsl:apply-templates select="$root/pages/entry[@handle = $handle]" mode="resolve"/>
</xsl:template>
</xsl:stylesheet>
diff --git a/source/02_meta/tags.xsl b/source/02_meta/tags.xsl
index 20b1f10..3c95932 100644
--- a/source/02_meta/tags.xsl
+++ b/source/02_meta/tags.xsl
@@ -12,17 +12,15 @@
<target mode="plain" value="tags.xml"/>
</xsl:variable>
-<xsl:template name="get_article_data">
- <xsl:param name="handle"/>
-
- <xsl:variable name="article" select="$root/articles/entry[@handle = $handle]/*[self::title | self::date]"/>
-
- <title>
- <xsl:value-of select="$article/self::title"/>
- </title>
- <date>
- <xsl:value-of select="$article/self::date/full"/>
- </date>
+<xsl:template match="articles/entry" mode="resolve">
+ <article handle="{@handle}">
+ <title>
+ <xsl:value-of select="title"/>
+ </title>
+ <date>
+ <xsl:value-of select="date/full"/>
+ </date>
+ </article>
</xsl:template>
<xsl:template match="tags/entry">
@@ -32,11 +30,9 @@
</xsl:template>
<xsl:template match="tags/*/article">
- <article handle="{@handle}">
- <xsl:call-template name="get_article_data">
- <xsl:with-param name="handle" select="@handle"/>
- </xsl:call-template>
- </article>
+ <xsl:variable name="handle" select="@handle"/>
+
+ <xsl:apply-templates select="$root/articles/entry[@handle = $handle]" mode="resolve"/>
</xsl:template>
</xsl:stylesheet>