logo

blog

My website can't be that messy, right? git clone https://hacktivis.me/git/blog.git
commit: 651c4072698bc8727a71cbe31b74132fc0a652a1
parent 96520e50d1d981f402072cd2b6dbda63abae8882
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Mon,  8 Jan 2024 16:00:08 +0100

atom.xsl: New xml-stylesheet for Atom feeds

Diffstat:

Aatom.xsl.in39+++++++++++++++++++++++++++++++++++++++
Mbuild.ninja1+
2 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/atom.xsl.in b/atom.xsl.in @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet version="1.0" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns="http://www.w3.org/1999/xhtml" + xmlns:xhtml="http://www.w3.org/1999/xhtml" + xmlns:xi="http://www.w3.org/2001/XInclude" + xmlns:atom="http://www.w3.org/2005/Atom" + xml:space="preserve" +> + <xsl:import href="templates/en/nav.xsl" /> + <xsl:output method="xml" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/> + <xsl:template match="/"><xsl:text disable-output-escaping='yes'>&lt;!DOCTYPE html&gt;</xsl:text> +<html xml:lang="en" lang="en"> + <head> + <xi:include href="templates/head.xml" parse="xml" xpointer="xpointer(/xml/*)"/> + <title><xsl:value-of select="/atom:feed/atom:title" /></title> + </head> + <body> + <xsl:call-template name="nav"> + <xsl:with-param name="feedURL" select="/atom:feed/atom:link[@rel='self']/@href"/> + </xsl:call-template> + <main> + <h1><xsl:value-of select="/atom:feed/atom:title" /></h1> + <p>This is an Atom feed, you can regularly pull updates from it via a <a href="https://en.wikipedia.org/wiki/Feedreader">feedreader</a> and <a href="{/atom:feed/atom:link[@rel='self']/@href}">this feed's URL</a>. Included below are entries included in it, rendered without their included content for simplicity.</p> + + <xsl:apply-templates select="/atom:feed/atom:entry"/> + </main> + <xi:include href="templates/en/footer.shtml" parse="xml"/> + </body> +</html></xsl:template> + + <xsl:template match="atom:entry"> + <a href="{atom:id}"><h2><xsl:value-of select="atom:title"/></h2></a> + <p class="timestamps"><xsl:apply-templates select="atom:published"/><xsl:apply-templates select="atom:updated"/></p> + </xsl:template> + +<xsl:template match="atom:published">published on <xsl:value-of select="."/></xsl:template> +<xsl:template match="atom:updated">, last updated on <xsl:value-of select="."/></xsl:template> +</xsl:stylesheet> diff --git a/build.ninja b/build.ninja @@ -25,6 +25,7 @@ build bookmarks.html: xslt bookmarks.xsl bookmarks.xbel build bookmarks.html.br: brotli bookmarks.html build feed.atom: xinclude feed.atom.in +build atom.xsl: xinclude atom.xsl.in build images/linux-audio-output.png: dot images/linux-audio-output.dot format = png