Jump to content

Module:Sandbox/ProcrastinatingReader

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by ProcrastinatingReader (talk | contribs) at 14:56, 23 July 2020 (no tag error). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local p = {}
local getArgs = require('Module:Arguments').getArgs
local error = require('Module:Error')
local tableTools = require('Module:TableTools')
local data = mw.loadData('Module:Sandbox/ProcrastinatingReader/data')

function p.main(frame)
	local args = getArgs(frame, {
		wrappers = {
			--'Template:Sandbox/ProcrastinatingReader'
		}
	})
	return p.build(frame, args)
end

function p.build(frame, args)
	local criterion = args['criterion']
	if criterion == nil or data[criterion] == nil then
		return error.error({message = "Valid CSD not provided"})
	end
	
	local cdata = data[criterion]
	local tag = cdata.tag
	
	if tag == nil then
		return error.error({message = "CSD "..criterion.." does not have a tag"})
	end

	template = frame:expandTemplate{ title = 'db-meta', args = {
		-- Required
		' '..tag['message'],												-- Main text, in bold
		tag['extra'] or '',														-- Main text, in italics
		criterion = criterion,													-- Criteron

		-- Additional data
		notes = tag['notes'] or '',
		anotes = tag['anotes'] or '',
		summary = data[criterion]['description'],
		temp = data[criterion]['warn_template'],

		-- Pass generic params onto db-meta
		bot = args['bot'] or '',
		raw = args['raw'] or '',
		['self'] = tag['self'] or '',
		image = args['image'] or '',
		wiki = args['wiki'] or '',
		blanked = args['blanked'] or '',
		blankedtext = args['blanked-text'] or '',
		pleaseblank = args['pleaseblank'] or '',
		divblank = args['divblank'] or '',
		help = args['help'] or ''
	}}

	categorisation = '<includeonly>' .. frame:expandTemplate{
		title = 'cat handler',
		args = {
			['all'] = '{{NOINDEX}}[[:Category:Candidates for speedy deletion]][[:Category:'..cdata['tracking_category']..']]',
			['nocat'] = 'false'
		}
	} .. '</includeonly>'

	return template .. frame:preprocess(categorisation)
end

return p