X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=list.sh;h=dd5c83d4a44989e69e23ee17e57c524adb9c2c03;hb=995cf28d73ab4d54981a98844304e522d924ac65;hp=6245261026db7b75a44d5c3722c363b7b4bfd2f4;hpb=dad9cd471358d165f1de2ce8d5806703ac85f5bb;p=serve0 diff --git a/list.sh b/list.sh index 6245261..dd5c83d 100755 --- 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,12 +156,17 @@ list_paginate() { local page i c n end qry page="$(GET p |grep -axE '[0-9]+' || printf 1)"; c=1 end=$((page + LISTSIZE)) - qry="${w_refuri#*\?}"; qry="${qry#p=*&}" + eval "$LOCAL_META" # localize vars from db_meta printf '[div .itemlist ' - while read -r i; do + while :; do c=$((c + 1)) - [ $c -gt $page -a $c -le $end ] && list_item "$i" + if [ $c -gt $page -a $c -le $end ]; then + read_meta || break + list_item + else + read -r discard || break + fi done printf ']' @@ -179,8 +178,8 @@ list_paginate() { 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" + && printf '[a .page .current href="?p=%i&%s" %i]' "${c}" "${QUERY_STRING#p=*&}" "$n" \ + || printf '[a .page href="?p=%i&%s" %i]' "${c}" "${QUERY_STRING#p=*&}" "$n" done printf ']' }