fn website_mirror() + generalized assert_tools()

This commit is contained in:
vv01f 2019-09-12 09:15:34 +02:00
parent 4a363d81c0
commit e04a19588e
Signed by untrusted user who does not match committer: vv01f
GPG Key ID: 02625A16AC1D1FF6
1 changed files with 35 additions and 4 deletions

39
gen.sh
View File

@ -1,16 +1,47 @@
#!/usr/bin/env sh #!/usr/bin/env sh
which xsltproc >/dev/null assert_tools () {
test $? -eq 0 || { while test $# -gt 0; do
echo "tool missing: xsltproc" which $1 >/dev/null 2>/dev/null || {
exit 1 echo "tool missing: "$1
exit 2
}
shift
done
} }
test $# -eq 0 && { test $# -eq 0 && {
dependencies="xsltproc"
assert_tools ${dependencies}
xsltproc --encoding utf-8 -o ds-feed.xml rss.xsl data.xml 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 iso-8859-1 -o download.html download.xsl data.xml
xsltproc --encoding utf-8 -o index.html index.xsl data.xml xsltproc --encoding utf-8 -o index.html index.xsl data.xml
exit 0 exit 0
} }
test "$1" = "sort" && { test "$1" = "sort" && {
dependencies="xsltproc"
assert_tools ${dependencies}
xsltproc --encoding utf-8 -o sorted.xml sort.xsl data.xml xsltproc --encoding utf-8 -o sorted.xml sort.xsl data.xml
mv -i sorted.xml 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