Wikibase/Installation/Advanced configuration

From mediawiki.org
Jump to navigation Jump to search

Introduction[edit]

This page describes advanced configuration for Wikibase's Client and Repository. If you haven't yet installed Wikibase, first consult the installation instructions.

Making changes to the client and repository configurations involves adding r changing $wgWBClientSettings or $wgWBRepoSettings lines (respectively) in the MediaWiki LocalSettings.php file. This document covers only some options; for an exhaustive list, consult full documentation (defaults: lient settings file and repo settings file ).

Note that the prefix "wg" in $wgWBRepoSettings is distinct from that of other extensions, which may use the prefix $eg. The difference is important; your configuration will fail if you use a different prefix.

The parameters you set in LocalSettings.php override those found in the aforementioned files. Place any configuration settings you wish to override at the bottom of your LocalSettings.php file.

Example:

$wgWBRepoSettings['dataRightsUrl'] = 'https://creativecommons.org/publicdomain/zero/1.0/';

The line above sets the parameter dataRightsUrl of the Wikibase Repository (because $wgWBRepoSettings) to the value https://creativecommons.org/publicdomain/zero/1.0/.

Wikibase repository[edit]

Define links for external identifiers[edit]

In order to add links for external identifiers in the main interface (as seen in this Wikidata example Q85#P214 and config P214#P1630):

  1. Create a property of type String (e.g., P214#P1630).
  2. Get the property's ID (e.g., P5).
  3. Configure in LocalSettings.php:
    $wgWBRepoSettings['formatterUrlProperty'] = 'P5';
    
  4. If adding the setting does not work on its own, run the following script:
    php extensions/Wikibase/repo/maintenance/rebuildPropertyInfo.php --rebuild-all --force
    
  5. Now users can define the pattern of the links, with $1 replaced by the identifier provided by each individual item.

Canonical URIs can be similarly configured in RDF dumps (prefixes wdtn:, psn:, pqn:, prn:), as seen on Wikidata with the property P1921 and used on the property P214#P1921). The configuration is similar to the parameter $wgWBRepoSettings['canonicalUriProperty'].

Optional settings[edit]

propertyOrderUrl allows custom ordering of properties using the LUA function mw.wikibase.orderProperties as explained in Manual:Interface/Wikibase-SortedProperties

$wgWBRepoSettings['propertyOrderUrl'] = $wgServer. $wgScriptPath . '/index.php?title=MediaWiki:Wikibase-SortedProperties&action=raw&sp_ver=1';

statementSections allows grouping items into several sections. For instance, to replicate how Wikidata separates External identifiers from the rest of its properties, set:

$wgWBRepoSettings['statementSections'] = [
	'item' => [
		'statements' => null,
		'identifiers' => [
			'type' => 'dataType',
			'dataTypes' => [ 'external-id' ],
		],
	],
];

Then set the name of the label on the MediaWiki:Wikibase-statementsection-identifiers page.

Available configuration settings[edit]

All available configuration settings are noted in the master configuration document.

Maintenance scripts[edit]

Wikibase provides a few maintenance scripts which can be found in the maintenance subdirectory. Wikibase must be installed in MediaWiki's extensions directory, extensions/Wikibase. If it's installed elsewhere, you can set the MW_INSTALL_PATH environment variable to the path of your MediaWiki installation and the scripts will use it.

Repo[edit]

A common way to set the environment for scripts called in cron jobs: env 'MW_INSTALL_PATH=/var/www/repo' php /path/to/php/script

populateSitesTable.php[edit]

This script will load the wiki matrix from meta.wikimedia.org and use that information to populate the local sites table. This provides Wikibase with the information it needs to connect to other wikis, such as for the purpose of suggesting or normalizing page titles when creating site links.

From the MediaWiki install folder, run:

php extensions/Wikibase/lib/maintenance/populateSitesTable.php

To insert a new Wikibase client without using the wiki matrix, see Manual:Sites table.


dispatchChanges.php[edit]

This script updates the client wiki's local items cache.

1. Provide the script with the information it needs about the client wiki databases.

LocalSettings.php:

$wgLocalDatabases = $wgWBRepoSettings['localClientDatabases'] = [ 'enwiki', 'fawiki' ];

2. Run the dispatch changes script.

php extensions/Wikibase/repo/maintenance/dispatchChanges.php

Note that this script performs the synchronization; the repo and the client will remain in sync only so long as this script is running.

pruneChanges.php[edit]

This script allows you to prune the Wikibase changes table. When run with no parameters, it will delete all changes older than 7 days. You may specify the number-of-days flag for periods of other lengths:

php repo/maintenance/pruneChanges.php --number-of-days 1
11:07:46 pruning entries older than 2020-12-11T11:07:46Z
11:07:47 151 rows pruned
11:07:47 done, exiting


Features & usage[edit]

After Wikibase is installed, interlanguage links are automatically obtained from the repo and added to client wiki pages as long as the polling script is running. The extension then sorts the links (as defined by the local wiki), displays them and saves them to the database exactly as they are defined on the page. The extension is robust and retains existing links when the central wiki is down.

By default the extension works only in the main namespace, but this can be changed using the namespaces configuration option.

Mixing Wikidata and local interlanguage links[edit]

The extension doesn't affect how interlanguage links work; they can be used in parallel with the extension. There are several use cases:

  • Links on pages in namespaces not configured to use the extension will work as if the extension were not installed.
  • If you want to add links in addition to the links stored in Wikidata, simply add new links in wikitext; your links and the Wikidata links will be displayed together.
  • To exclude one or more Wikidata links, use noexternallanglinks with the desired language(s). Other links will work normally.
  • To supersede one or more Wikidata links, use noexternallanglinks and add the new links in wikitext.
  • To turn off Wikidata links altogether, use noexternallanglinks on its own. Links you provide will work as if the extension were not installed.

noexternallanglinks[edit]

noexternallanglinks is a magic word and a parser function which can turn this extension off for a specific page, or suppress some of the interlanguage links produced by the extension.

When used on its own ({{noexternallanglinks}}), Wikibase is effectively disabled on the given page. Only interlanguage links present in the wikitext are used. The word works the same when used as a function, with an asterisk: {{noexternallanglinks:*}} (the asterisk "matches" all the languages).

When invoked as a function with parameters, links to the specified languages will be removed. For example, {{noexternallanglinks:fr|id}} removes links to French and Indonesian languages. You may also invoke the function more than once: {{noexternallanglinks:fr}} {{noexternallanglinks:id}}. It is safe to remove links to languages that don't exist.

Data transclusion[edit]

WikibaseClient allows data inclusion from the Wikibase repo using the {{#statements:…}} parser function along with Lua.

Lua
Parser functions
  • Lookup by property ID (e.g., P2), to include data from a Wikibase item connected by sitelink. For example, {{#statements:P2}}.
  • Lookup by property label. For example, {{#statements:country}}.
  • With arbitrary access enabled, it can be applied to any item. For example, {{#statements:P31|from=Q460679}}.
  • In addition to {{#statements:…}}, which outputs linked wikitext, you can use {{#property:…}}, which outputs unlinked labels.
  • See d:Wikidata:How to use data on Wikimedia projects for further documentation.

Other projects sidebar[edit]

See also m:Requests for comment/Interproject links interface for the current status for Wikimedia projects.

The configuration option otherProjectsLinks creates an "Other projects" sidebar section with links to other projects from the item linked to the current page. It currently supports exactly one link per project and does not yet override links in wikitext using a parser function (though current JavaScript hacks may be easily adapted).

Configuration sample (links will be displayed in the order specified):

$wgWBClientSettings['otherProjectsLinks'] = [ 'frwiki', 'frwikiquote', 'commonswiki', 'frwikivoyage' ];

The sidebar's id is "wikibase-otherprojects". You can use it to customize the section's position in the sidebar using MediaWiki:Sidebar.

Each link has a the label containing the i18n messages "wikibase-otherprojects-ID" with ID the id of the linked site group (like "wikipedia", "wikisource" or "commons").

Sample page: w:Wikipedia:Village pump.

commaseparatedlist[edit]

commaseparatedlist is a parser function that can be used in edit summaries for text formatting. It returns its list of arguments separated by the given language's proper separator. for example, {{#commaseparatedlist:word1|word2|word3}} results in word1, word2, word3.