Jump to content

Wikibase/扩展

From mediawiki.org
This page is a translated version of the page Wikibase/Extending and the translation is 30% complete.

Wikibase is a powerful and extensible piece of software, and a large amount of what it can do lies beyond the fairly stripped-down state Wikibase is in when you run your Docker images for the first time.

On this page you can take a quick, link-heavy tour of the resources available to help you extend your instance and give it the functionality you want and need it to have.

模板

MediaWiki templates work a bit like text macros in that they contain content meant to be transcluded into other wiki pages. But their functionality can extend far beyond simple text replacement when scripting comes into play (see calling Lua modules).

To view the templates installed on your (or any) instance, navigate to <your Wikibase URL>/wiki/Special:AllPages?from=&to=&namespace=10.

While there is no single repository for MediaWiki templates, Wikipedia does offer a robust template resource page. You can find them easily by searching the web or by looking through what’s installed on any given instance of MediaWiki. When you find a template you want to use, follow these instructions to start using it on your instance.

简单模板

一些对维基数据库用户有用的模板:

  • SPARQL - SPARQL查询语法高亮
  • Q - 创建指向数据项的直接链接
  • Property - 显示属性的本地化标签

您还可以查看这份有用的第三方模板概览: ryadel.com

强大的模板

模板可以通过调用使用Lua脚本语言编写的模块来使其功能更强大。

Mediawiki扩展组件入门

MediaWiki’s robust software ecosystem offers a wide range of extensions, pieces of code that modify how your installation looks and works. Extensions come in many shapes and sizes, from simple and useful tweaks to large modifications in functionality; as you probably know, Wikibase is itself an extension to MediaWiki. You can browse and download many of these extensions with the MediaWiki ExtensionDistributor. These install instructions should cover most cases, but some extensions have special instructions called out separately below.

To view the extensions you currently have installed, navigate to <your Wikibase URL>/wiki/Special:Version#mw-version-ext.

Wikibase的扩展组件

This section gives an overview over the available MediaWiki extensions that can extend Wikibase. 参见Category:Wikibase扩展

数据质量

下述扩展组件可以协助管理您Wikibase数据的质量。

维基数据库质量约束
A powerful extension that helps you impose constraints on your properties (which are actually more like guidelines) to improve the quality of your Wikibase data. See also the constraints portal which offers many constraints-oriented resources and tips on how to implement them effectively.
EntitySchema
Allows storing Shape Expressions Schemas on wiki pages (using ShExC syntax), as well as validating entities against those Schemas using the ShEx2 — Simple Online Validator.

更多数据类型

参见Category:WikibaseRepoDataTypes extensions Category:WikibaseClientDataTypes extensions

导入数据

参见Wikibase/Importing

其它扩展组件

PropertySuggester
Adds useful auto-suggestion of properties for manual edits.

小工具

Gadgets are small interface modifications that each user of an instance can choose to activate or deactivate for their own use. The Gadgets(小工具) extension enables the use of gadgets (see below). You may well find that this extension is already installed on your instance, but make sure: it needs to be installed and enabled before implementing anything listed in the next section!

Some examples can be found in the MediaWiki gadget list and Wikidata’s installed gadgets. Here’s a guide to writing your own , and here’s how to install a gadget .

其它Mediawiki扩展组件

General utility

Content management and spam protection

  • Abuse Filtercreate filters for editing to forestall abusive activity
  • Nukeenable mass deletion of pages
  • Confirm Editadd CAPTCHA checks before an edit is confirmed
  • Tor Blockrestrict access for Tor exit nodes

Wikibase-specific

  • OAuthimplements OAuth, required for some tools to work correctly with Wikibase
  • CLDRcontains and manages locale-specific information regarding the display of data in different languages and formats
  • Universal Language Selectorallows users to configure an interface language of their choice

Other additions

As if templates, extensions and gadgets weren’t enough, there are many other ways you can customise your Wikibase installation. Here are some of the most commonly used.

Interface messages

As an administrator (with editInterface permissions), you can customise the messages displayed to the user by Wikibase. A complete list of them can be found on the Special:AllMessages page of your instance: <your instance URL>/wiki/Special:AllMessages

Consult the System message documentation for more information.

站点链接

相比于简单的超链接,站点链接功能允许Wikidata的MediaWiki界面以更有用的方式链接到其它的wiki。 维基百科页面上的语言选择器是站点链接功能应用的一个典型案例,该功能依赖于建立的指向其他语言维基的站点链接。

Although the Docker images handle most of the config changes shown in the Wikibase install documentation, sitelinks are a notable exception.

To get sitelinks working, first work through the sitelinks section of the install doc. Then consult the sites table for further guidance.

Sorted properties and statements

By default, Wikibase displays content from queries and on entity/item pages in the order in which each item was added to the database. To make a change in the display order, you’ll need to use a sorted properties list.

Learn more about it on the Sorted Properties page, and check out Wikidata’s own Sorted Properties for inspiration.

Pywikibot

For more advanced users who seek tools to help them manage their data, there’s Pywikibot. It started life as a tool made for Wikipedia but was adapted to work on other Wikimedia projects, including Wikibase installations. Pywikibot amounts to a collection of scripts that can change and manipulate data programmatically, potentially saving large amounts of manual work.

Check out the third-party wiki quick start for Pywikibot to see if it might be right for your installation.