X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;f=widgets.sh;h=5cc4db9a7ec03d2526a5e6217896ee20a1b6ad48;hb=7c5e13183df4717e76f84a5cf99daa6d2d51d91b;hp=c0de813d3d6e2f3bb149c03b97cd58b0d6525b40;hpb=3c586e3fe4da20469de93897d03d41f82cb15b3b;p=serve0 diff --git a/widgets.sh b/widgets.sh index c0de813..5cc4db9 100644 --- a/widgets.sh +++ b/widgets.sh @@ -1,5 +1,15 @@ #!/bin/sh +[ -n "$include_widgets" ] && return 0 +include_widgets="$0" + +. "$_EXEC/cgilite/storage.sh" + +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_search(){ printf ' [form #search method=GET action=? @@ -16,10 +26,12 @@ w_search(){ } w_prefs(){ + local fakemp4 mode fakemp4="$(COOKIE fakemp4)" mode="$(COOKIE mode)" printf ' [form #prefs method="POST" action="?a=setprefs" + [a href="#" x] [hidden "ref" "%s"] [label for=prefs_ps Pagesize] [input #prefs_ps type=number name=pagesize value="%s"][br] @@ -34,3 +46,39 @@ w_prefs(){ "$([ "$mode" = index ] && printf checked)" \ "$([ "$fakemp4" = yes ] && printf checked)" } + +w_index(){ + [ -d "$_DATA/$ITEM/.index" ] || printf ' + [form #index method="POST" action="?a=spawnindex" + [hidden "ref" "%s"] + [label Set up for Index view: ] + [checkbox "recursive" "yes" #spawn_recursive] [label for=spawn_recursive Include subdirectories] + [submit "spawn" "spawn" Set up] + ] + ' "$(HTML "$REQUEST_URI")" +} + +w_tagging(){ + local tag category + printf '[div #multitag [input type="hidden" name="ref" value="%s"]' "$(HTML "$REQUEST_URI")" + printf '[a href="#" Hide][br]' + + printf '[fieldset [legend %s:][select name=tag size=4 multiple' "Tags" + printf %s "$w_tags" |grep -vF ":" |grep -vxF '' \ + | while read -r tag; do + 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 + 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#*:}")" + done + printf ']]' + done + + printf '[fieldset [legend New:][textarea name=newtag\n][button type=Submit Add Tags]]]' +}