Difference between revisions of "Wiki Monkey"
(1.7.0 released) |
|||
Line 1: | Line 1: | ||
+ | {{Out of date}} | ||
+ | {{Box YELLOW|TODO:|Update for 1.7.0}} | ||
[https://github.com/kynikos/wiki-monkey/ Wiki Monkey] is a [http://www.scriptish.org/ Scriptish] script that helps editing wiki pages by providing some Javascript functions to automate repetitive operations, or letting you create new functions exploiting its high-level API. | [https://github.com/kynikos/wiki-monkey/ Wiki Monkey] is a [http://www.scriptish.org/ Scriptish] script that helps editing wiki pages by providing some Javascript functions to automate repetitive operations, or letting you create new functions exploiting its high-level API. | ||
Revision as of 23:04, 11 February 2012
Template:Box YELLOW Wiki Monkey is a Scriptish script that helps editing wiki pages by providing some Javascript functions to automate repetitive operations, or letting you create new functions exploiting its high-level API.
Contents
Installation
Make sure you have installed Scriptish for Firefox.
Now just click on the link of one of the following Wiki Monkey configurations and Firefox should ask you to install it:
Otherwise create your own configuration.
Updates
Open Firefox's Add-ons Manager (Tools -> Add-ons), select User Scripts, right-click on Wiki Monkey and choose Find Updates.
If you want to enable automatic updates, choose Show More Information instead, then set Automatic Updates to On.
Usage
Wiki Monkey adds one button for each of its functions in some particular pages (currently editor pages and diff pages): by clicking on a button, the respective function is executed.
Below the buttons you will find a log where the functions will output their messages.
Bundled functions
Editor pages
These functions will automate some repetitive modifications of the source text of the article open for editing, as if you were performing them manually, so you will still be able to preview the changes and do other modifications before saving the page manually.
Update templates
This function tries to fulfil ArchWiki:Requests#Updating templates, also turning <pre>
into Template:bc, and <code>
and <tt>
into Template:ic.
See the source code for more information.
Expand contractions
This function tries to replace some common English contractions with their expanded form.
See the source code for more information.
Multiple line breaks
This function replaces multiple empty lines with only one, complying with Help:Style#Blank lines.
See the source code for more information.
Diff pages
These functions base their actions on diff pages.
Quick report
This function can be useful to Recent Changes patrollers, and adds a quick report to a properly-initialized table in User:USERNAME/RC Patrol, where USERNAME
is your user name. The input field next to the button can be used to accompany the report with a note. See User:Kynikos/RC Patrol for an example.
See the source code for more information.
Save discussion
Troubleshooting
Clicking on the configuration link does not trigger the installation
If clicking on the configuration links does not trigger the installation, save the target of the link into a WikiMonkey.user.js
file, then drag and drop it in a browser window, or open it with File → Open File...: this time you should get the installation popup.
Updating does not work
If you notice that Wiki Monkey has been updated upstream but for some reason you cannot update your local installation, just re-install the script.
Bug reports, feature requests
Please use the bug tracker at https://github.com/kynikos/wiki-monkey/issues.
Help, ideas
Use the talk page.
Custom configuration
Tutorial
- Open Firefox's Add-ons manager → User Scripts.
- Click on Wiki Monkey's Edit button (if it is the first time you are doing this it will ask you to choose a text editor).
- Add the module with a
@require
tag in the header of the main script, as shown in the example below; for local files use thefile
protocol, for remote files usehttps
. - Add the module to
WM.main()
, which requires two arguments: the first one is used for editor pages, the second one is used for diff pages. Each of these arguments is a 3-dimensional array with the following structure:- Level 1: this level separates the various rows of buttons that will be created.
- Level 2: this level separates the various functions in a row. When using the shortcut buttons, the modules in each row are executed in the order they are added here.
- Level 3: this level is where the module is actually installed: its first element is the module namespace, as a string; the second element is the label displayed on the button; the third element is passed as the argument for the module's
main
andmakeUI
methods.
- Save and exit the editor.
- The newly-added module will work at the next page reload.
WikiMonkey.user.js
// ==UserScript== ... // @require file:///home/user/path/to/ModuleExample1.js // ==/UserScript== WM.main( [ [ ["ModuleExample1", "Button example 1", null] ] ], [ [] ] );
WikiMonkey.user.js
// ==UserScript== ... // @require file:///home/user/path/to/ModuleExample2.js // ==/UserScript== WM.main( [ [ ["ModuleExample2", "Button example 2", "Hello World"] ] ], [ [] ] );
WikiMonkey.user.js
// ==UserScript== ... // @require file:///home/user/path/to/ModuleExample3.js // ==/UserScript== WM.main( [ [ ["ModuleExample3", "Button example 3", ["ExampleID", "Hello World"]] ] ], [ [] ] );
WikiMonkey.user.js
// ==UserScript== ... // @require file:///home/user/path/to/ModuleExample5.js // @require file:///home/user/path/to/ModuleExample6.js // @require file:///home/user/path/to/ModuleExample7.js // @require file:///home/user/path/to/ModuleExample8.js // ==/UserScript== WM.main( [ [ ["ModuleExample5", "Button example 5", ["ExampleID5", "Hello World 5"]], ["ModuleExample6", "Button example 6", ["ExampleID6", "Hello World 6"]] ], [ ["ModuleExample7", "Button example 7", ["ExampleID7", "Hello World 7"]], ["ModuleExample8", "Button example 8", ["ExampleID8", "Hello World 8"]] ] ], [ [ ["ModuleExample9", "Button example 9", ["ExampleID9", "Hello World 9"]], ["ModuleExample10", "Button example 10", ["ExampleID10", "Hello World 10"]] ], [ ["ModuleExample11", "Button example 11", ["ExampleID11", "Hello World 11"]], ["ModuleExample12", "Button example 12", ["ExampleID12", "Hello World 12"]] ] ] );
Plugin development
This section explains how to develop plugins for Wiki Monkey.
Tutorial
ModuleTemplate1.js
var ModuleTemplate1 = new function () { this.main = function () { // put your code here }; };
ModuleExample1.js
var ModuleExample1 = new function () { this.main = function () { alert("Hello World"); }; };
ModuleTemplate2.js
var ModuleTemplate2 = new function () { this.main = function (arg) { // put your code here }; };
ModuleExample2.js
var ModuleExample2 = new function () { this.main = function (arg) { alert(arg); }; };
ModuleTemplate3.js
var ModuleTemplate3 = new function (args) { this.makeUI = function () { // create and return a DOM element }; this.main = function (args) { // put your code here }; };
ModuleExample3.js
var ModuleExample3 = new function () { this.makeUI = function (args) { id = args[0]; input = document.createElement('input'); input.setAttribute('type', 'text'); input.id = id; return input; }; this.main = function (args) { id = args[0]; msg = args[1]; text = document.getElementById(id).value; alert(msg); }; };
ModuleTemplate4.js
var ModuleTemplate4 = new function () { var privateVariable = null; var privateFunction = function (args) { // put your code here }; this.publicVariable = null; this.publicFunction = function (args) { // put your code here }; this.makeUI = function (args) { // create and return a DOM element }; this.main = function (args) { // put your code here }; };