}
theme_footer(){
- printf '<footer>%s</footer>' "$(wiki '[wiki]/footer/' ||echo No footer)"
+ printf '<footer>%s</footer>' "$(wiki '[wiki]/footer/')"
+}
+
+theme_pagemenu(){
+ local page="$1"
+
+ if acl_write "$page"; then
+ printf '
+ <ul class="pagemenu">
+ <li><a href="[edit]">Edit</a></li>
+ <li><a href="[attachment]/">Attachments</a></li>
+ </ul>'
+ fi
}
theme_page(){
local page="$1" title
title="${page%/}"; title="${title##*/}"
- if [ ! "$(mdfile "$page")" ]; then
- theme_error 404
- return 0
- elif ! acl_read "$page"; then
- theme_error 403
- return 0
- fi
-
# Important! Web Server response including newline
printf "%s\r\n" "Content-Type: text/html; charset=utf-8" ""
</head><body id="$(HTML "$page")">
$(theme_header)
<main>
- $(acl_write "$page" && printf %s \
- '<ul class="pagemenu">
- <li><a href="[edit]">Edit</a></li>
- <li><a href="[attachment]/">Attachments</a></li>
- </ul>'
- )
+ $(theme_pagemenu)
<article>
$(wiki "$page" || printf 'Error while loading page <br> function "wiki" of index.sh returned with an error.')
</article>
local page="$1" template="$2" title
title="${page%/}"; title="${title##*/}"
- if ! acl_write "$page"; then
- theme_error 403
- return 0
- fi
-
[ "$template" ] && acl_read "$template" || template="$page"
# Important! Web Server response including newline
EOF
}
-theme_attachments(){
+theme_revisions(){
local page="$1" title
title="${page%/}"; title="${title##*/}"
- if [ ! "$(mdfile "$page")" ]; then
- theme_error 404
- return 0
- elif ! acl_read "$page"; then
- theme_error 403
- return 0
- fi
+ # Important! Web Server response including newline
+ printf "%s\r\n" "Content-Type: text/html; charset=utf-8" ""
+
+ cat <<-EOF
+ <!DOCTYPE HTML>
+ <html><head>
+ $(theme_head)
+ <title>Revisions $(HTML "${title}")</title>
+ </head><body id="$(HTML "$page")[attachment]/">
+ $(theme_header)
+ <main>
+ $("$_EXEC/macros/revisions" "$page")
+ </main>
+ $(theme_footer)
+ </body></html>
+ EOF
+}
+
+theme_attachments(){
+ local page="$1" title
+ title="${page%/}"; title="${title##*/}"
# Important! Web Server response including newline
printf "%s\r\n" "Content-Type: text/html; charset=utf-8" ""