diff options
author | June McEnroe <june@causal.agency> | 2020-11-26 21:17:04 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-11-26 21:17:04 -0500 |
commit | 38745e77ff24f55e8b5c702cce85088857f47cf6 (patch) | |
tree | ccfec0fa34d2931a516c33885c02b905331992cb /www | |
parent | Update plan with different things I won't do (diff) | |
download | src-38745e77ff24f55e8b5c702cce85088857f47cf6.tar.gz src-38745e77ff24f55e8b5c702cce85088857f47cf6.zip |
Render content into atom feed
And fix some atom lints.
Diffstat (limited to '')
-rw-r--r-- | www/text.causal.agency/feed.sh | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/www/text.causal.agency/feed.sh b/www/text.causal.agency/feed.sh index de9e7c54..fe028621 100644 --- a/www/text.causal.agency/feed.sh +++ b/www/text.causal.agency/feed.sh @@ -4,33 +4,50 @@ set -eu readonly Root='https://text.causal.agency' updated=$(date -u '+%FT%TZ') -cat <<- EOF +cat <<-EOF <?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom"> <title>Causal Agency</title> <author><name>June</name><email>june@causal.agency</email></author> <link href="${Root}"/> - <id>${Root}</id> + <link rel="self" href="${Root}/feed.atom"/> + <id>${Root}/</id> <updated>${updated}</updated> EOF +encode() { + sed ' + s/&/\&/g + s/</\</g + s/"/\"/g + ' "$@" +} + for entry in *.7; do - url="${Root}/${entry%.7}.txt" + txt="${entry%.7}.txt" date=$(grep '^[.]Dd' "$entry" | cut -c 5-) - title=$(grep '^[.]Nm' "$entry" | cut -c 5-) - summary=$(grep '^[.]Nd' "$entry" | cut -c 5-) + title=$(grep '^[.]Nm' "$entry" | cut -c 5- | encode) + summary=$(grep '^[.]Nd' "$entry" | cut -c 5- | encode) published=$(date -ju -f '%B %d, %Y %T' "${date} 00:00:00" '+%FT%TZ') mtime=$(stat -f '%m' "$entry") updated=$(date -ju -f '%s' "$mtime" '+%FT%TZ') - cat <<- EOF + cat <<-EOF <entry> <title>${title}</title> <summary>${summary}</summary> - <link href="${url}"/> - <id>${url}</id> + <link href="${Root}/${txt}"/> + <id>${Root}/${txt}</id> <published>${published}</published> <updated>${updated}</updated> - <content type="text/plain" src="${url}"/> + <content type="xhtml"> + <div xmlns="http://www.w3.org/1999/xhtml"> + EOF + printf '<pre>' + encode "$txt" + cat <<-EOF + </pre> + </div> + </content> </entry> EOF done |