There is a need for search and replace capability. This can help to workaround unfinished Rename Page action, which does not rename links to the page after a rename, and to fix various errors in multiple pages.

See /FromOutsideTheWiki for a python script to change pages using XMLRPC (requires xmlrpc and putpage enabled, authentication and python >=2.5).

Planning

  1. action and macro pair that works with release 1.3 (I need it for my 1.3 wiki now -- NirSoffer 2005-10-07 17:18:43 )

  2. support for 1.5 later
  3. merge in 1.5

Specification

Search and replace in page content

  1. You select "More Actions: Search and Replace". Get current page with a search and replace message at the top.
  2. Enter a search and replacement strings
  3. Check a [ ] "Use Regular Expressions" check box if needed
  4. Click "Preview"
  5. You get a search results of your replacements. I don't know how this will look like, maybe one line for match, one line for result.
  6. Click "Replace" to preform the replacement, or change the regular expressions and click Preview again.

The change will be made to all pages, even those that are being edited while you change them, ignoring the edit conflict. The user editing the such page will get a conflict when saving, but it should be an easy to fix. The search and replace will be restricted to admin users, as it too powerful for any user.

Lock wiki during replace

There is a problem when someone change a page after you got the search results, then you will replace stuff in the changed page although it did not appear in the preview.

A simple solution is to lock the wiki for writing during the change. You can do this manually by using u"You:read,write All:read" acl_rights_before.

Another solution is to remember all match and replace only the matches you preview. In this case, there may be new changes you would like to replace but will not be replaced because they were not previewed.

Possible additions to consider later

Discussion

Rename is not unfinished - this is by design.

Also should rename relative links -- for example, suppose on page Design there is a link to subpage [/Images]; then, if we do a search-and-replace to change "Design/Images" to "Design/Pictures", the code should traverse the Design/ hierarchy and update relative links as well.

MoinMoin: SearchAndReplace (last edited 2008-02-22 19:29:38 by ThomasWaldmann)