User:Inductiveload/maintain

This script is a framework for tools that can automate some actions and avoid having to dig about in an edit box after finding an issue on a page.

It is alpha-grade: expect bugs, use with care In particular, the API for config and adding hook can and probably will change.

There are a few WS-centric tools included, and you can add your own

Installation
The basic script can be installed by adding the following to your common.js page:



This will load:
 * ../maintain.js/: the core framework
 * ../maintain-ws-tools.js/: Tools for Wikisource

Maintain actions
The  link in the side bar brings up the "Action dialog", where you can choose a pre-set action to take.



Which actions are included depends on the page and what you have configured. Clicking an action will either present more options (e.g. a dropdown for page statuses) or take you directly to the confirmation dialog.

Some actions generate their own summaries. You can always amend the summary at that stage, even if an auto-summary is generated.

Configuration
Add a handler to the  hook:

The handler is called with two parameters:
 * : contains useful functions for tools
 * : the config object to add your tools to
 * : add tools to this list
 * : add IDs of tools to skip the confirmation step for. Be careful: you are still responsible for the edit.

Adding a tool
Tools are a dict of:
 * the label to show
 * a unique ID
 * : a function that returns an object with a  text field and a.

Transforms
The following transforms are included in :
 * summary (optional, default is generated from the text if not given)
 * how to separate the new content from the existing content (default: )
 * : append/prepend a template
 * : true to append to the page, false to prepend
 * : the template name
 * : list of parameters (not a dict!)
 * : object of config options:
 * summary (optional, default is generated from the template name if not given)
 * add newline between items (block-style, default is inline-style)
 * add a signature:
 * how to separate the template from the existing content (default: )
 * list of  pairs to apply in order
 * summary (required)
 * : delete templates (use with caution on nested templates)
 * : list of template names
 * summary (optional: default is generated from the template name if not given)
 * : delete templates (use with caution on nested templates)
 * : list of template names
 * summary (optional: default is generated from the template name if not given)

Replace
A simple replace dialog is included so you can fix typos without having to edit the page and locate the error:



You will be shown the proposed diff before the edit is saved, and you can amend the summary.

If you select text in the mainspace that appears to be transcluded from the page namespace, the replacement will be attempted at the source Page namespace page. You should still make sure the edit is correct.

Technical

 * User:Inductiveload/maintain.js
 * User:Inductiveload/maintain/load.js
 * User:Inductiveload/maintain-ws-tools.js
 * Phab Workboard (file bugs here)