itsb/bin/cdfmerge

18 lines
925 B
Bash
Executable File

#!/bin/bash
[ -z "$DIR" ] && DIR="$( cd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null 2>&1 && pwd )"
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<CHANNEL LASTMOD=\"$(date --utc '+%Y-%m-%dT%H:%M')\">
<A HREF=\"http://tilde.town/~lucidiot/itsb/\"/>
<ABSTRACT>A project to make transport accident investigation reports easier to access.</ABSTRACT>
<TITLE>International Transport Safety Bureau</TITLE>
<LOGO HREF=\"http://tilde.town/~lucidiot/itsb/img/itsb.gif\" STYLE=\"ICON\"/>
<LOGO HREF=\"http://tilde.town/~lucidiot/itsb/img/itsb.gif\" STYLE=\"IMAGE\"/>" > "$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 '</CHANNEL>' >> "$DIR/feeds.cdf.new"
mv "$DIR/feeds.cdf.new" "$DIR/feeds.cdf"