Wikidata Bridge/Development/DocDrafts/How to Enable Wikidata Bridge for your Infobox

From MediaWiki.org
Jump to navigation Jump to search

THIS IS NEITHER LIVE NOR FINAL! DO NOT USE IT YET!

In order for an infobox to be supported by the Wikidata Bridge Editor, it has to place 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=en#P856; to turn them into 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. Valid edit flows are TODO (currently: overwrite), and they are specified in a data-bridge-edit-flow attribute like this:

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

The following data attributes (all on the same element) are recognized:

data-bridge-edit-flow
The edit flow that should be used when editing this value. For now, it should always be overwrite. TODO

The entity 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"
|-
| official website
| {{#statements:P856|from=Q2013}}&nbsp;<span data-bridge-edit-flow="overwrite">[[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>
|}
official website https://www.wikidata.org/ Edit this on Wikidata

Example using en:Template:Infobox:

{{Infobox
|label1=official website
|data1={{#statements:P856|from=Q2013}}&nbsp;<span data-bridge-edit-flow="overwrite">[[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>
}}