X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=macros%2Fchanges;h=596a237d77e3d4b5d80430dc3039bd132b86de36;hb=7ee49ea6a4595386680b9a19ae75108068b93fb0;hp=c1e6946e4e4edd128fff206519800f4e14558668;hpb=9c54db6ec648c690cc3111faa19c3312d51d041e;p=shellwiki diff --git a/macros/changes b/macros/changes index c1e6946..596a237 100755 --- a/macros/changes +++ b/macros/changes @@ -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="$(HTML "$page")${odate%% +*}" + row="$(HTML "$page")${odate%%[+.]*}" 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}outdated${ldate%% +*}" + row="${row}$(_ outdated)${ldate%%[+.]*}" [ "$rowstate" = "${rowstate%*outdated*}" ] && rowstate="${rowstate}${rowstate:+ }outdated" else - row="${row}current${ldate%% +*}" + row="${row}$(_ current)${ldate%%[+.]*}" [ "$rowstate" = "${rowstate%*current*}" ] && rowstate="${rowstate}${rowstate:+ }current" fi else - row="${row}missing" + row="${row}$(_ missing)" [ "$rowstate" = "${rowstate%*missing*}" ] && rowstate="${rowstate}${rowstate:+ }missing" fi done