-Subproject commit 813580b4cdebfe5161ef01bcbd126405c3162d7a
+Subproject commit a55a4d8fb1dae783a93492c7d9b55d042791864f
[ -z "${_EXEC%/}" ] && _EXEC="$(realpath "${0%/*}")" || _EXEC="${_EXEC%/}"
[ -z "${_DATA%/}" ] && _DATA=. || _DATA="${_DATA%/}"
+
+
file_pattern='^.*\.(mov|ts|mpg|mpeg|mp4|m4v|avi|mkv|flv|sfv|wmv|ogm|ogv|webm|iso|rmvb)$'
. "$_EXEC/cgilite/cgilite.sh"
thumbnail)
. "$_EXEC/cgilite/file.sh"
index="$_DATA/${ITEM%/*}/.index"
- thumb="$index/${ITEM##*/}.jpg"
+ thumb="$index/${ITEM##*/}"; thumb="${thumb%.*}.jpg"
[ -d "$index" -a \! -f "$thumb" ] \
&& file="$_DATA/$ITEM" . "$_EXEC/thumbnail.sh"
FILE "$thumb"
fn="${fn##*/}"
fn="${fn%.*}"
STRING "$fn"
+ printf '\r'
}
meta_line() {
"${l-0}" "${w-0}" "${h-0}" "$(meta_name "$video")"
}
+meta_file(){
+ file="$1"
+ meta="${file%/*}/.index/meta"
+ name="$(meta_name "$file")"
+
+ if [ -d "${meta%/meta}" ] && LOCK "$meta"; then
+ grep -vF " ${name}" "$meta" >"$meta.tmp"
+ meta_line "$file" \
+ | tee -a "$meta.tmp"
+ mv "$meta.tmp" "$meta"
+ RELEASE "$meta"
+ fi
+}
+
+meta_info(){
+ file="$1"
+ meta="${file%/*}/.index/meta"
+
+ if [ -d "${meta%/meta}" ]; then
+ grep -m1 -F " $(meta_name "$file")" "$meta" \
+ | grep -xE '[0-9]+ [0-9]+ [0-9]+ tags=[^ ]* comment=[^ ]* .+' \
+ || meta_file "$file"
+ else
+ printf '0\t0\t0\ttags=\tcomment=\t\r'
+ fi
+}
+
meta_dir(){
dir="${1}"
meta="${dir}/.index/meta"
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'
#!/bin/sh
. "$_EXEC/cgilite/storage.sh"
+. "$_EXEC/indexmeta.sh"
for select in $(seq 1 $(POST_COUNT select)); do
file="$_DATA/$ITEM/$(POST select $select)"
meta="${file%/*}/.index/meta"
- fn="${file##*/}"
+
+ read -r length width height tags comment fn <<-EOF
+ $(meta_info "$file")
+ EOF
if LOCK "$meta"; then
grep -vF " $fn" "$meta" >"${meta}.tmp"
- read length width height tags comment x <<-EOF
- $(grep -F " $fn" "$meta")
- EOF
- tags="$(printf '%s' "${tags#tags=}" | tr , '\n')"
+ tags="$(UNSTRING "${tags#tags=}" |tr , '\n')"
for tn in $(seq 1 $(POST_COUNT tag)); do
- tags="$tags${BR}$(POST tag $tn |sed -r 's;\t;\\t;g; s;\r;;g;')"
+ tags="$(printf '%s\n%s' "$tags" "$(POST tag $tn)")"
done
- tags="$tags${BR}$(POST newtag |sed -r 's;\t;\\t;g; s;\r;;g;')"
+ tags="$(printf '%s\n%s' "$tags" "$(POST newtag |tr -d '\r')")"
+ tags="$(printf %s "$tags" |sort -u |tr '\n' ,)"
printf '%i\t%i\t%i\ttags=%s\t%s\t%s\n' \
"$length" "$width" "$height" \
- "$(printf %s "$tags" |sort -u |tr '\n' ,)" \
+ "$(STRING "${tags#,}")" \
"$comment" "$fn" \
>>"${meta}.tmp"
mv "${meta}.tmp" "$meta"
background-color: #004;
padding: .125em .5em;
}
+.list.file .tag {
+ color: white;
+ background-color: #400;
+ padding: .125em .5em;
+}
.list.file input[type="checkbox"] { display: none; }
.list.file input[type="checkbox"] + label {