X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=themes%2Fdefault.sh;h=e9e9d73f195466c6bfcf2433dfe0dcb8767aab60;hb=7af38aed3e2f4d019b371da3ec58a41457173248;hp=6fa6ba16566245e9e7c0b92b883a155bf9ad4a19;hpb=cb3cd16be2190c7e91aa1dafd22b295b641c0d32;p=shellwiki
diff --git a/themes/default.sh b/themes/default.sh
index 6fa6ba1..e9e9d73 100755
--- a/themes/default.sh
+++ b/themes/default.sh
@@ -15,7 +15,19 @@ theme_header(){
}
theme_footer(){
- printf '' "$(wiki '[wiki]/footer/' ||echo No footer)"
+ printf '' "$(wiki '[wiki]/footer/')"
+}
+
+theme_pagemenu(){
+ local page="$1"
+
+ if acl_write "$page"; then
+ printf '
+
'
+ fi
}
theme_page(){
@@ -33,12 +45,9 @@ theme_page(){
$(theme_header)
-
+ $(theme_pagemenu)
- $(wiki "$page" || printf 'Page not found')
+ $(wiki "$page" || printf 'Error while loading page
function "wiki" of index.sh returned with an error.')
$(theme_footer)
@@ -47,9 +56,11 @@ theme_page(){
}
theme_editor(){
- local page="$1" title
+ 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" ""
@@ -60,9 +71,10 @@ theme_editor(){
$(HTML "${title}")
$(theme_header)
-
$(theme_footer)
EOF
+ fi
}
-theme_login(){
- theme_page '[wiki]/login/'
-}
-
-theme_register(){
- theme_page '[wiki]/register/'
-}
-
-theme_404(){
- printf "%s\r\n" "Status: 404 Not Found"
-
- theme_page '[wiki]/404/'
+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
}