<h1>Delete Page</h1>
<p class="pageid">$(HTML "${page}")</p>
<p>This page and its attachments will be deleted</p>
+ <input type=checkbox name=delete_subpages value=true id=delsub><label for=delsub>Delete subpages</label>
<ul>
- <li>Past revisions of the page text (including the current one) will remain accessible and can be restored.</li>
- <li>Attachments will be deleted completely, and cannot be restored.</li>
- <li>Subpages will not be affected and can still be accessed normally.</li>
+ EOF
+ [ "$REV_PAGES" = true ] \
+ && printf ' <li>Past revisions of the page text (including the current one) will remain accessible and can be restored.</li>'
+ [ "$REV_PAGES" = true -a "$REV_ATTACHMENTS" = true ] \
+ && printf ' <li>Attachments can be restored as well.</li>' \
+ || printf ' <li>Attachments will be deleted completely, and cannot be restored.</li>'
+ cat <<-EOF
+ <li class="delsub">Subpages will not be affected and can still be accessed normally.</li>
</ul>
<button type=submit name=action value=delete>Delete</button>
<button type=submit name=action value=cancel>Cancel</button>
EOF
}
+list_writable() {
+ local PATH_INFO page="${1%/}/"
+
+ if acl_write "$page"; then
+ PATH_INFO="$page"
+ page_glob "*" 0 \
+ | while read page; do
+ list_writable "${PATH_INFO}${page}"
+ done
+ printf %s\\n "$page" |debug
+ fi
+}
+
if [ "$REQUEST_METHOD" = POST ]; then
action="$(POST action)"
newname="$(POST newname |grep -m1 -xE '[^#/]*')"
newlocation="$(POST newlocation |grep -m1 -xE '/[^#]*')"
+ delsub="$(POST delete_subpages |grep -m1 -xE 'true|false')"
else case "${PATH_INFO}" in
*/\[move\])
location="${page%/}" location="${location%/*}/"
printf 'Refresh: %i\r\n' 4
theme_error 403
return 0
- elif [ "$REV_PAGES" = true ]; then
- git -C "$_DATA" rm "pages/${oldname}/#page.md"
- git -C "$_DATA" commit -m 'Page # '"$oldname"' # deleted by user @ '"$USER_NAME"' @' \
- -- "pages/${oldname}/#page.md"
- rm -r -- "$_DATA/pages/${oldname}"/\#*
- rmdir -- "$_DATA/pages/${oldname}/" || true
- REDIRECT ./
- else
- rm -- "$_DATA/pages/${oldname}/#page.md"
- rm -r -- "$_DATA/pages/${oldname}"/\#*
- rmdir -- "$_DATA/pages/${oldname}/" || true
- REDIRECT ./
fi
+
+ printf 'Status: 202 Accepted\r\n'
+ { [ "$delsub" = true ] \
+ && list_writable "$oldname" \
+ || printf %s\\n "$oldname"
+ } | while read oldname; do
+ if [ "$REV_PAGES" = true -a "$REV_ATTACHMENTS" = true ]; then
+ git -C "$_DATA" rm "pages/${oldname}/#page.md" >&2
+ git -C "$_DATA" rm -r "pages/${oldname}/#attachments/" >&2
+ git -C "$_DATA" commit -m 'Page # '"$oldname"' # deleted by user @ '"$USER_NAME"' @' \
+ -- "pages/${oldname}/#page.md" "pages/${oldname}/#attachments/" >&2
+ rm -r -- "$_DATA/pages/${oldname}"/\#*
+ rmdir -- "$_DATA/pages/${oldname}/" || true
+ elif [ "$REV_PAGES" = true ]; then
+ git -C "$_DATA" rm "pages/${oldname}/#page.md" >&2
+ git -C "$_DATA" commit -m 'Page # '"$oldname"' # deleted by user @ '"$USER_NAME"' @' \
+ -- "pages/${oldname}/#page.md" >&2
+ rm -r -- "$_DATA/pages/${oldname}"/\#*
+ rmdir -- "$_DATA/pages/${oldname}/" || true
+ else
+ rm -- "$_DATA/pages/${oldname}/#page.md"
+ rm -r -- "$_DATA/pages/${oldname}"/\#*
+ rmdir -- "$_DATA/pages/${oldname}/" || true
+ fi
+ printf '%s\n' "$oldname"
+ done | {
+ cat <<-EOF
+ <article id="deleteconfirm">
+ <h1>$(_ "Pages deleted:")</h1>
+ <ul>
+ $(while read page; do
+ printf '<li>%s</li>' "$(HTML $page)"
+ done)
+ </ul>
+ <a class="button" href="./">$(_ OK)</a>
+ </article>
+ EOF
+ } | theme_page -
+ return 0
elif [ "$action" = cancel ]; then
REDIRECT ./
elif [ "$action" ]; then