Add the Wikibase extension to the main wiki
authorTom Hughes <tom@compton.nu>
Sun, 16 Sep 2018 11:08:10 +0000 (12:08 +0100)
committerTom Hughes <tom@compton.nu>
Sun, 16 Sep 2018 11:08:10 +0000 (12:08 +0100)
cookbooks/mediawiki/templates/default/apache.erb
cookbooks/wiki/recipes/default.rb
cookbooks/wiki/templates/default/mw-ext-Wikibase.inc.php.erb [new file with mode: 0644]

index f41e4ca50e0304663b0138a4c73e7d9d4db1ff6f..51a4b1bf0819ec76d37837311f8e97fd82e58852 100644 (file)
@@ -34,7 +34,7 @@
 
   php_admin_value open_basedir <%= @directory %>/:/usr/share/php/:/dev/null:/tmp/
   #php_admin_value disable_functions "exec,shell_exec,system,passthru,popen,proc_open"
-  php_value memory_limit 368M
+  php_value memory_limit 500M
   php_value max_execution_time 240
   php_value upload_max_filesize 70M
   php_value post_max_size 100M
index a5b5a80982a73166f16a9b94fffd2cab99ceb5c9..e574a884f6544dec6c69164c4ba0d4e6acc58919 100644 (file)
@@ -71,6 +71,19 @@ mediawiki_extension "Scribunto" do
   template_cookbook "wiki"
 end
 
+mediawiki_extension "Wikibase" do
+  site "wiki.openstreetmap.org"
+  compose true
+  template "mw-ext-Wikibase.inc.php.erb"
+  template_cookbook "wiki"
+end
+
+mediawiki_extension "OsmWikibase" do
+  site "wiki.openstreetmap.org"
+  repository "git://github.com/nyurik/OsmWikibase.git"
+  reference "master"
+end
+
 cookbook_file "/srv/wiki.openstreetmap.org/osm_logo_wiki.png" do
   owner node[:mediawiki][:user]
   group node[:mediawiki][:group]
diff --git a/cookbooks/wiki/templates/default/mw-ext-Wikibase.inc.php.erb b/cookbooks/wiki/templates/default/mw-ext-Wikibase.inc.php.erb
new file mode 100644 (file)
index 0000000..d4c2b97
--- /dev/null
@@ -0,0 +1,89 @@
+<?php
+# DO NOT EDIT - This file is being maintained by Chef
+
+$wgEnableWikibaseRepo = true;
+$wgEnableWikibaseClient = true;
+
+require_once "$IP/extensions/Wikibase/repo/Wikibase.php";
+require_once "$IP/extensions/Wikibase/client/WikibaseClient.php";
+// Include Wikibase.searchindex.php to include string and text values in the full text index:
+require_once "$IP/extensions/Wikibase/repo/config/Wikibase.searchindex.php";
+
+# Adapted from $IP/extensions/Wikibase/repo/config/Wikibase.example.php
+call_user_func( function() {
+    global $wgContentHandlerUseDB,
+        $wgDBname,
+        $wgExtraNamespaces,
+        $wgNamespacesToBeSearchedDefault,
+        $wgWBRepoSettings;
+
+    $wgContentHandlerUseDB = true;
+
+    $baseNs = 120;
+
+    // Define custom namespaces. Use these exact constant names.
+    define( 'WB_NS_ITEM', $baseNs );
+    define( 'WB_NS_ITEM_TALK', $baseNs + 1 );
+    define( 'WB_NS_PROPERTY', $baseNs + 2 );
+    define( 'WB_NS_PROPERTY_TALK', $baseNs + 3 );
+
+    // Register extra namespaces.
+    $wgExtraNamespaces[WB_NS_ITEM] = 'Item';
+    $wgExtraNamespaces[WB_NS_ITEM_TALK] = 'Item_talk';
+    $wgExtraNamespaces[WB_NS_PROPERTY] = 'Property';
+    $wgExtraNamespaces[WB_NS_PROPERTY_TALK] = 'Property_talk';
+
+    // Tell Wikibase which namespace to use for which kind of entity
+    $wgWBRepoSettings['entityNamespaces']['item'] = WB_NS_ITEM;
+    $wgWBRepoSettings['entityNamespaces']['property'] = WB_NS_PROPERTY;
+
+    // Make sure we use the same keys on repo and clients, so we can share cached objects.
+    $wgWBRepoSettings['sharedCacheKeyPrefix'] = $wgDBname . ':WBL/' . rawurlencode( WBL_VERSION );
+
+    // Tell MediaWiki to search the item namespace
+    // $wgNamespacesToBeSearchedDefault[WB_NS_ITEM] = true;
+
+    // the special group includes all the sites in the specialSiteLinkGroups,
+    // grouped together in a 'Pages linked to other sites' section.
+    $wgWBRepoSettings['siteLinkGroups'] = [ 'special' ];
+
+    // these are the site_group codes as listed in the sites table
+    $wgWBRepoSettings['specialSiteLinkGroups'] = ['osm'];
+} );
+
+// Adapted from "$IP/extensions/Wikibase/client/ExampleSettings.php";
+
+// The global site ID by which this wiki is known on the repo.
+// Defaults to $wgDBname.
+// $wgWBClientSettings['siteGlobalID'] = "osm";
+// $wgWBClientSettings['injectRecentChanges'] = true;
+// $wgWBClientSettings['showExternalRecentChanges'] = true;
+
+$wgWBClientSettings['namespaces'] = [ NS_MAIN ];
+
+// no edit rights for anonymous users
+$wgGroupPermissions['*']['item-term'] = false;
+$wgGroupPermissions['*']['item-merge'] = false;
+$wgGroupPermissions['*']['item-redirect'] = false;
+$wgGroupPermissions['*']['property-term'] = false;
+$wgGroupPermissions['*']['property-create'] = false;
+
+// Logged-in users can edit statements, but disable merge/redirect/creating props
+$wgGroupPermissions['user']['item-term'] = true;
+$wgGroupPermissions['user']['item-merge'] = false;
+$wgGroupPermissions['user']['item-redirect'] = false;
+$wgGroupPermissions['user']['property-term'] = true;
+$wgGroupPermissions['user']['property-create'] = false;
+
+// data-admin group should be the only one creating properties
+$wgGroupPermissions['data-admin']['item-redirect'] = true;
+$wgGroupPermissions['data-admin']['item-merge'] = true;
+$wgGroupPermissions['data-admin']['property-create'] = true;
+
+
+// ---- This should be set once formatUrl property is created
+// $wgWBRepoSettings['formatterUrlProperty'] = 'P3';
+
+// ---- This should be removed once all needed initial items and properties are set up
+$wgNamespaceProtection[WB_NS_ITEM] = [ 'create-wb-items' ];
+$wgGroupPermissions['data-admin']['create-wb-items'] = true;