]> git.plutz.net Git - serve0/commitdiff
simplified filter mechanism
authorpaul <paul@plutz.net>
Mon, 22 Sep 2014 01:10:01 +0000 (01:10 +0000)
committerpaul <paul@plutz.net>
Mon, 22 Sep 2014 01:10:01 +0000 (01:10 +0000)
svn path=/trunk/; revision=15

actions/filter.sh
templates/filterdiag.html.sh

index 32f867daf826ba1e4c72aff97b7c09a8560db66c..ea0f85cc78d5d6220c08d81adaec9fde11d61688 100755 (executable)
@@ -14,19 +14,11 @@ for fn in {0..9}; do
     egrep -q '(^|\^|\||!)$' <<<"$filters" || filters="${filters}^"
   fi
 
-  n=''
-  while [ -n "$_POST[\"filter${fn}_$n\"]" ]; do
-    filter="$(echo "$_POST[\"filter${fn}_$n\"]" |sed 's/\t/ /g;s/\r//g;s/\\/\\\\/g' |head -n1)"
-    egrep -q '(^|\^|\||!)$' <<<"${filters}" || filters="${filters}|"
-    filters="${filters}${filter}"
-    [ -z "$n" ] && n=0 || n=$(($n + 1))
-  done
-
   n=''
   while [ -n "$_POST[\"cfilter${fn}_$n\"]" ]; do
     cfilter="$(echo "$_POST[\"cfilter${fn}_$n\"]" |sed 's/\t/ /g;s/\r//g;s/\\/\\\\/g' |head -n1)"
     egrep -q '(^|\^|\||!)$' <<<"${filters}" || filters="${filters}|"
-    filters="${filters}${category}:${cfilter}"
+    [ "$category" = "none" ] && filters="${filters}${cfilter}" || filters="${filters}${category}:${cfilter}"
     [ -z "$n" ] && n=0 || n=$(($n + 1))
   done
 done
index 9a388887c9d294740e28b4ea84320ca857fb1e03..3e81b286152b7ac5fd1c316371449bbaeeac1ee8 100755 (executable)
@@ -44,7 +44,7 @@ cat <<FilterEnd
     <span class="help">Up to <b>10</b> filter boxes will appear as you start selecting tags. You can select <b>multiple</b> tags in each box by holding down the <b>Ctrl</b>-key. Click the "<b>Filter!</b>" button when you are ready.</span>
 
   $(for n in {0..9}; do
-    hideall="$(sed -rn "s;^([^:]+):.*$;hide('${n}_\\1')\\;;p" <<<"$taglist" |sort -u)hide('${n}_none');"
+    hideall="$(echo "$taglist" |sed -rn "s;^([^:]+):.*$;hide('${n}_\\1')\\;;p" |sort -u)hide('${n}_none');"
     echo "
     <div class="filter" id=\"filter$n\" $([ $n -gt 0 ] && echo 'style="display:none;"')>
       <span class=\"help conjunction\">and</span>
@@ -54,16 +54,16 @@ cat <<FilterEnd
       <span class=\"label category\">Category:</span>
       <select class=\"input category\" name=\"category$n\" size=\"1\" onchange=\"${hideall}show_block('${n}_'+this.options[this.options.selectedIndex].value)\">
         <option>none</option>
-        $(sed -rn 's;^([^:]+):.*$;<option>\1</option>;p' <<<"$taglist" |sort -u)
+        $(echo "$taglist" |sed -rn 's;^([^:]+):.*$;<option>\1</option>;p' |sort -u)
       </select>
-      <select class=\"input tagfilter\" name=\"filter${n}_\" size=\"12\" multiple id=\"${n}_none\"
+      <select class=\"input tagfilter\" name=\"cfilter${n}_\" size=\"12\" multiple id=\"${n}_none\"
               onchange=\"show_iblock('filter$((1+$n))')\">
-         $(sed -rn 's;^([^:]+)$;<option>\1</option>;p' <<<"$taglist")
+         $(echo "$taglist" |sed -rn 's;^([^:]+)$;<option>\1</option>;p')
       </select>
-      $(sed -rn 's;^([^:]+):.*$;\1;p' <<<"$taglist" |sort -u |while read cat; do echo "
+      $(echo "$taglist" |sed -rn 's;^([^:]+):.*$;\1;p' |sort -u |while read cat; do echo "
       <select class=\"input tagfilter\" name=\"cfilter${n}_\" size=\"12\" multiple id=\"${n}_$cat\" style=\"display:none;\"
               onchange=\"show_iblock('filter$((1+$n))')\">
-         $(sed -rn "s;^$cat:(.*)$;<option>\\1</option>;p" <<<"$taglist")
+         $(echo "$taglist" |sed -rn 's;^'"$cat"':(.*)$;<option>\1</option>;p')
       </select>"
       done)
     </div>"