Jump to content

User:Cacycle/wikEd installation

From Wikipedia, the free encyclopedia

Please support wikEd

Please support wikEd by helping to fix the following browser and MediaWiki issues.

  • Firefox:
    • 579763, 579760 Cursor/caret disappears (07-2010)
    • 1016372 Space lost when deleting text (05-2014)
    • 926230 Space at end of line not styled (10-2013)
    • 543204 Focus after search (01-2010)
    • 926164 Editor deletes blank before inserted block element when converting to text (10-2013)
    • 458524 Automatic syntax highlighting would interfere with undo/redo. The only reason why wikEd does not have automatic syntax highlighting. (10-2008)
  • Webkit/Chrome:
    • None.

This is the installation instruction page for wikEd, a full-featured in-browser text editor that adds enhanced text processing functions to Wikipedia and other MediaWiki edit pages.

Installation

wikEd can be used on every language Wikipedia as well as on any MediaWiki wiki installation. There are several different ways to install wikEd:

Type Scope Installation Remarks
Gadget Local Wikipedia language or wiki only Select wikEd under Gadgets in your wiki preferences The easiest option on the English Wikipedia. Not available on all wikis.
User script Local Wikipedia language or wiki only Paste a small code snippet to your User:YourUsername/common.js page
Every Wikipedia language and MediaWiki installation Paste a small code snippet to your meta:User:YourUsername/global.js page
Site wide Local wiki only A wiki administrator has to paste a code snippet to the MediaWiki:Common.js page Site wide installation for all users
Greasemonkey/Tampermonkey Every Wikipedia language and MediaWiki installation Install the Greasemonkey/Tampermonkey add-on for your browser, then install wikEd by clicking here Also works for anonymous users that are not logged in

See below for more details, including how to install wikEd on non-Wikipedia wikis and on wikis without internet connection.

Gadget

wikEd can be enabled simply by selecting it in the Gadget section in your Wikipedia preferences. This works on Wikipedia as well as on other wikis if they have the Gadgets extension installed. If you want to add wikEd as a gadget option on your wiki, please see below. If running wikEd as a gadget, the version information (hover over the wikEd logo on top of the page) has a "G" added.

Greasemonkey/Tampermonkey

wikEd runs automatically on every MediaWiki wiki when installed locally as a Greasemonkey (Firefox) or Tampermonkey (Chrome) userscript.

  1. Install Greasemonkey for Firefox or Tampermonkey for Chrome
  2. Install wikEd by clicking this link and completing the installation popup window
  3. Optional: wikEd can be customized by adding user settings to the code, but these settings will be overwritten by updates
  4. The version information (hover over the wikEd logo on top of the page) has a "GM" added when wikEd runs as a Greasemonkey/Tampermonkey userscript.

On-wiki installation code

Simply add one of the following code snippets to your User:YourUsername/common.js page. You need a user account and you have to be logged in in order to install and use wikEd. Both installation versions give identical results. After saving, you have to refresh your browser's cache to see the changes: hold down Shift while clicking Reload (or press Ctrl-Shift-R).

  • Please do not copy the complete wikEd program code to your page in order to get the frequent updates and bug fixes and to save disk space (but see wikis without internet connection).
  • Please do not use the importScript(), importScriptURI(), or mw.loader.load() functions as these interfere with the script's own installation mechanism and will delay the startup.

Ultra-simple version

This works only for installations on the English Wikipedia and for global installation:

  1. Log in under your username
  2. Click the following link to edit your User:YourUsername/common.js page (where YourUsername is your wiki username): Special:Mypage/common.js
  3. Alternatively, for installing wikEd on every Wikipedia language and MediaWiki installation, open your meta:User:YourUsername/global.js page (where YourUsername is your wiki username) by hand or click meta:Special:Mypage/global.js
  4. Add the following code to that edit page:
    {{subst:wikEd}}
    Remember that you must include the subst: keyword, as the Javascript interpreter does not understand the {{}} wiki syntax. If there is already code on your User:YourUsername/common.js page, please make sure not to paste the wikEd line between <pre>...</pre>, <nowiki>...</nowiki>, or /*...*/ tags.
  5. The ultra-simple version expands to the complete version (see below) upon previewing or saving the page
  6. Save the page
  7. Refresh your browser's cache: hold down Shift while clicking Reload (or press Ctrl-Shift-R)
  8. The wikEd logo should now be displayed on top of every page next to the log out link

Complete version

This is the real installation code that works for all MediaWiki installations:

