扩展:Wikibase知识库

From MediaWiki.org
Jump to: navigation, search
This page is a translated version of the page Extension:Wikibase Repository and the translation is 24% complete.

Outdated translations are marked like this.
Other languages:
català • ‎Deutsch • ‎English • ‎español • ‎suomi • ‎français • ‎magyar • ‎italiano • ‎日本語 • ‎polski • ‎português • ‎português do Brasil • ‎русский • ‎sicilianu • ‎中文
快捷方式: WBR
MediaWiki扩展手册Manual:Extensions
Crystal Clear action run.png
Wikibase Repository

发布状态:Extension status 测试

实现Template:Extension#type API, Ajax, User interface, ContentHandler
描述Template:Extension#description 结构化数据库
作者Template:Extension#username The Wikidata team
(contributors list)
最新版本Template:Extension#version continuous updates
MediaWikiTemplate:Extension#mediawiki master
PHPTemplate:Extension#php 5.5.9+
数据更新Template:Extension#needs-updatephp
许可协议Template:Extension#license GNU General Public License 2.0 or later
下载
readme
release notes
使用的钩子Template:Extension#hook
UnitTestsListManual:Hooks/UnitTestsList
BaseTemplateToolboxManual:Hooks/BaseTemplateToolbox
BeforePageDisplayManual:Hooks/BeforePageDisplay
OutputPageParserOutputManual:Hooks/OutputPageParserOutput
LoadExtensionSchemaUpdatesManual:Hooks/LoadExtensionSchemaUpdates
ResourceLoaderTestModulesManual:Hooks/ResourceLoaderTestModules
NewRevisionFromEditCompleteManual:Hooks/NewRevisionFromEditComplete
SkinTemplateNavigationManual:Hooks/SkinTemplateNavigation
RecentChange_saveManual:Hooks/RecentChange_save
ArticleDeleteCompleteManual:Hooks/ArticleDeleteComplete
ArticleUndeleteManual:Hooks/ArticleUndelete
GetPreferencesManual:Hooks/GetPreferences
NamespaceIsMovableManual:Hooks/NamespaceIsMovable
ContentHandlerForModelIDManual:Hooks/ContentHandlerForModelID
LinkBeginManual:Hooks/LinkBegin
ChangesListInitRowsManual:Hooks/ChangesListInitRows
OutputPageBodyAttributesManual:Hooks/OutputPageBodyAttributes
FormatAutocommentsManual:Hooks/FormatAutocomments
PageHistoryLineEndingManual:Hooks/PageHistoryLineEnding
ApiCheckCanExecuteManual:Hooks/ApiCheckCanExecute
SetupAfterCacheManual:Hooks/SetupAfterCache
ShowSearchHitManual:Hooks/ShowSearchHit
ShowSearchHitTitleManual:Hooks/ShowSearchHitTitle
TitleGetRestrictionTypesManual:Hooks/TitleGetRestrictionTypes
TitleQuickPermissionsManual:Hooks/TitleQuickPermissions
ContentModelCanBeUsedOnManual:Hooks/ContentModelCanBeUsedOn
OutputPageBeforeHTMLManual:Hooks/OutputPageBeforeHTML
BeforeDisplayNoArticleTextManual:Hooks/BeforeDisplayNoArticleText
InfoActionManual:Hooks/InfoAction
ContentHandlerForModelIDManual:Hooks/ContentHandlerForModelID
APIQuerySiteInfoGeneralInfoManual:Hooks/APIQuerySiteInfoGeneralInfo
APIQuerySiteInfoStatisticsInfoManual:Hooks/APIQuerySiteInfoStatisticsInfo
ImportHandleRevisionXMLTagManual:Hooks/ImportHandleRevisionXMLTag
SkinTemplateBuildNavUrlsNav_urlsAfterPermalinkManual:Hooks/SkinTemplateBuildNavUrlsNav_urlsAfterPermalink
SkinMinervaDefaultModulesManual:Hooks/SkinMinervaDefaultModules
ResourceLoaderRegisterModulesManual:Hooks/ResourceLoaderRegisterModules

翻译Wikibase Repository扩展(如果在translatewiki.net可用)

检查使用和版本矩阵。

问题Phabricator

