Wikidata Bridge/How to Enable Wikidata Bridge for your Infobox/ja
Wikidata Bridge allows editing data from Wikidata directly in the client wiki (e.g. Wikipedia). 編集者がウィキデータ ブリッジを使用できるようにするには、ウィキの構成でウィキデータ ブリッジを有効にする必要があります。 In addition infobox templates need to be adapted.
Creating special edit links
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=ja#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).
例
Plain wikitext example:
{|class="wikitable" |- | 公式ウェブサイト | {{#statements:P856|from=Q2013}} <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=ja#P856|Edit this on Wikidata]]</span> |}
Example using en:Template:Infobox:
{{Infobox |label1=公式ウェブサイト |data1={{#statements:P856|from=Q2013}} <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> }}