From c432b3ea2bdde965ef26ef07138f305717d05b69 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Fri, 5 Feb 2021 13:00:34 +0100 Subject: [PATCH] always sort categories, caching and ordering for list in course filter --- cards/widgets.sh | 17 +++++++++++++++-- categories/edit_categories.sh | 6 +++++- 2 files changed, 20 insertions(+), 3 deletions(-) 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 -- 2.39.2