开放的工作 · 报告错误

Wikibase Repository is part of Wikibase. Wikibase Repository allows you to use your wiki as a structured data repository. Its development is part of the Wikidata project. The data can in turn be used in a wiki using the Wikibase Client extension.

功能预览[edit]

  • Creation and maintenance of items
  • Histories and diffs of structured data
  • Labels, descriptions, and aliases for items
  • Rich interface and functionality for managing language links to items
  • Adds the content handler for structured data

条件[edit]

Wikibase Repository/zh需要:

以及以下之一:

If installed, Wikibase makes use of:

If installed and JavaScript is supported by the user client / browser, labels, aliases and descriptions will be shown to the user in frequently used languages in addition to the user interface language. (These languages are acquired from mw.uls.getFrequentLanguageList().)
If installed, logged-in users are able to define additional languages that labels, aliases and descriptions are shown in by specifying languages on their user pages using the Babel syntax.

下载[edit]

注意 注意: Wikibase知识库包含在维基数据架构中。

此扩展可直接从Git检索到 [?]:

  • 浏览代码
  • 部分扩展有稳定版本标签。
  • 每个分支与过去的MediaWiki发布版本相关联。 这里也有一个“主线”分支,包含最新alpha版本(可能需要MediaWiki的alpha版本)。

提取快照,并将它放置在您的MediaWiki安装副本的extensions/Wikibase/目录中。

如果您对git熟悉,并且拥有您服务器的shell访问权,您也可以通过以下方法获得扩展:

cd extensions/
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Wikibase.git

安装[edit]

The basic installation is recommended. See the basic installation instructions.

For more experienced configuration see Advanced Configuration.

Advanced Configuration[edit]

Setting up items in the main namespace[edit]

If you want to set up your items in the main namespace:

$baseNs = 100;

// Define the namespace indexes
define( 'WB_NS_PROPERTY', $baseNs + 2 );
define( 'WB_NS_PROPERTY_TALK', $baseNs + 3 );

// Define the namespaces
$wgExtraNamespaces[WB_NS_PROPERTY] = 'Property';
$wgExtraNamespaces[WB_NS_PROPERTY_TALK] = 'Property_talk';

// Assigning the correct entity types to the namespaces
$wgWBRepoSettings['entityNamespaces']['item'] = NS_MAIN; 
$wgWBRepoSettings['entityNamespaces']['property'] = WB_NS_PROPERTY;

Note that if the "Main Page" is still in the Main namespace there will be thrown an exception, at least when you try to access that page. If you see this exception comment out the content model for the Main namespace, and then move the "Main Page" out of Main space without leaving an redirect. Usually the page will be moved to "Project:Main Page". If so the system message Mediawiki:Mainpage should be updated, or a similar message if Mediawiki:Sidebar is changed. Also check if there are other pages in the Main namespace by using Special:Allpages. After the Main namespace is cleansed for other pages you can reenable the content model for Main namespace.

Items in a dedicated item namespace[edit]

If you want to set up your items in a namespace of its own, here called Item, set up and use a WB_NS_ITEM constant and optionally set $wgNamespacesToBeSearchedDefaultManual:$wgNamespacesToBeSearchedDefault:

$baseNs = 120;

// Define the namespace indexes
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 );

// Define the 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';

// Assigning the correct entity types to the namespaces
$wgWBRepoSettings['entityNamespaces']['item'] = WB_NS_ITEM;
$wgWBRepoSettings['entityNamespaces']['property'] = WB_NS_PROPERTY;

// Making the namespaces searched by default
$wgNamespacesToBeSearchedDefault[WB_NS_ITEM] = true;
$wgNamespacesToBeSearchedDefault[WB_NS_PROPERTY] = true;


HTML5[edit]

The extension uses HTML5 specific attributes, and because of this the $wgHtml5Manual:$wgHtml5 must be set to true in pre MW 1.22. In MW 1.22 and later versions this configurable feature is removed and the returned code is always HTML5.

配置[edit]

  • Basic Settings with changesDatabase,siteLinkGroups,localClientDatabases (with examples)
  • Insert with SQL in the table sites the site_global_key ? database repo and client ?
  • relations between siteLinkGroups of repo and siteGlobalID of client ?
  • example configs with a repo and a wiki family (fr,en)

