Site Tools


wiki:pluginsyntax:batchedit

BatchEdit Plugin

---- plugin ----
description: Edit wiki pages using regular expressions
author     : Mykola Ostrovskyy
email      : dwpforge@gmail.com
type       : admin
lastupdate : 2023-06-16
compatible : Hrun, Frusterick Manners, Greebo, Hogfather, Igor, Jack Jackrum
depends    : 
conflicts  : 
similar    : 
tags       : search, replace, regexp, editing

downloadurl: https://github.com/dwp-forge/batchedit/archive/v.2023-06-16.zip
bugtracker : https://github.com/dwp-forge/batchedit/issues
sourcerepo : https://github.com/dwp-forge/batchedit

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

Search and install the plugin using the Extension Manager. Refer to :Plugins on how to install plugins manually.

User Interface

After installation BatchEdit shows up on the Administration page. When started, the plugin displays a form with four primary edit fields:

Main UI

  • 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. Multiple namespaces may be specified separated by a comma. Standard name resolution of the namespaces applies here (e.g. “.” stands for the current namespace, etc.). Namespaces preceded with a hyphen are excluded from the search. If no namespaces are not provided, BatchEdit will search through the entire wiki.
  • Search for – depending on selected options this can be plain text string, regular expression, or fully qualified regular expression including delimiters and modifiers. BatchEdit uses Perl-compatible syntax of regular expression as defined by PHP PCRE extension.
  • Replace with – the replacement text or pattern. For the syntax see preg_replace documentation.
  • Edit summary – summary of the replacement. This field has the same purpose as the Edit 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.

Match box

BatchEdit displays search matches in separate boxes, which are grouped per page. Next to the page identifier and on every match box there is a check box, which is used to mark matches for replacement. In order to prevent unexpected results the check box is unchecked by default requiring the user to confirm every replacement. The match 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.

Configuration

BatchEdit uses two types of configuration options:

  • User-specific options – all options available on BatchEdit page are individual for each user. These options are stored in a browser cookie, so strictly speaking they are browser-specific.
  • Global options – can be modified on DokuWiki configuration page. They control aspects of BatchEdit operation, which are rarely (if ever) to be changed.

Technical details

Performance

BatchEdit performs caching of the search results to avoid repeating the search when replacement is applied. Yet on every preview attempt 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 or limit the number of search results in Advanced options.

Concurrent page edits

Because of two-staged approach of Preview&Apply, there is a possibility that while one user verifies and marks matches for replacement some other user modifies one of the involved pages. To prevent any data corruption BatchEdit locks pages during replacement and verifies that matched text is still located at the match offset. If any of the marked matches cannot be found at expected offsets, replacement for that page is rejected.

This verification still leaves a possibility that replacement will be applied to a different instance of the original text that happened to be at the exactly right offset after the edit, but likelihood of that is rather small. Anyway, it's recommended that administrators 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. Because of the missing or incomplete index BatchEdit may show less search results than expected. This is often the case for a freshly migrated wiki. You can use Searchindex Manager plugin to get the index up to date.

This limitation also applies to the “special” pages (e.g. namespace templates), which are not listed in the index and therefore cannot be edited by BatchEdit.

Version History

2023-06-16

  • Added support for replacement in multiple namespaces
  • Fixed compatibility with DokuWiki Jack Jackrum

2022-02-20

  • Added option to replace namespace template patterns
  • Added Portuguese localization
  • Added Dutch localization
  • Fixed Bootstrap conflict with jQuery tooltip
  • Minor localization updates

Bugs and Feature Requests

Please report bugs or feature requests at the bug tracker.

wiki/pluginsyntax/batchedit.txt · Last modified: 2023/10/31 23:14 by Alan Shea