Difference between revisions of "Visual editor"

From Organic Design wiki
(See also)
(Tag: visualeditor)
m (Configure Parsoid (apt package only))
 
(13 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
I'm creating a local page for this as it was quite difficult to install so I want some of my own notes for future reference. The main page for the extension is at [[MW:Extension:VisualEditor]].
 
I'm creating a local page for this as it was quite difficult to install so I want some of my own notes for future reference. The main page for the extension is at [[MW:Extension:VisualEditor]].
  
 +
== Install Parsoid from the Docker image ==
 +
This is by far the simplest method to install Parsoid, especially if you already have Docker installed on the system. Check the documentation at the [https://github.com/thenets/docker-parsoid Github repo]. In this case, Parsoid is configured directly from the ''docker run'' command rather than by editing the ''config.yaml'' file.
 +
 +
== Install Parsoid from the apt package ==
 
First download and unpack a snapshot for the extension corresponding to the wiki version as usual, then install ''nodejs'' with apt, but if your repo has an older version than 0.8, then remove it and install from [https://nodesource.com/ NodeSource] using the following commands (see [https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager this] for details).
 
First download and unpack a snapshot for the extension corresponding to the wiki version as usual, then install ''nodejs'' with apt, but if your repo has an older version than 0.8, then remove it and install from [https://nodesource.com/ NodeSource] using the following commands (see [https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager this] for details).
 
<source lang="bash">
 
<source lang="bash">
Line 8: Line 12:
  
  
Now install the ''paisoid'' package via apt (see [[MW:Parsoid/Setup]] for more detail). First add the key for the deb,
+
Now install ''Parsoid'' from the ''apt'' package as follows, or from the Docker image, (see [[MW:Parsoid/Setup]] for more detail and for possible updates to the procedure).
 
<source lang="bash">
 
<source lang="bash">
apt-key advanced --keyserver keys.gnupg.net --recv-keys 5C927F7C
+
apt-key advanced --keyserver keys.gnupg.net --recv-keys 90E9F83F22250DD7
</source>
+
apt-add-repository "deb https://releases.wikimedia.org/debian jessie-mediawiki main"
 
 
 
 
Then add the following to you ''/etc/apt/sources.list'' (only amd64 is available),
 
<source>
 
deb [arch=amd64] http://parsoid.wmflabs.org:8080/deb wmf-production main
 
</source>
 
 
 
 
 
Then udpate and install it,
 
<source>
 
 
apt-get update
 
apt-get update
 
apt-get install parsoid
 
apt-get install parsoid
 
</source>
 
</source>
  
 +
== Configure Parsoid ==
 +
If you installed Parsoid from the Docker image, then the configuration will be done directly in the ''docker run'' command, but you'll still need to understand how it works since it's just an indirect way of editing the ''config.yaml'' file within the docker image.
  
Edit the parsoid configuration (''/etc/mediawiki/parsoid/settings.js'') adding a line for each wiki in the wikia that will be using the editor, e.g.
+
Edit the parsoid configuration (''/etc/mediawiki/parsoid/config.yaml'') adding a ''uri'' and ''domain'' for each wiki in the wikia that will be using the editor, e.g.
<source>
+
<source lang="yaml">
parsoidConfig.setInterwiki( '123', 'http://123.organicdesign.co.nz/wiki/api.php' );
+
mwApis:
 +
- # First wiki
 +
  uri: 'https://foo.organicdesign.nz/wiki/api.php'
 +
  domain: 'foo'
 +
- # Second wiki
 +
  uri: 'https://bar.baz/api.php'
 +
  domain: 'bar'
 
</source>
 
</source>
  
Line 39: Line 41:
  
  
Restart the ''parsoid'' daemon and then test that you can read a page as follows (note the wiki ID matching the setting above):
+
Restart the ''parsoid'' daemon:
 
<source lang="bash">
 
<source lang="bash">
/etc/init.d/parsoid restart
+
service parsoid restart
wget -O - http://localhost:8142/123/Main_Page
 
 
</source>
 
</source>
  
 +
== Test the Parsoid service ==
 +
Test that you can read a page as follows (note the wiki ID matching the domain setting above):
 +
<source lang="bash">
 +
wget -O - http://localhost:8142/{!foo!}/v3/page/html/Main_Page
 +
</source>
 +
Check the ''parsoid'' log in ''/var/log/parsoid/parsoid.log'' to ensure that the request executed properly.
  
 +
== Configure your wikis ==
 
Include the extension and its settings in the wiki's LocalSettings.php, e.g.
 
Include the extension and its settings in the wiki's LocalSettings.php, e.g.
 
<source lang="php">
 
<source lang="php">
include( "$IP/extensions/VisualEditor/VisualEditor.php" );
+
wfLoadExtension( 'VisualEditor' );
  
 
// Enable by default for everybody
 
// Enable by default for everybody
Line 60: Line 68:
  
 
// Specify which wiki from the parsoid configuration we're using
 
// Specify which wiki from the parsoid configuration we're using
$wgVisualEditorParsoidURL = 'http://localhost:8142';
+
$wgVirtualRestConfig['modules']['parsoid'] = array(
$wgVisualEditorParsoidPrefix = '123';
+
'url' => 'http://localhost:8142',
 +
'domain' => 'foo',
 +
'prefix' => 'foo',
 +
);
  
// Add organicdesign to the supported skins
+
// Add organicdesign to the supported skins (vector, monobook etc are included by default)
$wgVisualEditorSupportedSkins[] = 'monobook';
+
$wgVisualEditorSupportedSkins[] = 'organicdesign';
  
 
// Namespaces to enable VisualEditor in
 
// Namespaces to enable VisualEditor in
$wgVisualEditorNamespaces[] = NS_USER_TALK;
+
$wgVisualEditorNamespaces[] = NS_MAIN;
 
</source>
 
</source>
  
== Private wikis ==
+
== Locked-down wikis (legacy?) ==
 
If you're running a private wiki (no public editing allowed) then you'll need to also set the following, but note that this means your cookie data is being sent over HTTP, so make sure you only do this if the ''parsoid'' daemon is on the localhost.
 
If you're running a private wiki (no public editing allowed) then you'll need to also set the following, but note that this means your cookie data is being sent over HTTP, so make sure you only do this if the ''parsoid'' daemon is on the localhost.
 
<source lang="php">
 
<source lang="php">
Line 76: Line 87:
 
$wgVisualEditorParsoidForwardCookies = true;
 
$wgVisualEditorParsoidForwardCookies = true;
 
</source>
 
</source>
 +
 +
Another way to handle private wikis is to simply make the ''LocalSettings.php'' file detect if the request is local and allow access in this case, for example:
 +
<source lang="php">
 +
$wgGroupPermissions['*']['read'] = $_SERVER['REMOTE_ADDR'] == '1.2.3.4';
 +
</source>
 +
Where ''1.2.3.4'' is the IP of the localhost (you'll need to check what the ''REMOTE_ADDR'' is on your server for local requests).
  
 
== SSD's ==
 
== SSD's ==
Line 81: Line 98:
  
 
== See also ==
 
== See also ==
* [[MW:Extension:VisualEditor|VisualEditor]] ''- mediawiki.org page about the extension''
+
* [[MW:Extension:VisualEditor|Extension:VisualEditor]] ''- mediawiki.org page about the extension''
 +
* [[MW:VisualEditor|VisualEditor]] ''- mediawiki.org page about the visual editor in general (i.e. for use outside MediaWiki)''
 
* [[MW:Parsoid|Parsoid]] ''- mediawiki.org Parsoid page''
 
* [[MW:Parsoid|Parsoid]] ''- mediawiki.org Parsoid page''
 
* [[MW:Parsoid/Setup|Parsoid/Setup]] ''- mediawiki.org Parsoid setup page''
 
* [[MW:Parsoid/Setup|Parsoid/Setup]] ''- mediawiki.org Parsoid setup page''
* [[MW:VisualEditor|VisualEditor]] ''- mediawiki.org page about the visual editor in general (i.e. for use outside MediaWiki)''
+
*[[MW:Parsoid/Troubleshooting]] ''- mediawiki.org Parsoid troubleshooting page''
 
[[Category:Extensions]][[Category:MediaWiki]][[Category:Help]]
 
[[Category:Extensions]][[Category:MediaWiki]][[Category:Help]]

Latest revision as of 23:26, 21 October 2018

I'm creating a local page for this as it was quite difficult to install so I want some of my own notes for future reference. The main page for the extension is at MW:Extension:VisualEditor.

Install Parsoid from the Docker image

This is by far the simplest method to install Parsoid, especially if you already have Docker installed on the system. Check the documentation at the Github repo. In this case, Parsoid is configured directly from the docker run command rather than by editing the config.yaml file.

Install Parsoid from the apt package

First download and unpack a snapshot for the extension corresponding to the wiki version as usual, then install nodejs with apt, but if your repo has an older version than 0.8, then remove it and install from NodeSource using the following commands (see this for details).

curl -sL https://deb.nodesource.com/setup | sudo bash -
apt-get install nodejs


Now install Parsoid from the apt package as follows, or from the Docker image, (see MW:Parsoid/Setup for more detail and for possible updates to the procedure).

apt-key advanced --keyserver keys.gnupg.net --recv-keys 90E9F83F22250DD7
apt-add-repository "deb https://releases.wikimedia.org/debian jessie-mediawiki main"
apt-get update
apt-get install parsoid

Configure Parsoid

If you installed Parsoid from the Docker image, then the configuration will be done directly in the docker run command, but you'll still need to understand how it works since it's just an indirect way of editing the config.yaml file within the docker image.

Edit the parsoid configuration (/etc/mediawiki/parsoid/config.yaml) adding a uri and domain for each wiki in the wikia that will be using the editor, e.g.

mwApis:
- # First wiki
  uri: 'https://foo.organicdesign.nz/wiki/api.php'
  domain: 'foo'
- # Second wiki
  uri: 'https://bar.baz/api.php'
  domain: 'bar'


You may also like to lock down the parsoid daemon so it can only be accessed from the local host which you can do by editing /etc/default/parsoid and changing the INTERFACE setting from 0.0.0.0 to 127.0.0.1.

INTERFACE="127.0.0.1"


Restart the parsoid daemon:

service parsoid restart

Test the Parsoid service

Test that you can read a page as follows (note the wiki ID matching the domain setting above):

wget -O - http://localhost:8142/foo/v3/page/html/Main_Page

Check the parsoid log in /var/log/parsoid/parsoid.log to ensure that the request executed properly.

Configure your wikis

Include the extension and its settings in the wiki's LocalSettings.php, e.g.

wfLoadExtension( 'VisualEditor' );

// Enable by default for everybody
$wgDefaultUserOptions['visualeditor-enable'] = 1;

// Don't allow users to disable it
$wgHiddenPrefs[] = 'visualeditor-enable';

// OPTIONAL: Enable VisualEditor's experimental code features
#$wgDefaultUserOptions['visualeditor-enable-experimental'] = 1;

// Specify which wiki from the parsoid configuration we're using
$wgVirtualRestConfig['modules']['parsoid'] = array(
	'url' => 'http://localhost:8142',
	'domain' => 'foo',
	'prefix' => 'foo',
);

// Add organicdesign to the supported skins (vector, monobook etc are included by default)
$wgVisualEditorSupportedSkins[] = 'organicdesign';

// Namespaces to enable VisualEditor in
$wgVisualEditorNamespaces[] = NS_MAIN;

Locked-down wikis (legacy?)

If you're running a private wiki (no public editing allowed) then you'll need to also set the following, but note that this means your cookie data is being sent over HTTP, so make sure you only do this if the parsoid daemon is on the localhost.

$wgSessionsInObjectCache = true;
$wgVisualEditorParsoidForwardCookies = true;

Another way to handle private wikis is to simply make the LocalSettings.php file detect if the request is local and allow access in this case, for example:

$wgGroupPermissions['*']['read'] = $_SERVER['REMOTE_ADDR'] == '1.2.3.4';

Where 1.2.3.4 is the IP of the localhost (you'll need to check what the REMOTE_ADDR is on your server for local requests).

SSD's

If you're system is running an SSD and you've gone through the SSD Optimisation checklist then you'll need to edit the start case in the /etc/init.d/parsoid file and have it create the /var/log/parsoid directory owned by parsoid. See the Nginx and MariaDB examples on that page for details.

See also