]> Sergey Matveev's repositories - zk.git/commitdiff
Show number of entries in category
authorSergey Matveev <stargrave@stargrave.org>
Sun, 4 May 2025 12:04:42 +0000 (15:04 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sun, 4 May 2025 12:06:10 +0000 (15:06 +0300)
zk.zsh

diff --git a/zk.zsh b/zk.zsh
index afe5680fde6c297f63a25d7245f5ea55286b2935..e331c55912bff1f53d6880f32ca1d24635ba2b3b 100755 (executable)
--- a/zk.zsh
+++ b/zk.zsh
@@ -35,7 +35,10 @@ for p (**(.)) {
     sizes[$p]=${size[1]}
 }
 typeset -A cats
-for p (**(/)) cats[$p]=1
+for p (**(/)) {
+    local files=($p/*(N))
+    cats[$p]=$#files
+}
 
 zmodload zsh/mapfile
 zmodload -F zsh/files b:zf_mkdir
@@ -183,12 +186,12 @@ genIndex() {
     }
     print "</table>"
     if [[ $_cats ]]; then
-        print "<hr/>Subdirectories:<ul>"
+        print "<table border=1><caption>Subdirectories</caption>"
         for p (${(oi)_cats}) {
             getrel $page $p/index
-            print "<li><a href=\"${REPLY}.html\">$p</a></li>"
+            print "<tr><td><a href=\"${REPLY}.html\">$p</a></td><td>${cats[$p]}</td></tr>"
         }
-        print "</ul>"
+        print "</table>"
     fi
     local bs=(${(oi)=${backs[$1]}})
     if [[ $bs ]]; then