if [ "$type" = dir ]; then
name="${meta%% *}";
- display="$(HTML "$name")"; link="$(URL "$ITEM/$name")"
+ display="$(HTML "$name")"; link="$(URL "${PATH_INFO%/}/$name")"
printf '[a .list .dir href="%s" %s]' "${link}?${w_refuri#*\?}" "$name"
return 0
fi
if [ "$type" = metashort ]; then
name="$(list_fullname "$(UNSTRING "${name%${CR}}")")"
fi
- if [ -f "$_DATA/$ITEM/$name" ]; then
- link="$(URL "$ITEM/$name")"
- name="$(HTML "$ITEM/$name")"
+ if [ -f "$_DATA/${PATH_INFO%/}/$name" ]; then
+ link="$(URL "${PATH_INFO%/}/${name#./}")"
+ name="$(HTML "${PATH_INFO%/}/${name#./}")"
printf '[div .list .file
- [a href="%s" [img src="%s?a=thumbnail"]][label %s]
+ [a href="%s" [img src="%s?a=thumbnail"]][label . %s]
[span .time %i:%02imin] [span .dim %ix%i] %s
[checkbox "select" "%s" id="select_%s"][label for="select_%s" +]
]' \
- "$link" "$link" "${name##*/}" \
+ "$link" "$link" "${name##/}" \
"$((length / 60))" "$((length % 60))" \
"$width" "$height" \
- "$(printf '%s\n' "${tags#tags=}" \
- | sed -r "$UNSTRING"' s;^;,;; s;,+;,;g; s;,$;;;
+ "$(UNSTRING "${tags#tags=}" \
+ | sed -r 's;^;,;; s;,+;,;g; s;,$;;;
:X s;,-?([^,]+)(,|$); [span .tag\n \1]\2;; tX;'
)" "$name" "$link" "$link"
else
- printf 'Canning record for nonexist file: %s\n' "$name" >&2
+ debug "Canning record for nonexist file: $name"
meta_purge "$_DATA/$ITEM/$name"
fi
}
[ "$FILTER" ] && list_fex="$(
fex='p'
STRING "$FILTER^" \
- | sed -r 's;\^;\n;g; s;[]\/\(\)\\\^\$\?\.\+\*\;\[\{\}];\\&;g' \
+ | sed -E 's;\^;\n;g; s;[]\/\(\)\\\^\$\?\.\+\*\;\[\{\}];\\&;g' \
| while read -r f; do
- [ ! "${f#~}" ] && continue
- [ "${f#~}" = "$f" ] \
- && fex="/(\ttags=([^\t]*,)?)(${f})((,[^\t]*)?\t)/{${fex}}" \
- || fex="/(\ttags=([^\t]*,)?)(${f#~})((,[^\t]*)?\t)/d; ${fex}"
+ [ "${f##*[A-Z]*}" ] && tl="y;ABCDEFGHIJKLMNOPQRSTUVWXYZ;abcdefghijklmnopqrstuvwxyz;;"
+ case $f in
+ ''|~) continue;;
+ ~\\\$:*) fex="h; ${tl} /${f#~\\\$:}/d; g;${fex}";;
+ \\\$:*) fex="h; ${tl} /${f#\\\$:}/{g;${fex}}";;
+ ~*) fex="/(\ttags=([^\t]*,)?)(${f#\~})((,[^\t]*)?\t)/d; ${fex}";;
+ *) fex="/(\ttags=([^\t]*,)?)(${f})((,[^\t]*)?\t)/{${fex}}";;
+ esac
printf '%s\n' "${fex}"
done \
| tail -n1
list_filter(){
if [ "$FILTER" ]; then
- sed -nr "$list_fex"
+ debug "FEX:" "$list_fex"
+ sed -nE "$list_fex"
elif [ "${SEARCH#!}" != "${SEARCH}" ]; then
grep -aviEe "$(STRING "${SEARCH}" \
- | sed -r ':x s;((^|[^\\])(\\\\)*)\+;\1 ;g; tx;
+ | sed -E ':x s;((^|[^\\])(\\\\)*)\+;\1 ;g; tx;
s;((^|[^\\])(\\\\)*)\\\+;\1+;g;
s; ;\\+;g;')"
elif [ "${SEARCH}" ]; then
grep -aiEe "$(STRING "${SEARCH}" \
- | sed -r ':x s;((^|[^\\])(\\\\)*)\+;\1 ;g; tx;
+ | sed -E ':x s;((^|[^\\])(\\\\)*)\+;\1 ;g; tx;
s;((^|[^\\])(\\\\)*)\\\+;\1+;g;
s; ;\\+;g;')"
else
fi
}
-groupmatch(){
- if [ ${#1} -gt ${#2} ]; then
- long="$1" short="$2"
- else
- long="$2" short="$1"
- fi
- com="$(expr substr "$long" 1 $((${#long} * 3 / 4)))"
- cut="${short#$com}"
- if [ ${#cut} -lt ${#short} ]; then
- return 0
- else
- return 1
- fi
-}
-
list_order(){
local fm fn fn al length ln h w t c name buffer l
if [ $ORDER = Name ]; then
sort -k6 |sed 's;^;metashort\t;;'
elif [ $ORDER = Group ]; then
- { sort -k6; echo '0 0 0 tags= comment= _'; } \
+ sed -E '
+ :X
+ s;^([^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^ 0-9]*)-([0-9a-zA-Z_-]{11}\r|ph[0-9a-f]{13}\r|[0-9]{8}\r)(.*)$;\1-\r\3 \2\n;;
+ t;
+ s;^([^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^ 0-9]*)([0-9]+)(.*)$;\1\r\3 \2;;
+ tX;' \
+ | { sort -n -k7 -k8 -k9 -k10 -k11 |sort -s -k6,6 ; echo '0 0 0 tags= comment= _'; } \
| while read -r length h w t c name; do
- if groupmatch "$ln" "$name"; then
+ if [ "${ln%% *}" = "${name%% *}" ]; then
al=$((al + length))
buffer="${buffer}${BR}$length $h $w $t $c $name"
else
- printf %s\\n "$buffer" |while read -r l; do
+ printf '%s\n' "$buffer" |while read -r l; do
[ "$l" ] && printf '%s %s\n' "$al" "$l"
done
al="$length"
fi
ln="$name"
done \
- | sort -sn -k1 |sed -r 's;^[0-9]+\t;metashort\t;;'
+ | sort -s -n -k1,1 |sed -E 's;^[0-9]+\t;metashort\t;;' \
+ | sed -E ':X s;^([^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\r]*)\r([^ ]*) ([^ ]+)( .*)?$;\1\3\2\4;; tX'
elif [ $ORDER = Length ]; then
sort -sn -k1 |sed 's;^;metashort\t;;'
elif [ $ORDER = Date ]; then
printf '%i %s %s\n' \
"$(stat -c %Y "$fn")" "${fm% *}" "$fn"
done \
- | sort -srn -k1 |sed -r 's;^[0-9]+\t;metalong\t;;'
+ | sort -srn -k1 |sed -E 's;^[0-9]+\t;metalong\t;;'
fi
}
list_items() {
local mode meta
- mode="$(COOKIE mode |grep -m1 -axE 'index|browse' || printf browse )"
+ mode="$(COOKIE mode |grep -m1 -axE 'index|browse' || printf index )"
if [ "$mode" = browse ]; then
[ "$ITEM" ] && printf 'dir\t..\n'
{ printf '
[!DOCTYPE HTML]
-[html [head [title Listing]
+[html [head [title '
+ w_bmname
+ printf ' by %s]' "$ORDER"
+ printf '
[meta name="viewport" content="width=device-width"]
+ [link rel=stylesheet href="/cgilite/common.css" ]
[link rel=stylesheet href="/style.css" ]
] [body
[div #navigation
[a #t_bookmarks href="#bookmarks" ★]'
w_search
printf '
- [a #t_avsearch href="#advsearch" Advanced]
[a #t_prefs href="#prefs" ⚙]
]'
w_bookmarks