Difference between revisions of "Visual Editor Install"

From SETV Springfield Technical Wiki
Jump to: navigation, search
m
 
(8 intermediate revisions by the same user not shown)
Line 2: Line 2:
  
 
After you have MediaWiki installed (to a users' account NOT <code>/var/www/mediawiki</code> and working, do the following
 
After you have MediaWiki installed (to a users' account NOT <code>/var/www/mediawiki</code> and working, do the following
# Get the Package
+
# Get the Package <ref>https://www.mediawiki.org/wiki/Extension:VisualEditor#Download</ref>
 
## <code>cd extensions</code>   
 
## <code>cd extensions</code>   
 
## <code>git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/VisualEditor.git</code>   
 
## <code>git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/VisualEditor.git</code>   
 
## <code>cd VisualEditor</code>     
 
## <code>cd VisualEditor</code>     
 
## <code>git submodule update --init</code>
 
## <code>git submodule update --init</code>
# Run This as Root from within the base wiki directory <code>curl --silent --location https://rpm.nodesource.com/setup_4.x | bash -</code>
+
# Run This as Root from within the base wiki directory <ref>https://nodejs.org/en/download/package-manager/#enterprise-linux-and-fedora</ref> <code>curl --silent --location https://rpm.nodesource.com/setup_4.x | bash -</code>
# Next we need to install Parsiod     
+
# Next we need to install Parsiod <ref>https://www.centos.org/forums/viewtopic.php?f=47&t=53223&p=225372#p225372</ref>    
 
## <code>cd /opt</code>   
 
## <code>cd /opt</code>   
 +
## <code>yum install -y policycoreutils-python</code> 
 
## <code>mkdir src</code>   
 
## <code>mkdir src</code>   
 
## <code>cd src</code>     
 
## <code>cd src</code>     
## <code>clone https://gerrit.wikimedia.org/r/p/mediawiki/services/parsoid</code>   
+
## <code>git clone https://gerrit.wikimedia.org/r/p/mediawiki/services/parsoid</code>   
## <code>cp -rv ~/parsoid /opt/</code>   
+
## <code>cp -rv parsoid /opt/</code>   
 
## <code>cd /opt/parsoid/</code>     
 
## <code>cd /opt/parsoid/</code>     
 
## <code>npm install</code>     
 
## <code>npm install</code>     
Line 41: Line 42:
 
<code>groupadd parsoid</code>
 
<code>groupadd parsoid</code>
  
<code>useradd -gparsoid parsoid</code>
+
<code>useradd -g parsoid parsoid</code>
  
 
<code>cd /opt/</code>
 
<code>cd /opt/</code>
Line 49: Line 50:
 
<code>chmod -Rv u+rw,g+r,o+r parsoid</code>
 
<code>chmod -Rv u+rw,g+r,o+r parsoid</code>
  
<code>chcon -Rv --type=system_u:object_r:usr_t:s0 parsoid</code>
+
<code>chcon -Rv --type=system_u:object_r:usr_t:s0 parsoid</code> **ForSELinux Only - We can ignore
  
 
Port 8000 should already be open on the hosted server, so we'll continue.
 
Port 8000 should already be open on the hosted server, so we'll continue.
  
Create init.d service
+
===== Create init.d service<ref>https://www.mediawiki.org/wiki/Topic:Sqzq4kxj3o5q8b1k</ref> =====
 
 
 
<code>cd /etc/init.d/</code>
 
<code>cd /etc/init.d/</code>
  
Line 61: Line 61:
 
paste the following:
 
paste the following:
  
<nowiki>#</nowiki>! /bin/bash
+
    #!/bin/sh
<nowiki>#</nowiki>
+
    #
<nowiki>#</nowiki> parsoid start
+
    # chkconfig: 35 99 99
<nowiki>#</nowiki>
+
    # description: Node.js /opt/services/parsoid/api/server.js
<nowiki>#</nowiki> chkconfig: 345 86 14
+
    #
<nowiki>#</nowiki> description: parsoid
+
    . /etc/rc.d/init.d/functions
<nowiki>#</nowiki>
+
    USER="parsoid"
<nowiki>###</nowiki> BEGIN INIT INFO
+
    DAEMON="/usr/bin/node"
<nowiki>#</nowiki> Provides: $parsoid
+
    ROOT_DIR="/opt/services/parsoid/api"
<nowiki>###</nowiki> END INIT INFO
+
    SERVER="$ROOT_DIR/server.js"
<nowiki>#</nowiki> Source function library.
+
    LOG_FILE="$ROOT_DIR/server.js.log"
. /etc/init.d/functions
+
    LOCK_FILE="/var/lock/subsys/node-server"
rc=0
+
    do_start()
<nowiki>#</nowiki> See how we were called.
+
    {
case "$1" in
+
    if [ ! -f "$LOCK_FILE" ] ; then
start)
+
    echo -n $"Starting $SERVER: "
echo    starting parsoid
+
    runuser -l "$USER" -c "$DAEMON $SERVER >> $LOG_FILE &" && echo_success || echo_failure
cd /opt/parsoid
+
    RETVAL=$?
/sbin/runuser parsoid -s /bin/bash -c "nohup node /opt/parsoid/bin/server.js > /dev/null 2>&1 &"
+
    echo
$0 status
+
    [ $RETVAL -eq 0 ] && touch $LOCK_FILE
<nowiki>;;</nowiki>
+
    else
stop)
+
    echo "$SERVER is locked."
process=`ps -ef | grep 'node /opt/parsoid/bin/server.js'| grep -v grep | awk '{print $2}'`
+
    RETVAL=1
if [ "${process}" != <nowiki>''</nowiki> ]
+
    fi
then
+
      }
