]> git.plutz.net Git - serve0/blobdiff - list.sh
Merge commit 'b931bbd0c30907b9cc956d3707b26b449bf41f76'
[serve0] / list.sh
diff --git a/list.sh b/list.sh
index 86b60fd55f3a0260fcf5c246db312d091f6f2fec..94a926465f40f161474b4ef364ab7f1744065c3e 100755 (executable)
--- a/list.sh
+++ b/list.sh
@@ -6,12 +6,6 @@
 
 list_item() {
   local meta file link name
-  eval "$LOCAL_META"
-  meta="${1}";
-
-  read_meta <<-EOF
-       $meta
-       EOF
 
   if [ "${META_NAME%/}" != "${META_NAME}" ]; then
     printf '[a .list .dir href="%s?%s" . %s]' \
@@ -61,7 +55,7 @@ list_item() {
 )"
 
 list_fullname(){
-  local short="$(UNSTRING "${1%${CR}}")" file
+  local short="$1" file
   file="$(printf %s\\n "$_DATA/$ITEM/$short".*)"
   file="${file%%${BR}*}"
   [ -e "$file" ] && printf %s\\n "${file#${_DATA}/${ITEM}/}"
@@ -162,11 +156,20 @@ list_paginate() {
   local page i c n end qry
   page="$(GET p |grep -axE '[0-9]+' || printf 1)"; c=1
   end=$((page + LISTSIZE))
+  eval "$LOCAL_META"  # localize vars from db_meta
 
   printf '[div .itemlist '
-  while read -r i; do
+  while :; do
+    if [ $c -lt $page ]; then
+      read -r discard || break
+    elif [ $c -ge $end ]; then
+      c=$((c + $(wc -l) ))
+      break
+    else
+      read_meta || break
+      list_item
+    fi
     c=$((c + 1))
-    [ $c -gt $page -a $c -le $end  ] && list_item "$i"
   done
   printf ']'