]> git.plutz.net Git - serve0/blobdiff - list.sh
Merge branch 'cgilite' of git.plutz.net:serve0 into cgilite
[serve0] / list.sh
diff --git a/list.sh b/list.sh
index 2dc1a8340307a7ca0f09f4d26c74d45b975d1ba8..9e2f2f8a110029dbd1ae8e766da9875e7c139703 100644 (file)
--- a/list.sh
+++ b/list.sh
@@ -4,9 +4,10 @@
 . "$_EXEC/widgets.sh"
 
 list_item() {
-  local name path length width height tags comment n
+  local name link path length width height tags comment n
   name="$(HTML "$1")"
-  path="$(URL "$ITEM/$1")"
+  link="$(URL "$ITEM/$1")"
+  path="$(HTML "$ITEM/$1")"
   qry=$(HTML "$QUERY_STRING")
 
   if [ -d "$_DATA/$ITEM/$1" ]; then
@@ -18,9 +19,9 @@ list_item() {
     printf '[div .list .file
               [a href="%s" [img src="%s?a=thumbnail"][label %s]]
               [span .time %i:%imin] [span .dim %ix%i] %s
-              [checkbox "select" "%s" id="select_%s" form="multitag"][label for="select_%s" +]
+              [checkbox "select" "%s" id="select_%s"][label for="select_%s" +]
             ]' \
-      "$path" "$path" "$name" \
+      "$link" "$link" "$name" \
       "$((length / 60))" "$((length % 60))" \
       "$width" "$height" \
       "$(UNSTRING "${tags#tags=}" |tr , '\0' |xargs -r0 printf ' [span .tag %s]')" \
@@ -69,20 +70,23 @@ list_filemeta(){
   if [ $ORDER = Name ]; then
     sort -k6 "$meta"
   elif [ $ORDER = Length ]; then
-    sort -n "$meta"
+    sort -n -k1 "$meta"
   else
     cat "$meta"
   fi \
   | if [ "$FILTER" ]; then
     sed -nr "$list_fex"
   elif [ "${SEARCH#!}" != "${SEARCH}" ]; then
-    grep -viE "$(STRING "${SEARCH#!}")"
+    grep -aviE "$(STRING "${SEARCH#!}" |sed -r ':x s;((^|[^\\])(\\\\)*)\+;\1\\+;g; tx;')"
   else
-    grep -iE "$(STRING "${SEARCH}")"
+    grep -aiE "$(STRING "${SEARCH}" \
+                 | sed -r ':x s;((^|[^\\])(\\\\)*)\+;\1 ;g; tx;
+                            s;((^|[^\\])(\\\\)*)\\\+;\1+;g;
+                            s; ;\\+;g;')"
   fi |cut -f6 | UNSTRING \
   | while read -r fn; do
     printf '%s\n' "${base}/${fn%${CR}}"
-  done
+  done | tee .index/debug
 }
 
 list_index(){
@@ -105,7 +109,7 @@ list_dateorder(){
 
 list_items() {
   local mode
-  mode="$(COOKIE mode |grep -m1 -xE 'index|browse' || printf browse )"
+  mode="$(COOKIE mode |grep -m1 -axE 'index|browse' || printf browse )"
 
   [ "$mode" = browse -a "$ITEM" ] && printf '..\n'
 
@@ -124,7 +128,7 @@ list_items() {
 
 list_paginate() {
   local page i c n end
-  page="$(GET p |grep -xE '[0-9]+' || printf 1)"; c=1
+  page="$(GET p |grep -axE '[0-9]+' || printf 1)"; c=1
   end=$((page + LISTSIZE))
 
   printf '[div .itemlist '