Add CDF feed, close #3

This commit is contained in:
~lucidiot 2021-07-24 23:40:10 +02:00
parent 705708a09b
commit e5a834d16b
4 changed files with 117 additions and 6 deletions

View File

@ -1,9 +1,10 @@
#!/bin/bash
#!/bin/bash -e
shopt -s globstar
include_after=$(mktemp "/tmp/$USER.XXXXXXXXXX")
tree_output=$(mktemp "/tmp/$USER.XXXXXXXXXX")
tree_file=$(mktemp "/tmp/$USER.XXXXXXXXXX")
trap "rm \"$include_after\" \"$tree_file\"" EXIT
trap "rm \"$include_after\" \"$tree_output\" \"$tree_file\"" EXIT
# Preprocess include-after.html
sed "s/{{ now }}/$(date --iso-8601=seconds)/g;s/{{ generator }}/$(pandoc --version | head -n1)/g" include-after.html > "$include_after"
@ -45,17 +46,25 @@ function link_assets {
}
link_assets assets
# Build the 'everything' page
# Build the 'everything' page and CDF feed
echo 'Building article list'
pushd html >/dev/null
tree --du --si -X --prune -P '*.html' > "$tree_output"
popd >/dev/null
echo "---
title: everything
---
" > "$tree_file"
pushd html >/dev/null
tree --du --si -X --prune -P '*.html' | xsltproc ../xsl/tree.xsl - >> "$tree_file"
popd >/dev/null
xsltproc xsl/tree-html.xsl "$tree_output" >> "$tree_file"
convert "$tree_file" "html/everything.html"
xsltproc xsl/tree-cdf.xsl "$tree_output" | xmllint --format - > "html/everything.cdf"
xmllint --noout --schema "assets/xsd/cdf.xsd" "html/everything.cdf"
chmod 644 "html/everything.cdf"
# Build an RSS feed
echo 'Building RSS feed'
echo '<?xml version="1.0"?>
<rss
version="2.0"

View File

@ -6,6 +6,8 @@ hello! this is lucidiot's personal wiki; a place where things that belong to
nowhere else but deserve to be published will go.
you can start by browsing [all the articles](./everything.html).
if you use internet explorer 4 to 7, you can bookmark the entire site using
[this CDF feed](./everything.cdf).
## other things hosted here

100
xsl/tree-cdf.xsl Normal file
View File

@ -0,0 +1,100 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns="https://msdn.microsoft.com/workshop/standards/cdf/"
xmlns:xsi="https://www.w3.org/1999/XMLSchema-instance"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xsi:schemaLocation="https://msdn.microsoft.com/workshop/standards/cdf/ ../assets/xsd/cdf.xsd">
<xsl:template match="tree">
<CHANNEL>
<xsl:apply-templates select="report" />
<xsl:apply-templates select="./file | ./directory/file | ./directory/directory">
<xsl:with-param name="base" select="'/~lucidiot'" />
</xsl:apply-templates>
<TITLE>lucidiot's wiki</TITLE>
</CHANNEL>
</xsl:template>
<xsl:template match="file">
<xsl:param name="base" />
<ITEM SHOW="Channel">
<A>
<xsl:attribute name="HREF">
<xsl:value-of select="$base" />
<xsl:text>/</xsl:text>
<xsl:value-of select="@name" />
</xsl:attribute>
</A>
<xsl:if test="@size">
<ABSTRACT>
<xsl:value-of select="@size" />
<xsl:text> bytes</xsl:text>
</ABSTRACT>
</xsl:if>
<TITLE>
<xsl:value-of select="@name" />
</TITLE>
<USAGE VALUE="Channel" />
</ITEM>
</xsl:template>
<xsl:template match="directory">
<xsl:param name="base" />
<CHANNEL>
<A>
<xsl:attribute name="HREF">
<xsl:value-of select="$base" />
<xsl:text>/</xsl:text>
<xsl:value-of select="@name" />
<xsl:text>/</xsl:text>
</xsl:attribute>
</A>
<xsl:if test="@size">
<ABSTRACT>
<xsl:value-of select="@size" />
<xsl:text> bytes</xsl:text>
</ABSTRACT>
</xsl:if>
<xsl:apply-templates select="file | directory">
<xsl:with-param name="base" select="concat($base, '/', @name)" />
</xsl:apply-templates>
<TITLE>
<xsl:value-of select="@name" />
</TITLE>
</CHANNEL>
</xsl:template>
<xsl:template match="report">
<ABSTRACT>
<xsl:value-of select="directories" />
<xsl:text> director</xsl:text>
<xsl:choose>
<xsl:when test="directories/text() = '1'">
<xsl:text>y</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>ies</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text> and </xsl:text>
<xsl:value-of select="files" />
<xsl:text> file</xsl:text>
<xsl:if test="files/text() != '1'">
<xsl:text>s</xsl:text>
</xsl:if>
<xsl:if test="size">
<xsl:text>, </xsl:text>
<xsl:value-of select="size" />
<xsl:text> bytes</xsl:text>
</xsl:if>
</ABSTRACT>
</xsl:template>
</xsl:stylesheet>