Módulo:WBHacks
Aspeto
Este módulo não apresenta nenhuma documentação. Por favor, documente-o caso o saiba usar ou tenha conhecimentos para tal. |
JSON = require('Module:JSON')
local p = {}
function p.get( id )
--this just returns the json object of the id
local id = id
if string.find(id, "P") ~= nil then
if string.find(id, "Property") == nil then
id = "Property:" .. id
end
end
local pg = mw.title.new(id):getContent()
return pg and JSON:decode(pg)
end
function p.thing(obj, typ, lang)
-- Can be used to fetch either label or description, depends on what you want.
local x = obj[typ][lang]
if x == nil then
x = obj[typ].en -- fallback to english
end
return x
end
function p.label(frame)
local config = frame.args
local qid = config.qid
local lang = config.lang
local obj = p.get(qid)
return obj and p.thing(obj, "label", lang) or "(no label)"
end
function p.description(frame)
local config = frame.args
local qid = config.qid
local lang = config.lang
local obj = p.get(qid)
return p.thing(obj, "description", lang)
end
function p.howmany(frame)
local config = frame.args
local qid = config.qid
local obj = p.get(qid)
local count = 0
for language,value in pairs(obj[config.what]) do
count=count+1
end
return count
end
function p.datatype(frame)
local config = frame.args
local qid = config.qid
local obj = p.get(qid)
return obj["datatype"]
end
return p