aboutsummaryrefslogtreecommitdiff
path: root/utility
diff options
context:
space:
mode:
Diffstat (limited to 'utility')
-rw-r--r--utility/datasource.xsl24
-rw-r--r--utility/formatter.xsl86
-rw-r--r--utility/master.xsl79
3 files changed, 189 insertions, 0 deletions
diff --git a/utility/datasource.xsl b/utility/datasource.xsl
new file mode 100644
index 0000000..411086a
--- /dev/null
+++ b/utility/datasource.xsl
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet
+ version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+>
+
+<xsl:output
+ method="xml"
+ omit-xml-declaration="no"
+ encoding="UTF-8"
+ indent="no"
+/>
+
+<xsl:variable name="root" select="/datasource"/>
+
+<xsl:template match="/">
+ <datasource>
+ <xsl:apply-templates />
+ </datasource>
+</xsl:template>
+
+<xsl:template match="text()|@*"/>
+
+</xsl:stylesheet>
diff --git a/utility/formatter.xsl b/utility/formatter.xsl
new file mode 100644
index 0000000..eae9395
--- /dev/null
+++ b/utility/formatter.xsl
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet
+ version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:xalan="http://xml.apache.org/xalan"
+ xmlns:InputXSLT="function.inputxslt.application"
+ exclude-result-prefixes="xalan InputXSLT"
+>
+
+<xsl:template name="plain_formatter">
+ <xsl:param name="format"/>
+ <xsl:param name="source"/>
+
+ <xsl:copy-of select="InputXSLT:external-command(
+ $format,
+ $source
+ )/self::command/node()"/>
+</xsl:template>
+
+<xsl:template name="highlighter">
+ <xsl:param name="source"/>
+ <xsl:param name="language"/>
+
+ <xsl:variable name="formatted_code">
+ <xsl:call-template name="plain_formatter">
+ <xsl:with-param name="format">
+ <xsl:text>highlight --out-format=xhtml --inline-css --style=molokai --fragment --enclose-pre --wrap-simple --syntax=</xsl:text>
+ <xsl:value-of select="$language"/>
+ </xsl:with-param>
+ <xsl:with-param name="source" select="$source"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <pre>
+ <xsl:copy-of select="xalan:nodeset($formatted_code)/pre/node()"/>
+ </pre>
+</xsl:template>
+
+<xsl:template match="@*|node()" mode="embellish">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()" mode="embellish"/>
+ </xsl:copy>
+</xsl:template>
+
+<xsl:template match="h2" mode="embellish">
+ <h3>
+ <xsl:copy-of select="node()"/>
+ </h3>
+</xsl:template>
+
+<xsl:template match="h3" mode="embellish">
+ <h4>
+ <xsl:copy-of select="node()"/>
+ </h4>
+</xsl:template>
+
+<xsl:template match="pre" mode="embellish">
+ <xsl:call-template name="highlighter">
+ <xsl:with-param name="source" select="code/text()"/>
+ <xsl:with-param name="language">
+ <xsl:choose>
+ <xsl:when test="code/@class">
+ <xsl:value-of select="substring(code/@class, 10, string-length(code/@class))"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>txt</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:with-param>
+ </xsl:call-template>
+</xsl:template>
+
+<xsl:template name="formatter">
+ <xsl:param name="source"/>
+
+ <xsl:variable name="content">
+ <xsl:call-template name="plain_formatter">
+ <xsl:with-param name="format">kramdown</xsl:with-param>
+ <xsl:with-param name="source" select="$source"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:apply-templates select="xalan:nodeset($content)" mode="embellish"/>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/utility/master.xsl b/utility/master.xsl
new file mode 100644
index 0000000..b495877
--- /dev/null
+++ b/utility/master.xsl
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet
+ version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+>
+
+<xsl:output
+ method="xml"
+ doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
+ doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
+ omit-xml-declaration="yes"
+ encoding="UTF-8"
+ indent="no"
+/>
+
+<xsl:variable name="root" select="/datasource"/>
+
+<xsl:template name="list_tags">
+ <ul>
+ <xsl:for-each select="$root/meta/tags/entry">
+ <li>
+ <a href="/tag/{@handle}">
+ <xsl:value-of select="@handle"/>
+ </a>
+ </li>
+ </xsl:for-each>
+ </ul>
+</xsl:template>
+
+<xsl:template match="/">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta name="author" content="Adrian Kummerländer" />
+ <meta name="robots" content="all"/>
+ <meta name="viewport" content="width=device-width,initial-scale=1.0"/>
+
+ <title><xsl:call-template name="title-text"/> @ <xsl:value-of select="$root/meta/title"/></title>
+ <link rel="stylesheet" type="text/css" href="/main.css" />
+
+ <link rel="shortcut icon" type="image/x-icon" href="/media/favicon.ico" />
+</head>
+<body>
+ <div id="wrapper">
+ <div id="content">
+ <div id="nav_wrap">
+ <h1><xsl:value-of select="$root/meta/title"/></h1>
+ <ul>
+ <li><a href="/0">Start</a></li>
+ <li><a href="/archive">Archive</a></li>
+ <li><a href="/category/projects">Projects</a></li>
+ <li><a href="/page/contact">Contact</a></li>
+ <li class="last_item"><a href="/atom.xml">Feed</a></li>
+ </ul>
+ </div>
+ <div id="main">
+ <xsl:apply-templates />
+ </div>
+ <div id="footer_wrap">
+ <div class="taglist">
+ <xsl:call-template name="list_tags"/>
+ </div>
+ </div>
+ <div id="last_line">
+ <a href="https://github.com/KnairdA/blog.kummerlaender.eu">Made with XSLT</a>
+ <ul>
+ <li><a href="/page/contact">Contact</a></li>
+ <li class="last_item"><a href="/atom.xml">Feed</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+</body>
+</html>
+</xsl:template>
+
+<xsl:template match="text()|@*"/>
+
+</xsl:stylesheet>