]> git.plutz.net Git - serve0/commitdiff
enable exclusive tags
authorPaul Hänsch <paul@plutz.net>
Mon, 12 Nov 2018 01:31:57 +0000 (02:31 +0100)
committerPaul Hänsch <paul@plutz.net>
Mon, 12 Nov 2018 01:31:57 +0000 (02:31 +0100)
advsearch.sh
list.sh
multitag.sh
view.sh
widgets.sh

index 38cb17023f453160043e99e52eed6bc2ff7610c5..df2e908a3a09b982fd0b511f673fa709ae9fb088 100644 (file)
@@ -9,7 +9,7 @@ for n in 1 2 3 4 5 6 7 8 9; do
   cat="$(POST cat_$n)"
   for m in $(seq 1 $(POST_COUNT tag_$n)); do
     tag="$(POST tag_$n $m)"
   cat="$(POST cat_$n)"
   for m in $(seq 1 $(POST_COUNT tag_$n)); do
     tag="$(POST tag_$n $m)"
-    [ ! "${tag##${cat}:*}" ] || [ "$cat" = '*' -a "${tag##*:*}" ] \
+    [ ! "${tag##${cat}:*}" ] || [ ! "${tag##-${cat}:*}" ] || [ "$cat" = '*' -a "${tag##*:*}" ] \
     && f="${f}${tag}|"
   done
   f="${f%[|^]}^"
     && f="${f}${tag}|"
   done
   f="${f%[|^]}^"
