diff options
author | Aki <please@ignore.pl> | 2023-12-27 00:42:28 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2023-12-27 00:44:08 +0100 |
commit | 995643cae1238ab3d3b21ae36ac666625d741afa (patch) | |
tree | 12adb222b1b5f78d1473d5f2ed9120596c0e8423 /atom.xml.sh | |
parent | 2232602e9f6583722b15389039ca486b0b22c3b9 (diff) | |
download | ignore.pl-995643cae1238ab3d3b21ae36ac666625d741afa.zip ignore.pl-995643cae1238ab3d3b21ae36ac666625d741afa.tar.gz ignore.pl-995643cae1238ab3d3b21ae36ac666625d741afa.tar.bz2 |
Added atom feed for the content
The entries are not yet ordered, placement in the index is... questionable,
and the content of "published-on" and "last-modified-on" is duplicated in
the subtitle line.
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>" |