wowana.me
website source
commit 92a025cb7b75a212d51f954b84ef0753216c0240 parent 2f195b70558a57986aeb9ad70c9a84c2c719d7e5 Author: opal hart <opal@wowana.me> Date: Sat, 11 May 2019 03:27:38 +0000 add feed.sh I'm committing these files all in the wrong order; oh well Diffstat:
A | feed.sh | | | 45 | +++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 45 insertions(+), 0 deletions(-)
diff --git a/feed.sh b/feed.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +cat <<HEADER +<?xml version="1.0" encoding="utf-8"?> +<feed xmlns="http://www.w3.org/2005/Atom"> + <title>opal's weblog</title> + <link href="/blog/" rel="alternate"/> + <link href="/blog/feed.atom" rel="self"/> + <id>/blog/</id> + <updated>$(date -Iseconds)</updated> +HEADER + +for filename in "$@"; do + slug="$(basename "$filename" .part.xht)" + + unset iso human datepat + date="$(<"$filename" sed -n '/<!--\[time / {s/.* \(.*\)]-->/\1/; p; q}')" + iso="$(date -Iseconds -d$date)" + datepat="s@<!--\[time.*]-->@<time datetime='$iso' title='$iso'>$human</time>@;" + + #<"$filename" sed -e"$datepat" + cat <<ENTRY_HEAD + <entry> + <title>$(<"$filename" pup 'h1 text{}')</title> + <link href="/blog/$slug.xht" rel="alternate" type="application/xhtml+xml" /> + <id>/blog/$slug.xht</id> + <published>$iso</published> + <updated>$(date -r${filename/.part.xht/.md} -Iseconds)</updated> + <author><name>opal hart</name></author> + <content type="xhtml"> + <div xmlns="http://www.w3.org/1999/xhtml"> +ENTRY_HEAD + # first four lines are <h1/> and time; if this changes then I'll + # change this hardcoded range to something else, no big deal + <"$filename" sed '1,4d' + cat <<ENTRY_FOOT + </div> + </content> + </entry> +ENTRY_FOOT +done + +cat <<FOOTER +</feed> +FOOTER