diff options
Diffstat (limited to 'atom.xml.sh')
-rwxr-xr-x | atom.xml.sh | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/atom.xml.sh b/atom.xml.sh new file mode 100755 index 0000000..157a924 --- /dev/null +++ b/atom.xml.sh @@ -0,0 +1,47 @@ +#!/bin/sh +now () { + date --rfc-3339=seconds | sed 's/ /T/' +} + + +meta () { + perl -nle '/<meta name="'"$1"'" content="(.*)">/ && print $1' "$2" +} + + +dates () { + local published=$(meta "published-on" "$1") + local modified=$(git rev-list --after="2023-12-27 00:45+01:00" -1 --no-commit-header --pretty=%aI HEAD -- "$1") + [ -z "$modified" ] && modified=$(meta "last-modified-on" "$1") + [ -z "$modified" ] && modified=$published + echo "<updated>$modified</updated>" + echo "<published>$published</published>" +} + + +cat <<HEADER +<?xml version="1.0" encoding="utf-8"?> +<feed xmlns="http://www.w3.org/2005/Atom"> +<title>~aki</title> +<id>https://ignore.pl/</id> +<updated>$(now)</updated> +<link rel="self" href="https://ignore.pl/atom.xml"/> +<icon>https://ignore.pl/favicon.png</icon> +<author> +<name>aki</name> +<email>please@ignore.pl</email> +</author> +HEADER +for article in [^_]*.html; do + if [ "$article" != "index.html" ]; then + cat <<-ENTRY + <entry> + $(grep "<title>" $article) + <id>https://ignore.pl/$article</id> + <link href="https://ignore.pl/$article"/> + $(dates $article) + </entry> +ENTRY + fi +done +echo "</feed>" |