3 . "$_EXEC/cgilite/file.sh"
5 CACHE_AGE=${CACHE_AGE:-300}
6 export MD_MACROS="$_EXEC/macros"
7 export MD_HTML="${MD_HTML:-false}"
10 # Print content of a wiki page
11 # Get page from data or underlay dir, handle caching
12 local page="$(PATH "$1")" mdfile cache cachetime
14 cache="$_DATA/pages/$page/#page.${USER_ID}.cache"
16 mdfile="$(mdfile "$page")" || return 4
17 acl_read "$page" || return 3
19 cachetime="$(stat -c %Y -- "$mdfile" "$cache" 2>/dev/null)"
21 if [ "${cachetime#*${BR}}" -gt "${cachetime%${BR}*}" \
22 -a "${cachetime#*${BR}}" -gt "$((_DATE - CACHE_AGE))" ]; then
25 mkdir -p -- "$_DATA/pages/$page/"
26 # Macros expect to find page directory as working dir
27 ( cd -- "$_DATA/pages/$page/";
29 | tee -- "${cache}.$$"
31 grep -q '^%nocache' "$mdfile" \
32 && rm -- "${cache}.$$" \
33 || mv -- "${cache}.$$" "${cache}"
37 case "${PATH_INFO}" in
39 # usually some file related to theme
40 # let file server handle errors
41 FILE "${_EXEC}/${PATH_INFO#/\[.\]}"
45 export ERROR_MSG='Page names containing newline character are not allowed'
50 export ERROR_MSG='Page names starting with "#" are not allowed'
55 # looks like some kind of handler
59 if [ ! "$(mdfile "$PATH_INFO")" ]; then
61 elif ! acl_read "$PATH_INFO"; then
64 theme_page "${PATH_INFO}"