Jump to content

Module:AfC topic

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by MusikBot II (talk | contribs) at 17:59, 12 November 2021 (Protected "Module:AfC topic": High-risk template or module: 279 transclusions (more info) ([Edit=Require autoconfirmed or confirmed access] (indefinite))). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local getArgs = require('Module:Arguments').getArgs
local JSON = require('Module:jf-JSON')

local p = {}

function p.main(frame)
	local args = getArgs(frame)
	return p._main(args)
end

function p._main(args)
	local ns = mw.title.getCurrentTitle().namespace
	if ns ~= 118 and ns ~= 2 then
		return '[[Category:AfC topic used in wrong namespace]]'
	end
	
	local jsondata = mw.title.new('Wikipedia:WikiProject Articles for creation/AfC topic map.json'):getContent()
	local data = JSON:decode(jsondata)
	
	local topic = args[1]
	local match = data[topic]
	
	if match ~= nil then
		return '[[Category:' .. match.category .. ']]'
	else 
		return '[[Category:AfC topic: invalid parameter]]'
	end
	
end

return p