X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;f=widgets.sh;h=84b656774c3ead4b1f2c2a5334e67f496e7b6eb4;hb=df289a9cb8ad5a53f29222f1fd9ce68ce35d1889;hp=23afd9d440ba6ffbf411faaffcd628f58634403d;hpb=2039c4c91343d754c1c92b39b4523d4d8a50c936;p=serve0 diff --git a/widgets.sh b/widgets.sh index 23afd9d..84b6567 100755 --- a/widgets.sh +++ b/widgets.sh @@ -180,31 +180,39 @@ w_advsearch(){ EOF f="|${f#\~}|" - printf '*\n%s\n$\n' "$w_tagcategories" \ - | while read -r category; do - lbid="cat_${n}_${category}" - - 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] - [div .catselect\n' \ - $n "$category" "$t" "$lbid" "$lbid" "$category" - - printf '%s\n' "$w_tags" \ - | { [ "$category" = '*' ] && grep -avF ':' || grep -awF "${category}"; } \ - | while read -r tag; do - [ "$tag" ] || continue - t=''; [ ! "${f%%*|${tag}|*}" ] && t=checked - d="${tag#-}"; d="${d#*:}" - printf '[label [checkbox "tag_%s" "%s" %s] %s]' "$n" "$tag" "$t" "$d" - done - d="${f##*\$:}" d="${d%%\|*}" - [ "$category" = \$ ] && printf '[input name="tag_%i" value="%s"]' "$n" "$(HTML "$d")" - printf '\n]' + printf '%s\n$:\n' "$w_tags" \ + | while read tctag; do + [ "$tctag" ] || continue + category="${tctag#-}"; category="${category%%:*}" + tag="${tctag#-}"; tag="${tag#*:}" + [ "${tag}" = "${tctag#-}" ] \ + && category="*" + + if [ "$category" != "$oldcat" ]; then + [ "$oldcat" ] && printf '\n]' + lbid="cat_${n}_${category}" + + 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] + [div .catselect\n' \ + $n "$category" "$t" "$lbid" "$lbid" "$category" + fi + + if [ "$category" = '$' ]; then + tag="${f##*\$:}" tag="${tag%%\|*}" + printf '[input name="tag_%i" value="%s"]' "$n" "$(HTML "$tag")" + else + t=''; [ ! "${f%%*|${tctag}|*}" ] && t=checked + printf '[label [checkbox "tag_%s" "%s" %s] %s]' "$n" "$tctag" "$t" "$tag" + fi + + oldcat="$category" done + [ "$w_tags" ] && printf '\n]' printf ']' done @@ -230,7 +238,7 @@ w_delete(){ } w_tagging(){ - local tctag oldcat category tag + local tctag oldcat="" category tag cat <<-EOF [a href="#multitag" Add Tags / Remove Tags] @@ -238,8 +246,6 @@ w_tagging(){ [a href="#" X] EOF - oldcat="Tags" - printf '[fieldset [legend %s:][div .tagselect\n' "Tags" printf '%s\n' "$w_tags" \ | while read tctag; do [ "$tctag" ] || continue @@ -250,14 +256,14 @@ w_tagging(){ && category="Tags" if [ "$category" != "$oldcat" ]; then - printf ']]' + [ "$oldcat" ] && printf ']]' printf '[fieldset [legend %s:][div .tagselect\n' "$category" fi printf '[label [checkbox "tag" "%s"] %s]\n' "$tctag" "$tag" oldcat="$category" done - printf ']]' + [ "$w_tags" ] && printf ']]' cat <<-EOF [fieldset [legend New:][textarea name=newtag\n]