X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=themes%2Fdefault.sh;h=e9e9d73f195466c6bfcf2433dfe0dcb8767aab60;hb=7af38aed3e2f4d019b371da3ec58a41457173248;hp=6370166017775241ed9691cfca7c23c78b7282d7;hpb=4fb35b146e7aca6faf5945105ab36a270b7f1ad5;p=shellwiki diff --git a/themes/default.sh b/themes/default.sh index 6370166..e9e9d73 100755 --- a/themes/default.sh +++ b/themes/default.sh @@ -1,27 +1,192 @@ #!/bin/sh -theme_404(){ - printf "%s\r\n" "Status: 404 Not Found" +. "$_EXEC/tools.sh" - theme_page '/[404]/' +theme_head(){ + printf ' + + + + ' "$_BASE" +} + +theme_header(){ + printf '
%s
' "$(wiki '[wiki]/header/')" +} + +theme_footer(){ + printf '' "$(wiki '[wiki]/footer/')" +} + +theme_pagemenu(){ + local page="$1" + + if acl_write "$page"; then + printf ' + ' + fi } theme_page(){ 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" "" cat <<-EOF - - + $(theme_head) $(HTML "${title}") -
-
$(wiki "$page" || printf 'Page not found')
- + $(theme_header) +
+ $(theme_pagemenu) +
+ $(wiki "$page" || printf 'Error while loading page
function "wiki" of index.sh returned with an error.') +
+
+ $(theme_footer) + + EOF +} + +theme_editor(){ + local page="$1" template="$2" title + title="${page%/}"; title="${title##*/}" + + [ "$template" ] && acl_read "$template" || template="$page" + + # Important! Web Server response including newline + printf "%s\r\n" "Content-Type: text/html; charset=utf-8" "" + + cat <<-EOF + + + $(theme_head) + $(HTML "${title}") + + $(theme_header) +
+ + + + +
+ $(theme_footer) + + EOF +} + +theme_revisions(){ + 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" "" + + cat <<-EOF + + + $(theme_head) + Revisions $(HTML "${title}") + + $(theme_header) +
+ $("$_EXEC/macros/revisions" "$page") +
+ $(theme_footer) + + 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" "" + + if acl_write "$page"; then + cat <<-EOF + + + $(theme_head) + Attachments $(HTML "${title}") + + $(theme_header) +
+
+ + + +
+ +
+
+ $(theme_footer) EOF + else + cat <<-EOF + + + $(theme_head) + Attachments $(HTML "${title}") + + $(theme_header) +
+ +
+ $(theme_footer) + + EOF + fi +} + +theme_error(){ + local errno="$1" + + case $errno in + 400) printf "%s\r\n" "Status: 400 Bad Request";; + 403) printf "%s\r\n" "Status: 403 Forbidden";; + 404) printf "%s\r\n" "Status: 404 Not Found";; + 409) printf "%s\r\n" "Status: 409 Conflict";; + 500) printf "%s\r\n" "Status: 500 Internal Server Error";; + esac + + if [ "$(mdfile "/[wiki]/$errno/")" ]; then + theme_page "/[wiki]/$errno/" + else + printf "Content-Length: 0\r\n\r\n" + fi }