Module:Sandbox/Tollens/Contentious topics/list

local p = {}

local data = mw.loadJsonData("Module:Sandbox/Tollens/Contentious topics/data.json")

function p._normalizeCode(code) return data.names[string.lower(code)] end

function p._codeExists(code) return p._normalizeCode(code) ~= nil end

function p._scope(code) code = p._normalizeCode(code)

return code and data.details[code].scope or nil end

function p._link(code) code = p._normalizeCode(code)

return code and data.details[code].link or nil end

function p._topicSubpage(code) code = p._normalizeCode(code)

return code and data.details[code].topicSubpage or nil end

function p.list(frame) local args = frame:getParent.args

local request = nil local code = nil for k, v in pairs(args) do		if request ~= nil then return "Only one argument is allowed (help) " end

request = k		code = v	end

if request == nil then return "No argument was provided (help) " end

if request == "code exists" then return p._codeExists(code) and "yes" or "no" elseif request == "scope" then return p._scope(code) or "Invalid code (help) " elseif request == "link" then return p._link(code) or "Invalid code (help) " elseif request == "topic-subpage" then return p._topicSubpage(code) or "Invalid code (help) " else return "Invalid argument (help) " end end

return p