Jump to content

TestingOfVisualEditor

From ChemWiki

PARSOID translation layer runtime installation and integration with mediawiki

The VisualEditor relies on a stand-alone parsoid service to bi-directionally translate between wikitext and RTF.

The parsoid server is written in nodejs and lives on the wiki in /var/www/html/wiki/parsoid

Install the appropriate EPEL repo which allows you to install nodejs and npm
pull parsoid from git


Run the installer from the parsoid directory wdddddddith: npm install

The resultant compiled service is run with:

node <parsoid dir>/api/server.js

or ...

cd <parsoid dir>
npm start


Simple stop script called with /etc/init.d/parsoid stop

#!/bin/bash
pkill -9 node

Simple start script called from /etc/init.d/parsoid start

#!/bin/bash
cd /var/lib/parsoid/
export INTERFACE=127.0.0.1
export PORT=8000
/usr/bin/node api/server.js &


I have written a basic startup script /etc/init.d/parsoid

!/bin/bash
chkconfig: 345 99 01
# description:  Quest Foglight 5 Agents.
 # Source function library
 . /etc/init.d/functions
 STARTPATH="/var/www/html/wiki/parsoid/api/start_parsoid"
 STOPPATH="/var/www/html/wiki/parsoid/api/stop_parsoid"
 USERNAME="apache"
 case "$1" in
 'start')
        if [ -x ${STARTPATH} ]; then
          daemon --user ${USERNAME} "${STARTPATH} --daemon" 1>/var/log/parsoid_error.log 2>/var/log/parsoid_error.log & 
       fi
        ;;
 'stop')
        if [ -x ${STOPPATH} ]; then
          daemon --user ${USERNAME} "${STOPPATH} --stop"
         pkill -9 node
        fi
        ;;
 'restart')
        $0 stop
        $0 start
        ;;
 'reload')
        $0 stop
        $0 start
        ;;
 'status')
        status -p "/var/www/html/wiki/parsoid.pid" parsoid
       ;;
 *)
        echo "Usage: parsoid {start|stop|status|restart|reload}"
       exit 1
        ;;
 esac
 exit 0

To autostart on reboot, run:

chkconfig parsoid on 

Download and install VisualEditor Extension https://www.mediawiki.org/wiki/Extension:VisualEditor

e.g. for this git snapshot

wget https://extdist.wmflabs.org/dist/extensions/VisualEditor-REL1_25-c947b49.tar.gz
 tar -xzf VisualEditor-REL1_25-c947b49.tar.gz -C /var/www/html/wiki/extensions/

Depends on the UniversalLanguageSelector extension so ...

wget https://extdist.wmflabs.org/dist/extensions/UniversalLanguageSelector-REL1_25-7661826.tar.gz
 tar -xzf UniversalLanguageSelector-REL1_25-7661826.tar.gz -C /var/www/html/wiki/extensions/

Setting up VisualEditor and Linking it to parsoid needs these modification in <wikidir>/LocalSettings.php

require_once "$IP/extensions/VisualEditor/VisualEditor.php";
//  enable by default for everyone
$wgDefaultUserOptions['visualeditor-enable'] = 1;
//  Don't allow users to disable it
$wgHiddenPrefs[] = 'visualeditor-enable';
//  OPTIONAL: Enable visualeditor experimental code features.
#  $wgDefaultUserOptions['visual-editorenable-experimental'] = 1;;
$wgVisualEditorParsoidURL = 'http://localhost:8000';
 #  $wgVisualEditorParsoidPrefix = 'chemwiki';


Parsoid Configuration file is /var/www/html/wiki/parsoid/api/localsettings.js

The basic file requires at least the following content ...

'use strict';

exports.setup = function(parsoidConfig) {
       // The URL of your MediaWiki API endpoint.
       parsoidConfig.setMwApi('localhost', { uri: 'http://localhost/wiki/api.php' });
        parsoidConfig.setInterwiki( 'localhost', 'http://localhost/wiki/api.php' );
 }


Testing parsoid on the command line ...

cd /var/www/html/wiki/parsoid
npm test
curl -L http://localhost/wiki/api.php 

This should return a lot of HTML and not errors


Get the Git version

cd /tmp/
git clone -b REL1_24 https://github.com/wikimedia/mediawiki-extensions-VisualEditor.git
 cd mediawiki-extensions-VisualEditor 
 git submodule update --init


Set appropriate permissions

cd /var/www/html/wiki/extensions/
sudo find VisualEditor -type d -exec chmod -R 575 {} \;
sudo find VisualEditor -type f -exec chmod -R 464 {} \;
sudo chown -R apache:webmaster VisualEditor
sudo chmod 575 VisualEditor/bin/*

Test Page is here https://wiki.ch.ic.ac.uk/wiki/index.php/TestingOfVisualEditor