1. Log in under your username
2. If you are on the English Wikipedia, open your User:YourUsername/common.js page (where YourUsername is your wiki username) by hand or click Special:Mypage/common.js
3. Alternatively, for installing wikEd on every Wikipedia language and MediaWiki installation, open your meta:User:YourUsername/global.js page (where YourUsername is your wiki username) by hand or click meta:Special:Mypage/global.js
4. Add the following code to that edit page:
// install [[:Wikipedia:User:Cacycle/wikEd]] in-browser text editor
(function ()
{
	var script = document.createElement('script');
	script.src = 'https://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js&action=raw&ctype=text/javascript';
	script.async = true;
	document.getElementsByTagName('head')[0].appendChild(script);
 }
) ();
If there is already code on your User:YourUsername/common.js (or meta:User:YourUsername/global.js) page, please make sure not to paste the installation code between /*...*/ tags.
5. Save the page
6. Refresh your browser's cache: hold down Shift while clicking Reload (or press Ctrl-Shift-R)
7. The wikEd logo should now be displayed on top of every page next to the log out link

Non-Wikimedia wikis

In order for user scripts like wikEd to function as a wiki user script (common.js installation), the following line has to be added to the MediaWiki configuration file LocalSettings.php by a server administrator (a site-wide installation does not need this setting):

$wgAllowUserJs = true;

If you get an error message similar to

Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 279876 bytes)
in /server-path-to-your-wiki/includes/Parser.php on line 496

then the following value in php.ini has to be increased from its default value to at least 32 MB by a server administrator:

memory_limit = 32M

Use the "complete version" of the installation code from below — the ultra-simple version works only on Wikipedia because it uses a template. If you have problems to get it to work because of JavaScript errors (check the JavaScript Error Console in the Options menu of your browser), please post a message to the wikEd discussion page.

Site-wide installation

wikEd can also be installed site-wide and can then also be used by not logged-in users. A wiki sysop (admin) or bureaucrat has to add the "complete version" of the installation code from above to the MediaWiki:Common.js page of their wiki. The script can then be used without allowing the users to run their own common.js JavaScript code. The $wgAllowUserJs = true; is not required for a site-wide installation.

For a logged-in user-only alternative, see above under Gadget.

Creating a gadget

Administrators can create a wikEd gadget option in the user preferences of a wiki (see also Wikipedia:Gadget). This requires write permissions for the interface messages in the MediaWiki namespace.

1. The wiki must have the Gadgets extension installed (check Special:Version)
2. Add the following code to MediaWiki:Gadget-wikEd.js:
// install [[Wikipedia:User:Cacycle/wikEd]] in-browser text editor
( function () { var script = document.createElement( 'script' ); script.src = '//en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js&action=raw&ctype=text/javascript'; script.async = true; document.getElementsByTagName( 'head' )[ 0 ].appendChild( script ); } ) ();
Translations are automatically loaded and should not be added here, see wikEd international. Only on wikis without internet connection should the whole code from User:Cacycle/wikEd.js be pasted instead (see also below). In that case also add the following line:
var wikEdAutoUpdateUrl = '//en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd_current_version&action=raw&maxage=0';
and change the link to your own wikEd version page. Please update these pages regularly for bug fixes and new features
3. Additionally, add any site- or language-specific customization code to this page
4. Add a description to MediaWiki:Gadget-wikEd. Please link to the wikEd home page and state that wikEd works under all browsers except Internet Explorer
5. Add the following line to MediaWiki:Gadgets-definition:
* wikEd[ResourceLoader]|wikEd.js
6. wikEd should now appear on Special:Gadgets and under Special:Preferences:Gadgets

Wikis without internet connection

If your wiki users do not have internet access, e.g., in an intranet, you can still use wikEd. This is the only case where it makes sense to copy the whole wikEd program code to another page.

  • Make sure that a server administrator has made the following settings (as described above):
    • $wgAllowUserJs = true; (per-user installation) and/or $wgUseSiteJs = true; (for all installation) in LocalSettings.php
    • memory_limit = 32M in php.ini
  • Copy the whole wikEd program code from the page wikEd.js to the page wikEd.js on your wiki
  • Copy the wikEd version page from wikEd current version to the page wikEd current version on your wiki
  • Copy the wikEd help page from wikEd help to the page wikEd help on your wiki
  • Copy the whole diff program code from the page diff.js to the page diff.js on your wiki
  • Optionally, copy the wikEd version page from Wikipedia:AutoWikiBrowser/Typos to the page AutoWikiBrowser typos on your wiki
  • Copy the respective translation page (see User:Cacycle/wikEd_international) to the page wikEd_translation.js on your wiki if needed
  • Download all wikEd images (~100). This can be done by attaching "&wiked=iconpage" to the address of an wikEd-enabled page with internet connection. The resulting page contains all icons and images used by the program and can be saved into one folder as "web page, complete". The original images are deposited on the Commons.
  • Upload the images (do not change the image names):
    • Either into one directory on a server accessible on your intranet (easier, but needs FTP access to that server)
    • Or upload all images manually onto your wiki using the Upload file page (more work)
  • Decide where to save the installation code on your wiki:
    • If you want to load wikEd by default for everybody, then save the installation code to the page MediaWiki:Common.js on your wiki
    • If you want to load wikEd on a per-user basis, then save the installation code to the template Template:wikEd — users can then install wikEd simply by adding {{subst:wikEd}} to their User:USERNAME/common.js page.
  • Save one of the two following installation codes to that place, depending on how you have uploaded the images:
