]> git.plutz.net Git - shellwiki/blobdiff - handlers/60_move_rename_delete.sh
list locations in move form
[shellwiki] / handlers / 60_move_rename_delete.sh
index 27246bd108acecac61ba2d7dc17406979aa2272d..eefd9b41b6d77bfcafe9b32d0bb58d983b7d917f 100755 (executable)
@@ -33,7 +33,7 @@ case "${PATH_INFO}" in
       printf 'Refresh: %i, url=%s\r\n' 4 ./
       theme_error 403
       return 0
-    elif [ -d "$_EXEC/pages/${page}/" ]; then
+    elif [ ! -d "$_DATA/pages/${page}" -a -d "$_EXEC/pages/${page}" ]; then
       theme_page - <<-EOF
        <article>
          <p class=error>
@@ -52,7 +52,7 @@ l10n_movepage >/dev/null 2>&1 \
   cat <<-EOF
          <h1>Move Page</h1>
          <p class="pageid">$(HTML "${page}")</p>
-         <input name="newlocation" value="$(HTML "$location")" placeholder="New Location">
+         <input list="locations" autocomplete="off" name="newlocation" value="$(HTML "$location")" placeholder="New Location">
          <ul>
            <li>A page with the same name must not already exist at the new location.</li>
            <li>You must have permission to create new pages at this location.</li>
@@ -68,7 +68,7 @@ l10n_renamepage >/dev/null 2>&1 \
   cat <<-EOF
          <h1>Rename Page</h1>
          <p class="pageid">$(HTML "${page}")</p>
-         <input name="newname" value="$(HTML "$name")" placeholder="New Name">
+         <input autocomplete="off" name="newname" value="$(HTML "$name")" placeholder="New Name">
          <ul>
            <li>A page with the new name must not already exist.</li>
            <li>You must have permission to create new pages at this location.</li>
@@ -125,6 +125,13 @@ else case "${PATH_INFO}" in
       theme_page - <<-EOF
        <form method=POST id=movepage>
          <input type=hidden name=session_id value="$SESSION_KEY">
+         <datalist id="locations">
+         $(page_glob / -1 |while read loc; do
+           [ "$loc" = "$page" ] && continue
+           acl_write "$loc" || continue
+           printf '\n    <option>%s</option>' "$(HTML "$loc")"
+         done)
+         </datalist>
          $(l10n_movepage)
        </form>
        EOF
@@ -165,15 +172,20 @@ if [ "$action" = rename -a "$newname" ]; then
     printf 'Refresh: %i\r\n' 4
     theme_error 403
     return 0
-  elif [ "$REV_PAGES" = true ]; then
+  fi
+  if [ "$REV_PAGES" = true ]; then
     git -C "$_DATA" mv "pages/$oldname" "pages/$newname"
     git -C "$_DATA" commit -m 'Page # '"$oldname"' # renamed to # '"$newname"' # by user @ '"$USER_NAME"' @' \
         -- "pages/$oldname" "pages/$newname"
-    REDIRECT "$_BASE${newname}"
   else
     mv -- "$_DATA/pages/$oldname" "$_DATA/pages/$newname"
-    REDIRECT "$_BASE${newname}"
   fi
+  if [ "$SEARCH_INDEX" = true ]; then
+    find "$_DATA/pages/$newname" -name "#index.flag" -delete
+    ( "$_EXEC/searchindex.sh" index --location "$newname" & ) &
+  fi
+  REDIRECT "$_BASE${newname}"
+
 elif [ "$action" = move -a "$newlocation" ]; then
   oldname="${PATH_INFO%\[*\]}"
   newlocation="$(PATH "$newlocation")"
@@ -194,15 +206,20 @@ elif [ "$action" = move -a "$newlocation" ]; then
     printf 'Refresh: %i\r\n' 4
     theme_error 403
     return 0
-  elif [ "$REV_PAGES" = true ]; then
+  fi
+  if [ "$REV_PAGES" = true ]; then
     git -C "$_DATA" mv "pages/${oldname}" "pages/${newname}"
     git -C "$_DATA" commit -m 'Page # '"$oldname"' # moved to # '"$newname"' # by user @ '"$USER_NAME"' @' \
         -- "pages/${oldname}" "pages/${newname}"
-    REDIRECT "$_BASE${newname}"
   else
     mv -- "$_DATA/pages/$oldname" "$_DATA/pages/$newname"
-    REDIRECT "$_BASE${newname}"
   fi
+  if [ "$SEARCH_INDEX" = true ]; then
+    find "$_DATA/pages/$newname" -name "#index.flag" -delete
+    ( "$_EXEC/searchindex.sh" index --location "$newname" & ) &
+  fi
+  REDIRECT "$_BASE${newname}"
+
 elif [ "$action" = delete ]; then
   oldname="${PATH_INFO%\[*\]}"
   if ! acl_write "$oldname"; then