]> git.plutz.net Git - serve0/blobdiff - widgets.sh
Merge commit '84d5f73a1c0258adf803c9ec53fbc9b36a1c0edc'
[serve0] / widgets.sh
index a039d97b6b486613b8e19ae2dbb71a318f3c07dd..cd9dda30ca344037e5db60751e9c8a990eec9bfe 100644 (file)
@@ -10,28 +10,11 @@ w_refuri="$(URL "$PATH_INFO")?$(HTML "$QUERY_STRING")"
 w_str_s="$(STRING "$SEARCH")"
 w_str_f="$(STRING "$FILTER")"
 
-w_ascii='
-  s-0-0-g; s-1-1-g; s-2-2-g; s-3-3-g; s-4-4-g; s-5-5-g;
-  s-6-6-g; s-7-7-g; s-8-8-g; s-9-9-g;
-  s-A-A-g; s-B-B-g; s-C-C-g; s-D-D-g; s-E-E-g; s-F-F-g;
-  s-G-G-g; s-H-H-g; s-I-I-g; s-J-J-g; s-K-K-g; s-L-L-g;
-  s-M-M-g; s-N-N-g; s-O-O-g; s-P-P-g; s-Q-Q-g; s-R-R-g;
-  s-S-S-g; s-T-T-g; s-U-U-g; s-V-V-g; s-W-W-g; s-X-X-g;
-  s-Y-Y-g; s-Z-Z-g;
-  s-a-a-g; s-b-b-g; s-c-c-g; s-d-d-g; s-e-e-g; s-f-f-g;
-  s-g-g-g; s-h-h-g; s-i-i-g; s-j-j-g; s-k-k-g; s-l-l-g;
-  s-m-m-g; s-n-n-g; s-o-o-g; s-p-p-g; s-q-q-g; s-r-r-g;
-  s-s-s-g; s-t-t-g; s-u-u-g; s-v-v-g; s-w-w-g; s-x-x-g;
-  s-y-y-g; s-z-z-g;
-  s---\--g; s-/-/-g; s-/-/-g; s-:-:-g; s-=-=-g; s-@-@-g;
-  s-_-_-g; s-~-~-g;              s- - -g; s-^-^-g; s-|-|-g;
-'
-
-w_tags="$_DATA/.index/tags.cache"; w_tagcategories="$_DATA/.index/tagcategories.cache"
-if [ ! -f "$w_tags" -o ! -f "$w_tagcategories" ] \
-   || [ "$(find "$_DATA/" -path '*/.index/meta' -newer "$w_tags")" ]
+c_tags="$_DATA/.index/tags.cache"; c_tagcategories="$_DATA/.index/tagcategories.cache"
+if [ ! -s "$c_tags" -o ! -s "$c_tagcategories" ] \
+   || [ "$(find "$_DATA/" -path '*/.index/meta' -newer "$c_tags")" ]
   then
-  w_tags="$( local cn=1
+  w_tags="$( local cn=1
     find "$_DATA/" -path '*/.index/meta' -print0 \
     | xargs -r0 sed -r '
       s;^.*\t.*\t.*\ttags=(.*)\tcomment=.*\t.*\r$;\1;;
@@ -45,14 +28,16 @@ if [ ! -f "$w_tags" -o ! -f "$w_tagcategories" ] \
         cn=1
       }
       otag="$tag"
-    done
-  } |sort -rn |cut -f2- |HTML |sed "$w_ascii s-
-\n-g; s;\n\n;\n;g;" |tee "$w_tags" )"
-  w_tagcategories="$(printf %s "$w_tags" \
-                     | sed -rn '/:/s;^-?([^:]+):.*$;\1;p' |sort -u \
-                     | tee "$w_tagcategories" )"
+    done \
+    |sort -rn |cut -f2- |HTML \
+    |sed "s-
-\n-g; s;\n\n;\n;g;"
+  )"
+  w_tagcategories="$(printf %s "$w_tags" | sed -rn '/:/s;^-?([^:]+):.*$;\1;p' |sort -u )"
+  printf %s "$w_tags" >"$c_tags"
+  printf %s "$w_tagcategories" >"$c_tagcategories"
 else
-  w_tags="$(cat "$w_tags")"
-  w_tagcategories="$(cat "$w_tagcategories")"
+  w_tags="$(cat "$c_tags")"
+  w_tagcategories="$(cat "$c_tagcategories")"
 fi
 
 
