+
+theme_editor(){
+ 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
+ <!DOCTYPE HTML>
+ <html><head>
+ $(theme_head)
+ <title>$(HTML "${title}")</title>
+ </head><body id="$(HTML "$page")" class="editor">
+ $(theme_header)
+ <main><form method=POST>
+ <input type=hidden name=session_key value="${SESSION_KEY}"/>
+ <textarea name=pagetext>$(wiki_text "$page" |HTML)</textarea>
+ <button type=submit name=action value=update>Update</button>
+ <button type=submit name=action value=cancel>Cancel</button>
+ </form></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" ""
+
+ cat <<-EOF
+ <!DOCTYPE HTML>
+ <html><head>
+ $(theme_head)
+ <title>Attachments $(HTML "${title}")</title>
+ </head><body id="$(HTML "$page")[attachment]/">
+ $(theme_header)
+ <main>
+ <form class=upload method=POST enctype="multipart/form-data">
+ <input type=file name=file multiple>
+ <button type=submit name=action value=upload>Upload</button>
+ </form>
+
+ <ul class="attachment list">
+ $(for file in "$_EXEC/pages/$page/#attachments"/* "$_DATA/pages/$page/#attachments"/*; do
+ [ "$file" = "$_EXEC/pages/$page/#attachments/${file##*/}" \
+ -a -f "$_DATA/pages/$page/#attachments/${file##*/}" ] && continue
+ stat="$(stat -c '%s %Y' -- "$file" 2>&-)" || continue
+ size="${stat% *}" date="${stat#* }"
+
+ printf '<li><span class=name>%s</span>
+ <span class=size>%s</span><span class=date>%s</span></li>' \
+ "$(HTML "${file##*/}")" "$(size_human "$size")" "$(date -d @"$date" +"%F %T")"
+ done)
+ </ul>
+ </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/'
+}