Wikidata Bridge/Hur man aktiverar Wikidata Bridge i din faktamall

From mediawiki.org
Jump to navigation Jump to search
This page is a translated version of the page Wikidata Bridge/How to Enable Wikidata Bridge for your Infobox and the translation is 32% complete.

Wikidata Bridge låter en redigera data från Wikidata direkt i klientens wiki (t.ex. Wikipedia). Wikidata Bridge behöver aktiveras i din wikis konfigurering för att kunna användas. Dessutom behöver faktamallar utvecklas.

Skapa speciella redigeringslänkar

In order for an infobox to be supported by the Wikidata Bridge Editor, it has to place specific edit links next to the values coming from Wikidata. Typically, those edit links are icons linking to some URL like https://www.wikidata.org/wiki/Q2013?uselang={{PAGELANGUAGE}}#P856. To turn them into Wikidata Bridge-enabled links, they must be wrapped in some element (typically a ‎<span>) which specifies the edit flow that should be used for this edit link.

Selecting the correct edit flow

An edit on the client wiki can result in several types of edits on Wikidata. For example when updating the mayor of a city the previous mayor's rank changes and an additional statement is added. However when adding an additional child for a person no rank change should be made. The Wikidata Bridge needs to know which type of edit to make on Wikidata. The edit flow parameter determines it.

Currently, the only supported edit flow is single-best-value. This edit flow is for edits similar to the new mayor example above. It will result in exactly one best-ranked value plus one or more non-best-ranked values after the edit has been made. More edit flows will follow in the future. The edit flow is specified in a data-bridge-edit-flow attribute like this:

<span data-bridge-edit-flow="single-best-value">
  <a href="https://www.wikidata.org/wiki/Q2013?uselang=sv#P856">
    <!-- edit link contents (e. g. icon) go here -->
  </a>
</span>

Selecting which statement to edit

The edit link needs to define the Item on which the statement you want to edit is located as well as the Property of the statement. The Item and Property ID are inferred from the target (href attribute) of the link (‎<a> element) inside the element with the data-bridge-edit-flow attribute. The link target must match the following regular expression:

/^https:\/\/www\.wikidata\.org\/wiki\/((Q[1-9][0-9]*)).*#(P[1-9][0-9]*)$/

Each element with a data-bridge-edit-flow attribute must contain exactly one such link, and no other links (‎<a> elements).

Exempel

Exempel med ren wikitext:

{|class="wikitable"
|-
| officiell hemsida
| {{#statements:P856|from=Q2013}}&nbsp;<span data-bridge-edit-flow="single-best-value">[[File:OOjs UI icon edit-ltr-progressive.svg|frameless|text-top|10px|alt=Redigera detta på Wikidata|link=https://www.wikidata.org/wiki/Q2013?uselang=sv#P856|Redigera detta på Wikidata]]</span>
|}

Exempel med en:Template:Infobox:

{{Infobox
|label1=official website
|data1={{#statements:P856|from=Q2013}}&nbsp;<span data-bridge-edit-flow="single-best-value">[[File:OOjs UI icon edit-ltr-progressive.svg|frameless|text-top|10px|alt=Edit this on Wikidata|link=https://www.wikidata.org/wiki/Q2013?uselang=en#P856|Edit this on Wikidata]]</span>
}}