list_item() {
name="$(HTML "$1")"
path="$(HTML "$ITEM/$1")"
- meta="$_DATA/$ITEM/$1"; meta="${meta%/*}/.index/meta"
if [ -d "$_DATA/$ITEM/$1" ]; then
printf '[a .list .dir href="%s?%s" %s]' \
"$path" "$(HTML "$QUERY_STRING")" "$name"
- elif [ -f "$meta" ]; then
+ else
read -r length width height tags comment n <<-EOF
- $(grep -m1 -F " $(meta_name "$1")" "$meta")
+ $(meta_info "$_DATA/$ITEM/$1")
EOF
printf '[div .list .file
[a href="%s" [img src="%s?a=thumbnail"][label %s]]
"$path" "$path" "$name" \
"$((length / 60))" "$((length % 60))" \
"$width" "$height" \
- "$(printf %s\\n "${tags#tags=}" |tr , ' ' |xargs printf '[span .tag %s]')" \
+ "$(UNSTRING "${tags#tags=}" |tr , '\0' |xargs -r0 printf ' [span .tag %s]')" \
"$path" "$path" "$path"
- else
- printf '[div .list .file [a href="%s" [img src="%s?a=thumbnail"][label %s]]]' \
- "$path" "$path" "$name"
fi
}
w_tagging(){
printf '[div #multitag [input type="hidden" name="ref" value="%s"]' "$(HTML "$REQUEST_URI")"
printf '[a href="#" Hide][br]'
- find "$_DATA/$ITEM" -path '*/.index/meta' \
- -exec cut -f4 '{}' + \
- | cut -d= -f2- |tr , '\n' | sort -u \
- | while read tag; do
- cat_old="${category}"; category="${tag%%:*}"
- [ "$category" = "$tag" ] && category="(none)"
- [ "$cat_old" -a "$cat_old" != "$category" ] && printf ']]'
- [ "$cat_old" != "$category" ] \
- && printf '[fieldset [legend %s:][select name="tag" size=4 multiple' $(HTML "$category")
- printf '[option value="%s" %s]' "$(HTML "$tag")" "$(HTML "${tag#*:}")"
+ tags="$(find "$_DATA/$ITEM" -path '*/.index/meta' -exec cut -f4 '{}' + \
+ | cut -d= -f2- |tr , '\n' | sort -u)"
+ tags="$(UNSTRING "$tags")"
+
+ printf '[fieldset [legend %s:][select name=tag size=4 multiple' "Tags"
+ printf %s "$tags" |grep -vF ":" |grep -vxF '' \
+ | while read -r tag; do
+ printf '[option value="%s" %s]' "$(HTML "$tag")" "$(HTML "$tag")"
done
- printf ']][fieldset [legend New:][textarea name=newtag\n][button type=Submit Add Tags]]]'
+ printf ']]'
+
+ printf %s "$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 "$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]]]'
}
printf 'Content-Type: text/html;charset=utf-8\r\n\r\n'