]> git.plutz.net Git - serve0/commitdiff
simplification and sanitizing
authorPaul Hänsch <paul@plutz.net>
Tue, 17 Jul 2018 00:26:09 +0000 (02:26 +0200)
committerPaul Hänsch <paul@plutz.net>
Tue, 17 Jul 2018 00:26:09 +0000 (02:26 +0200)
cgilite
widgets.sh

diff --git a/cgilite b/cgilite
index 6aa432e55d9227b58dbe3d20518eb7adfa057070..cbd426df72dee35e5920de18084ca6770454481d 160000 (submodule)
--- a/cgilite
+++ b/cgilite
@@ -1 +1 @@
-Subproject commit 6aa432e55d9227b58dbe3d20518eb7adfa057070
+Subproject commit cbd426df72dee35e5920de18084ca6770454481d
index 62a40271b735f06cd9a8bd255374d79457facdca..1b5f7708425a960b6d57e8496fa314e053964ec3 100644 (file)
@@ -13,18 +13,23 @@ w_tags="$(find "$_DATA/" -path '*/.index/meta' -print0 \
 w_tags="$(UNSTRING "$w_tags")"
 w_tagcategories="$(printf %s "$w_tags" |cut -sd: -f1 |sort -u)"
 
+CHECK(){ [ "$1" = "$2" ] && printf checked; }
+
 w_search(){
   printf '
   [form #search method=GET action=?
     [select name=o size=1 
       [option disabled=disabled Order By]
-      [option value=Name Name]
-      [option value=Date Date]
-      [option value=Length Length]
+      [option value=Name %s Name]
+      [option value=Date %s Date]
+      [option value=Length %s Length]
     ]
     [input name=s placeholder=Search value="%s"]
   ]
   ' \
+  "$(CHECK "$ORDER" Name)" \
+  "$(CHECK "$ORDER" Date)" \
+  "$(CHECK "$ORDER" Length)" \
   "$(HTML "$SEARCH")"
 }
 
@@ -45,9 +50,9 @@ w_prefs(){
   ]
   ' \
   "$w_refuri" "$LISTSIZE" \
-  "$([ "$mode" = index ] || printf checked)" \
-  "$([ "$mode" = index ] && printf checked)" \
-  "$([ "$fakemp4" = yes    ] && printf checked)"
+  "$([ "$mode" = index  ] || CHECK)" \
+  "$(CHECK "$mode" index)" \
+  "$(CHECK "$fakemp4" yes)"
 }
 
 w_index(){
@@ -81,9 +86,9 @@ w_advsearch(){
             [radio "pol_%i" "pos" .pol %s #pol_pos_%i"][label for=pol_pos_%i Any]
             [radio "pol_%i" "neg" .pol %s #pol_neg_%i"][label for=pol_neg_%i None]
             [label .head Category:]' \
-            $n "$([ "$f" ] && printf 'checked')" $n \
-            $n "$([ "$f" -a ! "${f%%~*}" ] || printf 'checked')" $n $n \
-            $n "$([ "$f" -a ! "${f%%~*}" ] && printf 'checked')" $n $n
+            $n "$([ "$f" ] && printf checked)" $n \
+            $n "$([ "$f" -a ! "${f%%~*}" ] || printf checked)" $n $n \
+            $n "$([ "$f" -a ! "${f%%~*}" ] && printf checked)" $n $n
     f="|${f#~}|"
 
     printf '*\n%s\n' "$w_tagcategories" \
@@ -93,7 +98,7 @@ w_advsearch(){
       printf '[radio "cat_%i" "%s" .cat id="%s" %s][label for="%s" %s]
               [select name=tag_%s size=10 multiple' \
               $n "$catn" "$lbid" \
-              "$([ ! "${f%%*|${category}:*}" -o ! "${category%\*}" ] && printf 'checked')" \
+              "$([ ! "${f%%*|${category}:*}" -o ! "${category%\*}" ] && printf checked)" \
               "$lbid" "$catn" $n
 
       printf %s "$w_tags" \
@@ -101,8 +106,8 @@ w_advsearch(){
       | while read -r tag; do
         [ ! "$tag" ] && continue
         tg="$(HTML "$tag")"; tn="${tg#*&#58;}"
-        printf '[option %s value="%s" %s]' \
-          "$([ ! "${f%%*|${tag}|*}" ] && printf 'selected')" \
+        printf '[option %s value="%s"\n%s]' \
+          "$([ ! "${f%%*|${tag}|*}" ] && printf selected)" \
           "$tg" "$tn"
       done
       printf '\n]'
@@ -112,11 +117,14 @@ w_advsearch(){
 
   printf '[fieldset .submit [select name=order
             [option disabled=disabled Order By]
-            [option value=Name Name]
-            [option value=Date Date]
-            [option value=Length Length]
+            [option value=Name %s Name]
+            [option value=Date %s Date]
+            [option value=Length %s Length]
           ][button type=submit Apply Filter]]
-          ]'
+          ]' \
+          "$(CHECK "$ORDER" Name)" \
+          "$(CHECK "$ORDER" Date)" \
+          "$(CHECK "$ORDER" Length)"
 }
 
 w_tagging(){
@@ -132,7 +140,7 @@ w_tagging(){
     | while read -r tag; do
       [ ! "$tag" ] && continue
       tag="$(HTML "$tag")"; tn="${tag#*&#58;}"
-      printf '[option value="%s" %s]' "$tag" "$tn"
+      printf '[option value="%s"\n%s]' "$tag" "$tn"
     done
     printf ']]'
   done