3 # Copyright 2022 - 2023 Paul Hänsch
5 # Permission to use, copy, modify, and/or distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
12 # SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
15 # IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 . "$_EXEC/cgilite/cgilite.sh"
21 tags='' ntags='' dir='' depth='' glob_system_pages=false
22 label='' labeltype='' altlabel='' cnt=0
25 while [ $# -gt 0 ]; do case $1 in
26 --system) glob_system_pages=true; shift 1;;
27 --depth) depth="$2" shift 2;;
28 \#*) tags="${tags}${tags:+ }${1###}"; shift 1;;
29 \!*) ntags="${ntags}${ntags:+ }${1##!}"; shift 1;;
30 --h1|--h2|--h3|--h4|--h5|--h6|--label)
31 labeltype="${1#--}" label="$2"; shift 2;;
33 altlabel="$2"; shift 2;;
35 *) if [ ! "$dir" ]; then
37 set -- "$@" "$1"; shift 1;
38 elif [ ! "$depth" ]; then
41 set -- "$@" "$1"; shift 1;
45 [ "$*" ] || set -- "*"
46 [ "$depth" -ge 0 -o "$depth" -le 0 ] 2>&- || depth=0
49 page_glob "$dir" "$depth"
53 while read -r page; do
54 pagedir="$(page_abs "$page")"
55 if [ -f "$_DATA/pages/${pagedir}/#page.md" -o \
56 -f "$_EXEC/pages/${pagedir}/#page.md" ] \
57 && acl_read "$pagedir" \
58 && has_tags "$pagedir" $tags \
59 && ! has_tag "$pagedir" $ntags
61 [ "$cnt" -eq 0 -a "$label" ] \
62 && printf '<%s class="macro pagelist label">%s</%s>' \
63 "$labeltype" "$(HTML "$label")" "$labeltype"
64 [ "$cnt" -eq 0 ] && printf '<ul class="macro pagelist">\n'
66 printf '<li><a href="%s">%s</a></li>' "$(HTML "$page")" "$(HTML "$page")"
71 if [ "$cnt" -gt 0 ]; then
73 elif [ "$altlabel" ]; then
74 printf '<label class="macro pagelist altlabel">%s</label>' "$(HTML "$altlabel")"