]> git.plutz.net Git - shellwiki/commitdiff
<<changes>> macro: fallback to filesystem timestamps if revisioning is disabled
authorPaul Hänsch <paul@plutz.net>
Tue, 15 Aug 2023 11:33:05 +0000 (13:33 +0200)
committerPaul Hänsch <paul@plutz.net>
Tue, 15 Aug 2023 11:33:05 +0000 (13:33 +0200)
macros/changes

index c1e6946e4e4edd128fff206519800f4e14558668..562fa8f6dddf35aed439dbd57ed4f3fc008be8f2 100755 (executable)
@@ -23,21 +23,27 @@ page_glob "$glob" "$depth" |while read page; do
   acl_read "${page_abs}" || continue
 
   read ostamp odate <<-EOF
-       $(git -C "$_DATA" log --pretty="format:%at %ai" -- "pages${page_abs}#page.md")
+       $([ "$REV_PAGES" = true ] \
+         && git -C "$_DATA" log --pretty="format:%at %ai" -- "pages${page_abs}#page.md" \
+         || stat -c "%Y %y" -- "$_DATA/pages${page_abs}#page.md"
+       )
        EOF
-  row="<td><a href=\"$(HTML "$page")\">$(HTML "$page")</a><span class=\"date\">${odate%% +*}</span></td>"
+  row="<td><a href=\"$(HTML "$page")\">$(HTML "$page")</a><span class=\"date\">${odate%%[+.]*}</span></td>"
   rowstate=''
  
   for l in $LANGUAGES; do
     if [ -f "${_DATA}/pages/${page}:${l}/#page.md" ]; then
       read lstamp ldate <<-EOF
-       $(git -C "$_DATA" log --pretty="format:%at %ai" -- "pages$(page_abs "${page_abs}:${l}")/#page.md")
+       $([ "$REV_PAGES" = true ] \
+         && git -C "$_DATA" log --pretty="format:%at %ai" -- "pages$(page_abs "${page_abs}:${l}")/#page.md" \
+         || stat -c "%Y %y" -- "$_DATA/pages$(page_abs "${page_abs}:${l}")/#page.md"
+       )
        EOF
       if [ $lstamp -lt $ostamp ] 2>&-; then
-        row="${row}<td class=\"outdated\"><a href=\"$(HTML "${page}:${l}")\">outdated</a><span class=\"date\">${ldate%% +*}</span></td>"
+        row="${row}<td class=\"outdated\"><a href=\"$(HTML "${page}:${l}")\">outdated</a><span class=\"date\">${ldate%%[+.]*}</span></td>"
         [ "$rowstate" = "${rowstate%*outdated*}" ] && rowstate="${rowstate}${rowstate:+ }outdated"
       else
-        row="${row}<td class=\"current\" ><a href=\"$(HTML "${page}:${l}")\">current</a ><span class=\"date\">${ldate%% +*}</span></td>"
+        row="${row}<td class=\"current\" ><a href=\"$(HTML "${page}:${l}")\">current</a ><span class=\"date\">${ldate%%[+.]*}</span></td>"
         [ "$rowstate" = "${rowstate%*current*}" ] && rowstate="${rowstate}${rowstate:+ }current"
       fi
     else