Extension:Wikibase Client
|
Wikibase Client Release status: beta |
|
|---|---|
| Description | Client for structured data repository |
| Author(s) | The Wikidata team (contributors list) |
| Last version | 0.4 alpha |
| MediaWiki | 1.21.0 or higher |
| PHP | 5.3 or above |
| Database changes | yes |
| License | GNU GPL v2+ |
| Download |
readme release notes |
| Check usage and version matrix | |
| Bugs: list open list all report | |
Wikibase Client is an extension that acts as a client to the Wikibase extension. Its development is part of the Wikidata project.
The Wikibase Client obtains interlanguage links from a Wikibase repository via a shared changes database table and polling maintenance script, and displays them on the client wiki. Links are sorted by the client's preferred sorting. It is in plan to also be able to edit the links on the repository from a client wiki, fetch other kinds of data besides links, manage updating of articles and have other related functionality.
Contents |
Usage [edit]
After the extension is installed, interlanguage links will automatically be obtained from the repo and be added to client wiki pages, as long as the polling script is running. The extension will then sort the links (sorting defined per-wiki), and display them, and save them to the database, just as if they are defined on the page. The extension is robust and will keep the existing links in case the central wiki is down.
By default the extension only works in the main namespace, but it is possible to change this with the namespaces configuration option.
Mixing Wikidata and local interlanguage links [edit]
The extension doesn't interfere with usual working of interlanguage links. They may continue to be used in parallel to the extension. There are several use cases:
- Links on pages in namespaces which are not configured to use the extension continue to work exactly as without the extension.
- If you want to add links in addition to the links stored in Wikidata, simply add new links in the wikitext, they will be added to the links from Wikidata, and all the links will be displayed together.
- If you want to not show some of the links from Wikidata you can use the noexternallanglinks parser function with the desired language(s). Other links will continue to work normally.
- If you want to overwrite some links from Wikidata, you can likewise use the noexternallanglinks parser function and add the new links in the wikitext.
- If you want to turn off Wikidata links completely, you can use the noexternallanglinks magic word. In this case the links won't even be sorted, but will continue to work exactly as without the extension.
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.
If used on its own, as {{noexternallanglinks}}, it will turn this extension off on the page. Only the interlanguage links that are present in the wikitext will be used. Sorting of the links will also be turned off, unless the alwaysSort option is turned on. The same effect is achieved if it is used as a function, with an asterisk: {{noexternallanglinks:*}} (the asterisk "matches" all the languages).
If used as a function, with parameters, only the links to the languages given as parameters will be removed. For example, {{noexternallanglinks:fr|id}} will remove the links to French and Indonesian languages. The same effect can be achieved by invoking the function repeatedly: {{noexternallanglinks:fr}} {{noexternallanglinks:id}}. Note that the remaining links will now be sorted, which means that wikitext links will be sorted even if French and Indonesian links were the only ones existing. It is safe to remove the link of a non-existing language.
Data transclusion [edit]
WikibaseClient allows for data inclusion from the Wikibase repo, via the {{#property}} parser function and Lua.
- Lua
- Parser function
- Supports lookup by property id (e.g. p2), to include data from a connected (via sitelink) Wikibase item. For example, {{#property:p2}}.
- Lookup by property label (experimental only)
Requirements [edit]
The Wikibase Client requires:
- MediaWiki 1.20 or above
- PHP 5.3 or above
- WikibaseLib
- Diff
- DataValues
- Scribunto
And one of the following:
Download [edit]
Wikibase Client (and Lib) [edit]
You can download the extension directly from the MediaWiki source code repository (browse code). You can get:
- One of the extensions tags
Not all extensions have tags. Some extensions have tags for each release, in which case those tags have the same stability as the release. To download a tag
- Go to the tags list
- Click the name of the tag you want to download
- Click "snapshot"
- The latest version of one of the extensions branches
Each extension has a master branch containing the latest code (might be unstable). Extensions can have further branches as well.
- Go to the branches list
- Click the branch name
- Click "snapshot"
- A snapshot made during the release of a MediaWiki version.
This might be unstable and is not guaranteed to work with the associated MediaWiki version.
After you've got the code, save it into the extensions/Wikibase directory of your wiki.
If you are familiar with git and have shell access to your server, you can obtain the extension, with all its tags and branches, as follows:
cd extensions
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Wikibase.git
The client extension will be available in Wikibase/client directory. Clone it to your MediaWiki extensions folder. You will also need the WikibaseLib extension which is in the Wikibase/lib directory.
Diff [edit]
Wikibase Client also requires the Diff extension installed.
You can download the extension directly from the MediaWiki source code repository (browse code). You can get:
- One of the extensions tags
Not all extensions have tags. Some extensions have tags for each release, in which case those tags have the same stability as the release. To download a tag
- Go to the tags list
- Click the name of the tag you want to download
- Click "snapshot"
- The latest version of one of the extensions branches
Each extension has a master branch containing the latest code (might be unstable). Extensions can have further branches as well.
- Go to the branches list
- Click the branch name
- Click "snapshot"
- A snapshot made during the release of a MediaWiki version.
This might be unstable and is not guaranteed to work with the associated MediaWiki version.
After you've got the code, save it into the extensions/Diff directory of your wiki.
If you are familiar with git and have shell access to your server, you can obtain the extension, with all its tags and branches, as follows:
cd extensions
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Diff.git
DataValues [edit]
Wikibase Client also requires the DataValues extension installed.
You can download the extension directly from the MediaWiki source code repository (browse code). You can get:
- One of the extensions tags
Not all extensions have tags. Some extensions have tags for each release, in which case those tags have the same stability as the release. To download a tag
- Go to the tags list
- Click the name of the tag you want to download
- Click "snapshot"
- The latest version of one of the extensions branches
Each extension has a master branch containing the latest code (might be unstable). Extensions can have further branches as well.
- Go to the branches list
- Click the branch name
- Click "snapshot"
- A snapshot made during the release of a MediaWiki version.
This might be unstable and is not guaranteed to work with the associated MediaWiki version.
After you've got the code, save it into the extensions/DataValues directory of your wiki.
If you are familiar with git and have shell access to your server, you can obtain the extension, with all its tags and branches, as follows:
cd extensions
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/DataValues.git DataValues
Installation [edit]
Diff and DataValues [edit]
# DataValues require_once( "$IP/extensions/DataValues/DataValues.php" ); # Diff require_once( "$IP/extensions/Diff/Diff.php" );
WikibaseLib and WikibaseClient [edit]
You also need to configure the WikibaseLib extension:
# WikibaseClient require_once( "$IP/extensions/Wikibase/lib/WikibaseLib.php" ); require_once( "$IP/extensions/Wikibase/client/WikibaseClient.php" );
The client needs foreign access the database of the Wikibase Repo. It uses MediaWiki's LoadBalancer functionality to do this, similar to the way foreign database access is handled for Wikimedia Foundation projects. In client/ExampleSettings.php you can see sample configurations for setting up the foreign database access.
Wikibase Client depends on the interwiki table to have appropriate values. The populateInterwiki.php maintenance script will add those used on the English Wikipedia. If you want to use them, run the following from your wiki's root directory:
php extensions/Wikibase/client/maintenance/populateInterwiki.php
This means that you will have all the Wikipedia language links ready for testing.
At the end, run update.php from your wiki's root directory:
php maintenance/update.php
Configuration [edit]
Configuration of Wikibase Client is done by assigning to members of $wgWBSettings array in your LocalSettings.php file. The options are listed below and their default is set in the Wikibase Client settings file. You should NOT modify the settings file, but can have a look at it to get an idea of how to use the settings, in case the below descriptions do not suffice.
The extension use the variable name $wgWBSettings, note the initial prefix $wg, while configuration of other extensions might use the initial prefix $eg. The difference is important and the configuration will fail if the later is used.
An example of how to change the settings:
Required settings [edit]
repoUrl optionally, can be protocol relative such as '//wikidata.org'; this setting defaults to "//wikidata.org")"
$wgWBSettings['repoUrl'] = 'http://wikidata-test-repo.wikimedia.de';
repoScriptPath same as $wgScriptPath in your repo
$wgWBSettings['repoScriptPath'] = '/w';
repoArticlePath same as $wgArticlePath setting, in your repo, and if not set, then it will either be "$wgScriptPath/index.php/$1" (whatever you have for $wgScriptPath in your repo) or '$wgScriptPath?title=$1'
$wgWBSettings['repoArticlePath'] = '/wiki/$1';
$wgWBSettings['siteGlobalID'] = 'enwiki'; $wgWBSettings['repoDatabase'] = 'wikidatawiki'; $wgWBSettings['changesDatabase'] = 'wikidatawiki';
Optional settings [edit]
$wgWBSettings['namespaces'] = array( NS_MAIN, NS_CATEGORY ); $wgWBSettings['siteGroup'] = 'wikipedia'; //you probably don't need this one, but do if your siteGroup is different from 'wikipedia' $wgWBSettings['sort'] = 'code'; //optional $wgWBSettings['sortPrepend'] = array( 'en' );
Overview of available settings [edit]
- The available settings are documented in extensions/Wikibase/docs/options.wiki https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/Wikibase.git;a=blob;f=docs/options.wiki
Maintenance scripts [edit]
This extension has some maintenance scripts in the maintenance subdirectory. They assume that the extension is installed in the extensions directory of the MediaWiki software (i.e. files are in the extensions/Wikibase directory), if this is not the case, you can set the MW_INSTALL_PATH environment variable to the path of your MediaWiki installation and the scripts will use it.
An usual way to set the environment for scripts run by cron jobs is to do something like
env 'MW_INSTALL_PATH=/var/www/client' php …
This should then run whatever php-script you want to append after the php interpreter.
rebuildAllData.php [edit]
This script should rebuild all the Wikidata data in secondary storage from articles in Data namespace. You may use it to rebuild data after testing.
(Clearify what this script is doing when called from the client)
deleteAllData.php [edit]
This script should delete all the Wikidata data in secondary storage and articles in Data namespace. You may use it to delete the data after testing.
(Clearify what this script is doing when called from the client)
Poll for changes [edit]
You need to run the Wikibase Lib maintenance script, pollForChanges.php from the client wiki installation, in order to update the cache of local items on the client wiki:
php extensions/Wikibase/lib/maintenance/pollForChanges.php
Note that this script does the synchronization. The repo and the client will only be in sync as long as this script is running.
Available settings [edit]
repoUrl [edit]
Link to the Wikibase repository. Example is 'http://wikidata-test-repo.wikimedia.de '.
repoScriptPath [edit]
Should be same as your $wgScriptPath setting in your repo, for example '/w'
repoArticlePath [edit]
Should be same as your $wgArticlePath setting in your repo, for example '/wiki/$1'. If you don't have $wgArticlePath set in your repo, then it should be either "$wgScriptPath/index.php/$1" (whatever you have for $wgScriptPath in your repo) or '$wgScriptPath?title=$1' which are MediaWiki defaults.
siteGlobalID [edit]
Global ID for the site tells the polling script to cache and display interwiki links from the repository that are pointing to the client. Default is 'enwiki' for "en" (language code) and "wiki" for the site group, but this could be set to something else;
siteGroup [edit]
Default siteGroup setting is 'wikipedia' (for Wikipedia).
namespaces [edit]
Array. An array of namespaces in which the extension will work.
Default: the extension will work only in the main namespace.
sort [edit]
String. Selects the sort method you want to use for the interlanguage links. Currently, it recognizes four sort methods:
- 'code': By language code (auto-languagecode)
- 'alphabetic': By language name (meta-native-languagename)
- 'alphabetic_revised': By language name (alternative) (meta-native-languagename-firstword)
- 'none': Don't sort. Basically, the order of the links is not guaranteed.
Default: 'code' sort mode.
sortPrepend [edit]
Array. Modifies the sort method so that it sorts certain languages at the top of the list of languages, regardless of their general sort order. It should be set to an array that has values set to desired language codes, in desired order. For example, to put English and then Simple English at the top of the list of languages, set it to array( 'en', 'simple' ). It is even possible to make an entire custom sort array with all the languages, that will completely override any of the sorting methods.
Default: the sort will be used unmodified.
alwaysSort [edit]
Boolean. Always sort the links, even when the extension is not used.
By default, the extension will not sort the links if it is not used: whether on pages outside of the defined namespaces, or if it is suppressed by the noexternallanglinks magic word. In these cases, by default, the links on the page will be shown in order they are in wikitext, which is the MediaWiki default. However, if alwaysSort is turned on (set to true), then the links will be sorted even if these cases.
Note that even if alwaysSort is off, the extension will still sort the links if there are no links in the repository, or each of the links is individually suppressed by noexternallanglinks.
Default: don't always sort.
Version [edit]
This is a copy of the release notes file on GIT, which might be more up to date then this page.
Internationalization [edit]
Wikibase Client is fully internationalized. Translation of Wikibase Client messages is done through translatewiki.net. The translation for this extension can be found here. To add language values or change existing ones, you should create an account on translatewiki.net, then request permission from the administrators to translate a certain language or languages on this page (this is a very simple process). Once you have permission for a given language, you can log in and add or edit whatever messages you want to in that language.
Screenshots [edit]
See also [edit]
External links [edit]
| This extension is being used on one or more Wikimedia projects. This probably means that the extension is stable and works well enough to be used by such high-traffic websites. Look for this extension's name in Wikimedia's CommonSettings.php and InitialiseSettings.php configuration files to see where it's installed. A full list of the extensions installed on a particular wiki can be seen on the wiki's Special:Version page. |