-Subproject commit d214859aadb31a565718da69754ad2573fa3f917
+Subproject commit fcb3e2096bd811a910c686bbfe181708878ba8b4
FILTER="$(GET f)"
SEARCH="$(GET s)"
-ORDER="$(GET o |grep -m1 -xE 'Date|Name|Length' || printf Name)"
-LISTSIZE="$(COOKIE pagesize |grep -m1 -xE '[1-9][0-9]*' || printf 50)"
+ORDER="$(GET o |grep -m1 -axE 'Date|Name|Length' || printf Name)"
+LISTSIZE="$(COOKIE pagesize |grep -m1 -axE '[1-9][0-9]*' || printf 50)"
ITEM="$(PATH "${PATH_INFO#/}")"
case $(GET a) in
setprefs)
- SET_COOKIE +$((86400 * 90)) pagesize="$(POST pagesize |grep -m1 -xE '[1-9][0-9]*' || printf 50)"
- SET_COOKIE +$((86400 * 90)) mode="$(POST mode |grep -m1 -xE 'browse|index' || printf browse)"
- SET_COOKIE +$((86400 * 90)) fakemp4="$(POST fakemp4 |grep -m1 -xE 'yes' || printf no)"
+ SET_COOKIE +$((86400 * 90)) pagesize="$(POST pagesize |grep -m1 -axE '[1-9][0-9]*' || printf 50)"
+ SET_COOKIE +$((86400 * 90)) mode="$(POST mode |grep -m1 -axE 'browse|index' || printf browse)"
+ SET_COOKIE +$((86400 * 90)) fakemp4="$(POST fakemp4 |grep -m1 -axE 'yes' || printf no)"
REDIRECT "$(POST ref)"
;;
esac
if [ -d "${meta%/meta}" ]; then
grep -aF " $(meta_name "$file")" "$meta" \
- | grep -m1 -xE '[0-9]+ [0-9]+ [0-9]+ tags=[^ ]* comment=[^ ]* .+' \
+ | grep -m1 -axE '[0-9]+ [0-9]+ [0-9]+ tags=[^ ]* comment=[^ ]* .+' \
|| meta_file "$file"
else
printf '0\t0\t0\ttags=\tcomment=\t\r'
if [ -d "$dir/.index" -a \! -f "$meta" ] && LOCK "$meta"; then
touch "$meta" # preliminary touch to prevent concurrent generators
find "$dir" -type f -mindepth 1 -maxdepth 1 \
- | grep -E "$file_pattern" \
+ | grep -aE "$file_pattern" \
| while read -r v; do
meta_line "$v"
done >"$meta"
elif [ -d "$dir/.index" -a "$dir" -nt "$meta" ] && LOCK "$meta"; then
touch "$meta"
find "$dir" -type f -mindepth 1 -maxdepth 1 \
- | grep -E "$file_pattern" \
+ | grep -aE "$file_pattern" \
| while read -r v; do
if [ "$v" -nt "$meta" ]; then
grep -qF " $(meta_name "$v")" "$meta" \
. "$_EXEC/widgets.sh"
list_item() {
- local name path length width height tags comment n
+ local name link path length width height tags comment n
name="$(HTML "$1")"
- path="$(URL "$ITEM/$1")"
+ link="$(URL "$ITEM/$1")"
+ path="$(HTML "$ITEM/$1")"
qry=$(HTML "$QUERY_STRING")
if [ -d "$_DATA/$ITEM/$1" ]; then
printf '[div .list .file
[a href="%s" [img src="%s?a=thumbnail"][label %s]]
[span .time %i:%imin] [span .dim %ix%i] %s
- [checkbox "select" "%s" id="select_%s" form="multitag"][label for="select_%s" +]
+ [checkbox "select" "%s" id="select_%s"][label for="select_%s" +]
]' \
- "$path" "$path" "$name" \
+ "$link" "$link" "$name" \
"$((length / 60))" "$((length % 60))" \
"$width" "$height" \
"$(UNSTRING "${tags#tags=}" |tr , '\0' |xargs -r0 printf ' [span .tag %s]')" \
if [ $ORDER = Name ]; then
sort -k6 "$meta"
elif [ $ORDER = Length ]; then
- sort -n "$meta"
+ sort -n -k1 "$meta"
else
cat "$meta"
fi \
| if [ "$FILTER" ]; then
sed -nr "$list_fex"
elif [ "${SEARCH#!}" != "${SEARCH}" ]; then
- grep -viE "$(STRING "${SEARCH#!}")"
+ grep -aviE "$(STRING "${SEARCH#!}" |sed -r ':x s;((^|[^\\])(\\\\)*)\+;\1\\+;g; tx;')"
else
- grep -iE "$(STRING "${SEARCH}")"
+ grep -aiE "$(STRING "${SEARCH}" \
+ | sed -r ':x s;((^|[^\\])(\\\\)*)\+;\1 ;g; tx;
+ s;((^|[^\\])(\\\\)*)\\\+;\1+;g;
+ s; ;\\+;g;')"
fi |cut -f6 | UNSTRING \
| while read -r fn; do
printf '%s\n' "${base}/${fn%${CR}}"
- done
+ done | tee .index/debug
}
list_index(){
list_items() {
local mode
- mode="$(COOKIE mode |grep -m1 -xE 'index|browse' || printf browse )"
+ mode="$(COOKIE mode |grep -m1 -axE 'index|browse' || printf browse )"
[ "$mode" = browse -a "$ITEM" ] && printf '..\n'
list_paginate() {
local page i c n end
- page="$(GET p |grep -xE '[0-9]+' || printf 1)"; c=1
+ page="$(GET p |grep -axE '[0-9]+' || printf 1)"; c=1
end=$((page + LISTSIZE))
printf '[div .itemlist '
file="$_DATA/$ITEM/$(POST select $select)"
meta="${file%/*}/.index/meta"
- read -r length width height tags comment fn <<-EOF
+ fn="$(meta_name "$file")"
+ read -r length width height tags comment discard <<-EOF
$(meta_info "$file")
EOF
+ [ "${length%%[1-9]*}" -o "${width%%[1-9]*}" -o "${height%%[1-9]*}" = 0 ] \
+ && read -r length width height discard <<-EOF
+ $(meta_line "$file"; echo Rereading meta for "$file" >&2)
+ EOF
+ [ "${tags%%tags=*}" ] && tags='tags=';
+ [ "${comment%%comment=*}" ] && comment='comment='
if LOCK "$meta"; then
- grep -vF " $fn" "$meta" >"${meta}.tmp"
+ grep -avF " $fn" "$meta" >"${meta}.tmp"
+
tags="$(UNSTRING "${tags#tags=}" |tr , '\n')"
for tn in $(seq 1 $(POST_COUNT tag)); do
* {
box-sizing: border-box;
margin: 0; padding: 0;
+ text-align: left;
}
button { padding: .125em .5em; }
a { color: inherit; text-decoration: none;}
position: relative;
overflow: hidden;
height: 0;
- text-align: left;
background-color: #333;
}
#prefs:target,
line-height: 2em;
background-color: inherit;
border-bottom: 1px solid;
- text-align: left;
padding-left: .5em;
position: relative;
top: -2em;
padding: .5em 1em;
background-color: #444;
line-height: 1.5em;
- text-align: left;
}
#advsearch input.and {display: none;}
min-width: 200px;
min-height: 12em;
overflow: hidden;
- text-align: left;
vertical-align: top;
}
background-color: #4F4;
}
+.itemlist,
.pagination {
display: block;
text-align: center;
}
#editing {
- text-align: left;
width: 100%;
background-color: #333;
border-top: 1px solid;
$n "$category" "$t" "$lbid" "$lbid" "$category" $n
printf '%s\n' "$w_tags" \
- | { [ "$category" = '*' ] && grep -vF ':' |grep -vxF '' || grep -wF "${category}"; } \
+ | { [ "$category" = '*' ] && grep -avF ':' |grep -avxF '' || grep -awF "${category}"; } \
| while read -r tag; do
t=''; [ ! "${f%%*|${tag}|*}" ] && t=checked
printf '[option %s value="%s"\n%s]' "$t" "$tag" "${tag#*:}"
| while read -r category; do
printf '[fieldset [legend %s:][select name=tag size=4 multiple' "$category"
printf %s "$w_tags" \
- | { [ "$category" = 'Tags' ] && grep -vF ':' | grep -vxF '' || grep -wF "${category}"; } \
+ | { [ "$category" = 'Tags' ] && grep -avF ':' | grep -avxF '' || grep -awF "${category}"; } \
| while read -r tag; do
printf '[option value="%s"\n%s]' "$tag" "${tag#*:}"
done