From 0419aadded163a6d4e00b700cab7794e3bd81ee4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Wed, 10 Feb 2021 13:19:37 +0100 Subject: [PATCH] list courses alphabetically when editing attendant --- cards/list.sh | 10 +++++----- cards/widgets.sh | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cards/list.sh b/cards/list.sh index cd0d21f..9f1e1d8 100755 --- a/cards/list.sh +++ b/cards/list.sh @@ -35,13 +35,13 @@ edit_card(){ [div .section .note $(edit_item "$card" NOTE)] [div .section .attendance [h3 $(l10n course_attendance) ] $( - for course in "$_DATA"/ical/*.ics; do + list_courses |while IFS=/ read course coursename; do printf '[label [input type="checkbox" name="attendance" value="%s" %s] %s]' \ - "${course##*/}" \ - "$(grep -qF "${course##*/} ${cardfile##*/}" "$_DATA/mappings/attendance" \ + "$(HTML "$course")" \ + "$(grep -qF "${course} ${cardfile##*/}" "$_DATA/mappings/attendance" \ && printf 'checked="checked"' )" \ - "$(pdi_value "$(pdi_load "$course")" SUMMARY || l10n "(unnamed course)" |unescape |HTML)" + "$coursename" done) [h3 $(l10n CATEGORIES) ] $( grep -xE '[^ ]+' "$_DATA"/mappings/categories |while read -r cat; do @@ -95,7 +95,7 @@ print_card(){ printf '[li [a .item .attendance href="/courses#%s" . %s]]' \ "$each" \ "$(pdi_value "$(pdi_load "$_DATA/ical/$each")" SUMMARY || l10n "(unnamed course)" |unescape |HTML)" - done)] + done |sort -k7)] $(card_item "$card" CATEGORIES) ] [div .control diff --git a/cards/widgets.sh b/cards/widgets.sh index 463a648..61a6938 100755 --- a/cards/widgets.sh +++ b/cards/widgets.sh @@ -25,10 +25,10 @@ list_courses() { cat "$cachefile" else for file in "$_DATA/ical"/*.ics; do - name="$(pdi_value "$(pdi_load "$file")" SUMMARY |HTML)" - printf '%s %s\n' "$file" "$name" + name="$(pdi_value "$(pdi_load "$file")" SUMMARY || l10n "(unnamed course)" |unescape |HTML)" + printf '%s/%s\n' "${file##*/}" "$name" done \ - | sort -k2 |tee "$cachefile" + | sort -t/ -k2 |tee "$cachefile" fi } @@ -54,7 +54,7 @@ cat <