]> Sergey Matveev's repositories - zk.zsh.git/commitdiff
Show notes mtime in title
authorSergey Matveev <stargrave@stargrave.org>
Sun, 13 Mar 2022 11:57:03 +0000 (14:57 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sun, 13 Mar 2022 11:57:03 +0000 (14:57 +0300)
zk.zsh

diff --git a/zk.zsh b/zk.zsh
index b8de2b3b8d050b8d7a9f630c1b760b8398066baf..253c5029a33edca6f0e21d353cf50c89444f5033 100755 (executable)
--- a/zk.zsh
+++ b/zk.zsh
@@ -19,8 +19,12 @@ EOF
 
 # Collect all pages
 setopt GLOB_STAR_SHORT
+zmodload -F zsh/stat b:zstat
 typeset -A pages
-for f (**(.)) pages[$f]=1
+for p (**(.)) {
+    zstat -A reply -F "%F %T" +mtime $p
+    pages[$p]=${reply[1]}
+}
 
 # Determine the links between them
 typeset -A links
@@ -78,12 +82,12 @@ genhtml() {
         data="${data//${p}/<a href=\"${REPLY}.html\">$p</a>}"
     }
     print "<\!DOCTYPE html>
-<html><head><title>$page</title></head><body><pre>
+<html><head><title>$page (${pages[$page]})</title></head><body><pre>
 $data
 </pre><hr/><ul>"
     for p (${(oi)=${backs[$page]}}) {
         getrel $page $p
-        print "<li><a href=\"${REPLY}.html\">$p</a></li>"
+        print "<li><a href=\"${REPLY}.html\">$p</a> <sup>${pages[$p]}</sup></li>"
     }
     print "</ul></body></html>"
 }
@@ -98,9 +102,11 @@ case $1 in
         mkdir -p $2/$subdir
         genhtml $p > $2/$p.html
     }
-    local all=""
-    for p (${(Oi)${(k)pages}}) all="$p\n$all"
-    genhtml ALL $all > $2/ALL.html
+    local all=()
+    for p (${(Oi)${(k)pages}}) all=("$p (${pages[$p]})" $all)
+    zmodload -F zsh/datetime b:strftime
+    pages[ALL]=$(strftime "%F %T")
+    genhtml ALL ${(j:\n:)all} > $2/ALL.html
     ;;
 (*) usage ;;
 esac