summary refs log tree commit diff
path: root/www
diff options
context:
space:
mode:
Diffstat (limited to 'www')
-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