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 v="$(line)"; do
+ | 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 v="$(line)"; do
+ | while read -r v; do
if [ "$v" -nt "$meta" ]; then
grep -qF " $(meta_name "$v")" "$meta" \
|| meta_line "$v"
. "$_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(){
local meta
(cd "$_DATA/$ITEM";
find ./ -path '*/.index/meta'
- ) | while meta="$(line)"; do
+ ) | while read -r meta; do
list_filemeta "${meta%/.index/meta}"
done
}
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 '
[ "$ORDER" = Date ] && w_codate=checked
[ "$ORDER" = Length ] && w_colength=checked
+w_bookmarks(){
+ local name link bm
+ bm="$_DATA/.index/bookmarks"
+
+ printf '[form #bookmarks action=?a=bookmarks method=POST
+ [a href="#" X]
+ [hidden "ref" "%s"]
+ ' "$w_refuri"
+
+ name="$(grep -m1 -F " $(STRING "${REQUEST_URI}")" "$bm")"
+ printf '[hidden "link" "%s"][input name="name" value="%s"]' \
+ "$(HTML "$link")" "$(HTML "$name")"
+
+ sort "$bm" |while read -r name link; do
+ name="$(UNSTRING "$name")"
+ link="$(UNSTRING "$link")"
+ if [ "$link" != "$REQUEST_URI" ]; then
+ printf '[a href="%s"\n%s]' "$(HTML "$link")" "$(HTML "$name")"
+ fi
+ done
+ printf ']'
+}
+
w_search(){
printf '
[form #search method=GET action=?
$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