Difference between revisions of "Wiki Monkey"

From ArchWiki
Jump to: navigation, search
(Troubleshooting: improve)
(move documentation to github)
Line 1: Line 1:
[https://github.com/kynikos/wiki-monkey/ Wiki Monkey] is a MediaWiki-compatible bot and editor assistant that can be used directly within wiki pages in the browser. Wiki Monkey is run as a [http://www.scriptish.org/ Scriptish] script for [[Firefox]] and can be easily extended through the creation of plugins, exploiting its high-level API.
+
[[:Category:ArchWiki Tools]] ''' << enable category!'''
 +
{{i18n|Wiki Monkey}}
 +
 
 +
[https://github.com/kynikos/wiki-monkey/wiki Wiki Monkey] is a MediaWiki-compatible bot and editor assistant that can be used directly within wiki pages in the browser. Wiki Monkey is run as a [http://www.scriptish.org/ Scriptish] script for [[Firefox]] and can be easily extended through the creation of plugins, exploiting its high-level API.
 +
 
 +
The project is currently focused on ArchWiki, and as such most plugins address ArchWiki-specific problems.
  
 
==Installation==
 
==Installation==
Line 7: Line 12:
  
 
Now just click on the link of one of the following Wiki Monkey configurations and Firefox should ask you to install it:
 
Now just click on the link of one of the following Wiki Monkey configurations and Firefox should ask you to install it:
*[https://raw.github.com/kynikos/wiki-monkey/master/src/configurations/WikiMonkey-editor.user.js Editor]: provides only manual-editing aid functions in editor pages
+
*[https://raw.github.com/kynikos/wiki-monkey/master/src/configurations/WikiMonkey-editor.user.js Editor]: provides manual-editing aid functions in editor pages, like automatic style fixes
 
*[https://raw.github.com/kynikos/wiki-monkey/master/src/configurations/WikiMonkey-patrol.user.js Patrol]: Editor + quick-report functions in diff pages
 
*[https://raw.github.com/kynikos/wiki-monkey/master/src/configurations/WikiMonkey-patrol.user.js Patrol]: Editor + quick-report functions in diff pages
*[https://raw.github.com/kynikos/wiki-monkey/master/src/configurations/WikiMonkey-bot.user.js Bot]: Patrol + automatic operations on list pages (currently only [[Special:WhatLinksHere]])
+
*[https://raw.github.com/kynikos/wiki-monkey/master/src/configurations/WikiMonkey-bot.user.js Bot]: Patrol + automatic operations on list pages
*[https://raw.github.com/kynikos/wiki-monkey/development/src/configurations/WikiMonkey-editor.user.js Dev-Editor]: latest Editor development release (unstable)
+
*[https://raw.github.com/kynikos/wiki-monkey/development/src/configurations/WikiMonkey-patrol.user.js Dev-Patrol]: latest Patrol development release (unstable)
+
*[https://raw.github.com/kynikos/wiki-monkey/development/src/configurations/WikiMonkey-bot.user.js Dev-Bot]: latest Bot development release (unstable)
+
  
Otherwise [[#Custom configuration|create your own configuration]].
+
Otherwise you can [https://github.com/kynikos/wiki-monkey/wiki/Custom-configuration create your own configuration].
  
 
{{Warning|Although it is possible to keep multiple configurations of Wiki Monkey installed together, make sure to enable only one at a time.}}
 
{{Warning|Although it is possible to keep multiple configurations of Wiki Monkey installed together, make sure to enable only one at a time.}}
  
==Updates==
+
===Automatic 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, open Firefox's ''Add-ons Manager'' (''Tools -> Add-ons''), select ''User Scripts'', right-click on Wiki Monkey and choose ''Show More Information'', then set ''Automatic Updates'' to ''On''.
 
+
If you want to enable automatic updates, choose ''Show More Information'' instead, then set ''Automatic Updates'' to ''On''.
+
 
+
==Bundled plugins==
+
 
+
===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.
+
 
+
{{Warning|Always preview and verify the correctness of the edited text before saving the page. Also examine the messages in the log at the bottom of Wiki Monkey's interface.}}
+
 
+
====Fix header====
+
This function tries to recognize and reorder the elements in the header of the article, as defined in [[Help:Style#Layout]]: MediaWiki magic words, categories, [[Template:i18n]] and interlanguage links. It also displays warnings for mistakes that cannot be fixed automatically, and adds [[Template:i18n]] if it is not present.
+
 
+
====Use code templates====
+
This function tries to turn {{ic|&lt;pre>}} into [[Template:bc]], and {{ic|&lt;code>}} and {{ic|&lt;tt>}} into [[Template:ic]].
+
 
+
See [https://github.com/kynikos/wiki-monkey/blob/master/src/plugins/ArchWikiNewTemplates.js the source code] for more information.
+
 
+
====Expand contractions====
+
This function tries to replace some common English contractions with their expanded form.
+
 
+
See [https://github.com/kynikos/wiki-monkey/blob/master/src/plugins/ExpandContractions.js the source code] for more information.
+
 
+
====Multiple line breaks====
+
This function replaces multiple empty lines with only one, complying with [[Help:Style#Blank lines]].
+
 
+
{{Note|Multiple empty lines can sometimes be found inside code samples: in these cases you will have to restore them manually.}}
+
 
+
See [https://github.com/kynikos/wiki-monkey/blob/master/src/plugins/MultipleLineBreaks.js the source code] for more information.
+
 
+
====RegExp substitution====
+
Perform a global regular expression substitution, based on JavaScript's string replace method.
+
 
+
===Diff pages===
+
These functions base their actions on diff pages.
+
 
+
====Quick report====
+
{{Expansion}}
+
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 {{ic|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 [https://github.com/kynikos/wiki-monkey/blob/master/src/plugins/ArchWikiQuickReport.js the source code] for more information.
+
 
+
====Save discussion====
+
{{Expansion}}
+
 
+
===List pages===
+
{{Expansion}}
+
 
+
{{Warning|A bot is not a "fire-and-forget" tool, you should always make sure to keep an eye on what it is doing, since the algorithm it is using may not take into consideration particular cases that should be exempted or treated in a different manner. Also remember to examine the messages in the log at the bottom of Wiki Monkey's interface.}}
+
 
+
====Simple replace====
+
{{Expansion}}
+
 
+
===Special pages===
+
{{Expansion}}
+
 
+
====Update main ToC====
+
{{Expansion}}
+
 
+
==Troubleshooting==
+
===Clicking on the configuration link does not trigger the installation===
+
If clicking on the [[#Installation|configuration links]] does not trigger the installation, save the target of the link into a {{ic|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.
+
 
+
===Automatic updating does not work===
+
Automatic updates are disabled by default and must be enabled manually, make sure to follow the instructions in [[#Updates]].
+
 
+
===Manual updating does not work===
+
If you notice that Wiki Monkey has been updated upstream but for some reason you cannot [[#Updates|update]] your local installation, just [[#Installation|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 [[User talk:Kynikos/Wiki Monkey|talk page]].
+
 
+
==Custom configuration==
+
{{Out of date}}
+
 
+
===Tutorial===
+
{{Expansion}}
+
 
+
# Open Firefox's ''Add-ons manager &rarr; 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 {{ic|@require}} tag in the header of the main script, as shown in the example below; for local files use the {{ic|file}} protocol, for remote files use {{ic|https}}.
+
# Add the module to {{ic|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 {{ic|main}} and {{ic|makeUI}} methods.
+
# Save and exit the editor.
+
# The newly-added module will work at the next page reload.
+
 
+
{{hc|WikiMonkey.user.js|2=
+
// ==UserScript==
+
 
+
...
+
 
+
// @require file:///home/user/path/to/ModuleExample1.js
+
// ==/UserScript==
+
 
+
WM.main(
+
    [
+
        [
+
            ["ModuleExample1", "Button example 1", null]
+
        ]
+
    ],
+
    [
+
        []
+
    ]
+
);
+
}}
+
 
+
 
+
{{hc|WikiMonkey.user.js|2=
+
// ==UserScript==
+
 
+
...
+
 
+
// @require file:///home/user/path/to/ModuleExample2.js
+
// ==/UserScript==
+
 
+
WM.main(
+
    [
+
        [
+
            ["ModuleExample2", "Button example 2", "Hello World"]
+
        ]
+
    ],
+
    [
+
        []
+
    ]
+
);
+
}}
+
 
+
 
+
{{hc|WikiMonkey.user.js|2=
+
// ==UserScript==
+
 
+
...
+
 
+
// @require file:///home/user/path/to/ModuleExample3.js
+
// ==/UserScript==
+
 
+
WM.main(
+
    [
+
        [
+
            ["ModuleExample3", "Button example 3", ["ExampleID", "Hello World"]]
+
        ]
+
    ],
+
    [
+
        []
+
    ]
+
);
+
}}
+
 
+
 
+
{{hc|WikiMonkey.user.js|2=
+
// ==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==
+
{{Out of date}}
+
This section explains how to develop plugins for Wiki Monkey.
+
 
+
===Tutorial===
+
{{Expansion}}
+
 
+
{{hc|ModuleTemplate1.js|2=
+
var ModuleTemplate1 = new function () {
+
    this.main = function () {
+
      // put your code here
+
    };
+
};
+
}}
+
 
+
{{hc|ModuleExample1.js|2=
+
var ModuleExample1 = new function () {
+
    this.main = function () {
+
        alert("Hello World");
+
    };
+
};
+
}}
+
 
+
 
+
{{hc|ModuleTemplate2.js|2=
+
var ModuleTemplate2 = new function () {
+
    this.main = function (arg) {
+
      // put your code here
+
    };
+
};
+
}}
+
 
+
{{hc|ModuleExample2.js|2=
+
var ModuleExample2 = new function () {
+
    this.main = function (arg) {
+
        alert(arg);
+
    };
+
};
+
}}
+
 
+
 
+
{{hc|ModuleTemplate3.js|2=
+
var ModuleTemplate3 = new function (args) {
+
    this.makeUI = function () {
+
        // create and return a DOM element
+
    };
+
 
+
    this.main = function (args) {
+
      // put your code here
+
    };
+
};
+
}}
+
 
+
{{hc|ModuleExample3.js|2=
+
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);
+
    };
+
};
+
}}
+
 
+
 
+
{{hc|ModuleTemplate4.js|2=
+
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
+
    };
+
};
+
}}
+
 
+
==API==
+
{{Out of date}}
+
{{Expansion}}
+
 
+
===WM===
+
 
+
====getURIParameter(name)====
+
 
+
====getLongTextNode(element)====
+
 
+
===WM.Diff===
+
 
+
====getEndTimestamp()====
+
 
+
===WM.Editor===
+
 
+
====getTitle()====
+
 
+
====isSection()====
+
 
+
====readSource()====
+
 
+
====writeSource(text)====
+
 
+
====readSummary()====
+
 
+
====writeSummary(text)====
+
 
+
====appendToSummary(text)====
+
 
+
===WM.HTTP===
+
 
+
====sendGetAsyncRequest(url, cfunc)====
+
 
+
====sendGetSyncRequest(url)====
+
 
+
====sendPostAsyncRequest(url, cfunc, string, header, headervalue)====
+
 
+
====sendPostSyncRequest(url, string, header, headervalue)====
+
 
+
====getResponseText(id)====
+
 
+
===WM.Log===
+
 
+
====logDebug(text)====
+
 
+
====logInfo(text)====
+
 
+
====logWarning(text)====
+
 
+
====logError(text)====
+
 
+
===WM.MW===
+
 
+
====callAPIGet(params)====
+
 
+
====callAPIPost(params)====
+
 
+
====getUserName()====
+
 
+
===WM.Tables===
+
 
+
====appendRow(title, mark, values, summary)====
+
 
+
===WM.UI===
+
 
+
====setEditor(rows)====
+
  
====setDiff(rows)====
+
==See also==
 +
* [https://github.com/kynikos/wiki-monkey/wiki/Bundled-plugins Bundled plugins]
 +
* [https://github.com/kynikos/wiki-monkey/wiki/Troubleshooting Troubleshooting]
 +
* [https://github.com/kynikos/wiki-monkey/issues Bug reports, feature requests, questions]
 +
* [https://github.com/kynikos/wiki-monkey/wiki/Custom-configuration Custom configuration]
 +
* [https://github.com/kynikos/wiki-monkey/wiki/Plugin-development Plugin development]

Revision as of 20:45, 1 March 2012

Category:ArchWiki Tools << enable category!

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Wiki Monkey is a MediaWiki-compatible bot and editor assistant that can be used directly within wiki pages in the browser. Wiki Monkey is run as a Scriptish script for Firefox and can be easily extended through the creation of plugins, exploiting its high-level API.

The project is currently focused on ArchWiki, and as such most plugins address ArchWiki-specific problems.

Installation

Make sure you have installed Scriptish for Firefox.

Note: Chrome/Chromium users can try Tampermonkey, but Wiki Monkey is not tested against it and does not currently support it.

Now just click on the link of one of the following Wiki Monkey configurations and Firefox should ask you to install it:

  • Editor: provides manual-editing aid functions in editor pages, like automatic style fixes
  • Patrol: Editor + quick-report functions in diff pages
  • Bot: Patrol + automatic operations on list pages

Otherwise you can create your own configuration.

Warning: Although it is possible to keep multiple configurations of Wiki Monkey installed together, make sure to enable only one at a time.

Automatic updates

If you want to enable automatic updates, open Firefox's Add-ons Manager (Tools -> Add-ons), select User Scripts, right-click on Wiki Monkey and choose Show More Information, then set Automatic Updates to On.

See also