资讯专栏INFORMATION COLUMN

VisualEditor安装笔记

import. / 1608人阅读

摘要:强大劳动要求让人深深体会了最喜欢的维基百科等站点背后凝结了多少编辑者的汗水。语言的不友好,也使得维基百科的新用户助手率与编辑者比例已经迎来了死亡交叉,简单说就是看的人多,写的人少。

简述

许多新用户不会着手大幅度修改,而只是做些细节调整,不过仅仅阅读源代码就必须学标记语言了。当我们的用户在演示操作时,这把他们吓走了。早在 2004 年,社群开始一再认识到必须采用更好的编辑方式。因为人们的请求,更重要的是他们的需要,所以我们开发了可视化编辑器。Wiki 标记语言让新人害怕,这种程度会随着其他站点的迁离而加剧。如果我们不开发可视化编辑器,那么图表的走势会在接下来五年中变得更加糟糕。

                                                                      —MediaWiki.org

近日鄙人搭建了Mediawiki站点,苦于没有好的wiki编辑器,默认自带的居然只有加粗、link、字体等几个再简单不过的功能。强大劳动要求让人深深体会了最喜欢的维基百科等wiki站点背后凝结了多少编辑者的汗水。wiki语言的不友好,也使得维基百科的新用户助手率与编辑者比例已经迎来了死亡交叉,简单说就是看的人多,写的人少。维基基金会官方也意识到了这一点,于是乎2013年开始VisualEditor项目应运而生,较好得解决了这方面需求,降低了编辑Wiki页面的入门门槛。
VisualEdirot的原理,简单来说就是通过后台Parsoid 的程序来承担把wiki标记转化成html的任务,同时VisualEditor以插件的形式在MediaWiki中运行,用户可以在原来的编辑界面直接使用,编辑者角度上几乎无学习成本。
通过几天的研究,实现了插件的成功安装,过程较为繁复(开源都这鸟样,没办法),故简述一下安装流程,供日后备忘。

优点

可视化编辑

所见即所得

缺点

安装复杂

编辑时页面加载时间较长

默认仅能运用在Namespace 0 (main page)

当前为测试版本,不知道有什么坑

安装步骤

不再赘述MediaWiki的安装步骤了,仅说明VisualEditor的安装方法。
VisualEditor需要2个安装步骤:
第一,是安装Parsoid服务,务必注意此处为Parsoid服务而不是Parsoid插件,仅安装插件是无效的,VisualEditor是不能使用的(能打开,但是不能保存页面)。
第二,是安装VisualEditor插件,配置与Parsoid服务的关联后启用。

基本环境

|产品|版本|
|-|-|
|RHEL|7update3|
|MediaWiki|1.28.0|
|PHP|5.6.28 (apache2handler)|
|MySQL|5.6.34|
|ICU|52.1|
建议环境使用bitnami的包安装,相关环境和基础包都已经打包,非常方便。
为了减少麻烦,关闭了防火墙和SElinux,不赘述开启相关端口、防火墙、布尔值等。

安装Parsoid 1.配置EPEL源
cd /tmp
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh epel-release-latest-7.noarch.rpm
yum clean all
yum list
2.安装基础包Nodejs、NPM等基础包
yum install  -y nodejs npm  git policycoreutils-python
3.配置淘宝NPM镜像源
npm install -g cnpm --registry=https://registry.npm.taobao.org
4.从Git仓库下载Parsoid最新版本
cd ~
git clone https://gerrit.wikimedia.org/r/p/mediawiki/services/parsoid
5.复制到/opt目录下
cp -rv ~/parsoid /opt/
6.进入/opt/parsoid目录
cd /opt/parsoid/
7.安装Parsoid使用的Node.js包

此处使用淘宝镜像的cnpm命令,加速包下载。原站点从国内访问的速度,真是无语了。

cnpm install
8. 修改config.yaml配置

config.yaml 在/Parsoid目录下,默认是 config.example.yaml文件,自行复制一个。
修改

        mwApis:
        - # This is the only required parameter,
          # the URL of you MediaWiki API endpoint.
          uri: "http://站点IP/mediawiki/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: "localhost"  # optional
9. 启动服务
node bin/server.js
10. 测试验证

Parsoid启动后,将自动启用http服务,可以通过几种方式验证。
第一、主机端口验证

netstat -tunlp | grep 8000

第二、访问http://站点IP:8000,正确配置的情况下可以见到以下页面。

