4 */\[move\]|*/\[rename\]|*/\[delete\])
5 page="${PATH_INFO%\[*\]}"
6 if [ ! -d "$_DATA/pages/${page}" -a ! -d "$_EXEC/pages/${page}" ]; then
9 elif ! acl_write "$page"; then
10 printf 'Refresh: %i, url=%s\r\n' 4 ./
13 elif [ -d "$_EXEC/pages/${page}/" ]; then
17 <h1>Immutable Page</h1>
18 This is a core page of the wiki system. Its name and position cannot be changed.
19 You may however update this page and you can use ACLs to hide it from various listings.
29 if [ "$REQUEST_METHOD" = POST ]; then
30 action="$(POST action)"
31 newname="$(POST newname |grep -m1 -xE '[^#/]*')"
32 newlocation="$(POST newlocation |grep -m1 -xE '/[^#]*')"
33 else case "${PATH_INFO}" in
35 location="${page%/}" location="${location%/*}/"
37 <form method=POST id=movepage>
38 <input type=hidden name=session_id value="$SESSION_KEY">
40 <p class="pageid">$(HTML "${page}")</p>
41 <input name="newlocation" value="$(HTML "$location")" placeholder="New Location">
43 <li>A page with the same name must not already exist at the new location.</li>
44 <li>You must have permission to create new pages at this location.</li>
45 <li>All subpages will become available under the new path name.</li>
46 <li>Subpages will become unavailable under their current name.</li>
48 <button type=submit name=action value=move>Move</button>
49 <button type=submit name=action value=cancel>Cancel</button>
55 name="${page%/}" name="${name##*/}"
57 <form method=POST id=renamepage>
58 <input type=hidden name=session_id value="$SESSION_KEY">
60 <p class="pageid">$(HTML "${page}")</p>
61 <input name="newname" value="$(HTML "$name")" placeholder="New Name">
63 <li>A page with the new name must not already exist.</li>
64 <li>You must have permission to create new pages at this location.</li>
65 <li>All subpages will become available under the new path name.</li>
66 <li>Subpages will become unavailable under their current name.</li>
68 <button type=submit name=action value=rename>Rename</button>
69 <button type=submit name=action value=cancel>Cancel</button>
76 <form method=POST id=deletepage>
77 <input type=hidden name=session_id value="$SESSION_KEY">
79 <p class="pageid">$(HTML "${page}")</p>
80 <p>This page and its attachments will be deleted</p>
82 <li>Past revisions of the page text (including the current one) will remain accessible and can be restored.</li>
83 <li>Attachments will be deleted completely, and cannot be restored.</li>
84 <li>Subpages will not be affected and can still be accessed normally.</li>
86 <button type=submit name=action value=delete>Delete</button>
87 <button type=submit name=action value=cancel>Cancel</button>
95 if [ "$action" = rename -a "$newname" ]; then
96 oldname="${PATH_INFO%\[*\]}"
97 newname="${oldname%/*/}$(PATH "${newname}/")"
99 if [ -d "$_DATA/pages/$newname" ]; then
100 printf 'Refresh: %i\r\n' 4
101 export ERRORMSG="A location of that name already exists."
104 elif ! acl_write "$oldname" || ! acl_write "$newname"; then
105 printf 'Refresh: %i\r\n' 4
109 git -C "$_DATA" mv "pages/$oldname" "pages/$newname"
110 git -C "$_DATA" commit -m 'Page # '"$oldname"' # renamed to # '"$newname"' # by user @ '"$USER_NAME"' @' \
111 -- "pages/$oldname" "pages/$newname"
112 REDIRECT "$_BASE${newname}"
114 elif [ "$action" = move -a "$newlocation" ]; then
115 oldname="${PATH_INFO%\[*\]}"
116 newlocation="$(PATH "$newlocation")"
117 newname="${oldname%/}"
118 newname="${newlocation%/}/${newname##*/}/"
120 if [ -d "$_DATA/pages/$newname" ]; then
121 printf 'Refresh: %i\r\n' 4
122 export ERRORMSG="A page of that name already exists at the given location."
125 elif [ ! -d "$_DATA/pages/$newlocation" ]; then
126 printf 'Refresh: %i\r\n' 4
127 export ERRORMSG="The given location does not exist."
130 elif ! acl_write "$oldname" || ! acl_write "$newname"; then
131 printf 'Refresh: %i\r\n' 4
135 git -C "$_DATA" mv "pages/${oldname}" "pages/${newname}"
136 git -C "$_DATA" commit -m 'Page # '"$oldname"' # moved to # '"$newname"' # by user @ '"$USER_NAME"' @' \
137 -- "pages/${oldname}" "pages/${newname}"
138 REDIRECT "$_BASE${newname}"
140 elif [ "$action" = delete ]; then
141 oldname="${PATH_INFO%\[*\]}"
142 if ! acl_write "$oldname"; then
143 printf 'Refresh: %i\r\n' 4
147 git -C "$_DATA" rm "pages/${oldname}/#page.md"
148 git -C "$_DATA" commit -m 'Page # '"$oldname"' # deleted by user @ '"$USER_NAME"' @' \
149 -- "pages/${oldname}/#page.md"
150 rm -r -- "$_DATA/pages/${oldname}"/\#*
151 rmdir -- "$_DATA/pages/${oldname}/" || true
154 elif [ "$action" = cancel ]; then
156 elif [ "$action" ]; then
157 printf 'Refresh: %i\r\n' 4
158 export ERRORMSG="Missing parameters."