about summary refs log tree commit diff stats
path: root/generate
diff options
context:
space:
mode:
authorManuel Graf <postmaster@grafoo.at>2021-01-15 17:04:21 +0100
committerManuel Graf <postmaster@grafoo.at>2021-01-15 17:04:21 +0100
commit4ec786cd24d2eafe5b924b24958d173f5e7e9db8 (patch)
tree3938d762038762d61059ece3d140049f58b6ed5f /generate
parent7cc673178f3c44d2509d823ea19171e2288308f9 (diff)
downloadtransfeed-4ec786cd24d2eafe5b924b24958d173f5e7e9db8.tar.gz
Add html rendering
Diffstat (limited to 'generate')
-rwxr-xr-xgenerate30
1 files changed, 22 insertions, 8 deletions
diff --git a/generate b/generate
index 0d5705d..47fb755 100755
--- a/generate
+++ b/generate
@@ -1,15 +1,29 @@
 #!/bin/sh
-test $# -ne 1 &&
-	{
-		echo "Usage: ${0} <xslt-stylesheet-file>"
-		exit 2
-	}
+
+usage() {
+	echo "Usage: ${0} <xslt-stylesheet-file> [atom | html]"
+	exit 2
+}
+
+test $# -ne 2 && usage "$0"
 
 echo "$1" | grep 'derstandard.at/international/asien/hongkong' -q && url='https://www.derstandard.at/international/asien/hongkong'
 # TODO: Add option to aggregate older articles using e.g. https://www.derstandard.at/international/asien/hongkong/2020/1/1
 
-curl -sL -b cookies "$url" |
+out=$(curl -sL -b cookies "$url" |
 	xmllint --html --xpath '//main' /dev/stdin 2>/dev/null |
-	xsltproc "$1" /dev/stdin |
-	xmllint --format /dev/stdin \
+	xsltproc "$1" /dev/stdin)
+
+case "$2" in
+atom)
+	printf "%s" "$out" | xmllint --format /dev/stdin \
 		>"$(dirname "$1")/feed.xml"
+	;;
+html)
+	printf "%s" "$out" | xmllint --format --html /dev/stdin \
+		>"$(dirname "$1")/index.html"
+	;;
+*)
+	usage "$0"
+	;;
+esac