11. 设置Parsoid服务自启动

第一、手工新建parsoid服务环境配置文件
新建配置文件

touch /opt/parsoid/parsoid.env
vim /opt/parsoid/parsoid.env

按照一下文件添加内容

PORT=8000
NODE_PATH=/opt/parsoid/node_modules

第二、手工新建parsoid.service服务
新建配置文件

touch /usr/lib/systemd/system/parsoid.servicevim /opt/parsoid/parsoid.env
vim /usr/lib/systemd/system/parsoid.service

按照以下文件添加内容

[Unit]
Description=Mediawiki Parsoid web service on node.js
Documentation=http://www.mediawiki.org/wiki/Parsoid
Wants=local-fs.target network.target
After=local-fs.target network.target

[Install]
WantedBy=multi-user.target

[Service]
Type=simple
User=nobody
Group=nobody
WorkingDirectory=/opt/parsoid
EnvironmentFile=-/opt/parsoid/parsoid.env
ExecStart=/usr/local/bin/node /opt/parsoid/bin/server.js
KillMode=process
Restart=on-success
PrivateTmp=true
StandardOutput=syslog

第三、启动parsoid.service服务

systemctl start parsoid.service

第四、设置parsoid.service服务自启动

systemctl enable parsoid.service
安装VisualEditor 1. 从Git仓库下载VisualEditor最新版本
cd /opt/mediawiki/mediawiki-1.28.0-0/apps/mediawiki/htdocs/extensions
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/VisualEditor.git
2. 修改LocalSettings.php配置
cd /opt/mediawiki/mediawiki-1.28.0-0/apps/mediawiki/htdocs
vim LocalSettings.php

在 LocalSettings.php的尾部追加以下配置

wfLoadExtension( "VisualEditor" );

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

// Optional: Set VisualEditor as the default for anonymous users
// otherwise they will have to switch to VE
// $wgDefaultUserOptions["visualeditor-editor"] = "visualeditor";

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

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

综上安装部分基本完成。
在原先的编辑页面上,可以看到VirsualEditor标签条目了,且相关页面均为所见即所得的形式。

参考资料

VisualEditor测试页面,来源于Mediawiki官网
https://www.mediawiki.org/w/i...
VisualEditor用户指南,来源于Mediawiki官网
https://www.mediawiki.org/wik...
VisualEditor插件站点(含下载),来源于Mediawiki官网
https://www.mediawiki.org/wik...
Parsoid服务介绍
https://www.mediawiki.org/wik...
Parsoid服务(service)安装指南
https://www.mediawiki.org/wik...

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/22418.html

相关文章

  • 前端开发学习笔记 - 1. Node.JS安装笔记

    摘要:安装笔记官网下载文件官网地址安装程序双击进行安装。点击下一步程序安装的一个好的习惯是,把程序安装到盘或者盘的目录下面。 Node.JS安装笔记 Node.js® is a JavaScript runtime built on Chromes V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O mo...

    jemygraw 评论0 收藏0
  • 前端开发学习笔记 - 1. Node.JS安装笔记

    摘要:安装笔记官网下载文件官网地址安装程序双击进行安装。点击下一步程序安装的一个好的习惯是,把程序安装到盘或者盘的目录下面。 Node.JS安装笔记 Node.js® is a JavaScript runtime built on Chromes V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O mo...

    BingqiChen 评论0 收藏0
  • 前端开发学习笔记 - 1. Node.JS安装笔记

    摘要:安装笔记官网下载文件官网地址安装程序双击进行安装。点击下一步程序安装的一个好的习惯是,把程序安装到盘或者盘的目录下面。 Node.JS安装笔记 Node.js® is a JavaScript runtime built on Chromes V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O mo...

    Bryan 评论0 收藏0
  • 制作Deepin深度系统镜像且快速安装笔记本电脑中

    摘要:具体的系统的安装后面老蒋再记录分享。我们已经制作好盘系统盘深度系统,那就准备安装到我们准备好的笔记本电脑中。老蒋这里有准备自己比较旧的配置较低的笔记本电脑,安装系统速度确实比较慢,所以这里我准备安装深度系统,以及以后运行一些软件。由于工作和业务需要,我们很多朋友会选择在Linux桌面系统中运行软件。在众多的Linux桌面系统中,我们国产的Deepin深度系统在UI上面是做的比较好的,而且陆续...

    baoxl 评论0 收藏0

发表评论

0条评论

import.

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<