]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/wiki/templates/default/mw-ext-Wikibase.inc.php.erb
Use new style extension loading for Wikibase
[chef.git] / cookbooks / wiki / templates / default / mw-ext-Wikibase.inc.php.erb
index dc1188c4baeccec96537b0c36c9d97fa89618db7..efb01cf775da1cb2af7ba8062d248cb89b2e8864 100644 (file)
@@ -4,8 +4,8 @@
 $wgEnableWikibaseRepo = true;
 $wgEnableWikibaseClient = true;
 
-require_once "$IP/extensions/Wikibase/repo/Wikibase.php";
-require_once "$IP/extensions/Wikibase/client/WikibaseClient.php";
+wfLoadExtension( 'WikibaseRepository', "$IP/extensions/Wikibase/extension-repo.json" );
+wfLoadExtension( 'WikibaseClient', "$IP/extensions/Wikibase/extension-client.json" );
 // 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";
 
@@ -38,10 +38,10 @@ call_user_func( function() {
     $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 );
+    $wgWBRepoSettings['sharedCacheKeyPrefix'] = $wgDBname;
 
-    // Tell MediaWiki to search the item namespace
-    // $wgNamespacesToBeSearchedDefault[WB_NS_ITEM] = true;
+    // Include Wikibase items in the regular search result by default
+    $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.
@@ -49,18 +49,65 @@ call_user_func( function() {
 
     // these are the site_group codes as listed in the sites table
     $wgWBRepoSettings['specialSiteLinkGroups'] = ['osm'];
+
+    // This option will start working in Wikibase v1.33 release. Noop until then.
+    // https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/Wikibase/+/469872/
+    $wgWBRepoSettings['enableEntitySearchUI'] = false;
+
 } );
 
-// Adapted from "$IP/extensions/Wikibase/client/ExampleSettings.php";
+// Adapted from "$IP/extensions/Wikibase/client/config/WikibaseClient.example.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['injectRecentChanges'] = true;
+$wgWBClientSettings['showExternalRecentChanges'] = true;
+
+// Base URL for building links to the repository.
+// Assumes your wiki is setup as "http://repo.example.org/wiki/"
+// This can be protocol relative, such as "//www.wikidata.org"
+$wgWBClientSettings['repoUrl'] = "https://wiki.openstreetmap.org";
+
+// This setting is optional if you have the same type of setup for your
+// repo and client.  It will default to using the client's $wgArticlePath setting,
+// and if you do not have $wgArticlePath set anywhere, MediaWiki has a default for it.
+$wgWBClientSettings['repoArticlePath'] = "/wiki/$1";
+
+// Assuming your wiki is setup with such script path as "http://repo.example.org/w/api.php". This
+// should be the same as the $wgScriptPath setting if you have it set in your repo. If $wgScriptPath
+// is not set, then MediaWiki assumes a default.
+//
+// If your client and repo are setup in the same way, then the below setting is optional and will
+// default to what you have $wgScriptPath set in the client.
+$wgWBClientSettings['repoScriptPath'] = "/w";
+
+// Tell the client which namespace ID on the repo holds which type of entity.
+$baseRepoNs = 120;
+
+define( 'WB_REPO_NS_ITEM', $baseRepoNs );
+define( 'WB_REPO_NS_PROPERTY', $baseRepoNs + 2 );
+
+$wgWBClientSettings['entitySources'] = [
+        'local' => [
+                'repoDatabase' => 'repo',
+                'baseUri' => $wgWBClientSettings['repoUrl'] . '/entity',
+                'entityNamespaces' => [
+                        'item' => WB_REPO_NS_ITEM,
+                        'property' => WB_REPO_NS_PROPERTY
+                ],
+                'rdfNodeNamespacePrefix' => 'wd',
+                'rdfPredicateNamespacePrefix' => '',
+                'interwikiPrefix' => '',
+        ],
+];
 
 $wgWBClientSettings['namespaces'] = [ NS_MAIN ];
 
+// Avoid complaints that nobody seems to know the cause off...
+$wgWBClientSettings['entityUsagePerPageLimit'] = 500;
+                                  
 // no edit rights for anonymous users
 $wgGroupPermissions['*']['item-term'] = false;
 $wgGroupPermissions['*']['item-merge'] = false;
@@ -83,7 +130,3 @@ $wgGroupPermissions['data-admin']['property-create'] = true;
 
 // See https://www.mediawiki.org/wiki/Wikibase/Installation/Advanced_configuration#Define_links_for_external_identifiers
 $wgWBRepoSettings['formatterUrlProperty'] = 'P8';
-
-// ---- 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;