]> git.plutz.net Git - shellwiki/blobdiff - macros/changes
omit empty parent pages from page listing
[shellwiki] / macros / changes
index 8714976154c43748cae3d56b31ac85782950931f..c399ee58f6393535e77768d68203336badbb689f 100755 (executable)
@@ -1,5 +1,19 @@
 #!/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"
@@ -8,12 +22,15 @@ _(){ printf %s\\n "$*"; }
 [ "${LANGUAGE}" -a -r "${_EXEC}/l10n/${LANGUAGE}.sh" ] && . "${_EXEC}/l10n/${LANGUAGE}.sh"
 
 LANGUAGES='' glob="/" depth=-1
+set -- "$@" --
 while [ $# -gt 0 ]; do case $1 in
   --system) glob_system_pages=true; shift 1;;
   :*) LANGUAGES="${LANGUAGES}${LANGUAGES:+ }${1#:}"; shift 1;;
   --depth) depth="$2"; shift 2;;
-  *) glob="$1"; shift 1;;
+  --) shift 1; break;;
+  *) set -- "$@" "$1"; shift 1;;
 esac; done
+[ "$*" ] || set -- /
 
 page='' page_abs='' ostamp='' odate='' lstamp='' ldate='' row='' rowstate=''
 
@@ -21,9 +38,14 @@ printf '<table class="macro changes"><thead>\n<th>Page</th>'
 for l in $LANGUAGES; do printf '<th>%s</th>' "$l"; done
 printf '\n</thead><tbody>\n'
 
-page_glob "$glob" "$depth" |while read page; do
+for glob in "$@"; do
+  page_glob "$glob" "$depth" 
+done \
+| sort -u \
+| while read page; do
   page_abs="$(page_abs "$page")"
   acl_read "${page_abs}" || continue
+  mdfile "${page_abs}" >&- || continue
 
   read ostamp odate <<-EOF
        $([ "$REV_PAGES" = true ] \