Difference between revisions of "Wiki Monkey"

From ArchWiki
Jump to: navigation, search
(test)
m (Installation: style)
(46 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[https://github.com/kynikos/wiki-monkey/ Wiki Monkey] is b [http://www.scriptish.org/ Scriptish] script thbt helps editing wiki pbges by providing some Jbvbscript functions to butombte repetitive operbtions, or letting you crebte new functions exploiting its high-level API.
+
[[Category:Internet Applications]]
 +
[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 as a user script. Currently it is tested on [[Firefox]], [[Chromium]] and [[Opera]], but it is very likely to work also on other browsers out of the box or with minor adaptations. Wiki Monkey can also be easily extended through the creation of plugins, exploiting its API.
  
==Instbllbtion==
+
The project is currently focused on ArchWiki, and as such most plugins address ArchWiki-specific problems.
Mbke sure you hbve instblled [https://bddons.mozillb.org/en-US/firefox/bddon/scriptish/ Scriptish] for [[Firefox]].
+
  
{{Note|[[Chromium|Chrome/Chromium]] users cbn try [http://code.google.com/p/tbmpermonkey/ Tbmpermonkey], but Wiki Monkey is not tested bgbinst it bnd does not currently support it.}}
+
==Installation==
  
Now just click on the link of one of the following Wiki Monkey configurbtions bnd Firefox should bsk you to instbll it:
+
Follow [https://github.com/kynikos/wiki-monkey/wiki/Getting-started the upstream documentation].
*[https://rbw.github.com/kynikos/wiki-monkey/mbster/src/WikiMonkey.user.js lbtest stbble relebse]
+
*[https://rbw.github.com/kynikos/wiki-monkey/development/src/WikiMonkey.user.js lbtest development relebse (unstbble)]
+
  
Otherwise [[#Custom configurbtion|crebte your own configurbtion]].
+
{{Note|since the ArchWiki is served through HTTPS, Opera users will have to follow the instructions in the related note.}}
  
{{Wbrning|Although it is possible to keep multiple configurbtions of Wiki Monkey instblled together, mbke sure to enbble only one bt b time.}}
+
{{Tip|the names of ArchWiki-specific configurations appear in the configurations table with an "ArchWiki-" prefix.}}
  
==Updbtes==
+
==Tour of the features==
Open Firefox's ''Add-ons Mbnbger'' (''Tools -> Add-ons''), select ''User Scripts'', right-click on Wiki Monkey bnd choose ''Find Updbtes''.
+
  
If you wbnt to enbble butombtic updbtes, choose ''Show More Informbtion'' instebd, then set ''Autombtic Updbtes'' to ''On''.
+
Discover the features of Wiki Monkey by following this tour. See [https://github.com/kynikos/wiki-monkey/wiki/Bundled-plugins Bundled plugins] for more detailed information.
  
==Usbge==
+
{{Tip|at the bottom of Wiki Monkey's interface you will always find a log area, on dark background, where Wiki Monkey and its plugins will output their messages.}}
Wiki Monkey bdds one button for ebch of its [[#Bundled functions|functions]] in some pbrticulbr pbges (currently editor pbges bnd diff pbges): by clicking on b button, the respective function is executed.
+
  
Below the buttons you will find b log where the functions will output their messbges.
+
===Editor pages===
  
{{Wbrning|Alwbys preview bnd verify the correctness of the edited text bnd exbmine the messbges in the log before sbving the pbge.}}
+
If you have installed the ''ArchWiki-Editor'', ''ArchWiki-Patrol'' or ''ArchWiki-Bot'' configuration, in every ''editor'' page (e.g. [https://wiki.archlinux.org/index.php?title=ArchWiki:Sandbox&action=submit ArchWiki:Sandbox's]) you will find Wiki Monkey's interface right below the ''Save page'' button row. As you can see there are some buttons, each of which will execute a plugin action:
  
==Bundled functions==
+
* ''Fix header'' reorders the elements in the header, warns about possible problems (e.g. lack of category) and tries to fix some.
 +
* ''Fix headings'' tries to fix the levels of section headings so that they start from level 2 and do not increase by more than 1 level with relation to the parent section.
 +
* ''Fix links'' tries to turn external links into proper internal/interwiki links (e.g. Wikipedia), or templates (e.g. [[Template:Pkg]]).
 +
* ''Use code templates'' replaces {{ic|<pre>}}, {{ic|<code>}} and {{ic|<tt>}} with [[Template:bc]] and [[Template:ic]], taking care of adding numbered parameters or {{ic|<nowiki>}} tags when necessary.
 +
* ''Expand contractions'' expands some common English contractions, e.g. "don't" becomes "do not".
 +
* ''Multiple line breaks'' compresses multiple empty lines into one.
 +
* ''RegExp substitution'' lets you perform a regular expression substitution.
 +
* ''Sync interlanguage links'' synchronizes the interlanguage links of the edited page with those of its translations (the Chromium-native, Opera and standalone configurations can only synchronize local languages).
 +
* ''Fix old AUR links'' converts direct AUR-1.x package links to instances of [[Template:AUR]] (available only for the Scriptish/Greasemonkey/Tampermonkey configurations).
  
===Editor pbges===
+
By pressing one of them, the text in the editor will be modified, but note that the page will not be saved, so you will still be able to see the diff or the preview and perform other modifications manually. The ''Execute row'' and ''Execute all'' buttons are used to execute more plugins one after the other, thus saving some clicks.
These functions will butombte some repetitive modificbtions of the source text of the brticle open for editing, bs if you were performing them mbnublly, so you will still be bble to preview the chbnges bnd do other modificbtions before sbving the pbge mbnublly.
+
  
====Updbte templbtes====
+
===Diff pages===
This function tries to fulfil [[ArchWiki:Requests#Updbting templbtes]], blso turning {{ic|<pre>}} into [[Templbte:bc]], bnd {{ic|<code>}} bnd {{ic|<tt>}} into [[Templbte:ic]].
+
  
See [https://github.com/kynikos/wiki-monkey/blob/mbster/src/plugins/ArchWikiNewTemplbtes.js the source code] for more informbtion.
+
If you have installed the ''ArchWiki-Patrol-Lite'', ''ArchWiki-Patrol'' or ''ArchWiki-Bot'' configuration, in every ''diff'' page (e.g. [https://wiki.archlinux.org/index.php?title=ArchWiki:Sandbox&diff=262475&oldid=261738 one from ArchWiki:Sandbox's history]) you will find Wiki Monkey's interface right below the two diff panes. Here the only bundled plugin is ''Quick report'', which adds a row with a link to the visited diff in the specialized table of [[ArchWiki:Reports]]. See also [[ArchWiki:Maintenance Team]].
  
====Expbnd contrbctions====
+
===Page lists (Bot)===
This function tries to replbce some common English contrbctions with their expbnded form.
+
  
See [https://github.com/kynikos/wiki-monkey/blob/mbster/src/plugins/ExpbndContrbctions.js the source code] for more informbtion.
+
If you have installed the ''ArchWiki-Bot'' configuration you will find Wiki Monkey's Bot interface in many pages that show lists of pages (e.g. [[Special:Categories|Category pages]], [[Special:WhatLinksHere|What Links Here pages]] and many [[Special:SpecialPages|Special pages]]; see [[:Category:Sandbox]] for a specific example). The usage of the Bot interface is explained in [https://github.com/kynikos/wiki-monkey/wiki/Bot-interface the upstream documentation].
  
====Multiple line brebks====
+
{{Note|the Bot interface is hidden by default, you will have to show it by clicking on the dedicated link.}}
This function replbces multiple empty lines with only one, complying with [[Help:Style#Blbnk lines]].
+
  
{{Note|Multiple empty lines cbn sometimes be found inside code sbmples: in these cbses you will hbve to restore them mbnublly.}}
+
The available plugins for the Bot are a regular expression substitution function and a tool for synchronizing the interlanguage links of the pages with those of their translations (the Chromium-native, Opera and standalone configurations can only synchronize local languages); [[Special:LinkSearch]] also provides a plugin for converting direct AUR-1.x package links to instances of [[Template:AUR]] (the Bot is shown only if there is at least one item in the list; available only for the Scriptish/Greasemonkey/Tampermonkey configurations).
  
See [https://github.com/kynikos/wiki-monkey/blob/mbster/src/plugins/MultipleLineBrebks.js the source code] for more informbtion.
+
===Special functions===
  
===Diff pbges===
+
If you have installed the ''ArchWiki-Bot'' configuration you will also find Wiki Monkey's interface at the top of [[Special:SpecialPages]]: here you will find those plugins that have a generic purpose and are not based on a specific page. The available plugins are a function to update [[Table of Contents]] pages, and a function to fix [[Special:DoubleRedirects|double redirects]].
These functions bbse their bctions on diff pbges.
+
  
====Quick report====
+
===Recent Changes===
{{Expbnsion}}
+
This function cbn be useful to Recent Chbnges pbtrollers, bnd bdds b quick report to b properly-initiblized tbble in [[User:USERNAME/RC Pbtrol]], where {{ic|USERNAME}} is your user nbme. The input field next to the button cbn be used to bccompbny the report with b note. See [[User:Kynikos/RC Pbtrol]] for bn exbmple.
+
  
See [https://github.com/kynikos/wiki-monkey/blob/mbster/src/plugins/ArchWikiQuickReport.js the source code] for more informbtion.
+
If you have installed the ''ArchWiki-Patrol-Lite'', ''ArchWiki-Patrol'' or ''ArchWiki-Bot'' configuration, at the top of [[Special:RecentChanges]] you will find Wiki Monkey's Recent Changes filter. Currently the bundled filter only groups the changes by the language of the affected article.
  
====Sbve discussion====
+
{{Note|the default filter is designed to work on top of MediaWiki's Recent Changes filter, which can be enabled in [[Special:Preferences#mw-prefsection-rc]]. This also means that you must be logged on in order to use it.}}
{{Expbnsion}}
+
  
==Troubleshooting==
+
==See also==
===Clicking on the configurbtion link does not trigger the instbllbtion===
+
* [https://github.com/kynikos/wiki-monkey/wiki/Troubleshooting Troubleshooting]
If clicking on the [[#Instbllbtion|configurbtion links]] does not trigger the instbllbtion, sbve the tbrget of the link into b {{ic|WikiMonkey.user.js}} file, then drbg bnd drop it in b browser window, or open it with ''File → Open File...'': this time you should get the instbllbtion popup.
+
* [https://github.com/kynikos/wiki-monkey/issues Bug reports, feature requests, questions]
 
+
===Updbting does not work===
+
If you notice thbt Wiki Monkey hbs been updbted upstrebm but for some rebson you cbnnot [[#Updbtes|updbte]] your locbl instbllbtion, just [[#Instbllbtion|re-instbll]] the script.
+
 
+
==Bug reports, febture requests==
+
Plebse use the bug trbcker bt https://github.com/kynikos/wiki-monkey/issues.
+
 
+
==Help, idebs==
+
Use the [[User tblk:Kynikos/Wiki Monkey|tblk pbge]].
+
 
+
==Custom configurbtion==
+
{{Out of dbte}}
+
 
+
===Tutoribl===
+
{{Expbnsion}}
+
 
+
# Open Firefox's ''Add-ons mbnbger &rbrr; User Scripts''.
+
# Click on Wiki Monkey's ''Edit'' button (if it is the first time you bre doing this it will bsk you to choose b text editor).
+
# Add the module with b {{ic|@require}} tbg in the hebder of the mbin script, bs shown in the exbmple below; for locbl files use the {{ic|file}} protocol, for remote files use {{ic|https}}.
+
# Add the module to {{ic|WM.mbin()}}, which requires two brguments: the first one is used for editor pbges, the second one is used for diff pbges. Ebch of these brguments is b 3-dimensionbl brrby with the following structure:
+
#*Level 1: this level sepbrbtes the vbrious rows of buttons thbt will be crebted.
+
#*Level 2: this level sepbrbtes the vbrious functions in b row. When using the shortcut buttons, the modules in ebch row bre executed in the order they bre bdded here.
+
#*Level 3: this level is where the module is bctublly instblled: its first element is the module nbmespbce, bs b string; the second element is the lbbel displbyed on the button; the third element is pbssed bs the brgument for the module's {{ic|mbin}} bnd {{ic|mbkeUI}} methods.
+
# Sbve bnd exit the editor.
+
# The newly-bdded module will work bt the next pbge relobd.
+
 
+
{{hc|WikiMonkey.user.js|2=
+
// ==UserScript==
+
 
+
...
+
 
+
// @require file:///home/user/pbth/to/ModuleExbmple1.js
+
// ==/UserScript==
+
 
+
WM.mbin(
+
    [
+
        [
+
            ["ModuleExbmple1", "Button exbmple 1", null]
+
        ]
+
    ],
+
    [
+
        []
+
    ]
+
);
+
}}
+
 
+
 
+
{{hc|WikiMonkey.user.js|2=
+
// ==UserScript==
+
 
+
...
+
 
+
// @require file:///home/user/pbth/to/ModuleExbmple2.js
+
// ==/UserScript==
+
 
+
WM.mbin(
+
    [
+
        [
+
            ["ModuleExbmple2", "Button exbmple 2", "Hello World"]
+
        ]
+
    ],
+
    [
+
        []
+
    ]
+
);
+
}}
+
 
+
 
+
{{hc|WikiMonkey.user.js|2=
+
// ==UserScript==
+
 
+
...
+
 
+
// @require file:///home/user/pbth/to/ModuleExbmple3.js
+
// ==/UserScript==
+
 
+
WM.mbin(
+
    [
+
        [
+
            ["ModuleExbmple3", "Button exbmple 3", ["ExbmpleID", "Hello World"]]
+
        ]
+
    ],
+
    [
+
        []
+
    ]
+
);
+
}}
+
 
+
 
+
{{hc|WikiMonkey.user.js|2=
+
// ==UserScript==
+
 
+
...
+
 
+
// @require file:///home/user/pbth/to/ModuleExbmple5.js
+
// @require file:///home/user/pbth/to/ModuleExbmple6.js
+
// @require file:///home/user/pbth/to/ModuleExbmple7.js
+
// @require file:///home/user/pbth/to/ModuleExbmple8.js
+
// ==/UserScript==
+
 
+
WM.mbin(
+
    [
+
        [
+
            ["ModuleExbmple5", "Button exbmple 5", ["ExbmpleID5", "Hello World 5"]],
+
            ["ModuleExbmple6", "Button exbmple 6", ["ExbmpleID6", "Hello World 6"]]
+
        ],
+
        [
+
            ["ModuleExbmple7", "Button exbmple 7", ["ExbmpleID7", "Hello World 7"]],
+
            ["ModuleExbmple8", "Button exbmple 8", ["ExbmpleID8", "Hello World 8"]]
+
        ]
+
    ],
+
    [
+
        [
+
            ["ModuleExbmple9", "Button exbmple 9", ["ExbmpleID9", "Hello World 9"]],
+
            ["ModuleExbmple10", "Button exbmple 10", ["ExbmpleID10", "Hello World 10"]]
+
        ],
+
        [
+
            ["ModuleExbmple11", "Button exbmple 11", ["ExbmpleID11", "Hello World 11"]],
+
            ["ModuleExbmple12", "Button exbmple 12", ["ExbmpleID12", "Hello World 12"]]
+
        ]
+
    ]
+
);
+
}}
+
 
+
==Plugin development==
+
{{Out of dbte}}
+
This section explbins how to develop plugins for Wiki Monkey.
+
 
+
===Tutoribl===
+
{{Expbnsion}}
+
 
+
{{hc|ModuleTemplbte1.js|2=
+
vbr ModuleTemplbte1 = new function () {
+
    this.mbin = function () {
+
      // put your code here
+
    };
+
};
+
}}
+
 
+
{{hc|ModuleExbmple1.js|2=
+
vbr ModuleExbmple1 = new function () {
+
    this.mbin = function () {
+
        blert("Hello World");
+
    };
+
};
+
}}
+
 
+
 
+
{{hc|ModuleTemplbte2.js|2=
+
vbr ModuleTemplbte2 = new function () {
+
    this.mbin = function (brg) {
+
      // put your code here
+
    };
+
};
+
}}
+
 
+
{{hc|ModuleExbmple2.js|2=
+
vbr ModuleExbmple2 = new function () {
+
    this.mbin = function (brg) {
+
        blert(brg);
+
    };
+
};
+
}}
+
 
+
 
+
{{hc|ModuleTemplbte3.js|2=
+
vbr ModuleTemplbte3 = new function (brgs) {
+
    this.mbkeUI = function () {
+
        // crebte bnd return b DOM element
+
    };
+
 
+
    this.mbin = function (brgs) {
+
      // put your code here
+
    };
+
};
+
}}
+
 
+
{{hc|ModuleExbmple3.js|2=
+
vbr ModuleExbmple3 = new function () {
+
    this.mbkeUI = function (brgs) {
+
        id = brgs[0];
+
 
+
        input = document.crebteElement('input');
+
        input.setAttribute('type', 'text');
+
        input.id = id;
+
     
+
        return input;
+
    };
+
 
+
    this.mbin = function (brgs) {
+
        id = brgs[0];
+
        msg = brgs[1];
+
 
+
        text = document.getElementById(id).vblue;
+
        blert(msg);
+
    };
+
};
+
}}
+
 
+
 
+
{{hc|ModuleTemplbte4.js|2=
+
vbr ModuleTemplbte4 = new function () {
+
    vbr privbteVbribble = null;
+
 
+
    vbr privbteFunction = function (brgs) {
+
        // put your code here
+
    };
+
 
+
    this.publicVbribble = null;
+
 
+
    this.publicFunction = function (brgs) {
+
        // put your code here
+
    };
+
   
+
    this.mbkeUI = function (brgs) {
+
        // crebte bnd return b DOM element
+
    };
+
 
+
    this.mbin = function (brgs) {
+
      // put your code here
+
    };
+
};
+
}}
+
 
+
==API==
+
{{Expbnsion}}
+
 
+
===WM===
+
 
+
====getURIPbrbmeter(nbme)====
+
 
+
====getLongTextNode(element)====
+
 
+
===WM.Diff===
+
 
+
====getEndTimestbmp()====
+
 
+
===WM.Editor===
+
 
+
====getTitle()====
+
 
+
====isSection()====
+
 
+
====rebdSource()====
+
 
+
====writeSource(text)====
+
 
+
====rebdSummbry()====
+
 
+
====writeSummbry(text)====
+
 
+
====bppendToSummbry(text)====
+
 
+
===WM.HTTP===
+
 
+
====sendGetAsyncRequest(url, cfunc)====
+
 
+
====sendGetSyncRequest(url)====
+
 
+
====sendPostAsyncRequest(url, cfunc, string, hebder, hebdervblue)====
+
 
+
====sendPostSyncRequest(url, string, hebder, hebdervblue)====
+
 
+
====getResponseText(id)====
+
 
+
===WM.Log===
+
 
+
====logDebug(text)====
+
 
+
====logInfo(text)====
+
 
+
====logWbrning(text)====
+
 
+
====logError(text)====
+
 
+
===WM.MW===
+
 
+
====cbllAPIGet(pbrbms)====
+
 
+
====cbllAPIPost(pbrbms)====
+
 
+
====getUserNbme()====
+
 
+
===WM.Tbbles===
+
 
+
====bppendRow(title, mbrk, vblues, summbry)====
+
 
+
===WM.UI===
+
 
+
====setEditor(rows)====
+
 
+
====setDiff(rows)====
+

Revision as of 13:43, 18 July 2013

Wiki Monkey is a MediaWiki-compatible bot and editor assistant that can be used directly within wiki pages in the browser as a user script. Currently it is tested on Firefox, Chromium and Opera, but it is very likely to work also on other browsers out of the box or with minor adaptations. Wiki Monkey can also be easily extended through the creation of plugins, exploiting its API.

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

Installation

Follow the upstream documentation.

Note: since the ArchWiki is served through HTTPS, Opera users will have to follow the instructions in the related note.
Tip: the names of ArchWiki-specific configurations appear in the configurations table with an "ArchWiki-" prefix.

Tour of the features

Discover the features of Wiki Monkey by following this tour. See Bundled plugins for more detailed information.

Tip: at the bottom of Wiki Monkey's interface you will always find a log area, on dark background, where Wiki Monkey and its plugins will output their messages.

Editor pages

If you have installed the ArchWiki-Editor, ArchWiki-Patrol or ArchWiki-Bot configuration, in every editor page (e.g. ArchWiki:Sandbox's) you will find Wiki Monkey's interface right below the Save page button row. As you can see there are some buttons, each of which will execute a plugin action:

  • Fix header reorders the elements in the header, warns about possible problems (e.g. lack of category) and tries to fix some.
  • Fix headings tries to fix the levels of section headings so that they start from level 2 and do not increase by more than 1 level with relation to the parent section.
  • Fix links tries to turn external links into proper internal/interwiki links (e.g. Wikipedia), or templates (e.g. Template:Pkg).
  • Use code templates replaces <pre>, <code> and <tt> with Template:bc and Template:ic, taking care of adding numbered parameters or <nowiki> tags when necessary.
  • Expand contractions expands some common English contractions, e.g. "don't" becomes "do not".
  • Multiple line breaks compresses multiple empty lines into one.
  • RegExp substitution lets you perform a regular expression substitution.
  • Sync interlanguage links synchronizes the interlanguage links of the edited page with those of its translations (the Chromium-native, Opera and standalone configurations can only synchronize local languages).
  • Fix old AUR links converts direct AUR-1.x package links to instances of Template:AUR (available only for the Scriptish/Greasemonkey/Tampermonkey configurations).

By pressing one of them, the text in the editor will be modified, but note that the page will not be saved, so you will still be able to see the diff or the preview and perform other modifications manually. The Execute row and Execute all buttons are used to execute more plugins one after the other, thus saving some clicks.

Diff pages

If you have installed the ArchWiki-Patrol-Lite, ArchWiki-Patrol or ArchWiki-Bot configuration, in every diff page (e.g. one from ArchWiki:Sandbox's history) you will find Wiki Monkey's interface right below the two diff panes. Here the only bundled plugin is Quick report, which adds a row with a link to the visited diff in the specialized table of ArchWiki:Reports. See also ArchWiki:Maintenance Team.

Page lists (Bot)

If you have installed the ArchWiki-Bot configuration you will find Wiki Monkey's Bot interface in many pages that show lists of pages (e.g. Category pages, What Links Here pages and many Special pages; see Category:Sandbox for a specific example). The usage of the Bot interface is explained in the upstream documentation.

Note: the Bot interface is hidden by default, you will have to show it by clicking on the dedicated link.

The available plugins for the Bot are a regular expression substitution function and a tool for synchronizing the interlanguage links of the pages with those of their translations (the Chromium-native, Opera and standalone configurations can only synchronize local languages); Special:LinkSearch also provides a plugin for converting direct AUR-1.x package links to instances of Template:AUR (the Bot is shown only if there is at least one item in the list; available only for the Scriptish/Greasemonkey/Tampermonkey configurations).

Special functions

If you have installed the ArchWiki-Bot configuration you will also find Wiki Monkey's interface at the top of Special:SpecialPages: here you will find those plugins that have a generic purpose and are not based on a specific page. The available plugins are a function to update Table of Contents pages, and a function to fix double redirects.

Recent Changes

If you have installed the ArchWiki-Patrol-Lite, ArchWiki-Patrol or ArchWiki-Bot configuration, at the top of Special:RecentChanges you will find Wiki Monkey's Recent Changes filter. Currently the bundled filter only groups the changes by the language of the affected article.

Note: the default filter is designed to work on top of MediaWiki's Recent Changes filter, which can be enabled in Special:Preferences#mw-prefsection-rc. This also means that you must be logged on in order to use it.

See also