tTurn feed generator into a sed script - monochromatic - monochromatic blog: http://blog.z3bra.org
HTML git clone git://z3bra.org/monochromatic
DIR Log
DIR Files
DIR Refs
---
DIR commit f8766d5669e5570414c488539899c2cd61727fb1
DIR parent b9ce70737868b8fff46d06e1cd448d328ea3282f
HTML Author: Willy Goiffon <wgoiffon@LPWGF01.centro.fr>
Date: Sun, 22 Dec 2019 11:16:24 +0100
Turn feed generator into a sed script
Diffstat:
M Makefile | 2 +-
A feed.sed | 17 +++++++++++++++++
D feeds.sh | 22 ----------------------
3 files changed, 18 insertions(+), 23 deletions(-)
---
DIR diff --git a/Makefile b/Makefile
t@@ -25,7 +25,7 @@ FOOTER = foot.html
$(FEEDS): index.txt
@echo "RSSGEN $@"
@mkdir -p `dirname $(FEEDS)`
- @./feeds.sh index.txt > $(FEEDS)
+ @sed -f feed.sed < index.txt > $(FEEDS)
.txt.html: $(HEADER) $(FOOTER)
@echo "MARKDOWN `basename $@`"
DIR diff --git a/feed.sed b/feed.sed
t@@ -0,0 +1,17 @@
+#!/bin/sed -f
+
+# RSS feed header
+1i<?xml version='1.0'?>
+1i<rss version='2.0' xmlns:atom="http://www.w3.org/2005/Atom">
+1i\ <channel>
+1i\ <title>Monochromatic</title>
+1i\ <description>z3bra, the stripes appart</description>
+1i\ <link>https://blog.z3bra.org</link>
+1i\ <atom:link href="https://blog.z3bra.org/rss/feed.xml" rel="self" type="application/rss+xml" />
+
+# Append all entries to the feed, one item per post
+s^\* \([x0-9a-f]*\) - \[\(.*\)\](\(.*\)) <item><title>\2</title><guid isPermaLink=\"false\">\1</guid><link>https://blog.z3bra.org\3</link></item>
+
+# close tags
+$a\ </channel>
+$a</rss>
DIR diff --git a/feeds.sh b/feeds.sh
t@@ -1,22 +0,0 @@
-#!/bin/sh
-
-BASEURL="https://blog.z3bra.org"
-
-test -z "$1" && echo "usage: `basename $0` <input file>" && exit 1
-
-cat << EOF
-<?xml version='1.0'?>
-<rss version='2.0' xmlns:atom="http://www.w3.org/2005/Atom">
-<channel>
-<title>Monochromatic</title>
-<description>z3bra, the stripes appart</description>
-<link>https://blog.z3bra.org</link>
-<atom:link href="https://blog.z3bra.org/rss/feed.xml" rel="self" type="application/rss+xml" />
-EOF
-
-sed "s^\* \([x0-9a-f]*\) - \[\(.*\)\](\(.*\))<item><title>\2</title><guid isPermaLink=\"false\">\1</guid><link>$BASEURL\3</link></item>" $1
-
-cat << EOF
-</channel>
-</rss>
-EOF