fi
}
+case $PATH_INFO in
+ */\[edit\]) : ;;
+ *) return 1 ;;
+esac
+
edit_page="${PATH_INFO%\[edit\]}"
edit_file="$_DATA/pages/$edit_page/#page.md"
[ "$REQUEST_METHOD" = POST ] && edit_action="$(POST action)"
-if [ "$edit_page" = "$PATH_INFO" ]; then
- unset edit_page edit_action edit_file
- # END EDIT SCRIPT, continue in index.cgi
+if ! acl_write "$edit_page"; then
+ theme_error 403
+ return 0
+
+elif [ "$edit_action" = cancel ]; then
+ S_RELEASE "$edit_file"
+ REDIRECT "${_BASE}${PATH_INFO%\[edit\]}"
elif [ "$edit_action" = update ]; then
if mkdir -p -- "${edit_file%/#page.md}" \
if [ "$(which git)" ]; then
git -C "$_DATA" add \
-- "pages/$edit_page/#page.md"
- git -C "$_DATA" commit -m \
+ git -C "$_DATA" commit -qm \
"Page # ${edit_page} # updated by user @ ${USER_NAME} @" \
-- "pages/$edit_page/#page.md"
- fi
+ fi 1>&2
- REDIRECT "${_BASE}${PATH_INFO%\[edit\]}"
-
-elif [ "$edit_action" = cancel ]; then
- S_RELEASE "$edit_file"
- REDIRECT "${_BASE}${PATH_INFO%\[edit\]}"
-
-elif ! acl_write "$edit_page"; then
- theme_error 403
- return 0
+ REDIRECT "${_BASE}${edit_page}"
elif mkdir -p -- "${edit_file%/#page.md}" \
&& S_LOCK "$edit_file"; then