From 70ef6b9e978aa58170e80bbb7121f3a6089f8ac3 Mon Sep 17 00:00:00 2001 From: Lucidiot Date: Sun, 21 Mar 2021 15:48:57 +0100 Subject: [PATCH] Add CDF meta-feed --- .gitignore | 1 + bin/cdfmerge | 17 +++++++++++++++++ feedgen.sh | 17 +++++++++++------ itsb.xml | 5 +++-- 4 files changed, 32 insertions(+), 8 deletions(-) create mode 100755 bin/cdfmerge diff --git a/.gitignore b/.gitignore index b3e5639..1540b2e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ feeds feeds.opml +feeds.cdf index.html *~ *.sw[a-z] diff --git a/bin/cdfmerge b/bin/cdfmerge new file mode 100755 index 0000000..fb6ceac --- /dev/null +++ b/bin/cdfmerge @@ -0,0 +1,17 @@ +#!/bin/bash +[ -z "$DIR" ] && DIR="$( cd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null 2>&1 && pwd )" + +echo " + + + A project to make transport accident investigation reports easier to access. + International Transport Safety Bureau + + " > "$DIR/feeds.cdf.new" + +# Grab the paths to all generated CDF feeds from the XML in stdin +bin/xml2json | jq --raw-output --arg DIR "$DIR" '.. | objects | select(.["@format"] == "cdf") | "\($DIR)/feeds/\(.output // .link)"' | xargs tail -q -n+2 > "$DIR/feeds.cdf.new" + +echo '' >> "$DIR/feeds.cdf.new" + +mv "$DIR/feeds.cdf.new" "$DIR/feeds.cdf" diff --git a/feedgen.sh b/feedgen.sh index 6af2b9e..efa5c3a 100755 --- a/feedgen.sh +++ b/feedgen.sh @@ -1,8 +1,13 @@ #!/bin/bash [ -z "$DIR" ] && DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -xsltproc "$DIR/xslt/itsb.xsl" "$DIR/itsb.xml" \ - | tee \ - >(xsltproc "$DIR/xslt/opml.xsl" - > "$DIR/feeds.opml") \ - >(xsltproc "$DIR/xslt/html.xsl" - > "$DIR/index.html") \ - | xsltproc "$DIR/xslt/feedgen.xsl" - \ - | DIR="$DIR" bash -s -- "$@" + +tmpfile=$(mktemp /tmp/itsb.XXXXXXXXXX) +trap "rm \"$tmpfile\"" EXIT + +xsltproc "$DIR/xslt/itsb.xsl" "$DIR/itsb.xml" > "$tmpfile" + +xsltproc "$DIR/xslt/feedgen.xsl" "$tmpfile" | DIR="$DIR" bash -s -- "$@" +xsltproc "$DIR/xslt/opml.xsl" "$tmpfile" > "$DIR/feeds.opml" +xsltproc "$DIR/xslt/html.xsl" "$tmpfile" > "$DIR/index.html" + +bin/cdfmerge < "$tmpfile" diff --git a/itsb.xml b/itsb.xml index 5dfa8dd..fa30e2d 100644 --- a/itsb.xml +++ b/itsb.xml @@ -14,8 +14,9 @@

but hey, i can still browse webpages to find the reports—what if i parsed those pages?

this is the whole goal of this project; to centralize accident reports into manageable RSS feeds and maybe more formats later on.

- you can get all the feeds at once in one OPML file: - OPML Feeds + you can get all the feeds at once: + OPML + CDF

]]>