From c804cffce30c171a5ed7aabfd26040787ef23bd1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Sun, 8 Dec 2019 23:15:24 +0100 Subject: [PATCH] stubs for course lists --- courses/list.sh | 22 +++++---- courses/widgets.sh | 115 +++++++++++++++++---------------------------- 2 files changed, 56 insertions(+), 81 deletions(-) diff --git a/courses/list.sh b/courses/list.sh index a0eb6d1..aeafc8b 100755 --- a/courses/list.sh +++ b/courses/list.sh @@ -3,21 +3,21 @@ . "${_EXEC}"/pdiread.sh edit_card(){ - local cardfile="$_DATA/vcard/$1" - local tempfile card + local coursefile="$_DATA/courses/$1" + local tempfile course . $_EXEC/session_lock.sh - if ! tempfile="$(CHECK_SLOCK "$cardfile")"; then - printf '[div .message %s]' "$(l10n "This card is not set up for editing within this session.")" + if ! tempfile="$(CHECK_SLOCK "$coursefile")"; then + printf '[div .message %s]' "$(l10n "This course is not set up for editing within this session.")" else - card="$(pdi_load "$tempfile")" + course="$(pdi_load "$tempfile")" cat <<-EOF - [form .card #${cardfile##*/} action="/cards/update_card.sh" method="POST" + [form .course #${coursefile##*/} action="/cards/update_course.sh" method="POST" [input type="hidden" name="tid" value="$(transid ${tempfile})"] [div .section .basic $( - edit_item "$card" N GENDER - [ "$(pdi_count "$card" NICKNAME)" -gt 0 ] \ + edit_item "$course" N GENDER + [ "$(pdi_count "$course" NICKNAME)" -gt 0 ] \ && edit_item "$card" NICKNAME edit_item "$card" BDAY edit_item "$card" X-ZACK-JOINDATE @@ -88,10 +88,12 @@ print_course(){ "$each" \ "$(pdi_value "$(pdi_load "$_DATA/ical/$each")" SUMMARY |unescape |HTML)" done)] - $(cal_item "$card" CATEGORIES) ] [div .control - [a .item href="" $(l10n edit)] + [a .item href="/courses/edit_course.sh?course=${coursefile##*/}" $(l10n edit)] + [a .item href="/courses/export_pdf.sh?course=${coursefile##*/}" target="blank" $(l10n courselist)] + [a .item href="/courses/export_ical.sh?course=${coursefile##*/}" $(l10n ics_export)] + [a .item href="mailto:zack@vuesch.org?bcc=$(course_mail "${coursefile##*/}")" $(l10n course_mail)] ] ] EOF diff --git a/courses/widgets.sh b/courses/widgets.sh index ec30a78..41fc686 100755 --- a/courses/widgets.sh +++ b/courses/widgets.sh @@ -107,98 +107,71 @@ cal_item(){ } edit_item(){ - local card="$1" + local course="$1" local item cnt c shift 1 for item in $@; do - cnt="$(pdi_count "$card" "$item")" + cnt="$(pdi_count "$course" "$item")" [ $cnt -lt 1 ] && cnt=1 case $item in - N)N="$(pdi_value "$card" N)" - if [ "$N" ]; then - IFS=\; read n1 n2 n3 n4 n5 <<-EOF - $N - EOF - else - N="$(pdi_value "$card" FN |unescape)" - n1="${N%%[a-z]*}" n1="${N#$n1}" - [ "$n1" ] || n1="${N##* }" - n2="${N%$n1}" - fi - printf ' - [h3 %s] - [input .item .N name="4N" placeholder="%s" value="%s"] - [input .item .N name="2N" placeholder="%s" value="%s"] - [input .item .N name="1N" placeholder="%s" value="%s"] - [input .item .N name="5N" placeholder="%s" value="%s"] - ' "$(l10n "$item")" \ - "$(l10n n_pre)" "$(HTML "$n4")" \ - "$(l10n n_first)" "$(HTML "$n2" "$n3")" \ - "$(l10n n_last)" "$(HTML "$n1")" \ - "$(l10n n_post)" "$(HTML "$n5")" - ;; - GENDER) - gender="$(pdi_value "$card" GENDER)" - printf ' - [select .item .GENDER name="GENDER" - [option value="" disabled="disabled" %s %s] - [option value="female" %s %s] - [option value="male" %s %s] - [option value="other" %s %s] - [option value="none" %s %s] - ]\n' \ - "$([ "$gender" = '' ] && printf 'selected="selected"')" "$(l10n GENDER)" \ - "$([ "$gender" = 'female' ] && printf 'selected="selected"')" "$(l10n gender_female)" \ - "$([ "$gender" = 'male' ] && printf 'selected="selected"')" "$(l10n gender_male)" \ - "$([ "$gender" = 'other' ] && printf 'selected="selected"')" "$(l10n gender_other)" \ - "$([ "$gender" = 'none' ] && printf 'selected="selected"')" "$(l10n gender_none)" + DTSTART) + dtstart="$(pdi_value "$course" DTSTART |cal_date)" + ystart="${dtstart%%-*}"; ystart="${ystart##* }" + mstart="${dtstart#*-}"; mstart="${mstart%%-*}" + dstart="${dtstart##*-}"; dstart="${dstart%% *}" + hhstart="${dtstart##* }"; hhstart="${hhstart%%:*}" + mmstart="${dtstart##*:}"; + + printf '[div .section .DTSTART][h3 %s]' "$(l10n DTSTART)" + printf '[select .DTSYEAR name="DTSYEAR" onchange="this.form.submit();"' + seq $((ystart - 50)) $((ystart + 50)) |while read y; do + printf '[option value="%i" %s %i]' $y "$([ $y -eq $ystart ] && printf selected)" $y + done + printf ']' + printf '[select .DTSMONTH name="DTSMONTH" onchange="this.form.submit();"' + seq 1 12 |while read m; do + printf '[option value="%i" %s %s]' $m "$([ $m -eq $mstart ] && printf selected)" "$(date -d "2000-${m}-01" +%B)" + done + printf '][submit "DTS" "update" .DTS %s]' "$(l10n edit_dtscal)" + printf 'mon tue wed thu fri sat sun' |xargs -n1 date -d '{}' +"[span .DTSCALHEAD %a]" + seq 2 "$(date -d ${ystart}-${mstart}-1 +%u)" |xargs -n1 printf '[span .DTSCAL]' + cnt=$(date -d ${dts_year}-${dts_month}-1 +%s) + dn=1; while [ "$(date ${ystart}-${mstart}-${dn} +%m)" -eq "$mstart" ]; do + printf '[input .DTSCAL type="radio" name="DTSDAY" #DTSCAL_%i value="%i" %s][label .DTSCAL for="DTSCAL_%i" %i]' \ + $dn $n "$([ $dn -eq "$dstart" ] && printf checked)" $dn $dn + dn=$((dn + 1)) + done 2>/dev/null + printf '[span .DTSTIME %s:][select .DTSTIME name="DTSHOUR"' "$(l10n time)" + seq 0 23 |while read h; do + printf '[option value="%i" %s %i]' $h "$([ $h -eq $hhstart ] && printf checked)" $h + done + printf ']:[select .DTSTIME name="DTSMINUTE"' + seq 0 5 55 |while read m; do + printf '[option value="%i" %s %i]' $m "$([ $m -eq $mmstart ] && printf checked)" $m + done + printf ']' ;; - BDAY|X-ZACK-JOINDATE|X-ZACK-LEAVEDATE) - printf '[h3 %s] - [input .item .%s name="%s" value="%s" placeholder="YYYY-MM-DD"]' \ - "$(l10n "$item")" "$item" "$item" "$(pdi_value "$card" "$item" |grep -xE '[0-9-]+')" + RRULE) ;; - ADR|NOTE) + COMMENT) printf '[h3 %s]' "$(l10n "$item")" seq 1 $cnt |while read c; do printf '[checkbox "%s_delete_%i" "true" .delete #%s_delete_%i][label for="%s_delete_%i" %s]' \ "$item" $c "$item" $c "$item" $c "$(l10n delete)" printf '' \ - "$item" "$item" "$(pdi_value "$card" "$item" $c |unescape |HTML)" + "$item" "$item" "$(pdi_value "$course" "$item" $c |unescape |HTML)" done printf '[button type="submit" name="action" value="addfield %s" %s ]' "$item" "$(l10n edit_addfield)" ;; - TEL) printf '[h3 %s]' "$(l10n "$item")" - seq 1 $cnt |while read c; do - printf '[checkbox "%s_delete_%i" "true" .delete #%s_delete_%i][label for="%s_delete_%i" %s]' \ - "$item" $c "$item" $c "$item" $c "$(l10n delete)" - teltype="$(pdi_attrib "$card" TEL $c TYPE)" - printf '[select .item .teltype name="teltype" - [option value="" disabled="disabled" %s %s] - [option value="HOME" %s %s] - [option value="WORK" %s %s] - [option value="CELL" %s %s] - [option value="FAX" %s %s] - ]\n' \ - "$([ "$teltype" = '' ] && printf 'selected="selected"')" "$(l10n teltype)" \ - "$([ "$teltype" = 'HOME' ] && printf 'selected="selected"')" "$(l10n TYPE=HOME)" \ - "$([ "$teltype" = 'WORK' ] && printf 'selected="selected"')" "$(l10n TYPE=WORK)" \ - "$([ "$teltype" = 'CELL' ] && printf 'selected="selected"')" "$(l10n TYPE=CELL)" \ - "$([ "$teltype" = 'FAX' ] && printf 'selected="selected"')" "$(l10n TYPE=FAX)" - - printf '[input .item .%s name="%s" value="%s" placeholder="%s"]' \ - "$item" "$item" "$(pdi_value "$card" "$item" $c |unescape |HTML)" "$(l10n "$item")" - done - printf '[button type="submit" name="action" value="addfield %s" %s ]' "$item" "$(l10n edit_addfield)" - ;; - *)printf '[h3 %s]' "$(l10n "$item")" + attendance);; + SUMMARY|*)printf '[h3 %s]' "$(l10n "$item")" seq 1 $cnt |while read c; do printf '[checkbox "%s_delete_%i" "true" .delete #%s_delete_%i][label for="%s_delete_%i" %s]' \ "$item" $c "$item" $c "$item" $c "$(l10n delete)" printf '[input .item .%s name="%s" value="%s" placeholder="%s"]' \ - "$item" "$item" "$(pdi_value "$card" "$item" $c |unescape |HTML)" "$(l10n "$item")" + "$item" "$item" "$(pdi_value "$course" "$item" $c |unescape |HTML)" "$(l10n "$item")" done printf '[button type="submit" name="action" value="addfield %s" %s ]' "$item" "$(l10n edit_addfield)" ;; -- 2.39.2