diff --git a/README.markdown b/README.markdown index 0d6057d..6e84e74 100644 --- a/README.markdown +++ b/README.markdown @@ -8,15 +8,22 @@ generate parts of the datenschleuder website from source `data.xml`: utilizing XML transformations. +and supporting to manage the `data.xml`. + ## using simply call `./gen.sh` for generating the target files. -for sorting `data.xml`, call `./gen sort`. +creating a new entry for `data.xml` is supported with `./gen.sh release` or `./gen.sh release 99` for a custom issue number, here 99. +to omit the explaining information, simply disregard stderr: `./gen.sh release 2>/dev/null`. +replicating entry for ds #99 including the datetime: `./gen.sh release 99 1568505600`. +the release message is whatever are remaining non-numeric arguments: `./gen.sh release 99 1568505600 Die Ausgabe \#100 ist schon einige Zeit fertig und ausgeliefert. Die Freunde der Digitalen Ausgabe wird freuen, dass die Aushabe \#99 nun online ist.` + +for sorting `data.xml`, call `./gen.sh sort`. ## dependecies -* sh +* sh, coreutils, date, sed etc. * xsltproc ## preview: screenshots diff --git a/gen.sh b/gen.sh index 32a1490..8508322 100755 --- a/gen.sh +++ b/gen.sh @@ -1,12 +1,14 @@ #!/usr/bin/env sh assert_tools () { + err=0 while test $# -gt 0; do which $1 >/dev/null 2>/dev/null || { - echo "tool missing: "$1 - exit 2 + >&2 echo "tool missing: "$1 + err=$(( $err + 1 )) } shift done + test $err -eq 0 || exit $err } test $# -eq 0 && { dependencies="xsltproc" @@ -22,6 +24,18 @@ test "$1" = "sort" && { xsltproc --encoding utf-8 -o sorted.xml sort.xsl data.xml mv -i sorted.xml data.xml } +linkcheck () { + dependencies="curl uuid" + assert_tools ${dependencies} + tmpfile="/tmp/"$(uuid); curl https://ds.ccc.de/download.html > $tmpfile + for f in $(echo "download.html "$tmpfile); do + test -e $f || continue + for e in $(cat ${f}|sed 's/&2 echo ${e}" – "${status}" OK" || >&2 echo ${e}" – "${status}" FAILED" + done + done +} mirror_website () { dependencies="wget" assert_tools ${dependencies} @@ -38,10 +52,95 @@ mirror_website () { --no-parent \ $url } +newdataentry () { + dependencies="cat grep head cut date printf" + assert_tools ${dependencies} + err=0 + fl="" + test $# -eq 0 && { + >&2 echo "determining entry based on data.xml.\n" + lastentry=$(cat data.xml |grep -i "&2 echo "custom entry for data.xml.\n" + newentry=$1; shift; + } || { echo "argument not a number."; exit 1; } + test $(( $1 * 1 )) -eq $1 && { + >&2 echo "custom datetime.\n" + datetime=$1; shift; + } || { datetime=0; } # remaining arguments should be teaser xml-message. + } + echo "" + test $datetime -eq 0 && { + #~ datetime=$(LANG=en_US.utf8 date -u +"%a %d %b %Y %H:%M") # manual copy of known entries + datetime=$(LANG=en_US.utf8 date -u -R |rev|cut -d":" -f2-|rev) # RFC-5322-Format without seconds and TZ + } || { + datetime=$(LANG=en_US.utf8 date -d @${datetime} -u -R|rev|cut -d":" -f2-|rev) + } + echo "\t"${datetime}" UT" # custom format universal time + fn="ds"$(printf "%03d" $newentry) + for d in $(echo "covers pdfs epubs"); do + case "$d" in + covers) ffn=${d}"/"${fn}".jpg"; cover=$ffn ;; + pdfs) ffn=${d}"/"${fn}".pdf" ;; + epubs) ffn=${d}"/"${fn}".epub" ;; + #~ *) echo "file "${ffn}" not found, in "${d}"." ;; + esac + #~ echo $ffn + test -e ${ffn} && { + test "$d" = "covers" && { + echo "\t"${cover}"" + } || { + fs=$(stat -c %s ${ffn}) + echo "\t"${ffn}"" + } + } || { + mfl=${ffn}"\n" + #~ echo "file "${ffn}" not found." + err=3 + } + done + #~ echo "\t" # not used on server yet + test $# -eq 0 && { teaser="" ; } || { + teaser=$@ ; + echo "\t"${teaser}"" + } + echo "" + test "$teaser" = "" && { >&2 echo "\nmissing teaser message."; } + test -e $cover || { >&2 echo "\nmissing cover."; } + test $err -gt 0 && { >&2 echo "\nmissing files:\n"${mfl}; } +} +newinfoentry () { + echo "not implemented yet.\n\nwill be similar to `release`." +} # a mirror is useful for local testing with files test "$1" = "mirror" && { - echo "downloading the website may take quite some time." + shift + >&2 echo "downloading the website may take quite some time." mirror_website http://ds.ccc.de/ } +test "$1" = "linkcheck" && { + shift + linkcheck http://ds.ccc.de/ +} +test "$1" = "release" && { + shift + newdataentry $@ +} +test "$1" = "info" && { + shift + newinfoentry $@ +} #gs -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -q -o ds100-smaller.pdf ds100.pdf