added rss generation scripts
authorMatthewOwens <matthew@owens.tech>
Sun, 19 Jul 2020 12:11:09 +0000 (13:11 +0100)
committerMatthewOwens <matthew@owens.tech>
Sun, 19 Jul 2020 12:11:09 +0000 (13:11 +0100)
scripts/gen_feed.sh [new file with mode: 0755]
scripts/gen_feed_item.sh [new file with mode: 0755]

diff --git a/scripts/gen_feed.sh b/scripts/gen_feed.sh
new file mode 100755 (executable)
index 0000000..5ca1292
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+printf '<!--  <?xml-stylesheet type="text/css" href="rss.css" ?>  -->\n'
+printf '<!--  <?xml-stylesheet href="rss.xsl" type="text/xsl" media="screen"?>  -->\n'
+printf '<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" data-minimalscrollbar="yes">\n'
+printf '<channel>\n'
+
+printf '\t<title>Matthew Owens</title>\n'
+printf '\t<description>Updates from Matthew Owens</description>\n'
+printf '\t<language>en-gb</language>\n'
+printf '\t<link>https://owens.tech/rss.xml</link>\n'
+printf '\t<atom:link href="https://owens.tech/rss.xml" rel="self" type="application/rss+xml"/>\n'
+
+# generate
+
+printf '\n\n'
+find posts/ -type f -exec sh -c "scripts/gen_feed_item.sh {}" \;
+printf '\n\n'
+
+printf '</channel>\n'
+printf '</rss>\n'
diff --git a/scripts/gen_feed_item.sh b/scripts/gen_feed_item.sh
new file mode 100755 (executable)
index 0000000..7892595
--- /dev/null
@@ -0,0 +1,13 @@
+# ensuring that at least that the post md file is passed in
+[ $# -eq 1 ] || exit 1
+
+HTMLPATH=$(echo $1 | sed 's/\.md$/.html/')
+TITLE=$(scripts/post_title.sh $1)
+BODY=$(markdown $1 | sed -e 's/&rsquo;/'/g -e 's/&lsquo;//g')
+
+echo "<item>"
+echo " <title>$TITLE</title>"
+echo " <guid>https://owens.tech/posts/$HTMLPATH</guid>"
+echo " <pubDate>TODO</pubDate>"
+echo " <description>$BODY</description>" 
+echo "</item>"