]> git.plutz.net Git - serve0/commitdiff
bugfix: dont drop last tag in listing
authorPaul Hänsch <paul@plutz.net>
Sat, 21 Jul 2018 02:10:16 +0000 (04:10 +0200)
committerPaul Hänsch <paul@plutz.net>
Sat, 21 Jul 2018 02:10:16 +0000 (04:10 +0200)
widgets.sh

index 0474fa5ea7f07ce669995f6caaf3ed4288438c0f..f64930661445622732d23b372caaa082a8ce7ea1 100644 (file)
@@ -21,7 +21,7 @@ w_ascii='
   s-&#115;-s-g; s-&#116;-t-g; s-&#117;-u-g; s-&#118;-v-g; s-&#119;-w-g; s-&#120;-x-g;
   s-&#121;-y-g; s-&#122;-z-g;
   s-&#45;-\--g; s-&#47;-/-g; s-&#47;-/-g; s-&#58;-:-g; s-&#61;-=-g; s-&#64;-@-g;
   s-&#115;-s-g; s-&#116;-t-g; s-&#117;-u-g; s-&#118;-v-g; s-&#119;-w-g; s-&#120;-x-g;
   s-&#121;-y-g; s-&#122;-z-g;
   s-&#45;-\--g; s-&#47;-/-g; s-&#47;-/-g; s-&#58;-:-g; s-&#61;-=-g; s-&#64;-@-g;
-  s-&#95;-_-g; s-&#126;-~-g;              s-&#20;- -g; s-&#94;-^-g; s-&#124;-|-g;
+  s-&#95;-_-g; s-&#126;-~-g;              s-&#32;- -g; s-&#94;-^-g; s-&#124;-|-g;
 '
 
 w_tags="$_DATA/.index/tags.cache"; w_tagcategories="$_DATA/.index/tagcategories.cache"
 '
 
 w_tags="$_DATA/.index/tags.cache"; w_tagcategories="$_DATA/.index/tagcategories.cache"
@@ -33,8 +33,8 @@ if [ ! -f "$w_tags" -o ! -f "$w_tagcategories" ] \
     | xargs -r0 sed -r '
       s;^.*\t.*\t.*\ttags=(.*)\tcomment=.*\t.*\r$;\1;;
       s;,;\n;g;'"$UNSTRING" \
     | xargs -r0 sed -r '
       s;^.*\t.*\t.*\ttags=(.*)\tcomment=.*\t.*\r$;\1;;
       s;,;\n;g;'"$UNSTRING" \
-    | sort \
-    | while read tag; do
+    | { sort; printf '\n'; } \
+    | while read -r tag; do
       [ "$tag" = "$otag" ] \
       && cn=$((cn + 1)) \
       || {
       [ "$tag" = "$otag" ] \
       && cn=$((cn + 1)) \
       || {
@@ -43,8 +43,7 @@ if [ ! -f "$w_tags" -o ! -f "$w_tagcategories" ] \
       }
       otag="$tag"
     done
       }
       otag="$tag"
     done
-    printf "%i %s\n" "$cn" "$otag"
-  } |sort -rn |cut -f2- |HTML |sed "$w_ascii s-&#10;-\n-g;" |tee "$w_tags" )"
+  } |sort -rn |cut -f2- |HTML |sed "$w_ascii s-&#10;-\n-g; s;\n\n;\n;g;" |tee "$w_tags" )"
   w_tagcategories="$(printf %s "$w_tags" \
                      | cut -sd: -f1 |sort -u \
                      | tee "$w_tagcategories" )"
   w_tagcategories="$(printf %s "$w_tags" \
                      | cut -sd: -f1 |sort -u \
                      | tee "$w_tagcategories" )"
@@ -196,9 +195,10 @@ w_advsearch(){
               $n "$category" "$t" "$lbid" "$lbid" "$category" $n
 
       printf '%s\n' "$w_tags" \
               $n "$category" "$t" "$lbid" "$lbid" "$category" $n
 
       printf '%s\n' "$w_tags" \
-      | { [ "$category" = '*' ] && grep -avF ':' |grep -avxF '' || grep -awF "${category}"; } \
-      | { for n in 1 2 3 4 5 6 7 8 9 0; do line; done; sort; } \
+      | { [ "$category" = '*' ] && grep -avF ':' || grep -awF "${category}"; } \
+      | { for n in 1 2 3 4 5 6 7 8 9 0; do line || break; done; sort; } \
       | while read -r tag; do
       | while read -r tag; do
+        [ "$tag" ] || continue
         t=''; [ ! "${f%%*|${tag}|*}" ] && t=checked
         printf '[option %s value="%s"\n%s]' "$t" "$tag" "${tag#*:}"
       done
         t=''; [ ! "${f%%*|${tag}|*}" ] && t=checked
         printf '[option %s value="%s"\n%s]' "$t" "$tag" "${tag#*:}"
       done
@@ -228,9 +228,10 @@ w_tagging(){
   | while read -r category; do
     printf '[fieldset [legend %s:][select name=tag size=4 multiple' "$category"
     printf %s "$w_tags" \
   | while read -r category; do
     printf '[fieldset [legend %s:][select name=tag size=4 multiple' "$category"
     printf %s "$w_tags" \
-    | { [ "$category" = 'Tags' ] && grep -avF ':' | grep -avxF '' || grep -awF "${category}"; } \
-    | { for n in 1 2 3 4 5 6 7 8 9 0; do line; done; sort; } \
+    | { [ "$category" = 'Tags' ] && grep -avF ':' || grep -awF "${category}"; } \
+    | { for n in 1 2 3 4 5 6 7 8 9 0; do line || break; done; sort; } \
     | while read -r tag; do
     | while read -r tag; do
+      [ "$tag" ] || continue
       printf '[option value="%s"\n%s]' "$tag" "${tag#*:}"
     done
     printf ']]'
       printf '[option value="%s"\n%s]' "$tag" "${tag#*:}"
     done
     printf ']]'