This installation code is for images in one single directory:
// path to images
var wikEdUseLocalImages = true;
var wikEdImagePathLocal = '//YOUR-DOMAIN.WHATEVER/PATH-TO-YOUR-IMAGES/';

// diff script URL
var wikEdDiffScriptSrc = '//YOUR-DOMAIN.WHATEVER/PATH-TO-YOUR-WIKI/index.php?title=diff.js&action=raw&ctype=text/javascript';

// wikEdDiff script URL
var wikEdDiffSrc = '//YOUR-DOMAIN.WHATEVER/PATH-TO-YOUR-WIKI/index.php?title=wikEdDiff.js&action=raw&ctype=text/javascript';

// InstaView script URL
var wikEdInstaViewSrc = '//YOUR-DOMAIN.WHATEVER/PATH-TO-YOUR-WIKI/index.php?title=instaview.js&action=raw&ctype=text/javascript';

// help page link (if you do not host your own translation)
var wikEdText = {
  'wikEdHelpPageLink': ' | <a href="//YOUR-DOMAIN.WHATEVER/PATH-TO-YOUR-WIKI/wikEd_help" target="helpwindow">wikEd help</a>';
}

// auto update: set to false or create a wiki version page
// var wikEdAutoUpdate = false;

// auto update: version url (Ajax)
var wikEdAutoUpdateUrl = '//YOUR-DOMAIN.WHATEVER/PATH-TO-YOUR-WIKI/index.php?title=wikEd_current_version&action=raw&maxage=0';

// RegExTypoFix rules page, the address must have the exact same domain name as the used wiki
var wikEdRegExTypoFixURL = '//YOUR-DOMAIN.WHATEVER/PATH-TO-YOUR-WIKI/index.php?title=AutoWikiBrowser_typos&action=raw';

// install the wikEd translation (omit if no translation needed)
 document.write('<script type="text/javascript" src="'
 + '//YOUR-DOMAIN.WHATEVER/PATH-TO-YOUR-WIKI/index.php?title=wikEd_translation.js'
 + '&action=raw&ctype=text/javascript"></' + 'script>');

// install [https://en.wikipedia.org/wiki/User:Cacycle/wikEd] in-browser text editor
 document.write('<script type="text/javascript" src="'
 + '//YOUR-DOMAIN.WHATEVER/PATH-TO-YOUR-WIKI/index.php?title=wikEd.js'
 + '&action=raw&ctype=text/javascript"></' + 'script>');
This installation code is for images manually uploaded onto the wiki:
// define image path
var wikEdImagePath = '//YOUR-DOMAIN.WHATEVER/PATH-TO-YOUR-IMAGES/';

// diff script URL
var wikEdDiffScriptSrc = '//YOUR-DOMAIN.WHATEVER/PATH-TO-YOUR-WIKI/index.php?title=diff.js&action=raw&ctype=text/javascript';

// wikEdDiff script URL
var wikEdDiffSrc = '//YOUR-DOMAIN.WHATEVER/PATH-TO-YOUR-WIKI/index.php?title=wikEdDiff.js&action=raw&ctype=text/javascript';

// InstaView script URL
var wikEdInstaViewSrc = '//YOUR-DOMAIN.WHATEVER/PATH-TO-YOUR-WIKI/index.php?title=instaview.js&action=raw&ctype=text/javascript';

// help page link (if you do not host your own translation)
var wikEdText = {
  'wikEdHelpPageLink': ' | <a href="//YOUR-DOMAIN.WHATEVER/PATH-TO-YOUR-WIKI/wikEd_help" target="helpwindow">wikEd help</a>';
}

// auto update: set to false or create a wiki version page
// var wikEdAutoUpdate = false;

