}
theme_editor(){
- local page="$1" title
+ local page="$1" template="$2" title
title="${page%/}"; title="${title##*/}"
if ! acl_write "$page"; then
return 0
fi
+ [ "$template" ] && acl_read "$template" || template="$page"
+
# Important! Web Server response including newline
printf "%s\r\n" "Content-Type: text/html; charset=utf-8" ""
<title>$(HTML "${title}")</title>
</head><body id="$(HTML "$page")" class="editor">
$(theme_header)
- <main><form method=POST>
+ <main><form method=POST action="$(HTML "${page%/}/[edit]")">
<input type=hidden name=session_key value="${SESSION_KEY}"/>
- <textarea name=pagetext>$(wiki_text "$page" |HTML)</textarea>
+ <textarea name=pagetext>$({ wiki_text "$page" \
+ || wiki_text "$template"; } |HTML)</textarea>
<button type=submit name=action value=update>Update</button>
<button type=submit name=action value=cancel>Cancel</button>
</form></main>