Module:WikidataBridge
This module simplifies the generation of edit links for infoboxes that are enabled to use the Wikidata bridge.
local p = {}
function p.getBridgeValue(frame)
local propertyId = frame.args[1]
local editflow = frame.args[2]
local entityId = mw.wikibase.getEntityIdForCurrentPage()
if entityId == nil then return end
local statement = mw.wikibase.getBestStatements(entityId, propertyId)[1]
if statement == nil then return end
local value = mw.wikibase.renderSnak(statement['mainsnak'])
return value..' '..p.makeBridgeLink({args = {propertyId, editflow}})
end
function p.makeBridgeLink(frame)
local propertyID = frame.args[1]
local editflow = frame.args[2]
local description = "Edit this on Wikidata"
local contentLanguage = mw.language.getContentLanguage()
local query = "?uselang="..contentLanguage:getCode()
local anchor = "#"..propertyID
local linkhref = "https://wikidata.beta.wmflabs.org/wiki/"..mw.wikibase.getEntityIdForCurrentPage()..query..anchor
local dir = contentLanguage:getDir()
return '<span data-bridge-edit-flow="'..editflow..'">[[File:OOjs UI icon edit-'..dir..'-progressive.svg|frameless|text-top|10px|alt='..description..'|link='..linkhref..'|'..description..']]</span>'
end
return p