diff --git a/list.sh b/list.sh
index 98305c94f1f6a2a0e8cf2d71f6e3b58b5d6d0c6a..e9a98c0ecf8e75d8a338c8d06350d612568edaf9 100644 (file)
--- a/list.sh
+++ b/list.sh
@@ -37,7 +37,7 @@ list_item() {
       "$width" "$height" \
       "$(printf '%s\n' "${tags#tags=}" \
          | sed -r "$UNSTRING"' s;^;,;; s;,+;,;g; s;,$;;;
       "$width" "$height" \
       "$(printf '%s\n' "${tags#tags=}" \
          | sed -r "$UNSTRING"' s;^;,;; s;,+;,;g; s;,$;;;
-                   :X s;,([^,]+)(,|$); [span .tag\n \1]\2;; tX;'
+                   :X s;,-?([^,]+)(,|$); [span .tag\n \1]\2;; tX;'
       )" "$name" "$link" "$link"
   else
     printf 'Canning record for nonexist file: %s\n' "$name" >&2
       )" "$name" "$link" "$link"
   else
     printf 'Canning record for nonexist file: %s\n' "$name" >&2
index 8b60adebb1ac8e265866f00570c47d124c0ca9e3..20b39391f9db1a9c103cda521c8ac145df334e33 100644 (file)
@@ -17,13 +17,18 @@ for select in $(seq 1 $(POST_COUNT select)); do
   read -r length width height tags comment fn <<-EOF
        $(meta_info "$file")
        EOF
   read -r length width height tags comment fn <<-EOF
        $(meta_info "$file")
        EOF
-  tags="$(UNSTRING "${tags#tags=}" |tr , '\n')"
 
   if [ ! "$deltags" ]; then
 
   if [ ! "$deltags" ]; then
+    extags="$(printf '%s' "$newtags" |tr , '\n' |grep -e "^-" |cut -d: -f1 )"
+    tags="$(UNSTRING "${tags#tags=}" |tr , '\n' |grep -vwFe "$extags")"
+    if printf %s "$extags" |grep -vq :; then
+      tags="$(printf %s\\n "$tags" |grep -vE '^-[^:]+$')"
+    fi
     tags="$(printf '%s\n' "${tags},${newtags}" \
             | tr , '\n' |sort -u |tr '\n' , \
             | STRING)"
   else
     tags="$(printf '%s\n' "${tags},${newtags}" \
             | tr , '\n' |sort -u |tr '\n' , \
             | STRING)"
   else
+    tags="$(UNSTRING "${tags#tags=}" |tr , '\n')"
     detag="${deltags},"; while [ "$detag" ]; do
       tags="$(printf '%s\n' "$tags" |grep -vxFe "${detag%%,*}")"
       detag="${detag#*,}"
     detag="${deltags},"; while [ "$detag" ]; do
       tags="$(printf '%s\n' "$tags" |grep -vxFe "${detag%%,*}")"
       detag="${detag#*,}"
diff --git a/view.sh b/view.sh
index c08be24fa1a662a98bcb2bd88b3e4e01f03e0185..eb348c60522fa0b30f95c6dec35d3068f99351f1 100644 (file)
--- a/view.sh
+++ b/view.sh
@@ -36,7 +36,7 @@ printf 'Content-Type: text/html;charset=utf-8\r\n\r\n'
   ' "$(HTML "${ITEM##*/}" |sed -r "$w_ascii"' s;[^0-9a-zA-Z&#];&[wbr];g')" \
     "$((length / 60))" "$((length % 60))" "$width" "$height" \
     "$(printf '%s\n' "${tags#tags=}" |sed -r "$UNSTRING"'
   ' "$(HTML "${ITEM##*/}" |sed -r "$w_ascii"' s;[^0-9a-zA-Z&#];&[wbr];g')" \
     "$((length / 60))" "$((length % 60))" "$width" "$height" \
     "$(printf '%s\n' "${tags#tags=}" |sed -r "$UNSTRING"'
-       s;^;,;; s;,+;,;g; s;,$;;; :X s;,([^,]+)(,|$); [span .tag\n \1]\2;; tX;'
+       s;^;,;; s;,+;,;g; s;,$;;; :X s;,-?([^,]+)(,|$); [span .tag\n \1]\2;; tX;'
     )"
   printf '
   [div #editing
     )"
   printf '
   [div #editing
index 2736f66f52f4fc0a5c96ec883bcac64ede3fec8d..896ca6cdfab3d97ebdcfd59374221f618100a336 100644 (file)
@@ -45,7 +45,7 @@ if [ ! -f "$w_tags" -o ! -f "$w_tagcategories" ] \
     done
   } |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" \
     done
   } |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 \
+                     | sed -rn '/:/s;^-?([^:]+):.*$;\1;p' |sort -u \
                      | tee "$w_tagcategories" )"
 else
   w_tags="$(cat "$w_tags")"
                      | tee "$w_tagcategories" )"
 else
   w_tags="$(cat "$w_tags")"
@@ -162,7 +162,7 @@ w_index(){
 }
 
 w_advsearch(){
 }
 
 w_advsearch(){
-  local n lbid tag category filter f t
+  local n lbid tag category filter f t d
   filter="$(HTML "${FILTER}^" |sed "$w_ascii")"
 
   printf '[form #advsearch action=?a=advsearch method=POST
   filter="$(HTML "${FILTER}^" |sed "$w_ascii")"
 
   printf '[form #advsearch action=?a=advsearch method=POST
@@ -193,6 +193,7 @@ w_advsearch(){
       t=''
       [ "$category"  = '*' -a   "${f%%|${category}:*}" ] && t=checked
       [ "$category" != '*' -a ! "${f%%|${category}:*}" ] && t=checked
       t=''
       [ "$category"  = '*' -a   "${f%%|${category}:*}" ] && t=checked
       [ "$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' \
 
       printf '[radio "cat_%i" "%s" .cat %s id="%s"][label for="%s" %s]
               [select name=tag_%s size=10 multiple' \
@@ -202,12 +203,13 @@ w_advsearch(){
       | { [ "$category" = '*' ] && grep -avF ':' || grep -awF "${category}"; } \
       | { for n in 1 2 3 4 5 6 7 8 9 0; do
           read -r line && printf '%s\n' "$line" || break;
       | { [ "$category" = '*' ] && grep -avF ':' || grep -awF "${category}"; } \
       | { for n in 1 2 3 4 5 6 7 8 9 0; do
           read -r line && printf '%s\n' "$line" || break;
-          done;  # path 10 lines through without modification
+          done;  # pass 10 lines through without modification
           sort;  # and sort remaining lines
       } | while read -r tag; do
         [ "$tag" ] || continue
         t=''; [ ! "${f%%*|${tag}|*}" ] && t=checked
           sort;  # and sort remaining lines
       } | while read -r tag; do
         [ "$tag" ] || continue
         t=''; [ ! "${f%%*|${tag}|*}" ] && t=checked
-        printf '[option %s value="%s"\n%s]' "$t" "$tag" "${tag#*:}"
+        d="${tag#-}"; d="${d#*:}"
+        printf '[option %s value="%s"\n%s]' "$t" "$tag" "$d"
       done
       printf '\n]'
     done
       done
       printf '\n]'
     done
@@ -227,7 +229,7 @@ w_advsearch(){
 }
 
 w_tagging(){
 }
 
 w_tagging(){
-  local tag category
+  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="#multitag" Add Tags / Remove Tags]
           [div #multitag [input type="hidden" name="ref" value="%s"]' "$w_refuri"
   printf '[a href="#" Hide][br]'
@@ -244,7 +246,8 @@ w_tagging(){
         sort;
     } | while read -r tag; do
       [ "$tag" ] || continue
         sort;
     } | while read -r tag; do
       [ "$tag" ] || continue
-      printf '[option value="%s"\n%s]' "$tag" "${tag#*:}"
+      d="${tag#-}"; d="${d#*:}"
+      printf '[option value="%s"\n%s]' "$tag" "$d"
     done
     printf ']]'
   done
     done
     printf ']]'
   done