From: Paul Hänsch Date: Mon, 12 Nov 2018 01:31:57 +0000 (+0100) Subject: enable exclusive tags X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=b3e752c8f50110859bc9e3aaf9d709e2006b3de6;p=serve0 enable exclusive tags --- diff --git a/advsearch.sh b/advsearch.sh index 38cb170..df2e908 100644 --- a/advsearch.sh +++ b/advsearch.sh @@ -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)" - [ ! "${tag##${cat}:*}" ] || [ "$cat" = '*' -a "${tag##*:*}" ] \ + [ ! "${tag##${cat}:*}" ] || [ ! "${tag##-${cat}:*}" ] || [ "$cat" = '*' -a "${tag##*:*}" ] \ && f="${f}${tag}|" done f="${f%[|^]}^" diff --git a/list.sh b/list.sh index 98305c9..e9a98c0 100644 --- 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;,$;;; - :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 diff --git a/multitag.sh b/multitag.sh index 8b60ade..20b3939 100644 --- a/multitag.sh +++ b/multitag.sh @@ -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 - tags="$(UNSTRING "${tags#tags=}" |tr , '\n')" 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="$(UNSTRING "${tags#tags=}" |tr , '\n')" detag="${deltags},"; while [ "$detag" ]; do tags="$(printf '%s\n' "$tags" |grep -vxFe "${detag%%,*}")" detag="${detag#*,}" diff --git a/view.sh b/view.sh index c08be24..eb348c6 100644 --- 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"' - 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 diff --git a/widgets.sh b/widgets.sh index 2736f66..896ca6c 100644 --- a/widgets.sh +++ b/widgets.sh @@ -45,7 +45,7 @@ if [ ! -f "$w_tags" -o ! -f "$w_tagcategories" ] \ 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" \ - | cut -sd: -f1 |sort -u \ + | sed -rn '/:/s;^-?([^:]+):.*$;\1;p' |sort -u \ | tee "$w_tagcategories" )" else w_tags="$(cat "$w_tags")" @@ -162,7 +162,7 @@ w_index(){ } 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 @@ -193,6 +193,7 @@ w_advsearch(){ 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' \ @@ -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; - 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 - 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 @@ -227,7 +229,7 @@ w_advsearch(){ } 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]' @@ -244,7 +246,8 @@ w_tagging(){ 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