]> git.openstreetmap.org Git - chef.git/blob - cookbooks/wiki/templates/default/mw-ext-Wikibase.inc.php.erb
Merge remote-tracking branch 'tigerfell/pr257'
[chef.git] / cookbooks / wiki / templates / default / mw-ext-Wikibase.inc.php.erb
1 <?php
2 # DO NOT EDIT - This file is being maintained by Chef
3
4 use MediaWiki\MediaWikiServices;
5 use Wikibase\Lib\SettingsArray;
6
7 $wgEnableWikibaseRepo = true;
8 $wgEnableWikibaseClient = true;
9
10 wfLoadExtension( 'WikibaseRepository', "$IP/extensions/Wikibase/extension-repo.json" );
11 wfLoadExtension( 'WikibaseClient', "$IP/extensions/Wikibase/extension-client.json" );
12 // Include Wikibase.searchindex.php to include string and text values in the full text index:
13 require_once "$IP/extensions/Wikibase/repo/config/Wikibase.searchindex.php";
14
15 # Adapted from $IP/extensions/Wikibase/repo/config/Wikibase.example.php
16 call_user_func( function() {
17     global $wgContentHandlerUseDB,
18         $wgDBname,
19         $wgExtraNamespaces,
20         $wgNamespacesToBeSearchedDefault,
21         $wgWBRepoSettings;
22
23     $baseNs = 120;
24
25     // Define custom namespaces. Use these exact constant names.
26     define( 'WB_NS_ITEM', $baseNs );
27     define( 'WB_NS_ITEM_TALK', $baseNs + 1 );
28     define( 'WB_NS_PROPERTY', $baseNs + 2 );
29     define( 'WB_NS_PROPERTY_TALK', $baseNs + 3 );
30
31     // Register extra namespaces.
32     $wgExtraNamespaces[WB_NS_ITEM] = 'Item';
33     $wgExtraNamespaces[WB_NS_ITEM_TALK] = 'Item_talk';
34     $wgExtraNamespaces[WB_NS_PROPERTY] = 'Property';
35     $wgExtraNamespaces[WB_NS_PROPERTY_TALK] = 'Property_talk';
36
37     $wgWBRepoSettings['entitySources'] = function ( SettingsArray $settings ) {
38         global $wgServer;
39
40         $entityNamespaces = [
41             'item' => WB_NS_ITEM,
42             'property' => WB_NS_PROPERTY,
43         ];
44
45         $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
46         $hookContainer->run( 'WikibaseRepoEntityNamespaces', [ &$entityNamespaces ] );
47
48         return [
49              $settings->getSetting( 'localEntitySourceName' ) => [
50                                     'entityNamespaces' => $entityNamespaces,
51                                     'repoDatabase' => false,
52                                     'baseUri' => $wgServer . '/entity/',
53                                     'rdfNodeNamespacePrefix' => 'wd',
54                                     'rdfPredicateNamespacePrefix' => '',
55                                     'interwikiPrefix' => '',
56              ],
57         ];
58     };
59
60     // Make sure we use the same keys on repo and clients, so we can share cached objects.
61     $wgWBRepoSettings['sharedCacheKeyPrefix'] = $wgDBname . ':WBL';
62     $wgWBRepoSettings['sharedCacheKeyGroup'] = $wgDBname;
63
64     // Include Wikibase items in the regular search result by default
65     $wgNamespacesToBeSearchedDefault[WB_NS_ITEM] = true;
66
67     // the special group includes all the sites in the specialSiteLinkGroups,
68     // grouped together in a 'Pages linked to other sites' section.
69     $wgWBRepoSettings['siteLinkGroups'] = [ 'special' ];
70
71     // these are the site_group codes as listed in the sites table
72     $wgWBRepoSettings['specialSiteLinkGroups'] = ['osm'];
73
74     // This option will start working in Wikibase v1.33 release. Noop until then.
75     // https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/Wikibase/+/469872/
76     $wgWBRepoSettings['enableEntitySearchUI'] = false;
77
78 } );
79
80 // Adapted from "$IP/extensions/Wikibase/client/config/WikibaseClient.example.php";
81
82 // The global site ID by which this wiki is known on the repo.
83 // Defaults to $wgDBname.
84 // $wgWBClientSettings['siteGlobalID'] = "osm";
85
86 $wgWBClientSettings['injectRecentChanges'] = true;
87 $wgWBClientSettings['showExternalRecentChanges'] = true;
88
89 // Base URL for building links to the repository.
90 // Assumes your wiki is setup as "http://repo.example.org/wiki/"
91 // This can be protocol relative, such as "//www.wikidata.org"
92 $wgWBClientSettings['repoUrl'] = "https://wiki.openstreetmap.org";
93
94 // This setting is optional if you have the same type of setup for your
95 // repo and client.  It will default to using the client's $wgArticlePath setting,
96 // and if you do not have $wgArticlePath set anywhere, MediaWiki has a default for it.
97 $wgWBClientSettings['repoArticlePath'] = "/wiki/$1";
98
99 // Assuming your wiki is setup with such script path as "http://repo.example.org/w/api.php". This
100 // should be the same as the $wgScriptPath setting if you have it set in your repo. If $wgScriptPath
101 // is not set, then MediaWiki assumes a default.
102 //
103 // If your client and repo are setup in the same way, then the below setting is optional and will
104 // default to what you have $wgScriptPath set in the client.
105 $wgWBClientSettings['repoScriptPath'] = "/w";
106
107 // Tell the client which namespace ID on the repo holds which type of entity.
108 $baseRepoNs = 120;
109
110 define( 'WB_REPO_NS_ITEM', $baseRepoNs );
111 define( 'WB_REPO_NS_PROPERTY', $baseRepoNs + 2 );
112
113 $wgWBClientSettings['entitySources'] = [
114         'local' => [
115                 'repoDatabase' => $wgDBname,
116                 'baseUri' => $wgWBClientSettings['repoUrl'] . '/entity',
117                 'entityNamespaces' => [
118                         'item' => WB_REPO_NS_ITEM,
119                         'property' => WB_REPO_NS_PROPERTY
120                 ],
121                 'rdfNodeNamespacePrefix' => 'wd',
122                 'rdfPredicateNamespacePrefix' => '',
123                 'interwikiPrefix' => '',
124         ],
125 ];
126
127 $wgWBClientSettings['namespaces'] = [ NS_MAIN ];
128
129 // Avoid complaints that nobody seems to know the cause off...
130 $wgWBClientSettings['entityUsagePerPageLimit'] = 500;
131                                   
132 // no edit rights for anonymous users
133 $wgGroupPermissions['*']['item-term'] = false;
134 $wgGroupPermissions['*']['item-merge'] = false;
135 $wgGroupPermissions['*']['item-redirect'] = false;
136 $wgGroupPermissions['*']['property-term'] = false;
137 $wgGroupPermissions['*']['property-create'] = false;
138
139 // Logged-in users can edit statements, but disable merge/redirect/creating props
140 $wgGroupPermissions['user']['item-term'] = true;
141 $wgGroupPermissions['user']['item-merge'] = false;
142 $wgGroupPermissions['user']['item-redirect'] = false;
143 $wgGroupPermissions['user']['property-term'] = true;
144 $wgGroupPermissions['user']['property-create'] = false;
145
146 // data-admin group should be the only one creating properties
147 $wgGroupPermissions['data-admin']['item-redirect'] = true;
148 $wgGroupPermissions['data-admin']['item-merge'] = true;
149 $wgGroupPermissions['data-admin']['property-create'] = true;
150
151
152 // See https://www.mediawiki.org/wiki/Wikibase/Installation/Advanced_configuration#Define_links_for_external_identifiers
153 $wgWBRepoSettings['formatterUrlProperty'] = 'P8';