aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/03_meta/categories.xsl22
-rw-r--r--source/99_result/category/category.xsl57
2 files changed, 51 insertions, 28 deletions
diff --git a/source/03_meta/categories.xsl b/source/03_meta/categories.xsl
index a0b1a41..a2945b3 100644
--- a/source/03_meta/categories.xsl
+++ b/source/03_meta/categories.xsl
@@ -20,12 +20,14 @@
<xsl:variable name="page" select="$root/pages/entry[@handle = $handle]"/>
- <title>
- <xsl:value-of select="$page/title"/>
- </title>
- <digest>
- <xsl:copy-of select="$page/content/p[1]/node()"/>
- </digest>
+ <page handle="{$handle}">
+ <title>
+ <xsl:value-of select="$page/title"/>
+ </title>
+ <digest size="{string-length($page/content/p[1])}">
+ <xsl:copy-of select="$page/content/p[1]/node()"/>
+ </digest>
+ </page>
</xsl:template>
<xsl:template match="files/pages/*[name() != 'file']">
@@ -35,11 +37,9 @@
</xsl:template>
<xsl:template match="files/pages/*/file[./extension = '.md']">
- <page handle="{./name}">
- <xsl:call-template name="get_page_data">
- <xsl:with-param name="handle" select="./name"/>
- </xsl:call-template>
- </page>
+ <xsl:call-template name="get_page_data">
+ <xsl:with-param name="handle" select="./name"/>
+ </xsl:call-template>
</xsl:template>
</xsl:stylesheet>
diff --git a/source/99_result/category/category.xsl b/source/99_result/category/category.xsl
index 2b54348..1713c84 100644
--- a/source/99_result/category/category.xsl
+++ b/source/99_result/category/category.xsl
@@ -2,7 +2,8 @@
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:math="http://exslt.org/math"
+ xmlns:xalan="http://xml.apache.org/xalan"
+ exclude-result-prefixes="xalan"
>
<xsl:include href="[utility/master.xsl]"/>
@@ -17,33 +18,55 @@
<xsl:value-of select="/datasource/category/entry/@handle"/>
</xsl:template>
+<xsl:template name="page_entry">
+ <xsl:param name="source"/>
+
+ <li>
+ <em>»</em>
+ <a href="{$url}/page/{$source/@handle}">
+ <strong><xsl:value-of select="$source/title"/></strong>
+ <p>
+ <xsl:copy-of select="$source/digest/node()"/>
+ </p>
+ </a>
+ </li>
+</xsl:template>
+
<xsl:template match="category/entry">
<h3>
<xsl:text>All pages categorized as &#187;</xsl:text>
<xsl:value-of select="@handle"/>
- <xsl:text>&#171; in random order</xsl:text>
+ <xsl:text>&#171;</xsl:text>
</h3>
<div class="archiv columns">
<ul class="prettylist">
- <xsl:for-each select="page">
- <xsl:sort select="position() mod math:random()" order="descending"/>
+ <xsl:variable name="ceiling" select="count(page) + 1"/>
+ <xsl:variable name="boundary" select="$ceiling div 2"/>
+
+ <xsl:variable name="sorted_pages">
+ <xsl:for-each select="page">
+ <xsl:sort select="digest/@size" order="ascending"/>
+ <xsl:copy-of select="."/>
+ </xsl:for-each>
+ </xsl:variable>
- <xsl:apply-templates select="."/>
+ <xsl:for-each select="xalan:nodeset($sorted_pages)/page">
+ <xsl:variable name="index" select="position()"/>
+
+ <xsl:if test="$index &lt;= $boundary">
+ <xsl:call-template name="page_entry">
+ <xsl:with-param name="source" select="."/>
+ </xsl:call-template>
+
+ <xsl:if test="$ceiling - $index != $index">
+ <xsl:call-template name="page_entry">
+ <xsl:with-param name="source" select="xalan:nodeset($sorted_pages)/page[$ceiling - $index]"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:if>
</xsl:for-each>
</ul>
</div>
</xsl:template>
-<xsl:template match="category/entry/page">
- <li>
- <em>»</em>
- <a href="{$url}/page/{@handle}">
- <strong><xsl:value-of select="title"/></strong>
- <p>
- <xsl:copy-of select="digest/node()"/>
- </p>
- </a>
- </li>
-</xsl:template>
-
</xsl:stylesheet>