typo, separation of caching functions
authorPaul Hänsch <paul@plutz.net>
Sun, 4 Aug 2019 12:20:42 +0000 (14:20 +0200)
committerPaul Hänsch <paul@plutz.net>
Sun, 4 Aug 2019 12:20:42 +0000 (14:20 +0200)
cards/list.sh

index f598cd2..4a57bd2 100755 (executable)
@@ -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 &shy;$(
         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
 }