3 CACHE_AGE=${CACHE_AGE:-300}
4 export MD_MACROS="$_EXEC/macros"
5 export MD_HTML="${MD_HTML:-false}"
8 # Print content of a wiki page
9 # Get page from data or underlay dir, handle caching
10 local page="$(PATH "$1")" mdfile cache cachetime
12 cache="$_DATA/pages/$page/#page.${USER_ID}.cache"
14 mdfile="$(mdfile "$page")" || return 4
15 acl_read "$page" || return 3
17 cachetime="$(stat -c %Y -- "$mdfile" "$cache" 2>/dev/null)"
19 if [ "${cachetime#*${BR}}" -gt "${cachetime%${BR}*}" \
20 -a "${cachetime#*${BR}}" -gt "$((_DATE - CACHE_AGE))" ]; then
23 mkdir -p -- "$_DATA/pages/$page/"
24 # Macros expect to find page directory as working dir
25 ( cd -- "$_DATA/pages/$page/";
27 | tee -- "${cache}.$$"
29 grep -q '^%nocache' "$mdfile" \
30 && rm -- "${cache}.$$" \
31 || mv -- "${cache}.$$" "${cache}"
35 case "${PATH_INFO}" in
37 FILE "${_EXEC}/${PATH_INFO#/\[.\]}"
41 export ERROR_MSG='Page names containing newline character are not allowed'
46 export ERROR_MSG='Page names starting with "#" are not allowed'
54 theme_page "${PATH_INFO}"