X-Git-Url: https://git.plutz.net/?p=confetti;a=blobdiff_plain;f=courses%2Fexport_pdf.sh;h=62bb69e50f6c00e3c36bcdacc2c84f9f86a0e5ed;hp=7a9a9dd17ee49e876d40cfc7cd62ddad06d7b8ef;hb=f0f4a2847ec2fe8226682eee26c902a3b6d64f58;hpb=d87e28c811b76a4f9bdcc5b8478f7e7b0db37c8f diff --git a/courses/export_pdf.sh b/courses/export_pdf.sh index 7a9a9dd..62bb69e 100755 --- a/courses/export_pdf.sh +++ b/courses/export_pdf.sh @@ -16,7 +16,7 @@ elif ! mkdir -p "$_DATA/export"; then fi ics="$(pdi_load "$coursefile")" -htmlfile="${_DATA}/export/$(pdi_value "$ics" SUMMARY |URL |tr / _).html" +htmlfile="${_DATA}/export/$(pdi_value "$ics" SUMMARY |unescape |tr \\n/ __).html" pdffile=${htmlfile%.html}.pdf pdi_date() { @@ -64,12 +64,15 @@ get_dates() { while [ "$dts_date" -lt "$today" ]; do dts_date="$(date -d "${dts_date} + ${rec}" +%Y%m%d)"; done for n in 1 2 3 4 5 6 7 8 9 10; do - LANG=de_DE.UTF-8 date -d "$dts_date" +"%A, %d. %b." + LANG=de_DE.UTF-8 date -d "$dts_date" +"%d. %b." dts_date="$(date -d "${dts_date} + ${rec}" +%Y%m%d)" done } -"$_EXEC/cgilite/html-sh.sed" <<-EOF |sed -E 's;<(td|th)([^>]*)>;<\1 \2 style="border: 1pt solid\; padding: 1mm 2mm\;">;g' >"$htmlfile" +# some table styles need to be inline, because this is how libreoffice works +style_td='style="border: 1pt solid; padding: 1mm 2mm; vertical-align: top;"' + +"$_EXEC/cgilite/html-sh.sed" <<-EOF >"$htmlfile" [html [head [meta http-equiv="content-type" content="text/html; charset=utf-8"] @@ -86,10 +89,10 @@ get_dates() { th, td { text-align: left; } ] ][body lang="de_DE" - [table width="100%" + [table width="100%" style="page-break-after: always;" [col width=10*] [col width=5*] [col width=10*] [col width=15*] [thead - [tr [th . $(l10n N)] [th . $(l10n BDAY)] [th . $(l10n TEL)] [th . $(l10n NOTE)]] + [tr [th $style_td . $(l10n N)] [th $style_td . $(l10n BDAY)] [th $style_td . $(l10n TEL)] [th $style_td . $(l10n NOTE)]] ][tbody $(grep -F "${coursefile##*/} " "$_DATA/mappings/attendance" |while read discard each; do vcf="$(pdi_load "$_DATA/vcard/$each")" @@ -98,26 +101,32 @@ get_dates() { [ "$type" ] && type="$(l10n "TYPE=$type"):" printf '%s %s
' "$type" "$(pdi_value "$vcf" TEL $n)" done )" - printf '[tr [td .N . %s] [td .BDAY . %s] [td .TEL . %s] [td .NOTE . %s]]\n' \ - "$(pdi_value "$vcf" FN |unescape |HTML)" \ - "$(pdi_value "$vcf" BDAY |unescape |HTML)" \ - "$tel" \ - "$(pdi_value "$vcf" NOTE |unescape |HTML)" - done |sort -k4)] + printf '[tr valign=top [td %s .N . %s] [td %s .BDAY . %s] [td %s .TEL . %s] [td %s .NOTE . %s]]\n' \ + "$style_td" "$(pdi_value "$vcf" FN |unescape |HTML)" \ + "$style_td" "$(pdi_value "$vcf" BDAY |unescape |HTML)" \ + "$style_td" "$tel" \ + "$style_td" "$(pdi_value "$vcf" NOTE |unescape |HTML)" + done |sort)] ] - [table width="100%" style="page-break-before: always;" + [table width="100%" [col width=30*] [col width=10*] [col width=10*] [col width=10*] [col width=10*] [col width=10*] [col width=10*] [col width=10*] [col width=10*] [col width=10*] [col width=10*] [thead - [tr [th ] $(get_dates |xargs -d\\n printf '[th . %s]')] + [tr [th $style_td ] $(get_dates |xargs -d\\n printf "[th $style_td . %s]")] ][tbody $(grep -F "${coursefile##*/} " "$_DATA/mappings/attendance" |while read discard each; do vcf="$(pdi_load "$_DATA/vcard/$each")" - printf '[tr [td .N . %s] [td] [td] [td] [td] [td] [td] [td] [td] [td] [td]]\n' \ - "$(pdi_value "$vcf" FN |unescape |HTML)" - done |sort -k4)] + printf '[tr [td %s .N . %s] [td %s] [td %s] [td %s] [td %s] [td %s] [td %s] [td %s] [td %s] [td %s] [td %s]]\n' \ + "$style_td" "$(pdi_value "$vcf" FN |unescape |HTML)" \ + "$style_td" "$style_td" "$style_td" "$style_td" "$style_td" "$style_td" "$style_td" "$style_td" "$style_td" "$style_td" + done |sort)] ] ]] EOF -lowriter --convert-to pdf --outdir "$_DATA/export/" "$htmlfile" -REDIRECT "/export/${pdffile##*/}" +export HOME="$_DATA" +export XDG_CONFIG_HOME="$_DATA/xdg_config" +export XDG_CACHE_HOME="$_DATA/xdg_cache" +export XDG_DATA_HOME="$_DATA/xdg_local" + +lowriter --convert-to pdf --outdir "$_DATA/export/" "$htmlfile" >/dev/null +REDIRECT "$(URL "/export/${pdffile##*/}")"