echo    stopping parsoid
+
        do_stop()
killall -9 node
+
      {
fi
+
    echo -n $"Stopping $SERVER: "
$0 status
+
    pid=`ps -aefw | grep "$DAEMON $SERVER" | grep -v " grep " | awk '{print $2}'`
<nowiki>;;</nowiki>
+
    kill -9 $pid > /dev/null 2>&1 && echo_success || echo_failure
status)
+
        RETVAL=$?
proc_find=`ps -ef | grep 'node /opt/parsoid/bin/server.js'| grep -v grep`
+
        echo
if [ "${proc_find}" = <nowiki>''</nowiki> ]
+
        [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE
then
+
    }
echo    parsoid is not running
+
    case "$1" in
else
+
    start)
echo parsoid is running: ${proc_find}
+
      do_start
fi
+
    ;;
<nowiki>;;</nowiki>
+
    stop)
restart|reload)
+
      do_stop
cd "$CWD"
+
    ;;
$0 status
+
    restart)
$0 stop
+
      do_stop
$0 start
+
      do_start
<nowiki>;;</nowiki>
+
    ;;
<nowiki>*</nowiki>)
+
    *)
echo $"Usage: $0 {start|stop|restart|reload|status}"
+
    echo "Usage: $0 {start|stop|restart}"
exit 1
+
    RETVAL=1
esac
+
        esac
exit $rc
+
    exit $RETVAL
 +
 
 
CTRL+X, Y, Enter
 
CTRL+X, Y, Enter
  
Line 121: Line 122:
 
Navigate to http://wiki.ssdcougars.tv:8000 and you should see a webpage loaded with links about Parsoid.
 
Navigate to http://wiki.ssdcougars.tv:8000 and you should see a webpage loaded with links about Parsoid.
  
4. Edit MediaWiki <code>LocalSettings.js</code>
+
NOTE: At the time of this writing, there was a page displayed about parsoid. Some browsers will show "SERVER TOOK TOO LONG TO RESPOND"
 +
 
 +
Use SSH and run <code>nmap -sT -O localhost</code>
 +
 
 +
Verify you see: <code>8000/tcp open http-alt</code>
 +
 
 +
4. Edit MediaWiki <code>LocalSettings.php</code>
  
 
  <nowiki>#</nowiki> Add more configuration options below.
 
  <nowiki>#</nowiki> Add more configuration options below.
Line 151: Line 158:
 
   
 
   
 
  );
 
  );
 +
 +
Now, if you did everything correctly, when you go to a Wikipage, you should see 'EDIT' AND 'EDIT SOURCE' on the page. 'EDIT' will take you to the visual editor.
 +
 +
If it didn't work, go through the steps again.
 +
 +
====== Sources ======
 +
<references />

Latest revision as of 17:13, 2 March 2017

Mediawiki's Visual Editor is not included with Mediawiki. It is an external add-on that requires a LOT of work to get working.

