Ori.livneh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/63440


Change subject: Add mediawiki::parsoid class
......................................................................

Add mediawiki::parsoid class

This change adds a mediawiki::parsoid class which configures a Parsoid HTTP
service on the Vagrant virtual machine.

Change-Id: Ib81213c91ecc9af5ddf5827d886e6a5f67d17f7e
---
A puppet/modules/mediawiki/manifests/parsoid.pp
A puppet/modules/mediawiki/templates/parsoid.conf.erb
A puppet/modules/mediawiki/templates/parsoid.localsettings.js.erb
3 files changed, 120 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/vagrant 
refs/changes/40/63440/1

diff --git a/puppet/modules/mediawiki/manifests/parsoid.pp 
b/puppet/modules/mediawiki/manifests/parsoid.pp
new file mode 100644
index 0000000..deffebe
--- /dev/null
+++ b/puppet/modules/mediawiki/manifests/parsoid.pp
@@ -0,0 +1,88 @@
+# == Class: mediawiki::parsoid
+#
+# Parsoid is a wiki runtime which can translate back and forth between
+# MediaWiki's wikitext syntax and an equivalent HTML / RDFa document model with
+# better support for automated processing and visual editing. Its main user
+# currently is the visual editor project.
+#
+# === Parameters
+#
+# [*dir*]
+#   Install Parsoid to this directory (default: '/srv/parsoid').
+#
+# [*port*]
+#   The Parsoid web service will listen on this port.
+#
+# [*use_php_preprocessor*]
+#   If true, use the PHP pre-processor to expand templates via the
+#   MediaWiki API (default: true).
+#
+# [*use_selser*]
+#   Use selective serialization (default: false).
+#
+# [*allow_cors*]
+#   Domains that should be permitted to make cross-domain requests
+#   (default: '*'). If false or undefined, disables CORS.
+#
+# === Examples
+#
+#  class { 'mediawiki::parsoid':
+#    port => 8100,
+#  }
+#
+class mediawiki::parsoid(
+       $dir                  = '/srv/parsoid',
+       $port                 = 8000,
+       $use_php_preprocessor = true,
+       $use_selser           = true,
+       $allow_cors           = '*',
+) {
+       include mediawiki
+
+       package { 'nodejs':
+               ensure => '0.8.2-1chl1~precise1',
+       }
+
+       package { 'npm':
+               ensure => '1.1.39-1chl1~precise1',
+       }
+
+       @git::clone { 'mediawiki/extensions/Parsoid':
+               directory  => $dir,
+               require    => Package['nodejs', 'npm'],
+       }
+
+       exec { 'npm install parsoid':
+               command   => 'npm install',
+               onlyif    => 'npm list --json | grep -q \'"missing": true\'',
+               cwd       => "${dir}/js",
+               require   => Git::Clone['mediawiki/extensions/Parsoid'],
+       }
+
+       file { "${dir}/js/api/localsettings.js":
+               content => template('mediawiki/parsoid.localsettings.js.erb'),
+               require => Git::Clone['mediawiki/extensions/Parsoid'],
+       }
+
+       file { '/etc/init/parsoid.conf':
+               ensure  => present,
+               content => template('mediawiki/parsoid.conf.erb'),
+               require => Exec['npm install parsoid'],
+       }
+
+       file { '/etc/init.d/parsoid':
+               ensure  => link,
+               target  => '/lib/init/upstart-job',
+               require => File['/etc/init/parsoid.conf'],
+       }
+
+       service { 'parsoid':
+               ensure    => running,
+               provider  => 'upstart',
+               subscribe => File['/etc/init/parsoid.conf', 
"${dir}/js/api/localsettings.js"],
+               require   => [
+                       Exec['npm install parsoid'],
+                       File['/etc/init/parsoid.conf', 
"${dir}/js/api/localsettings.js"],
+               ],
+       }
+}
diff --git a/puppet/modules/mediawiki/templates/parsoid.conf.erb 
b/puppet/modules/mediawiki/templates/parsoid.conf.erb
new file mode 100644
index 0000000..ef29a68
--- /dev/null
+++ b/puppet/modules/mediawiki/templates/parsoid.conf.erb
@@ -0,0 +1,20 @@
+# vim: set ft=upstart:
+
+# Upstart job configuration for Parsoid
+# This file is managed by Puppet
+
+description "Parsoid HTTP service"
+
+start on (local-filesystems and net-device-up IFACE!=lo)
+stop on runlevel [!2345]
+
+setuid "www-data"
+setgid "www-data"
+
+env VCAP_APP_PORT="<%= @port %>"
+env NODE_PATH="<%= @parsoid_path %>/js/node_modules"
+
+chdir "<%= @dir %>/js"
+exec node api/server.js 
+
+respawn
diff --git a/puppet/modules/mediawiki/templates/parsoid.localsettings.js.erb 
b/puppet/modules/mediawiki/templates/parsoid.localsettings.js.erb
new file mode 100644
index 0000000..e1b1e97
--- /dev/null
+++ b/puppet/modules/mediawiki/templates/parsoid.localsettings.js.erb
@@ -0,0 +1,12 @@
+/**
+ * Parsoid web service configuration file.
+ * This file is managed by Puppet.
+ */
+exports.setup = function( parsoidConfig ) {
+    parsoidConfig.setInterwiki( 'localhost', '<%= 
scope.lookupvar("mediawiki::server_url") %>/w/api.php' );
+    parsoidConfig.usePHPPreProcessor = <%= @use_php_preprocessor %>;
+    parsoidConfig.useSelser = <%= @use_selser %>;
+    <%- if @allow_cors -%>
+    parsoidConfig.allowCORS = '<%= @allow_cors %>';
+    <%- end %>
+};

-- 
To view, visit https://gerrit.wikimedia.org/r/63440
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib81213c91ecc9af5ddf5827d886e6a5f67d17f7e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/vagrant
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to