@@ -113,7 +98,7 @@ w_bookmarks(){
             [a .link target=blank href="/?o=Date&s=%s&f=%s" by Date]
             [a .link target=blank href="/?o=Length&s=%s&f=%s" by Length]
             [a .link target=blank href="/?o=Group&s=%s&f=%s" by Group]
-            [br]' \
+            ' \
             "$(HTML "$name" |sed 's;&#44\;;&[wbr];g;')" \
             "$search" "$filter" \
             "$search" "$filter" \
@@ -134,6 +119,7 @@ w_search(){
       [option value=Group %s Group]
     ]
     [input name=s placeholder=Search value="%s"]
+    [a #t_avsearch href="#advsearch" Advanced]
   ]
   ' \
   "$w_coname" "$w_codate" "$w_colength" "$w_cogroup" \
@@ -179,11 +165,11 @@ w_index(){
 
 w_advsearch(){
   local n lbid tag category filter f t d
-  filter="$(HTML "${FILTER}^" |sed "$w_ascii")"
+  filter="$(HTML "${FILTER}^")"
 
   printf '[form #advsearch action=./?a=advsearch method=POST
-            [a href="#" Hide]
-            [p .help Select multiple tags from each category by holding down the [strong Ctrl] key on your keyboard.[br]
+            [a href="#" X]
+            [p .help Select multiple tags from each category by holding down the [strong Ctrl] key on your keyboard.
             Refine the search further by setting additional search tags using the [strong "+and"] button.]'
 
   for n in 1 2 3 4 5 6 7 8 9 10; do
@@ -211,9 +197,12 @@ w_advsearch(){
       [ "$category" != '*' -a ! "${f%%|${category}:*}" ] && t=checked
       [ "$category" != '*' -a ! "${f%%|-${category}:*}" ] && t=checked
 
+      # printf '[radio "cat_%i" "%s" .cat %s id="%s"][label for="%s" %s]
+      #         [select name=tag_%s size=10 multiple' \
+      #         $n "$category" "$t" "$lbid" "$lbid" "$category" $n
       printf '[radio "cat_%i" "%s" .cat %s id="%s"][label for="%s" %s]
-              [select name=tag_%s size=10 multiple' \
-              $n "$category" "$t" "$lbid" "$lbid" "$category" $n
+              [div .catselect\n' \
+              $n "$category" "$t" "$lbid" "$lbid" "$category"
 
       printf '%s\n' "$w_tags" \
       | { [ "$category" = '*' ] && grep -avF ':' || grep -awF "${category}"; } \
@@ -225,7 +214,8 @@ w_advsearch(){
         [ "$tag" ] || continue
         t=''; [ ! "${f%%*|${tag}|*}" ] && t=checked
         d="${tag#-}"; d="${d#*:}"
-        printf '[option %s value="%s"\n%s]' "$t" "$tag" "$d"
+        # printf '[option %s value="%s"\n%s]' "$t" "$tag" "$d"
+       printf '[label [checkbox "tag_%s" "%s" %s] %s]' "$n" "$tag" "$t" "$d"
       done
       printf '\n]'
     done
@@ -247,7 +237,7 @@ w_advsearch(){
 w_delete(){
   printf '[a href="#multitag" Add Tags / Remove Tags]
           [div #multitag [input type="hidden" name="ref" value="%s"]
-          [a href="#" Hide][br]
+          [a href="#" X]
           [fieldset [legend New:]
           [submit "op" "filedelete" Delete Files]
           ]]' "$w_refuri"
@@ -257,12 +247,13 @@ w_tagging(){
   local tag category d
   printf '[a href="#multitag" Add Tags / Remove Tags]
           [div #multitag [input type="hidden" name="ref" value="%s"]' "$w_refuri"
-  printf '[a href="#" Hide][br]'
+  printf '[a href="#" X]'
 
   printf 'Tags\n%s\n' "$w_tagcategories" \
   | while read -r category; do
     [ "$category" ] || continue
-    printf '[fieldset [legend %s:][select name=tag size=4 multiple\n' "$category"
+    # printf '[fieldset [legend %s:][select name=tag size=4 multiple\n' "$category"
+    printf '[fieldset [legend %s:][div .tagselect\n' "$category"
     printf %s "$w_tags" \
     | { [ "$category" = 'Tags' ] && grep -avF ':' || grep -awF "${category}"; } \
     | { for n in 1 2 3 4 5 6 7 8 9 0; do
@@ -272,7 +263,8 @@ w_tagging(){
     } | while read -r tag; do
       [ "$tag" ] || continue
       d="${tag#-}"; d="${d#*:}"
-      printf '[option value="%s"\n%s]' "$tag" "$d"
+      # printf '[option value="%s"\n%s]' "$tag" "$d"
+      printf '[label [checkbox "tag" "%s"] %s]\n' "$tag" "$d"
     done
     printf ']]'
   done