// auto update: version url (Ajax)
var wikEdAutoUpdateUrl = '//YOUR-DOMAIN.WHATEVER/PATH-TO-YOUR-WIKI/index.php?title=wikEd_current_version&action=raw&maxage=0';

// RegExTypoFix rules page, the address must have the exact same domain name as the used wiki
var wikEdRegExTypoFixURL = '//YOUR-DOMAIN.WHATEVER/PATH-TO-YOUR-WIKI/index.php?title=AutoWikiBrowser_typos&action=raw';

// install the wikEd translation (omit if no translation needed)
( function () { var script = document.createElement( 'script' ); script.src = '//YOUR-DOMAIN.WHATEVER/PATH-TO-YOUR-WIKI/index.php?title=wikEd_translation.js&action=raw&ctype=text/javascript'; script.async = true; document.getElementsByTagName( 'head' )[ 0 ].appendChild( script ); } ) ();

// install [https://en.wikipedia.org/wiki/User:Cacycle/wikEd] in-browser text editor
( function () { var script = document.createElement( 'script' ); script.src = '//YOUR-DOMAIN.WHATEVER/PATH-TO-YOUR-WIKI/index.php?title=wikEd.js&action=raw&ctype=text/javascript'; script.async = true; document.getElementsByTagName( 'head' )[ 0 ].appendChild( script ); } ) ();
  • Change YOUR-DOMAIN.WHATEVER to your domain name
  • Change PATH-TO-YOUR-WIKI to the web-accessible path to your wiki (usually w)
  • Change PATH-TO-YOUR-IMAGES to the web-accessible path to your images (usually w/images)
  • Protect the program code pages ending in ".js" from editing — this is very important for security reasons:
    • A wiki sysop (admin) or bureaucrat has to click the "protect" tab on top of wikEd.js and wikEd_translation.js and change "Edit" and "Move" to "Block all non-admin users" and enter JavaScript security as the reason.
  • Make sure to update the wikEd code pages regularly as the code is under constant development and you will not receive any bugfix or new feature automatically.

Integrated into a wiki farm

Some hosts of the farm may listen only to private intranet interface. Also, installing via copying scripts content to wiki pages causes many similar duplicate pages to be created at every wiki host. Code base is common and shared between wikis. Core integration may be a better option for such wiki farms. You have to follow these steps:

1. Download icons and images as described above. Copy or extract the images into $IP/skins/common/images, so the images will be located in $IP/skins/common/images/wikEd directory.
2. Save content of the following pages into the particular file in $IP/skins/common/ directory. Open the source wiki page, press Edit / View source, copy and paste the "raw" content to the destination file. Make sure UTF-8 characters are not corrupted by the text editor.
Source wiki page Destination file name
User:Cacycle/wikEd.js wikEd.js
User:Cacycle/wikEdDiff.js wikEdDiff.js
User:Cacycle/diff.js wDiff.js
3. Copy and paste the following JavaScript code into the $IP/skins/common/wikEd_setup.js file:
var commonPath = mw.config.get('wgServer') + stylepath + '/common/';

// use local path to images
var wikEdUseLocalImages = true;
var wikEdImagePathLocal = commonPath + 'images/wikEd/';

// diff script URL
var wikEdDiffScriptSrc = commonPath + 'wDiff.js';

// wikEdDiff script URL
var wikEdDiffSrc = commonPath + 'wikEdDiff.js';

// help page link (if you do not host your own translation)
var wikEdText = {
  'wikEdHelpPageLink': ' | <a href="'+mw.config.get('wgScript')+'/wikEd_help" target="helpwindow">wikEd help</a>'
}

// auto update: set to false or create a wiki version page
var wikEdAutoUpdate = false
4. Find the following line of code in $IP/includes/EditPage.php:
		$wgOut->addScriptFile( 'edit.js' );
and change it to:
		$wgOut->addScriptFile( 'edit.js' );
		$wgOut->addScriptFile( 'wikEd_setup.js' );
		$wgOut->addScriptFile( 'wikEd.js' );
5. The wikEd_help page has to be created manually at every wiki host (copy the raw content from the User:Cacycle/wikEd_help page). Another possibility is to make 'wikEdHelpPageLink' point to the English Wikipedia page:
var wikEdText = {
  'wikEdHelpPageLink': ' | <a href="//en.wikipedia.org/wiki/User:Cacycle/wikEd_help" target="helpwindow">wikEd help</a>'
}

(Checked in MediaWiki 1.14 / 1.15 farm on Linux.)

  • Make sure to update the wikEd code pages regularly as the code is under constant development and you will not receive any bugfixes or new feature automatically.