3 [ "$include_tools" ] && return 0
10 md "${_EXEC}"/parsers/*
11 elif [ "$#" = 1 ]; then
21 # Check if page exists, if possible fall
22 # back to default page from installation
23 local page="$(PATH "$1")"
26 # Regular processing, keep in sync with tools.sh
27 if [ -f "$_DATA/pages/$page/:$LANGUAGE/#page.md" ]; then
28 printf %s\\n "$_DATA/pages/$page/:$LANGUAGE/#page.md"
29 elif [ -f "$_DATA/pages/$page/#page.md" ]; then
30 printf %s\\n "$_DATA/pages/$page/#page.md"
31 elif [ -f "$_EXEC/pages/$page/:$LANGUAGE/#page.md" ]; then
32 printf %s\\n "$_EXEC/pages/$page/:$LANGUAGE/#page.md"
33 elif [ -f "$_EXEC/pages/$page/#page.md" ]; then
34 printf %s\\n "$_EXEC/pages/$page/#page.md"
38 # ^^ suppress error messages produced
39 # by printf when stdout was closed
47 if [ $size -gt $((1024 * 1024 * 1024)) ]; then
48 size=$((size / 1024 / 1024 / 1024 * 10 + size / 1024 / 1024 % 1024 / 100))
49 printf "%i.%i GB" "$((size / 10))" "$((size % 10))"
51 elif [ $size -gt $((1024 * 1024)) ]; then
52 size=$((size / 1024 / 1024 * 10 + size / 1024 % 1024 / 100))
53 printf "%i.%i MB" "$((size / 10))" "$((size % 10))"
55 elif [ $size -gt $((1024)) ]; then
56 size=$((size / 1024 * 10 + size % 1024 / 100))
57 printf "%i.%i KB" "$((size / 10))" "$((size % 10))"
65 local pattern="${1%/}" IFS=''
66 local glob page pagedir
69 [ "$page" = "$pattern" ] && page=.
70 [ ! "$page" ] && page=/
71 pattern="${pattern##*/}"
72 [ ! "$pattern" ] && pattern="*"
76 for glob in "$_DATA/pages/$page/#attachments"/$pattern; do printf '%s\n' "${glob#"$_DATA/pages"}"; done
77 for glob in "$_EXEC/pages/$page/#attachments"/$pattern; do printf '%s\n' "${glob#"$_EXEC/pages"}"; done
80 for glob in "$_DATA/pages/$PATH_INFO/$page/#attachments"/$pattern; do printf '%s\n' "${glob#"$_DATA/pages/$PATH_INFO/"}"; done
81 for glob in "$_EXEC/pages/$PATH_INFO/$page/#attachments"/$pattern; do printf '%s\n' "${glob#"$_EXEC/pages/$PATH_INFO/"}"; done
85 | while read -r glob; do
86 [ -e "$glob" ] || continue
87 pagedir="$(page_abs "${glob%%/#attachments/*}/")"
88 [ -d "$_DATA/pages/$pagedir" -o -d "$_EXEC/pages/$pagedir" ] \
89 && printf '%s\n' "${glob%%/#attachments/*}/${glob#*/#attachments/}"
94 local pattern="${1%/}/" IFS=''
95 local glob page pagedir
99 for glob in "$_DATA/pages"$pattern; do printf '%s\n' "${glob#"$_DATA/pages"}"; done
100 for glob in "$_EXEC/pages"$pattern; do printf '%s\n' "${glob#"$_EXEC/pages"}"; done
103 for glob in "$_DATA/pages/$PATH_INFO"/$pattern; do printf '%s\n' "${glob#"$_DATA/pages/$PATH_INFO/"}"; done
104 for glob in "$_EXEC/pages/$PATH_INFO"/$pattern; do printf '%s\n' "${glob#"$_EXEC/pages/$PATH_INFO/"}"; done
108 | while read -r page; do
110 \#*|*/\#*) continue;;
111 *) pagedir="$(page_abs "$page")";;
113 [ -d "$_DATA/pages/$pagedir" -o -d "$_EXEC/pages/$pagedir" ] \
114 && printf '%s\n' "$page"
119 local page="${1:-${PATH_INFO}}" depth="${2:-1}"
120 local glob pagedir IFS=''
123 [ "$depth" -eq 0 ] && return 0
127 for glob in "$_DATA/pages/${page}"*/; do printf '%s\n' "${glob#"$_DATA/pages/"}"; done
128 for glob in "$_EXEC/pages/${page}"*/; do printf '%s\n' "${glob#"$_EXEC/pages/"}"; done
131 for glob in "$_DATA/pages/$PATH_INFO/${page}"*/; do printf '%s\n' "${glob#"$_DATA/pages/$PATH_INFO/"}"; done
132 for glob in "$_EXEC/pages/$PATH_INFO/${page}"*/; do printf '%s\n' "${glob#"$_EXEC/pages/$PATH_INFO/"}"; done
136 | while read -r page; do
138 \#*|*/\#*) continue;;
139 *) pagedir="$(page_abs "$page")";;
141 if [ -d "$_DATA/pages/$pagedir" -o -d "$_EXEC/pages/$pagedir" ]; then
143 page_children "$page" "$((depth - 1))"
151 *) PATH "${PATH_INFO%/*}/${1%/}/";;