Difference between revisions of "Module:WikidataCheck"
Jump to navigation
Jump to search
blackwiki>Happy5214 m (Forgot category syntax) |
blackwiki>Legoktm (only work in ns0) |
||
| Line 9: | Line 9: | ||
local value = config.value | local value = config.value | ||
local catbase = config.category | local catbase = config.category | ||
| − | + | if not mw.title.getCurrentTitle().namespace == 0 then | |
| + | return "" | ||
| + | end | ||
local entity = mw.wikibase.getEntity() | local entity = mw.wikibase.getEntity() | ||
local hasProp = entity.claims[property] | local hasProp = entity.claims[property] | ||
Revision as of 18:09, 28 April 2013
- REDIRECT Template:WikidataCheck/doc
local p = {}
function p.wikidatacheck(frame)
local pframe = frame:getParent()
local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
local args = pframe.args -- the arguments passed TO the template, in the wikitext that transcludes the template
local property = config.property
local value = config.value
local catbase = config.category
if not mw.title.getCurrentTitle().namespace == 0 then
return ""
end
local entity = mw.wikibase.getEntity()
local hasProp = entity.claims[property]
if not hasProp then
return "[[Category:" .. catbase .. " not in Wikidata]]"
end
local propValue = hasProp[0].mainsnak.datavalue.value
if propValue == value then
return "[[Category:" .. catbase .. " same as Wikidata]]"
else
return "[[Category:" .. catbase .. " different from Wikidata]]"
end
end
return p