Jump to content

Help:Extension:UnlinkedWikibase

From mediawiki.org

The UnlinkedWikibase extension provides access (via Lua functions) to Wikibase entities from wikis that are not linked to a Wikibase site. There are two main aspects to the features it provides: the data-retrieval API, and a method to associate a given wiki page to a single Wikibase entity.

Lua data-retrieval API

[edit]

The extension integrates with Scribunto to provide two Lua data-retrieval functions: one to retrieve a single entity and another one to retrieve the results of a SPARQL query.

mw.ext.UnlinkedWikibase.getEntity( id )
Returns the entire entity object (as is seen at d:Special:EntityData/Q2934.json for the goat example). This is similar to Wikibase's own mw.wikibase.getEntity( id ), which works for pages that do have a sitelink to an entity.
mw.ext.UnlinkedWikibase.query( sparql )
Runs the given SPARQL query against the Wikidata Query Service and returns the result.

Linking pages to Wikibase entities

[edit]

There is also a means to associate a wiki page with a Wikibase entity. This is done with the {{#unlinkedwikibase| id=Q2934 }} parser function, which stores the given ID as a page property for the page on which it's used. This ID can then be retrieved in the context of other pages via the mw.ext.UnlinkedWikibase.getLocalTitle( id ) method, which returns a Title object for the relevant page.

Parser function {{#unlinkedwikibase: id= }}
Set a page's Wikibase entity ID.
Lua method mw.ext.UnlinkedWikibase.getLocalTitle( id )
Get a Title object for a page that uses {{#unlinkedwikibase: id= }}.