From: Paul Hänsch Date: Sun, 8 Jul 2018 07:46:42 +0000 (+0200) Subject: listing by indexed length X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=a3df4e8f297a16faf93847dab6cbd15d6e524e73;p=serve0 listing by indexed length --- diff --git a/list.sh b/list.sh index ddf1111..324d8eb 100644 --- a/list.sh +++ b/list.sh @@ -3,14 +3,14 @@ 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]] @@ -26,35 +26,75 @@ list_item() { 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() { diff --git a/style.css b/style.css index dd5a231..0d2bd6e 100644 --- a/style.css +++ b/style.css @@ -6,7 +6,6 @@ button { padding: .125em .5em; } a { color: inherit; text-decoration: none;} body { - position: relative; color: white; background-color: black; } @@ -152,6 +151,7 @@ a[href="#advsearch"]:before { } #editing { + position: absolute; width: 100%; bottom: 0; background-color: #333; border-top: 1px solid;