list_item() {
name="$(HTML "$1")"
path="$(HTML "$ITEM/$1")"
- meta="$_DATA/$ITEM/.index/meta"
+ meta="$_DATA/$ITEM/$1"; meta="${meta%/*}/.index/meta"
if [ -d "$_DATA/$ITEM/$1" ]; then
- printf '[a .list .dir href="%s" %s]' \
- "$path" "$name"
+ printf '[a .list .dir href="%s?%s" %s]' \
+ "$path" "$(HTML "$QUERY_STRING")" "$name"
elif [ -f "$meta" ]; then
read -r length width height tags comment n <<-EOF
- $(grep -m1 -F " $1" "$meta")
+ $(grep -m1 -F " ${1##*/}" "$meta")
EOF
printf '[div .list .file
[a href="%s" [img src="%s?a=thumbnail"][label %s]]
fi
}
+list_fs_browse(){
+ [ -d "$_DATA/$ITEM/.index" -a \! "$_DATA/$ITEM" -ot "$_DATA/$ITEM/.index/meta" ] \
+ && dir="$_DATA/$ITEM" . "$_EXEC/update_meta.sh"
+ (cd "$_DATA/$ITEM";
+ find ./ -type d \! -name .index -mindepth 1 -maxdepth 1 \
+ -exec stat -c '%Y %n' '{}' +
+ find ./ -type f -mindepth 1 -maxdepth 1 \
+ -exec stat -c '%Y %n' '{}' +
+ )
+}
+list_fs_index(){
+ find "$_DATA/$ITEM" -type d -name .index \
+ | while d="$(line)"; do
+ [ ! "${d%/.index}" -ot "$d/meta" ] \
+ && dir="${d%/.index}" . "$_EXEC/update_meta.sh"
+ done
+ (cd "$_DATA/$ITEM";
+ find ./ \! -path '*/.index/*' -type f \
+ -exec stat -c '%Y %n' '{}' +
+ )
+}
+
+list_browse(){
+ meta="$_DATA/$ITEM/.index/meta"
+ [ -d "${meta%/meta}" -a \! "$_DATA/$ITEM" -ot "${meta}" ] \
+ && dir="$_DATA/$ITEM" . "$_EXEC/update_meta.sh"
+ (cd "$_DATA/$ITEM";
+ find ./ -type d \! -name .index -mindepth 1 -maxdepth 1 \
+ ) | cut -d/ -f2- | sort
+ sort -n "$meta" | cut -f6- \
+ | while f="$(line)"; do
+ [ -e "$_DATA/$ITEM/$f" ] && printf '%s\n' "$f"
+ done
+}
+list_index(){
+ (cd "$_DATA/$ITEM";
+ find ./ -path '*/.index/meta'
+ ) | while meta="$(line)"; do
+ base="${meta%/.index/meta}"
+ [ \! "$_DATA/$ITEM/$base" -ot "$_DATA/$ITEM/$meta" ] \
+ && dir="$_DATA/$ITEM/$base" . "$_EXEC/update_meta.sh"
+ cut -f1,6- <"$_DATA/$ITEM/$meta" \
+ | while f="$(line)"; do
+ [ -e "$_DATA/$ITEM/$base/${f#* }" ] \
+ && printf '%s %s\n' "${f%% *}" "${base}/${f#* }"
+ done
+ done \
+ | sort -n \
+ | cut -d/ -f2-
+}
+
list_items() {
mode="$(COOKIE mode |grep -m1 -xE 'index|browse' || printf browse )"
[ "$mode" = browse -a "$ITEM" ] && printf '..\n'
- if [ "$mode" = browse ]; then
- [ -d "$_DATA/$ITEM/.index" -a \! "$_DATA/$ITEM" -ot "$_DATA/$ITEM/.index/meta" ] \
- && dir="$_DATA/$ITEM" . "$_EXEC/update_meta.sh"
- (cd "$_DATA/$ITEM";
- find ./ -type d \! -name .index -mindepth 1 -maxdepth 1 \
- -exec stat -c '%Y %n' '{}' +
- find ./ -type f -mindepth 1 -maxdepth 1 \
- -exec stat -c '%Y %n' '{}' +
- )
- elif [ "$mode" = index ]; then
- find "$_DATA/$ITEM" -type d -name .index \
- | while d="$(line)"; do
- [ ! "${d%/.index}" -ot "$d/meta" ] \
- && dir="${d%/.index}" . "$_EXEC/update_meta.sh"
- done
- (cd "$_DATA/$ITEM";
- find ./ -type f \
- -exec stat -c '%Y %n' '{}' +
- )
- fi \
- | case $ORDER in
- Date) sort -rn;;
- Name) sort -k 2;;
- esac \
- | cut -d/ -f2-
+
+ if [ "$mode" = browse -a "$ORDER" = Date ]; then
+ list_fs_browse | sort -rn | cut -d/ -f2-
+ elif [ "$mode" = browse -a "$ORDER" = Name ]; then
+ list_fs_browse | sort -k 2 | cut -d/ -f2-
+ elif [ "$mode" = index -a "$ORDER" = Date ]; then
+ list_fs_index | sort -rn | cut -d/ -f2-
+ elif [ "$mode" = index -a "$ORDER" = Name ]; then
+ list_fs_index | sort -k 2 | cut -d/ -f2-
+ elif [ "$mode" = browse -a "$ORDER" = Length ]; then
+ list_browse
+ elif [ "$mode" = index -a "$ORDER" = Length ]; then
+ list_index
+ fi
}
list_paginate() {