3 . "$_EXEC/cgilite/file.sh"
6 CACHE_AGE=${CACHE_AGE:-300}
7 export MD_MACROS="$_EXEC/macros"
8 export MD_HTML="${MD_HTML:-false}"
11 # Print content of a wiki page
12 # Get page from data or underlay dir, handle caching
13 local page="$(PATH "$1")" mdfile cache cachetime
15 cache="$_DATA/pages/$page/#page.${USER_ID}.cache"
17 mdfile="$(mdfile "$page")" || return 4
18 acl_read "$page" || return 3
20 cachetime="$(stat -c %Y -- "$mdfile" "$cache" 2>/dev/null)"
22 if [ "${cachetime#*${BR}}" -gt "${cachetime%${BR}*}" \
23 -a "${cachetime#*${BR}}" -gt "$((_DATE - CACHE_AGE))" ]; then
26 mkdir -p -- "$_DATA/pages/$page/"
27 # Macros expect to find page directory as working dir
28 ( cd -- "$_DATA/pages/$page/";
30 | tee -- "${cache}.$$"
32 grep -q '^%nocache' "$mdfile" \
33 && rm -- "${cache}.$$" \
34 || mv -- "${cache}.$$" "${cache}"
38 case "${PATH_INFO}" in
40 # usually some file related to theme
41 # let file server handle errors
42 FILE "${_EXEC}/${PATH_INFO#/\[.\]}"
46 export ERROR_MSG='Page names containing newline character are not allowed'
51 export ERROR_MSG='Page names starting with "#" are not allowed'
56 # looks like some kind of handler
60 if [ ! "$(mdfile "$PATH_INFO")" ]; then
62 elif ! acl_read "$PATH_INFO"; then
65 PAGE_CSS="$(css "${PATH_INFO}")"
66 theme_page "${PATH_INFO}"