ds-rss/gen.sh

48 lines
1.1 KiB
Bash
Raw Normal View History

2019-05-07 09:17:09 +02:00
#!/usr/bin/env sh
assert_tools () {
while test $# -gt 0; do
which $1 >/dev/null 2>/dev/null || {
echo "tool missing: "$1
exit 2
}
shift
done
2019-06-13 04:09:43 +02:00
}
test $# -eq 0 && {
dependencies="xsltproc"
assert_tools ${dependencies}
xsltproc --encoding utf-8 -o ds-feed.xml rss.xsl data.xml
xsltproc --encoding iso-8859-1 -o download.html download.xsl data.xml
xsltproc --encoding utf-8 -o index.html index.xsl data.xml
exit 0
}
test "$1" = "sort" && {
dependencies="xsltproc"
assert_tools ${dependencies}
xsltproc --encoding utf-8 -o sorted.xml sort.xsl data.xml
mv -i sorted.xml data.xml
}
mirror_website () {
dependencies="wget"
assert_tools ${dependencies}
local url=$@
local domain=`expr "$url" : '^http[s]*://\([^/?]*\)'`
wget \
--recursive \
--no-clobber \
--page-requisites \
--html-extension \
--convert-links \
--restrict-file-names=windows \
--domains $domain \
--no-parent \
$url
}
# a mirror is useful for local testing with files
test "$1" = "mirror" && {
echo "downloading the website may take quite some time."
mirror_website http://ds.ccc.de/
}
#gs -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -q -o ds100-smaller.pdf ds100.pdf