After you have MediaWiki installed (to a users' account NOT /var/www/mediawiki and working, do the following

  1. Get the Package [1]
    1. cd extensions
    2. git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/VisualEditor.git
    3. cd VisualEditor
    4. git submodule update --init
  2. Run This as Root from within the base wiki directory [2] curl --silent --location https://rpm.nodesource.com/setup_4.x | bash -
  3. Next we need to install Parsiod [3]
    1. cd /opt
    2. yum install -y policycoreutils-python
    3. mkdir src
    4. cd src
    5. git clone https://gerrit.wikimedia.org/r/p/mediawiki/services/parsoid
    6. cp -rv parsoid /opt/
    7. cd /opt/parsoid/
    8. npm install
    9. nano config.example.yaml
    10. FIND and EDIT below:
mwApis:
# This is the only required parameter,
# the URL of you MediaWiki API endpoint.
uri: 'http://wiki.ssdcougars.tv/api.php'
# The "domain" is used for communication with Visual Editor
# and RESTBase.  It defaults to the hostname portion of
# the `uri` property below, but you can manually set it
# to an arbitrary string.
domain: 'wiki.ssdcougars.tv'  # optional
# To specify a proxy (or proxy headers) specific to this prefix
# (which overrides defaultAPIProxyURI). Alternatively, set `proxy`
# to `null` to override and force no proxying when a default proxy
# has been set.
#proxy:
#    uri: 'http://my.proxy:1234/'
#    headers:  # optional
#        'X-Forwarded-Proto': 'https'

CTL+X, Y, and rename the file to config.yaml

Next we need to add a parsoid user and group.

groupadd parsoid

useradd -g parsoid parsoid

cd /opt/

chown -Rv parsoid:parsoid parsoid

chmod -Rv u+rw,g+r,o+r parsoid

chcon -Rv --type=system_u:object_r:usr_t:s0 parsoid **ForSELinux Only - We can ignore

Port 8000 should already be open on the hosted server, so we'll continue.

Create init.d service[4]

cd /etc/init.d/

nano parsoid

paste the following:

   #!/bin/sh
   #
   # chkconfig: 35 99 99
   # description: Node.js /opt/services/parsoid/api/server.js
   #
   . /etc/rc.d/init.d/functions
   USER="parsoid"
   DAEMON="/usr/bin/node"
   ROOT_DIR="/opt/services/parsoid/api"
   SERVER="$ROOT_DIR/server.js"
   LOG_FILE="$ROOT_DIR/server.js.log"
   LOCK_FILE="/var/lock/subsys/node-server"
   do_start()
   {
   if [ ! -f "$LOCK_FILE" ] ; then
   echo -n $"Starting $SERVER: "
   runuser -l "$USER" -c "$DAEMON $SERVER >> $LOG_FILE &" && echo_success || echo_failure
   RETVAL=$?
   echo
   [ $RETVAL -eq 0 ] && touch $LOCK_FILE
   else
   echo "$SERVER is locked."
   RETVAL=1
   fi
      }
       do_stop()
      {
   echo -n $"Stopping $SERVER: "
   pid=`ps -aefw | grep "$DAEMON $SERVER" | grep -v " grep " | awk '{print $2}'`
   kill -9 $pid > /dev/null 2>&1 && echo_success || echo_failure
       RETVAL=$?
       echo
       [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE
   }
   case "$1" in
   start)
     do_start
   ;;
   stop)
     do_stop
   ;;
   restart)
     do_stop
     do_start
   ;;
   *)
   echo "Usage: $0 {start|stop|restart}"
   RETVAL=1
       esac
   exit $RETVAL

CTRL+X, Y, Enter

chown parsoid parsoid

chmod 0755 parsoid

/etc/init.d/parsoid start

Navigate to http://wiki.ssdcougars.tv:8000 and you should see a webpage loaded with links about Parsoid.

NOTE: At the time of this writing, there was a page displayed about parsoid. Some browsers will show "SERVER TOOK TOO LONG TO RESPOND"

Use SSH and run nmap -sT -O localhost

Verify you see: 8000/tcp open http-alt

4. Edit MediaWiki LocalSettings.php

# Add more configuration options below.
#VisualEditor
require_once "$IP/extensions/VisualEditor/VisualEditor.php";
// Enable by default for everybody

$wgDefaultUserOptions['visualeditor-enable'] = 1;

// Don't allow users to disable it

#$wgHiddenPrefs[] = 'visualeditor-enable';

$wgVirtualRestConfig['modules']['parsoid'] = array(

// URL to the Parsoid instance

// Use port 8142 if you use the Debian package

'url' => 'http://wiki.ssdcougars.tv:8000',

// Parsoid "domain", see below (optional)

'domain' => 'wiki.ssdcougars.tv',

// Parsoid "prefix", see below (optional)

'prefix' => 'localhost'

);

Now, if you did everything correctly, when you go to a Wikipage, you should see 'EDIT' AND 'EDIT SOURCE' on the page. 'EDIT' will take you to the visual editor.

If it didn't work, go through the steps again.

Sources
  1. https://www.mediawiki.org/wiki/Extension:VisualEditor#Download
  2. https://nodejs.org/en/download/package-manager/#enterprise-linux-and-fedora
  3. https://www.centos.org/forums/viewtopic.php?f=47&t=53223&p=225372#p225372
  4. https://www.mediawiki.org/wiki/Topic:Sqzq4kxj3o5q8b1k