X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=themes%2Fdefault.sh;h=36710dbd44e8194f6fd6fad0dba0dfc60e4ef4f9;hb=4d35c26aaac2a8738a8831118671d7a70dca827c;hp=1830e26673ccd60c29e95a85f446143cce3dd18c;hpb=f3d22dba45391ab591b38159a52cfa7cb803a03c;p=shellwiki diff --git a/themes/default.sh b/themes/default.sh index 1830e26..36710db 100755 --- a/themes/default.sh +++ b/themes/default.sh @@ -22,6 +22,14 @@ theme_page(){ local page="$1" title title="${page%/}"; title="${title##*/}" + if [ ! "$(mdfile "$page")" ]; then + theme_404 + return 0 + elif ! acl_read "$page"; then + theme_403 + return 0 + fi + # Important! Web Server response including newline printf "%s\r\n" "Content-Type: text/html; charset=utf-8" "" @@ -33,12 +41,14 @@ theme_page(){ $(theme_header)
- + $(acl_write "$page" && printf %s \ + '' + )
- $(wiki "$page" || printf 'Page not found') + $(wiki "$page" || printf 'Error while loading page
function "wiki" of index.sh returned with an error.')
$(theme_footer) @@ -50,6 +60,14 @@ theme_editor(){ local page="$1" title title="${page%/}"; title="${title##*/}" + if [ ! "$(mdfile "$page")" ]; then + theme_404 + return 0 + elif ! acl_write "$page"; then + theme_403 + return 0 + fi + # Important! Web Server response including newline printf "%s\r\n" "Content-Type: text/html; charset=utf-8" "" @@ -75,10 +93,19 @@ theme_attachments(){ local page="$1" title title="${page%/}"; title="${title##*/}" + if [ ! "$(mdfile "$page")" ]; then + theme_404 + return 0 + elif ! acl_read "$page"; then + theme_403 + return 0 + fi + # Important! Web Server response including newline printf "%s\r\n" "Content-Type: text/html; charset=utf-8" "" - cat <<-EOF + if acl_write "$page"; then + cat <<-EOF $(theme_head) @@ -87,10 +114,38 @@ theme_attachments(){ $(theme_header)
+
+
+
+ $(theme_footer) + + EOF + else + cat <<-EOF + + + $(theme_head) + Attachments $(HTML "${title}") + + $(theme_header) +
$(theme_footer) EOF + fi } theme_login(){ - theme_page '[wiki]/login/' + theme_page '/[wiki]/login/' } theme_register(){ - theme_page '[wiki]/register/' + theme_page '/[wiki]/register/' +} + +theme_403(){ + printf "%s\r\n" "Status: 403 Forbidden" + + if [ "$(mdfile '/[wiki]/403/')" ]; then + theme_page '/[wiki]/403/' + else + printf "Content-Length: 0\r\n\r\n" + fi } theme_404(){ printf "%s\r\n" "Status: 404 Not Found" - theme_page '[wiki]/404/' + if [ "$(mdfile '/[wiki]/404/')" ]; then + theme_page '/[wiki]/404/' + else + printf "Content-Length: 0\r\n\r\n" + fi +} + +theme_409(){ + printf "%s\r\n" "Status: 409 Conflict" + + if [ "$(mdfile '/[wiki]/409/')" ]; then + theme_page '/[wiki]/409/' + else + printf "Content-Length: 0\r\n\r\n" + fi +} + +theme_500(){ + printf "%s\r\n" "Status: 500 Internal Server Error" + + if [ "$(mdfile '/[wiki]/500/')" ]; then + theme_page '/[wiki]/500/' + else + printf "Content-Length: 0\r\n\r\n" + fi }