summary refs log tree commit diff
path: root/www/text.causal.agency
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-11-26 21:17:04 -0500
committerJune McEnroe <june@causal.agency>2020-11-26 21:17:04 -0500
commit38745e77ff24f55e8b5c702cce85088857f47cf6 (patch)
treeccfec0fa34d2931a516c33885c02b905331992cb /www/text.causal.agency
parentUpdate plan with different things I won't do (diff)
downloadsrc-38745e77ff24f55e8b5c702cce85088857f47cf6.tar.gz
src-38745e77ff24f55e8b5c702cce85088857f47cf6.zip
Render content into atom feed
And fix some atom lints.
Diffstat (limited to 'www/text.causal.agency')
-rw-r--r--www/text.causal.agency/feed.sh35
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/&/\&amp;/g
+		s/</\&lt;/g
+		s/"/\&quot;/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