]> git.plutz.net Git - serve0/blobdiff - list.sh
update cgilite
[serve0] / list.sh
diff --git a/list.sh b/list.sh
index a408af9b33567c3be511d6fab8659b1c600d3e35..e9a98c0ecf8e75d8a338c8d06350d612568edaf9 100644 (file)
--- a/list.sh
+++ b/list.sh
@@ -37,7 +37,7 @@ list_item() {
       "$width" "$height" \
       "$(printf '%s\n' "${tags#tags=}" \
          | sed -r "$UNSTRING"' s;^;,;; s;,+;,;g; s;,$;;;
-                   :X s;,([^,]+)(,|$); [span .tag\n \1]\2;; tX;'
+                   :X s;,-?([^,]+)(,|$); [span .tag\n \1]\2;; tX;'
       )" "$name" "$link" "$link"
   else
     printf 'Canning record for nonexist file: %s\n' "$name" >&2
@@ -160,10 +160,16 @@ list_paginate() {
   done
   printf ']'
 
+  [ $(( c % LISTSIZE )) -gt 0 ] \
+  && end=$((c / LISTSIZE + 1)) \
+  || end=$((c / LISTSIZE))
+
   printf '[div .pagination'
-  for n in $( seq 1 $((c / LISTSIZE + 1)) ); do
-    printf '[a .page href="%s" %s]' \
-      "?p=$(( (n - 1) * LISTSIZE + 1))&${qry}" "$n"
+  for n in $( seq 1 $end ); do
+    c=$(( (n - 1) * LISTSIZE + 1 ))
+    [ $c = $page ] \
+    && printf '[a .page .current href="%s" %s]' "?p=${c}&${qry}" "$n" \
+    || printf '[a .page href="%s" %s]' "?p=${c}&${qry}" "$n"
   done
   printf ']'
 }