commit 211b36cf5521766f8a6b069f552502c72a1878c1
parent 2f787b18f5666c44236716a78095372ea1925aa5
Author: Charlie Stanton <charlie@shtanton.com>
Date: Tue, 21 Sep 2021 10:39:54 +0100
Add RSS
Diffstat:
4 files changed, 36 insertions(+), 12 deletions(-)
diff --git a/Makefile b/Makefile
@@ -7,19 +7,10 @@ GEMINI = $(GEMINI_POSTS) gemini/index.gmi gemini/posts/index.gmi
.PHONY: all clean publish
-all: html html/posts gemini gemini/posts $(WEB) $(GEMINI)
+all: html/rss.xml $(WEB) $(GEMINI)
-html:
- mkdir html
-
-html/posts: html
- mkdir html/posts
-
-gemini:
- mkdir gemini
-
-gemini/posts: gemini
- mkdir gemini/posts
+html/rss.xml: posts-config html_src/rss_template.xml $(POSTS:%=posts/%.gmi) html_src/rss.sh html_src/rss_items.sh html_src/rss_template.xml
+ ./html_src/rss.sh posts-config < html_src/rss_template.xml > $@
html/%.css: html_src/%.css
cp $^ $@
diff --git a/html_src/rss.sh b/html_src/rss.sh
@@ -0,0 +1,12 @@
+#!/usr/bin/dash
+while read line
+do
+ case $line in
+ "{ITEMS}")
+ ./html_src/rss_items.sh < $1
+ ;;
+ *)
+ echo $line
+ ;;
+ esac
+done
diff --git a/html_src/rss_items.sh b/html_src/rss_items.sh
@@ -0,0 +1,13 @@
+#!/usr/bin/dash
+while read line
+do
+ ID=$(echo $line | awk -F :: '{print $1}')
+ TITLE=$(echo $line | awk -F :: '{print $2}')
+ DATE=$(echo $line | awk -F :: '{print $3}')
+ echo "<item>"
+ echo "<title>$TITLE</title>"
+ echo "<link>http://shtanton.xyz/posts/${ID}.html</link>"
+ echo "<pubDate>$(date -d $DATE '+%d %b %y 12:00:00 GMT')</pubDate>"
+ echo "<guid>http://shtanton.xyz/posts/${ID}.html</guid>"
+ echo "</item>"
+done
diff --git a/html_src/rss_template.xml b/html_src/rss_template.xml
@@ -0,0 +1,8 @@
+<rss version="2.0">
+ <channel>
+ <title>Shtanton's Blog</title>
+ <link>http://shtanton.xyz</link>
+ <description>Charlie's blog posts</description>
+{ITEMS}
+ </channel>
+</rss>