X-Git-Url: http://git.plutz.net/?p=serve0;a=blobdiff_plain;f=widgets.sh;h=dc16b30e0396f5244d8446b630b06b3dd6f5bcc9;hp=b7767c0299afec316cd11bbc7259717b93bdd2ad;hb=c7333f20eb9e0f18c5cb1094a2a82411fab71812;hpb=84232e55d22c7ae59ff9709e350d739813c6aaf6 diff --git a/widgets.sh b/widgets.sh index b7767c0..dc16b30 100644 --- a/widgets.sh +++ b/widgets.sh @@ -1,5 +1,14 @@ #!/bin/sh +[ -n "$include_widgets" ] && return 0 +include_widgets="$0" + +. "$_EXEC/cgilite/storage.sh" + +w_tags="$(find "$_DATA/" -path '*/.index/meta' -exec cut -f4 '{}' + \ + | cut -d= -f2- |tr , '\n' | sort -u)" +w_tags="$(UNSTRING "$w_tags")" + w_search(){ printf ' [form #search method=GET action=? @@ -46,3 +55,27 @@ w_index(){ ] ' "$(HTML "$REQUEST_URI")" } + +w_tagging(){ + 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]]]' +}