Moduł:Wikidane
Z Nonsensopedii, polskiej encyklopedii humoru
Dokumentacja dla tego modułu może zostać utworzona pod nazwą Moduł:Wikidane/opis
local linkedwiki = require('linkedwiki')
local p = {}
function p.new(entity)
local wd = 'http://www.wikidata.org/entity/'
local wdt = 'http://www.wikidata.org/prop/direct/'
local rdfs = 'http://www.w3.org/2000/01/rdf-schema#'
local propertyLabel = rdfs.."label";
if mw.ustring.sub(entity, 1, 4) ~= 'http' then
entity = wd .. entity
end
local subject = linkedwiki.new(entity)
local Wd = {}
function Wd:getProperty(prop)
if mw.ustring.sub(prop, 1, 4) ~= 'http' then
prop = wdt .. prop
end
return subject:getValue(prop)
end
function Wd:getLabel()
return subject:getString(propertyLabel)
end
return Wd
end
return p