From: Paul Hänsch Date: Sun, 4 Aug 2019 12:20:42 +0000 (+0200) Subject: typo, separation of caching functions X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=444462594b41e81946546c1376ef1c06e0c414f8;p=confetti typo, separation of caching functions --- diff --git a/cards/list.sh b/cards/list.sh index f598cd2..4a57bd2 100755 --- a/cards/list.sh +++ b/cards/list.sh @@ -121,7 +121,7 @@ edit_item(){ "$([ "$(pdi_value "$card" GENDER)" = 'none' ] && printf 'selected="selected"')" \ "$(l10n gender_none)" ;; - BDAY|X-ZACK-JOIDATE|X-ZACK-LEAVEDATE) + BDAY|X-ZACK-JOINDATE|X-ZACK-LEAVEDATE) printf '[h3 %s] [input .item .%s name="%s" value="%s" placeholder="YYYY-MM-DD"] ' \ @@ -161,6 +161,7 @@ edit_card(){ edit_item "$card" N GENDER [ "$(pdi_count "$card" NICKNAME)" -gt 0 ] \ && edit_item "$card" NICKNAME + edit_item "$card" BDAY edit_item "$card" X-ZACK-JOINDATE [ "$(pdi_count "$card" X-ZACK-LEAVEDATE)" -gt 0 ] \ && edit_item "$card" X-ZACK-LEAVEDATE @@ -217,13 +218,8 @@ edit_card(){ print_card(){ local cardfile="$1" - local cachefile="${_DATA}/cache/${cardfile##*/}.cache" - - if [ "$cachefile" -nt "$cardfile" -a "$cachefile" -nt "${_EXEC}/cards" ]; then - cat "$cachefile" - else - local card="$(pdi_load "$cardfile")" - tee "$cachefile" <<-EOF + local card="$(pdi_load "$cardfile")" + cat <<-EOF [div .card #${cardfile##*/} [div .section .basic ­$( card_item "$card" FN GENDER NICKNAME BDAY X-ZACK-JOINDATE X-ZACK-LEAVEDATE SOUND PHOTO LOGO @@ -246,7 +242,20 @@ print_card(){ ] ] EOF - fi +} + +print_cards(){ + local cardfile cachefile date size name ldate=0 lsize lname + + while read cardfile; do + cachefile="${_DATA}/cache/${cardfile##*/}.cache" + if [ -s "$cachefile" -a "$cachefile" -nt "$cardfile" \ + -a "$cachefile" -nt "${_EXEC}/cards" ]; then + cat "$cachefile" + else + print_card "$cardfile" |tee "$cachefile" + fi + done } filter_cards(){ @@ -307,7 +316,5 @@ list_cards(){ filter_cards \ | order_cards \ | grep -xvF "$edit" \ - | while read cardfile; do - print_card "$cardfile" - done + | print_cards }