From: Paul Hänsch Date: Fri, 5 Feb 2021 12:00:34 +0000 (+0100) Subject: always sort categories, caching and ordering for list in course filter X-Git-Url: https://git.plutz.net/?p=confetti;a=commitdiff_plain;h=c432b3ea2bdde965ef26ef07138f305717d05b69 always sort categories, caching and ordering for list in course filter --- diff --git a/cards/widgets.sh b/cards/widgets.sh index 7dfa3ad..c0c0594 100755 --- a/cards/widgets.sh +++ b/cards/widgets.sh @@ -19,6 +19,19 @@ list_categories() { grep -vxE '^[ ]*$' "${_DATA}/mappings/categories" } +list_courses() { + local file name cachefile="${_DATA}/cache/courses.ui.cache" + if [ $cachefile -nt "${_DATA}/ical" ]; then + cat "$cachefile" + else + for file in "$_DATA/ical"/*.ics; do + name="$(pdi_value "$(pdi_load "$file")" SUMMARY |HTML)" + printf '%s %s\n' "$file" "$name" + done \ + | sort -k2 |tee "$cachefile" + fi +} + w_filter_item() { n=$3 cat <>"$catfile" + categories="$( { + cat "$catfile" + printf %s\\n "$newcat" + } |sort -u )" + printf %s\\n "$categories" >"$catfile" elif [ "$remove" ]; then sed -E -i '/^'"${remove}"'$/d' "$catfile" fi