#!/bin/sh
-theme_404(){
- printf "%s\r\n" "Status: 404 Not Found"
+theme_head(){
+ printf '
+ <meta name="viewport" content="width=device-width"/>
+ <link rel="stylesheet" type="text/css" href="%s/[.]/cgilite/common.css">
+ ' "$_BASE"
+}
- theme_page '/[404]/'
+theme_header(){
+ printf '<header>%s</header>' "$(wiki '[wiki]/header/')"
+}
+
+theme_footer(){
+ printf '<footer>%s</footer>' "$(wiki '[wiki]/footer/' ||echo No footer)"
}
theme_page(){
local page="$1" title
title="${page%/}"; title="${title##*/}"
+ # Important! Web Server response including newline newline
printf "%s\r\n" "Content-Type: text/html; charset=utf-8" ""
cat <<-EOF
<!DOCTYPE HTML>
<html><head>
- <meta name="viewport" content="width=device-width"/>
- <link rel="stylesheet" type="text/css" href="$_BASE/[wiki]/cgilite/common.css">
+ $(theme_head)
<title>$(HTML "${title}")</title>
</head><body id="$(HTML "$page")">
- <header></header>
+ $(theme_header)
<main>$(wiki "$page" || printf 'Page not found')</main>
- <footer></footer>
+ $(theme_footer)
</body></html>
EOF
}
+
+theme_editor(){
+ local page="$1" title
+ title="${page%/}"; title="${title##*/}"
+
+ # Important! Web Server response including newline newline
+ printf "%s\r\n" "Content-Type: text/html; charset=utf-8" ""
+
+ cat <<-EOF
+ <!DOCTYPE HTML>
+ <html><head>
+ $(theme_head)
+ <title>$(HTML "${title}")</title>
+ </head><body id="$(HTML "$page")" class="editor">
+ $(theme_header)
+ <main><form method=POST>
+ <textarea name=page>$(wiki_text "$page" |HTML)</textarea>
+ <button type=submit name=update value="$(HTML "$page")">Update</button>
+ <button type=submit name=cancel value="$(HTML "$page")">Cancel</button>
+ </form></main>
+ $(theme_footer)
+ </body></html>
+ EOF
+}
+
+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/'
+}