3 . "${_EXEC}/pdiread.sh"
4 . "$_EXEC/cards/l10n.sh"
6 coursefile="${_DATA}/ical/$(GET course)"
8 if [ ! -r "$coursefile" ]; then
9 SET_COOKIE 0 message="Cannot read course file"
12 elif ! mkdir -p "$_DATA/export"; then
13 SET_COOKIE 0 message="Cannot create export directory"
18 ics="$(pdi_load "$coursefile")"
19 htmlfile="${_DATA}/export/$(pdi_value "$ics" SUMMARY |URL |tr / _).html"
20 pdffile=${htmlfile%.html}.pdf
23 local pdt y m d H M S Z
24 [ $# -eq 0 ] && read pdt || pdt="$*"
28 Z=UTC; pdt="${pdt%Z}";;
30 Z="${pdt%%:*}"; Z=${Z#TZID=}; pdt=${pdt#TZID=*:};;
33 y="${pdt%%????T*}" pdt=${pdt#????}
34 m="${pdt%%??T*}" pdt=${pdt#??}
35 d="${pdt%%T*}" pdt=${pdt#??T}
36 H="${pdt%%????}" pdt=${pdt#??}
37 M="${pdt%%??}" pdt=${pdt#??}
41 UTC) date -d "${y}-${m}-${d} ${H}:${M}:${S} UTC" +%s;;
42 '') date -d "${y}-${m}-${d} ${H}:${M}:${S}" +%s;;
43 *) date -d "TZ=\"${Z}\" ${y}-${m}-${d} ${H}:${M}:${S}" +%s;;
48 local dts_date rrule rr_int rr_freq rec today="$(date +%Y%m%d)"
50 dts_date="$(pdi_value "$ics" DTSTART || printf %s "$today")"
51 dts_date="${dts_date#TZID=*:}" dts_date="${dts_date%%T*}"
52 rrule="$(pdi_value "$ics" RRULE)"
53 rr_int="${rrule##*INTERVAL=}" rr_int="${rr_int%%;*}"
54 rr_freq="${rrule##*FREQ=}" rr_freq="${rr_freq%%;*}"
56 [ "$rr_int" -ge 0 ] || rr_int=1 2>/dev/null
58 YEARLY) rec="$rr_int year";;
59 MONTHLY) rec="$rr_int month";;
60 DAILY) rec="$rr_int day";;
61 WEEKLY) rec="$rr_int week";;
62 *) rec="$rr_int week";;
65 while [ "$dts_date" -lt "$today" ]; do dts_date="$(date -d "${dts_date} + ${rec}" +%Y%m%d)"; done
66 for n in 1 2 3 4 5 6 7 8 9 10; do
67 LANG=de_DE.UTF-8 date -d "$dts_date" +"%A, %d. %b."
68 dts_date="$(date -d "${dts_date} + ${rec}" +%Y%m%d)"
72 "$_EXEC/cgilite/html-sh.sed" <<-EOF |sed -E 's;<(td|th)([^>]*)>;<\1 \2 style="border: 1pt solid\; padding: 1mm 2mm\;">;g' >"$htmlfile"
73 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
75 [meta http-equiv="content-type" content="text/html; charset=utf-8"]
77 [meta name="generator" content="Confetti"]
78 [meta name="created" content="$(date +%FT%T)"]
79 [meta name="changed" content="$(date +%FT%T)"]
80 [style type="text/css"
81 @page { size: 29.7cm 21cm; margin: 1.5cm; }
82 * { background: inherit; }
83 body { background: transparent; font-family: Liberation Sans, Sans-Serif; }
85 th { white-space: pre; }
86 th, td { text-align: left; }
90 [col width=10*] [col width=5*] [col width=10*] [col width=15*]
92 [tr [th . $(l10n N)] [th . $(l10n BDAY)] [th . $(l10n TEL)] [th . $(l10n NOTE)]]
94 $(grep -F "${coursefile##*/} " "$_DATA/mappings/attendance" |while read discard each; do
95 vcf="$(pdi_load "$_DATA/vcard/$each")"
96 tel="$( seq 1 $(pdi_count "$vcf" TEL) |while read n; do
97 type="$(pdi_attrib "$vcf" TEL $n TYPE)"
98 [ "$type" ] && type="$(l10n "TYPE=$type"):"
99 printf '%s %s<br>' "$type" "$(pdi_value "$vcf" TEL $n)"
101 printf '[tr [td .N . %s] [td .BDAY . %s] [td .TEL . %s] [td .NOTE . %s]]\n' \
102 "$(pdi_value "$vcf" FN |unescape |HTML)" \
103 "$(pdi_value "$vcf" BDAY |unescape |HTML)" \
105 "$(pdi_value "$vcf" NOTE |unescape |HTML)"
108 [table width="100%" style="page-break-before: always;"
109 [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*]
111 [tr [th ] $(get_dates |xargs -d\\n printf '[th . %s]')]
113 $(grep -F "${coursefile##*/} " "$_DATA/mappings/attendance" |while read discard each; do
114 vcf="$(pdi_load "$_DATA/vcard/$each")"
115 printf '[tr [td .N . %s] [td] [td] [td] [td] [td] [td] [td] [td] [td] [td]]\n' \
116 "$(pdi_value "$vcf" FN |unescape |HTML)"
122 lowriter --convert-to pdf --outdir "$_DATA/export/" "$htmlfile"
123 REDIRECT "/export/${pdffile##*/}"