for tn in $(seq 1 $(POST_COUNT tag)); do
newtags="${newtags},$(POST tag $tn)"
done
-newtags="${newtags},$(POST newtag |tr -d '\r')"
+newtags="${newtags},$(POST newtag |tr -d '\r' |tr '\n' ,)"
+[ "$(POST op)" = del ] && deltags="$newtags"
for select in $(seq 1 $(POST_COUNT select)); do
file="$_DATA/$ITEM/$(POST select $select |PATH)"
read -r length width height tags comment fn <<-EOF
$(meta_info "$file")
EOF
-
- tags="$(UNSTRING "${tags#tags=}")"
- tags="$(printf '%s\n' "${tags}" "${newtags}" |tr , '\n' |sort -u |tr '\n' , |STRING)"
+ tags="$(UNSTRING "${tags#tags=}" |tr , '\n')"
+
+ if [ ! "$deltags" ]; then
+ tags="$(printf '%s\n' "${tags},${newtags}" \
+ | tr , '\n' |sort -u |tr '\n' , \
+ | STRING)"
+ else
+ detag="${deltags},"; while [ "$detag" ]; do
+ tags="$(printf '%s\n' "$tags" |grep -vxFe "${detag%%,*}")"
+ detag="${detag#*,}"
+ done
+ tags="$(printf '%s\n' "$tags" |sort -u |tr '\n' , |STRING)"
+ fi
tags="${tags#,}"; tags="${tags%,}"
if LOCK "$meta"; then
w_tagging(){
local tag category
- printf '[a href="#multitag" Add Tags]
+ 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 ']]'
done
- printf '[fieldset [legend New:][textarea name=newtag\n][button type=Submit Add Tags]]]'
+ printf '[fieldset [legend New:][textarea name=newtag\n]
+ [submit "op" "del" Remove Tags][submit "op" "add" Add Tags]
+ ]]'
}