X-Git-Url: http://git.plutz.net/?p=serve0;a=blobdiff_plain;f=widgets.sh;h=3142b4485aedbdeece2d7bd89a0c090c063f4fb3;hp=158df4bb3ee57eda12cf30a469ed9b1a403a8330;hb=bbf0a951d1ff6106d1d2dd8032333b1b1ccd67f2;hpb=503565a7be2813fcf8eba25c542b8e21d29c8d1c diff --git a/widgets.sh b/widgets.sh index 158df4b..3142b44 100644 --- a/widgets.sh +++ b/widgets.sh @@ -6,10 +6,12 @@ include_widgets="$0" . "$_EXEC/cgilite/storage.sh" w_refuri="$(HTML "$REQUEST_URI")" + w_tags="$(find "$_DATA/" -path '*/.index/meta' -print0 \ | xargs -r0 cut -f4 \ | cut -d= -f2- |tr , '\n' | sort -u)" w_tags="$(UNSTRING "$w_tags")" +w_tagcategories="$(printf %s "$w_tags" |cut -sd: -f1 |sort -u)" w_search(){ printf ' @@ -78,45 +80,41 @@ w_advsearch(){ ][fieldset .select [input .pol type="radio" name=pol_%i %s id="pol_pos_%i"][label for=pol_pos_%i Any] [input .pol type="radio" name=pol_%i %s id="pol_neg_%i"][label for=pol_neg_%i None] - [label .head Category:] - [input .cat type=radio name="cat_%i" %s id="%s" ][label for="%s" %s] - [select name=tag_%s size=10 multiple="multiple"' \ + [label .head Category:]' \ $n "$([ "$f" ] && printf 'checked="checked"')" $n \ - $n "$([ "$f" -a \! "${f%%~*}" ] || printf 'checked="checked"')" $n $n \ - $n "$([ "$f" -a \! "${f%%~*}" ] && printf 'checked="checked"')" $n $n \ - $n "$([ "$f" = "${f%:*}" ] && printf 'checked="checked"')" "$lbid" "$lbid" "(none)" \ - $n - + $n "$([ "$f" -a ! "${f%%~*}" ] || printf 'checked="checked"')" $n $n \ + $n "$([ "$f" -a ! "${f%%~*}" ] && printf 'checked="checked"')" $n $n f="|${f#~}|" - printf %s "$w_tags" |grep -vF ":" \ - | while read -r tag; do - [ ! "$tag" ] && continue - tg="$(HTML "$tag")" - printf '[option %s value="%s" %s]' \ - "$([ "$f" != "${f%|${tag}|*}" ] && printf 'selected="selected"')" \ - "$tg" "$tg" - done - printf ']' - printf %s "$w_tags" |cut -sd: -f1 |sort -u \ + + printf '*\n%s\n' "$w_tagcategories" \ | while read -r category; do lbid="$(HTML "cat_${n}_${category}")" - printf '[input .cat type=radio name="cat_%i" %s id="%s"][label for="%s" %s] + printf '[input .cat type=radio %s name="cat_%i" id="%s"][label for="%s" %s] [select name=tag_%s size=10 multiple="multiple"' \ - $n "$([ "$f" != "${f%|${category}:*}" ] && printf 'checked="checked"')" \ - "$lbid" "$lbid" "$(HTML "$category")" $n - printf %s "$w_tags" |grep -wF "${category}" \ + "$([ ! "${f%%*|${category}:*}" -o ! "${category%\*}" ] && printf 'checked="checked"')" \ + $n "$lbid" "$lbid" "$(HTML "$category")" $n + + printf %s "$w_tags" \ + | { [ "$category" = '*' ] && grep -vF ':' || grep -wF "${category}"; } \ | while read -r tag; do + [ ! "$tag" ] && continue tg="$(HTML "$tag")"; tn="${tg#*:}" printf '[option %s value="%s" %s]' \ - "$([ "$f" != "${f%|${tag}|*}" ] && printf 'selected="selected"')" \ + "$([ ! "${f%%*|${tag}|*}" ] && printf 'selected="selected"')" \ "$tg" "$tn" done - printf ']' + printf '\n]' done printf ']' done - printf ']' + printf '[fieldset .submit [select name=order + [option disabled=disabled Order By] + [option value=Name Name] + [option value=Date Date] + [option value=Length Length] + ][button type=submit Apply Filter]] + ]' } w_tagging(){ @@ -124,19 +122,13 @@ w_tagging(){ printf '[div #multitag [input type="hidden" name="ref" value="%s"]' "$w_refuri" printf '[a href="#" Hide][br]' - printf '[fieldset [legend %s:][select name=tag size=4 multiple' "Tags" - printf %s "$w_tags" |grep -vF ":" \ - | while read -r tag; do - [ ! "$tag" ] && continue - printf '[option value="%s" %s]' "$(HTML "$tag")" "$(HTML "$tag")" - done - printf ']]' - - printf %s "$w_tags" |cut -sd: -f1 |sort -u \ + printf 'Tags\n%s\n' "$w_tagcategories" \ | while read -r category; do printf '[fieldset [legend %s:][select name=tag size=4 multiple' "$(HTML "$category")" - printf %s "$w_tags" |grep -wF "${category}" \ + printf %s "$w_tags" \ + | { [ "$category" = 'Tags' ] && grep -vF ':' || grep -wF "${category}"; } \ | while read -r tag; do + [ ! "$tag" ] && continue tag="$(HTML "$tag")"; tn="${tag#*:}" printf '[option value="%s" %s]' "$tag" "$tn" done