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 local page="$(PATH "$1")"
17 if [ -f "$_DATA/pages/$page/#page.md" ]; then
18 printf %s\\n "$_DATA/pages/$page/#page.md"
19 elif [ -f "$_EXEC/pages/$page/#page.md" ]; then
20 printf %s\\n "$_EXEC/pages/$page/#page.md"
29 if [ $size -gt $((1024 * 1024 * 1024)) ]; then
30 size=$((size / 1024 / 1024 / 1024 * 10 + size / 1024 / 1024 % 1024 / 100))
31 printf "%i.%i GB" "$((size / 10))" "$((size % 10))"
33 elif [ $size -gt $((1024 * 1024)) ]; then
34 size=$((size / 1024 / 1024 * 10 + size / 1024 % 1024 / 100))
35 printf "%i.%i MB" "$((size / 10))" "$((size % 10))"
37 elif [ $size -gt $((1024)) ]; then
38 size=$((size / 1024 * 10 + size % 1024 / 100))
39 printf "%i.%i KB" "$((size / 10))" "$((size % 10))"
47 local pattern="${1%/}/" IFS=''
48 local glob page pagedir
52 for glob in "$_DATA/pages"$pattern; do printf '%s\n' "${glob#"$_DATA/pages"}"; done
53 for glob in "$_EXEC/pages"$pattern; do printf '%s\n' "${glob#"$_EXEC/pages"}"; done
56 for glob in "$_DATA/pages/$PATH_INFO"/$pattern; do printf '%s\n' "${glob#"$_DATA/pages/$PATH_INFO/"}"; done
57 for glob in "$_EXEC/pages/$PATH_INFO"/$pattern; do printf '%s\n' "${glob#"$_EXEC/pages/$PATH_INFO/"}"; done
61 | while read -r page; do
64 *) pagedir="$(page_abs "$page")";;
66 [ -d "$_DATA/pages/$pagedir" -o -d "$_EXEC/pages/$pagedir" ] \
67 && printf '%s\n' "$page"
72 local page="${1:-${PATH_INFO}}" depth="${2:-1}"
73 local glob pagedir IFS=''
76 [ "$depth" -eq 0 ] && return 0
80 for glob in "$_DATA/pages/${page}"*/; do printf '%s\n' "${glob#"$_DATA/pages/"}"; done
81 for glob in "$_EXEC/pages/${page}"*/; do printf '%s\n' "${glob#"$_EXEC/pages/"}"; done
84 for glob in "$_DATA/pages/$PATH_INFO/${page}"*/; do printf '%s\n' "${glob#"$_DATA/pages/$PATH_INFO/"}"; done
85 for glob in "$_EXEC/pages/$PATH_INFO/${page}"*/; do printf '%s\n' "${glob#"$_EXEC/pages/$PATH_INFO/"}"; done
89 | while read -r page; do
92 *) pagedir="$(page_abs "$page")";;
94 if [ -d "$_DATA/pages/$pagedir" -o -d "$_EXEC/pages/$pagedir" ]; then
96 page_children "$page" "$((depth - 1))"
104 *) PATH "${PATH_INFO%/*}/${1%/}/";;