Module:Wikidata: Difference between revisions
From Zoophilia Wiki
Jump to navigationJump to search
meta>RexxS IDs are not just numeric |
meta>RexxS getDateValue |
||
Line 56: | Line 56: | ||
end | end | ||
-- This is used to get a value like 'male' which won't be linked | |||
p.getRawValue = function(frame) | p.getRawValue = function(frame) | ||
local propertyID = mw.text.trim(frame.args[1] or "") | local propertyID = mw.text.trim(frame.args[1] or "") | ||
Line 65: | Line 66: | ||
for k, v in pairs(entity.claims[propertyID]) do | for k, v in pairs(entity.claims[propertyID]) do | ||
out[#out + 1] = mw.wikibase.label("Q" .. v.mainsnak.datavalue.value["numeric-id"]) | out[#out + 1] = mw.wikibase.label("Q" .. v.mainsnak.datavalue.value["numeric-id"]) | ||
end | |||
return table.concat(out, ", ") | |||
else | |||
return "" | |||
end | |||
else | |||
return input_parm | |||
end | |||
end | |||
-- This is used to get a date value which won't be linked | |||
p.getDateValue = function(frame) | |||
local propertyID = mw.text.trim(frame.args[1] or "") | |||
local input_parm = mw.text.trim(frame.args[2] or "") | |||
if input_parm == "FETCH_WIKIDATA" then | |||
local entity = mw.wikibase.getEntity() | |||
if entity.claims[propertyID] ~= nil then | |||
local out = {} | |||
for k, v in pairs(entity.claims[propertyID]) do | |||
out[#out + 1] = v.mainsnak.datavalue.value.time | |||
end | end | ||
return table.concat(out, ", ") | return table.concat(out, ", ") |
Revision as of 16:36, 26 August 2013
Documentation for this module may be created at Module:Wikidata/doc
local p = {}
p.getSpouse = function(frame)
local input_parm = mw.text.trim(frame.args[1] or "")
if input_parm == "FETCH_WIKIDATA" then
local entity = mw.wikibase.getEntity()
if entity.claims.p26 ~= nil then
local out = {}
for k, v in pairs(entity.claims.p26) do
out[#out + 1] = "[[" .. mw.wikibase.sitelink("Q" .. v.mainsnak.datavalue.value["numeric-id"]) .. "]]"
end
return table.concat(out, ", ")
else
return ""
end
else
return input_parm
end
end
p.getBirthPlace = function(frame)
local input_parm = mw.text.trim(frame.args[1] or "")
if input_parm == "FETCH_WIKIDATA" then
local entity = mw.wikibase.getEntity()
if entity.claims.p19 ~= nil then
local out = {}
for k, v in pairs(entity.claims.p19) do
out[#out + 1] = "[[" .. mw.wikibase.sitelink("Q" .. v.mainsnak.datavalue.value["numeric-id"]) .. "]]"
end
return table.concat(out, ", ")
else
return ""
end
else
return input_parm
end
end
p.getValue = function(frame)
local propertyID = mw.text.trim(frame.args[1] or "")
local input_parm = mw.text.trim(frame.args[2] or "")
if input_parm == "FETCH_WIKIDATA" then
local entity = mw.wikibase.getEntity()
if entity.claims[propertyID] ~= nil then
local out = {}
for k, v in pairs(entity.claims[propertyID]) do
out[#out + 1] = "[[" .. mw.wikibase.sitelink("Q" .. v.mainsnak.datavalue.value["numeric-id"]) .. "]]"
end
return table.concat(out, ", ")
else
return ""
end
else
return input_parm
end
end
-- This is used to get a value like 'male' which won't be linked
p.getRawValue = function(frame)
local propertyID = mw.text.trim(frame.args[1] or "")
local input_parm = mw.text.trim(frame.args[2] or "")
if input_parm == "FETCH_WIKIDATA" then
local entity = mw.wikibase.getEntity()
if entity.claims[propertyID] ~= nil then
local out = {}
for k, v in pairs(entity.claims[propertyID]) do
out[#out + 1] = mw.wikibase.label("Q" .. v.mainsnak.datavalue.value["numeric-id"])
end
return table.concat(out, ", ")
else
return ""
end
else
return input_parm
end
end
-- This is used to get a date value which won't be linked
p.getDateValue = function(frame)
local propertyID = mw.text.trim(frame.args[1] or "")
local input_parm = mw.text.trim(frame.args[2] or "")
if input_parm == "FETCH_WIKIDATA" then
local entity = mw.wikibase.getEntity()
if entity.claims[propertyID] ~= nil then
local out = {}
for k, v in pairs(entity.claims[propertyID]) do
out[#out + 1] = v.mainsnak.datavalue.value.time
end
return table.concat(out, ", ")
else
return ""
end
else
return input_parm
end
end
return p