]> git.plutz.net Git - shellwiki/commitdiff
new tool function page_abs
authorPaul Hänsch <paul@plutz.net>
Wed, 18 May 2022 20:00:34 +0000 (22:00 +0200)
committerPaul Hänsch <paul@plutz.net>
Wed, 18 May 2022 20:00:34 +0000 (22:00 +0200)
macros/pagelist
tools.sh

index e9f5a33e191be7ba9796e2aa8911cdccd6d1b5db..54d4a693f2f0d8d2d0fc76bb40b3bbe3b50d6077 100755 (executable)
@@ -14,10 +14,7 @@ printf '<ul class="pagelist">\n'
     page_children "$glob" "$((depth - 1))"
   done \
   | while read -r page; do
-    case $page in
-      /*) pagedir="$(PATH "$page")";;
-      *)  pagedir="$(PATH "$PATH_INFO/$page")";;
-    esac
+    pagedir="$(page_abs "$page")"
     [ -f "$_DATA/pages/${pagedir}/#page.md" -o \
       -f "$_EXEC/pages/${pagedir}/#page.md" ] \
     && acl_read "$pagedir" \
index c88cc55c12bfdeaedf482d4dddcfed51941e7281..2a851ab0726648818a1335872656a64bdadc6a4d 100644 (file)
--- a/tools.sh
+++ b/tools.sh
@@ -58,8 +58,7 @@ page_glob(){
   | while read -r page; do
     case $page in
       \#*|*/\#*) continue;;
-      /*) pagedir="$(PATH "$page")";;
-      *)  pagedir="$(PATH "$PATH_INFO/$page")";;
+      *) pagedir="$(page_abs "$page")";;
     esac
     [ -d "$_DATA/pages/$pagedir" -o -d "$_EXEC/pages/$pagedir" ] \
     && printf '%s\n' "$page"
@@ -87,8 +86,7 @@ page_children(){
   | while read -r page; do
     case $page in
       \#*|*/\#*) continue;;
-      /*) pagedir="$(PATH "$page")";;
-      *)  pagedir="$(PATH "$PATH_INFO/$page")";;
+      *) pagedir="$(page_abs "$page")";;
     esac
     if [ -d "$_DATA/pages/$pagedir" -o -d "$_EXEC/pages/$pagedir" ]; then
       printf %s\\n "$page"
@@ -96,3 +94,10 @@ page_children(){
     fi
   done
 }
+
+page_abs(){
+  case $1 in
+    /*) PATH "${1%/}/";;
+    *)  PATH "${PATH_INFO%/*}/${1%/}/";;
+  esac
+}