DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:batchedit

BatchEdit Plugin

Compatible with DokuWiki

  • 2017-02-19 "Frusterick Manners" unknown
  • 2016-06-26 "Elenor Of Tsort" unknown
  • 2015-08-10 "Detritus" unknown
  • 2014-09-29 "Hrun" yes

plugin Edit wiki pages using regular expressions

Last updated on
2014-05-24
Provides
Admin
Repository
Source

Tagged with editing, regexp, replace, search

BatchEdit is an admin plugin that allows you to use regular expressions to search and replace text on DokuWiki pages. As it works with raw DokuWiki text, the plugin can be also used to modify markup of the pages. This can be very helpful when there are multiple pages with similar markup. For example, you can update pages created from a namespace template if you decide to change the template.

Download and Installation

Download and install the plugin using the Plugin Manager using the following URL. Refer to plugins on how to install plugins manually.

User Interface

Screenshot

After installation BatchEdit shows up on the Administration page.

When started, the plugin displays a form with four edit fields:

  • Namespace — allows you to select a top level namespace that contains pages to search in. All the namespaces below the selected one will be included in the search as well. Standard name resolution of the namespaces applies here (e.g. “.” stands for the current namespace, etc.). If the namespace is not provided, BatchEdit will search through the entire wiki.
  • Regular expression — fully qualified regular expression including the modifiers. BatchEdit uses PHP PCRE extension to do the matching.
  • Replacement — the replacement pattern. For the syntax see preg_replace documentation.
  • Summary — summary of the replacement. This field has the same purpose as the Summary field of the DokuWiki text editor.

Below the edit fields there are two buttons:

  • Preview – shows the search results with corresponding replacements but does not do the replacement itself.
  • Apply – replaces selected (see below) matches. If there are no selected matches it acts identical to the Preview button.

BatchEdit displays every match of the search results in a separate box. On top of the box the plugin shows a check box with the page name and a character offset where the match occurred. The check box is used to select matches for the replacement. In order to prevent unexpected results the check box is unchecked by default requiring the user to confirm every replacement. To the right from the page name there are two icons: the first one links to the page itself and the second one to the editor. The rest of the box is split in two parts: matched text with some context on the left side; and the same fragment with applied replacement on the right. Both the matched text and the replacement are highlighted.

After the replacement, the matches show up with no check box in the caption and replaced text is highlighted with green.

Technical details

Performance

BatchEdit does not rely on any caching to do the search, so every time Preview or Apply button is clicked the DokuWiki server reads all the pages from a hard drive. To reduce the server load and search time use Namespace field that limits the search scope.

Page locking

While BatchEdit locks pages during replacement, there is still a small possibility for the data corruption. The replacement is performed in two stages:

  1. BatchEdit searches for the regular expression matches in all the pages. For every match the plugin records character offset in the page where the match occurs.
  2. On the second stage BatchEdit compares matches found during the first pass with a list of matches selected for replacement. For the matches found in both lists BatchEdit locks the page and performs the replacement using the offset.

If the page is modified between these two stages, BatchEdit will apply the replacement to random data in the updated page. Though the chances of such corruption are rather small, the administrators should take care to minimize DokuWiki activity when Batchedit is used.

Page lookup

BatchEdit uses DokuWiki page index to get the list of existing pages instead of going through the data directories. If the index is incomplete the plugin will not see some pages. This also applies to the “special” pages, for example, namespace templates.

Version History

2014-05-24

  • Support common special characters in replacement string
  • Minor fixes

2009-02-14

  • Added View and Edit links to matched pages.

2008-12-07

  • Fixes in regular expression validation

2008-10-27

  • First public release

Bugs and Feature Requests

Please report bugs or feature requests at the bug tracker.

plugin/batchedit.txt · Last modified: 2016-02-27 18:53 by 212.90.38.102