Configuration of Wikibase Repository/zh is done by assigning to $wgWBRepoSettings in your LocalSettings.phpManual:LocalSettings.php file. The options are listed below and their default is set in the Wikibase Repository/zh 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 $wgWBRepoSettings, 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 latter is used.

Example of how to change a setting:

$wgWBRepoSettings['serializationFormat'] = 'application/json';

Available settings:

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/repo' 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.

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.

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, e.g. to suggest or normalize the titles of pages when creating site links.

extractInterlang.sql[edit]

This is an SQL query that extracts interlanguage links from a wiki in a format readable by importInterlang.php. You may use it in a database of a wiki that has interlanguage links, so that you can later import them for testings.

importInterlang.php[edit]

This script imports interlanguage links from a file into a wiki, also creating labels in the process. The file is a tab-separated CSV file, in the following format:

page_title     ll_lang   ll_title
-архив        cs        Seznam forem vlády
-архив        de        Liste der Staatsformen und Regierungssysteme
-архив        en        Government#Forms of government
-архив        eo        Listo de formoj de registaro
-архив        es        Anexo:Formas de gobierno
-архив        fr        Liste de formes de gouvernements
-архив        jv        Daftar wangun pamaréntahan
-архив        ku        Lîsteya pergalên siyasî
-архив        mk        Список на општествени уредувања
-графика       de        -graphie
-графика       en        -graphy
-графика       id        -grafi
-графика       ka        ...გრაფია
-графика       sv        -grafi

The first row of the file is ignored.

  • The first column contains article titles of articles on the base wiki (the wiki the links are linked from).
  • The second column contains language codes of the links.
  • The third column contains article titles of the linked articles.

脚本选项:

  • --verbose: if set, the script will print API requests, responses, and other information.
  • --ignore-errors: if set, the script will ignore API errors and continue importing even if it encounters an error.
  • <lang>: This should be the language code of the base wiki, the wiki you have extracted interlanguage links from.
  • <filename>: The file with interlanguage links, presumably generated by extractInterlang.sql.
  • <api>: Base API url of the wiki you are importing the link into. For example, http://localhost/wiki/w/api.php

Example command line:

php importInterlang.php --verbose --ignore-errors sr sr_interwiki.csv http://localhost/wiki/w/api.php

To import the test items from extensions/Wikibase/repo/maintenance run

php importInterlang.php --verbose --ignore-errors simple simple-elements.csv

pruneChanges.php[edit]

This script is located in Wikibase/repo/maintenance/pruneChanges.php. It allows to prune the Wikibase changes table. If you run it without any parameters, it will delete all changes older than 7 days. To delete all changes older than 1 day run

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

createBlacklistedItems.php[edit]

This script creates blacklisted items in Wikidata Data namespace, typically to create easter eggs and similar. The actual data is hardcoded in the script. You may use it before the item ids reaches the first blacklisted items.

importProperties.php[edit]

Maintenance script for importing properties in Wikidata. Usually this will use the example file in en-elements-properties.csv as source while building the example entries. You may also use it to create other entries for testing.

To import the test properties from extensions/Wikibase/repo/maintenance run

php importProperties.php --verbose en en-elements-properties.csv

rebuildEntityPerPage.php[edit]

Maintenance script for rebuilding the items_per_page table.

rebuildTermsSearchKey.php[edit]

Maintenance script for rebuilding the search key of the TermSQLCache. The search key is an additional column in the wb_terms table. This column is optional in the table and is used for caseless searches.

searchEntityArtefacts.php[edit]

This is a maintenance script that queries the database for entity artifacts. During use the database accumulates failed entries and this script tries to find them and print them.

版本[edit]

以下是Git发行文档的拷贝,它由机器人保持半自动更新。

国际化[edit]

Wikibase Repository/zh是完全支持国际化的。Wikibase Repository/zh信息的翻译由translatewiki.net提供。此扩展的翻译可在此找到。要添加或修改现有的语言版本,您应该在translatewiki.net创建账户,并在此请求译者权限。一旦您获得权限,您就可以开始翻译此扩展了。

截图[edit]

参见[edit]

外部链接[edit]