--- /dev/null
+#!/bin/sh
+
+. "$_EXEC/cgilite/cgilite.sh"
+. "$_EXEC/acl.sh"
+. "$_EXEC/tools.sh"
+
+dir="${1:-./}"
+depth="${2:-1}"
+
+printf '<ul class="pagelist">\n'
+ page_glob "$dir" \
+ | while read -r glob; do
+ page_children "$glob" "$depth"
+ done \
+ | while read -r page; do
+ case $page in
+ /*) pagedir="$(PATH "$page")";;
+ *) pagedir="$(PATH "$PATH_INFO/$page")";;
+ esac
+ acl_read "$pagedir" \
+ && printf '<li><a href="%s">%s</a></li>' "$(HTML "$page")" "$(HTML "$page")"
+ done
+printf '</ul>\n'
printf "%i B" "$size"
fi
}
+
+page_glob(){
+ local pattern="$1" IFS=''
+ local glob page pagedir
+
+ case $pattern in
+ /*)
+ for glob in "$_DATA/pages"$pattern; do printf '%s\n' "${glob#"$_DATA/pages"}"; done
+ for glob in "$_EXEC/pages"$pattern; do printf '%s\n' "${glob#"$_EXEC/pages"}"; done
+ ;;
+ *)
+ for glob in "$_DATA/pages/$PATH_INFO"/$pattern; do printf '%s\n' "${glob#"$_DATA/pages/$PATH_INFO/"}"; done
+ for glob in "$_EXEC/pages/$PATH_INFO"/$pattern; do printf '%s\n' "${glob#"$_EXEC/pages/$PATH_INFO/"}"; done
+ ;;
+ esac \
+ | sort -u \
+ | while read -r page; do
+ case $page in
+ \#*|*/\#*) continue;;
+ /*) pagedir="$(PATH "$page")";;
+ *) pagedir="$(PATH "$PATH_INFO/$page")";;
+ esac
+ [ -d "$_DATA/pages/$pagedir" -o -d "$_EXEC/pages/$pagedir" ] \
+ && printf '%s\n' "$page"
+ done
+}
+
+page_children(){
+ local page="${1%/}/" depth="${2:--1}"
+ local glob pagedir IFS=''
+
+ debug "CHILDREN $page $depth"
+
+ [ "$depth" -eq 0 ] && return 0
+ printf %s\\n "$page"
+
+ case $page in
+ /*)
+ for glob in "$_DATA/pages/${page}"*/; do printf '%s\n' "${glob#"$_DATA/pages"}"; done
+ for glob in "$_EXEC/pages/${page}"*/; do printf '%s\n' "${glob#"$_EXEC/pages"}"; done
+ ;;
+ *)
+ for glob in "$_DATA/pages/$PATH_INFO/${page}"*/; do printf '%s\n' "${glob#"$_DATA/pages/$PATH_INFO/"}"; done
+ for glob in "$_EXEC/pages/$PATH_INFO/${page}"*/; do printf '%s\n' "${glob#"$_EXEC/pages/$PATH_INFO/"}"; done
+ ;;
+ esac \
+ | debug \
+ | sort -u \
+ | while read -r page; do
+ case $page in
+ \#*|*/\#*) continue;;
+ /*) pagedir="$(PATH "$page")";;
+ *) pagedir="$(PATH "$PATH_INFO/$page")";;
+ esac
+ [ -d "$_DATA/pages/$pagedir" -o -d "$_EXEC/pages/$pagedir" ] \
+ && page_children "$page" "$((depth - 1))"
+ done
+}