fn website_mirror() + generalized assert_tools()
This commit is contained in:
parent
4a363d81c0
commit
e04a19588e
39
gen.sh
39
gen.sh
|
@ -1,16 +1,47 @@
|
|||
#!/usr/bin/env sh
|
||||
which xsltproc >/dev/null
|
||||
test $? -eq 0 || {
|
||||
echo "tool missing: xsltproc"
|
||||
exit 1
|
||||
assert_tools () {
|
||||
while test $# -gt 0; do
|
||||
which $1 >/dev/null 2>/dev/null || {
|
||||
echo "tool missing: "$1
|
||||
exit 2
|
||||
}
|
||||
shift
|
||||
done
|
||||
}
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue