]> git.plutz.net Git - shellwiki/blobdiff - macros/changes
Merge commit 'a68722ad0e8de9bcac0bcb4af12025f3b903745c'
[shellwiki] / macros / changes
index c1e6946e4e4edd128fff206519800f4e14558668..596a237d77e3d4b5d80430dc3039bd132b86de36 100755 (executable)
@@ -1,9 +1,26 @@
 #!/bin/sh
 
+# Copyright 2023 Paul Hänsch
+# 
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+# 
+# THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+# IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
 . "$_EXEC/cgilite/cgilite.sh"
 . "$_EXEC/tools.sh"
 . "$_EXEC/acl.sh"
 
+_(){ printf %s\\n "$*"; }
+[ "${LANGUAGE}" -a -r "${_EXEC}/l10n/${LANGUAGE}.sh" ] && . "${_EXEC}/l10n/${LANGUAGE}.sh"
+
 LANGUAGES='' glob="/" depth=-1
 while [ $# -gt 0 ]; do case $1 in
   --system) glob_system_pages=true; shift 1;;
@@ -23,25 +40,32 @@ 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" 2>&- \
+         || printf "0 %s\n" "$(_ "(never edited)")"
+       )
        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
-      row="${row}<td class=\"missing\"><a href=\"$(HTML "${page}:${l}")\">missing</a></td>"
+      row="${row}<td class=\"missing\"><a href=\"$(HTML "${page}:${l}")\">$(_ missing)</a></td>"
       [ "$rowstate" = "${rowstate%*missing*}" ] && rowstate="${rowstate}${rowstate:+ }missing"
     fi
   done