]> git.openstreetmap.org Git - chef.git/commitdiff
mediawiki: Add visualeditor support
authorGrant Slater <git@firefishy.com>
Sat, 2 Jan 2016 09:41:05 +0000 (09:41 +0000)
committerGrant Slater <git@firefishy.com>
Sat, 2 Jan 2016 09:41:05 +0000 (09:41 +0000)
cookbooks/mediawiki/providers/site.rb
cookbooks/mediawiki/recipes/default.rb
cookbooks/mediawiki/templates/default/mw-ext-VisualEditor.inc.php [new file with mode: 0644]
cookbooks/mediawiki/templates/default/parsoid-settings.js.erb [new file with mode: 0644]

index 52ae3224c841b897e8777c86264ddd8342521530..c422b9c2f6d6e224d1e2c9b2a74ee8e8239690d4 100644 (file)
@@ -413,6 +413,12 @@ action :create do
     update_site false
   end
 
+  mediawiki_extension "VisualEditor" do
+    site new_resource.name
+    template "mw-ext-VisualEditor.inc.php.erb"
+    update_site false
+  end
+
   cookbook_file "#{site_directory}/cc-wiki.png" do
     cookbook "mediawiki"
     owner node[:mediawiki][:user]
index cadefe60c48efc250b98d3f959bb86aed616da74..34c4f0ab686659c722b3d2abf7fc296d9ef1bb70 100644 (file)
@@ -49,6 +49,19 @@ package "xz-utils"
 package "curl"
 package "parsoid"
 
+template "/etc/mediawiki/parsoid/settings.js" do
+  source "parsoid-settings.js.erb"
+  owner "root"
+  group "root"
+  mode 0644
+end
+
+service "parsoid" do
+  action [:enable]
+  supports :status => false, :restart => true, :reload => false
+  subscribes :restart, "template[/etc/mediawiki/parsoid/settings.js]"
+end
+
 link "/etc/php5/apache2/conf.d/20-wikidiff2.ini" do
   to "../../mods-available/wikidiff2.ini"
 end
diff --git a/cookbooks/mediawiki/templates/default/mw-ext-VisualEditor.inc.php b/cookbooks/mediawiki/templates/default/mw-ext-VisualEditor.inc.php
new file mode 100644 (file)
index 0000000..58209d5
--- /dev/null
@@ -0,0 +1,13 @@
+<?php
+$wgVirtualRestConfig['modules']['parsoid'] = array(
+  'url' => 'http://<%= @mediawiki[:name] %>:8142'
+);
+$wgVirtualRestConfig['modules']['parsoid']['forwardCookies'] = true;
+
+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';
diff --git a/cookbooks/mediawiki/templates/default/parsoid-settings.js.erb b/cookbooks/mediawiki/templates/default/parsoid-settings.js.erb
new file mode 100644 (file)
index 0000000..8a5b93f
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * This is a sample configuration file.
+ *
+ * Copy this file to localsettings.js and edit that file to fit your needs.
+ *
+ * Also see:
+ * - api/server.js for more information about passing config files via
+ *   the commandline.
+ * - lib/mediawiki.ParsoidConfig.js all the properties
+ *   that you can configure here. Not all properties are
+ *   documented here.
+ */
+'use strict';
+
+exports.setup = function(parsoidConfig) {
+       // Set your own user-agent string
+       // Otherwise, defaults to "Parsoid/<current-version-defined-in-package.json>"
+       //parsoidConfig.userAgent = "My-User-Agent-String";
+
+       // The URL of your MediaWiki API endpoint.
+       //parsoidConfig.setMwApi({ prefix: 'localhost', uri: 'http://localhost/w/api.php' });
+
+       <% node[:mediawiki][:sites].each do |mediawiki_name| -%>
+  parsoidConfig.setMwApi({ uri: 'http://<%= @mediawiki_name %>/w/api.php' });
+       <% end -%>
+
+       // To specify a proxy (or proxy headers) specific to this prefix (which
+       // overrides defaultAPIProxyURI) use:
+       /*
+       parsoidConfig.setMwApi({
+               prefix: 'localhost',
+               uri: 'http://localhost/w/api.php',
+               // set `proxy` to `null` to override and force no proxying.
+               proxy: {
+                       uri: 'http://my.proxy:1234/',
+                       headers: { 'X-Forwarded-Proto': 'https' } // headers are optional
+               }
+       });
+       */
+
+       // We pre-define wikipedias as 'enwiki', 'dewiki' etc. Similarly
+       // for other projects: 'enwiktionary', 'enwikiquote', 'enwikibooks',
+       // 'enwikivoyage' etc. (default true)
+       //parsoidConfig.loadWMF = false;
+
+       // A default proxy to connect to the API endpoints.
+       // Default: undefined (no proxying).
+       // Overridden by per-wiki proxy config in setMwApi.
+       //parsoidConfig.defaultAPIProxyURI = 'http://proxy.example.org:8080';
+
+       // Enable debug mode (prints extra debugging messages)
+       //parsoidConfig.debug = true;
+
+       // Use the PHP preprocessor to expand templates via the MW API (default true)
+       //parsoidConfig.usePHPPreProcessor = false;
+
+       // Use selective serialization (default false)
+       parsoidConfig.useSelser = true;
+
+       // Allow cross-domain requests to the API (default '*')
+       // Sets Access-Control-Allow-Origin header
+       // disable:
+       //parsoidConfig.allowCORS = false;
+       // restrict:
+       //parsoidConfig.allowCORS = 'some.domain.org';
+
+       // Set to true for using the default performance metrics reporting to statsd
+       // If true, provide the statsd host/port values
+       /*
+       parsoidConfig.useDefaultPerformanceTimer = true;
+       parsoidConfig.txstatsdHost = 'statsd.domain.org';
+       parsoidConfig.txstatsdPort = 8125;
+       */
+
+       // Alternatively, define performanceTimer as follows:
+       /*
+       parsoidConfig.performanceTimer = {
+               timing: function(metricName, time) { }, // do-something-with-it
+               count: function(metricName, value) { }, // do-something-with-it
+       };
+       */
+
+       // How often should we emit a heap sample? Time in ms.
+       // This setting is only relevant if you have enabled
+       // performance monitoring either via the default metrics
+       // OR by defining your own performanceTimer properties
+       //parsoidConfig.heapUsageSampleInterval = 5 * 60 * 1000;
+
+       // Allow override of port/interface:
+       //parsoidConfig.serverPort = 8000;
+       //parsoidConfig.serverInterface = '127.0.0.1';
+
+       // The URL of your LintBridge API endpoint
+       //parsoidConfig.linterAPI = 'http://lintbridge.wmflabs.org/add';
+
+       // Require SSL certificates to be valid (default true)
+       // Set to false when using self-signed SSL certificates
+       //parsoidConfig.strictSSL = false;
+
+       // Use a different server for CSS style modules.
+       // Set to true to use bits.wikimedia.org, or to a string with the URI.
+       // Leaving it undefined (the default) will use the same URI as the MW API,
+       // changing api.php for load.php.
+       //parsoidConfig.modulesLoadURI = true;
+
+       // Suppress some warnings from the Mediawiki API
+       // (defaults to suppressing warnings which the Parsoid team knows to
+       // be harmless)
+       //parsoidConfig.suppressMwApiWarnings = /annoying warning|other warning/;
+};