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:
-
+ you can get all the feeds at once:
+
+
]]>