X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;f=list.sh;h=2f8e1390774469156406829f49ff702cbc3001d6;hb=ad9ff11ccc78543cee20d00e0a0e7c9610761b0f;hp=cb0e4c159bc9a556638301087c046c1e7a232617;hpb=3c586e3fe4da20469de93897d03d41f82cb15b3b;p=serve0 diff --git a/list.sh b/list.sh index cb0e4c1..2f8e139 100644 --- a/list.sh +++ b/list.sh @@ -1,18 +1,21 @@ #!/bin/sh list_dir(){ - dir="$(HTML "$1")" + name="$(HTML "$1")" + path="$(HTML "${ITEM}/$1")" printf '[a .list .dir href="%s" %s]' \ - "$dir" "$dir" + "$path" "$name" } list_file(){ - file="$(HTML "$1")" + name="$(HTML "$1")" + path="$(HTML "$ITEM/$1")" printf '[div .list .file [a href="%s" [img src="%s?a=thumbnail"] %s]]' \ - "$file" "$file" "$file" + "$path" "$path" "$name" } list_dirs(){ + [ "$ITEM" ] && printf '..\n' (cd "$_DATA/$ITEM"; find ./ -type d -mindepth 1 -maxdepth 1 \ -exec stat -c '%Y %n' '{}' + @@ -24,7 +27,7 @@ list_dirs(){ list_files(){ (cd "$_DATA/$ITEM"; find ./ -type f -mindepth 1 -maxdepth 1 \ - -exec stat -c '%Y %n' "${f#./}" '{}' + + -exec stat -c '%Y %n' "${f#./}" '{}' + 2>&- ) \ | { [ "$(GET o)" = Date ] && sort -rn || sort -k 2; } \ | cut -d/ -f2- @@ -49,7 +52,7 @@ printf 'Content-Type: text/html;charset=utf-8\r\n\r\n' $(w_search) [input type=checkbox #t_prefs .toggle ][label for=t_prefs ⚙] $(w_prefs) - $(if [ $(COOKIE mode) = index ]; then + $(if [ "$(COOKIE mode)" = index ]; then list_tree |while read -r file; do list_file "$file"; done else list_dirs |while read -r dir; do list_dir "$dir"; done