3 [ "$include_tools" ] && return 0
6 if [ "$(which awk)" ]; then
7 md() { awk -f "$_EXEC/md_macros.awk" -f "$_EXEC/cgilite/markdown.awk"; }
8 elif [ "$(which busybox)" ]; then
9 md() { busybox awk -f "$_EXEC/md_macros.awk" -f "$_EXEC/cgilite/markdown.awk"; }
15 # Check if page exists, if possible fall
16 # back to default page from installation
17 local page="$(PATH "$1")"
19 # IMPORTANT: A Copy of this function exists
20 # in `handlers/10_translations.sh`
22 # Keep it synchronized, when changing anything
24 if [ -f "$_DATA/pages/$page/#page.md" ]; then
25 printf %s\\n "$_DATA/pages/$page/#page.md"
27 elif [ -f "$_EXEC/pages/$page/#page.md" ]; then
28 printf %s\\n "$_EXEC/pages/$page/#page.md"
33 # ^^ suppress error messages produced
34 # by printf when stdout was closed
40 if [ $size -gt $((1024 * 1024 * 1024)) ]; then
41 size=$((size / 1024 / 1024 / 1024 * 10 + size / 1024 / 1024 % 1024 / 100))
42 printf "%i.%i GB" "$((size / 10))" "$((size % 10))"
44 elif [ $size -gt $((1024 * 1024)) ]; then
45 size=$((size / 1024 / 1024 * 10 + size / 1024 % 1024 / 100))
46 printf "%i.%i MB" "$((size / 10))" "$((size % 10))"
48 elif [ $size -gt $((1024)) ]; then
49 size=$((size / 1024 * 10 + size % 1024 / 100))
50 printf "%i.%i KB" "$((size / 10))" "$((size % 10))"
58 local pattern="${1%/}/" IFS=''
59 local glob page pagedir
63 for glob in "$_DATA/pages"$pattern; do printf '%s\n' "${glob#"$_DATA/pages"}"; done
64 for glob in "$_EXEC/pages"$pattern; do printf '%s\n' "${glob#"$_EXEC/pages"}"; done
67 for glob in "$_DATA/pages/$PATH_INFO"/$pattern; do printf '%s\n' "${glob#"$_DATA/pages/$PATH_INFO/"}"; done
68 for glob in "$_EXEC/pages/$PATH_INFO"/$pattern; do printf '%s\n' "${glob#"$_EXEC/pages/$PATH_INFO/"}"; done
72 | while read -r page; do
75 *) pagedir="$(page_abs "$page")";;
77 [ -d "$_DATA/pages/$pagedir" -o -d "$_EXEC/pages/$pagedir" ] \
78 && printf '%s\n' "$page"
83 local page="${1:-${PATH_INFO}}" depth="${2:-1}"
84 local glob pagedir IFS=''
87 [ "$depth" -eq 0 ] && return 0
91 for glob in "$_DATA/pages/${page}"*/; do printf '%s\n' "${glob#"$_DATA/pages/"}"; done
92 for glob in "$_EXEC/pages/${page}"*/; do printf '%s\n' "${glob#"$_EXEC/pages/"}"; done
95 for glob in "$_DATA/pages/$PATH_INFO/${page}"*/; do printf '%s\n' "${glob#"$_DATA/pages/$PATH_INFO/"}"; done
96 for glob in "$_EXEC/pages/$PATH_INFO/${page}"*/; do printf '%s\n' "${glob#"$_EXEC/pages/$PATH_INFO/"}"; done
100 | while read -r page; do
102 \#*|*/\#*) continue;;
103 *) pagedir="$(page_abs "$page")";;
105 if [ -d "$_DATA/pages/$pagedir" -o -d "$_EXEC/pages/$pagedir" ]; then
107 page_children "$page" "$((depth - 1))"
115 *) PATH "${PATH_INFO%/*}/${1%/}/";;