- # TODO: deliver downscaled images, etc.
- if [ -f "$_DATA/pages/${file%/*}/#attachments/${file#*/}" ]; then
- FILE "$_DATA/pages/${file%/*}/#attachments/${file#*/}"
- elif [ -f "$_EXEC/pages/${file%/*}/#attachments/${file#*/}" ]; then
- FILE "$_EXEC/pages/${file%/*}/#attachments/${file#*/}"
- elif [ -d "$_DATA/pages/${file}/" -o -d "$_EXEC/pages/${file}" ]; then
- # path looks like a rogue page name (without trailing slash), so redirect
- REDIRECT "$_BASE/${file}/"
- else
- return 1
- fi
-}
-
-case "${PATH_INFO}" in
- /"[.]"/*)
- FILE "${_EXEC}/${PATH_INFO#/\[.\]}"
- ;;
- */)
- if [ -f "$_DATA/pages/$PATH_INFO/#page.md" \
- -o -f "$_EXEC/pages/$PATH_INFO/#page.md" ]; then
- theme_page "${PATH_INFO}"
- else
- theme_404
- fi
- ;;
- */"[edit]")
- theme_editor "${PATH_INFO%\[edit\]}"
- ;;
- */"[login]")
- [ "$USER_NAME" ] \
- && REDIRECT "./" \
- || theme_login
- ;;
- */"[register]")
- theme_register
- ;;
- */"[attachment]"/*)
- : # TODO: Original attachment file
- ;;
- */"#"*)
- : # TODO: Invalid page name
- ;;
- *)
- attachment "${PATH_INFO}"
- ;;
-esac