X-Git-Url: http://git.plutz.net/?p=serve0;a=blobdiff_plain;f=widgets.sh;h=81807c05a74679fda1a83e03fff105d9711ef5ce;hp=5cc4db9a7ec03d2526a5e6217896ee20a1b6ad48;hb=b22f5dedd33a3c4b3a42f06072923b0f75b6799f;hpb=7c5e13183df4717e76f84a5cf99daa6d2d51d91b diff --git a/widgets.sh b/widgets.sh index 5cc4db9..81807c0 100644 --- a/widgets.sh +++ b/widgets.sh @@ -5,6 +5,7 @@ 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)" @@ -41,7 +42,7 @@ w_prefs(){ [submit "store" "store" Set Cookie] ] ' \ - "$(HTML "$REQUEST_URI")" "$LISTSIZE" \ + "$w_refuri" "$LISTSIZE" \ "$([ "$mode" = index ] || printf checked)" \ "$([ "$mode" = index ] && printf checked)" \ "$([ "$fakemp4" = yes ] && printf checked)" @@ -55,17 +56,61 @@ w_index(){ [checkbox "recursive" "yes" #spawn_recursive] [label for=spawn_recursive Include subdirectories] [submit "spawn" "spawn" Set up] ] - ' "$(HTML "$REQUEST_URI")" + ' "$w_refuri" +} + +w_advsearch(){ + printf '[form #advsearch action=?a=advsearch method=POST + [a href="#" Hide] + [p .help Select multiple tags from each category by holding down the [strong Ctrl] key on your keyboard.[br] + Refine the search further by setting additional search tags using the [strong "+and"] button.] + [hidden "ref" "%s"] + ' "$w_refuri" + + for n in 1 2 3 4 5 6 7 8 9 10; do + lbid="$(HTML "cat_${n}_(none)")" + printf '[input .and type=checkbox name=and id="and_%i"][label for="and_%i" +and + ][fieldset .select + [input .pol type="radio" name=pol_%i id="pol_pos_%i"][label for=pol_pos_%i Any] + [input .pol type="radio" name=pol_%i id="pol_neg_%i"][label for=pol_neg_%i None] + [label .head Category:] + [input .cat type=radio name="cat_%i" id="%s" ][label for="%s" %s] + [select name=tag_%s size=10 multiple' \ + $n $n $n $n $n $n $n $n \ + $n "$lbid" "$lbid" "(none)" $n + 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 \ + | while read -r category; do + lbid="$(HTML "cat_${n}_${category}")" + printf '[input .cat type=radio name="cat_%i" id="%s" [label for="%s" %s]] + [select name=tag_%s size=10 multiple' $n "$lbid" "$lbid" "$(HTML "$category")" $n + printf %s "$w_tags" |grep -wF "${category}" \ + | while read -r tag; do + tag="$(HTML "$tag")"; tn="${tag#*:}" + printf '[option value="%s" %s]' "$tag" "$tn" + done + printf ']' + done + printf ']' + done + + printf ']' } w_tagging(){ local tag category - printf '[div #multitag [input type="hidden" name="ref" value="%s"]' "$(HTML "$REQUEST_URI")" + 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 ":" |grep -vxF '' \ + printf %s "$w_tags" |grep -vF ":" \ | while read -r tag; do + [ ! "$tag" ] && continue printf '[option value="%s" %s]' "$(HTML "$tag")" "$(HTML "$tag")" done printf ']]' @@ -75,7 +120,8 @@ w_tagging(){ printf '[fieldset [legend %s:][select name=tag size=4 multiple' "$(HTML "$category")" printf %s "$w_tags" |grep -wF "${category}" \ | while read -r tag; do - printf '[option value="%s" %s]' "$(HTML "$tag")" "$(HTML "${tag#*:}")" + tag="$(HTML "$tag")"; tn="${tag#*:}" + printf '[option value="%s" %s]' "$tag" "$tn" done printf ']]' done