indexhtml: Simplify and fix date format
authorChristoph Berg <myon@debian.org>
Mon, 22 Mar 2021 16:39:20 +0000 (17:39 +0100)
committerChristoph Berg <myon@debian.org>
Mon, 22 Mar 2021 16:39:20 +0000 (17:39 +0100)
repo/bin/indexhtml

index e0bd8067941819b7c7ce2a35c34dd12b426cfb33..de6edcf1eb537ffc84c98a4726de08238efb1fcc 100755 (executable)
@@ -6,17 +6,13 @@ cd "$1"
 
 (
 echo "<tt>"
-ls -al | tail -n +2 | while read line; do
-  prefix="${line% *}"
-  file="${line##* }"
-  case $file in
-    .|index.html) continue ;;
-  esac
-  case $line in
-    d*) link="$file/index.html" file="$file/" ;;
-    *) link="$file" ;;
-  esac
-  echo "$prefix <a href=\"$link\">$file</a> <br />"
+(echo ".."; ls) | while read file; do
+  [ "$file" = "index.html" ] && continue
+  if test -d $file; then
+    stat -c '%.10y <a href="%n/index.html">%n/</a> <br />' $file
+  else
+    stat -c '%.10y <a href="%n">%n</a> %s Bytes <br />' $file
+  fi
 done
 echo "</tt>"
 ) > index.html