Moduł:Sterowanie SG

Z Nonsensopedii, polskiej encyklopedii humoru

local tools = require('Moduł:Narzędzia')
local p = {}

local settings = {}

local function parseSettings(frame)
	local args = tools.getArgs(frame)
	
	-- artykuł
	local amode = args['tryb_art'] or ''
	local aset = {}
	
	if amode == 'konkurs' then
		aset.template = args['konkurs'] or 'Brak szablonu'
		aset.readable = '[[' .. aset.template .. ']]'
	elseif amode == 'anm' then
		aset.template = 'ANM główna'
		aset.arg = args['anm'] or 'NIE PODANO TYTUŁU ARTYKUŁU'
		aset.readable = '[[' .. aset.arg .. ']] ([[Szablon:ANM/' .. aset.arg .. ']])'
	elseif amode == 'promowane' then
		aset.template = 'Promowane'
		aset.arg = args['promowane'] or 'NIE PODANO TYTUŁU ARTYKUŁU'
		aset.readable = '[[' .. aset.arg .. ']] ([[Szablon:Promowane/' .. aset.arg .. ']])'
	else -- zakładamy losowy anm
		amode = 'losowy anm'
		aset.template = 'ANM główna'
		aset.readable = 'jak losowy to losowy, nie?'
	end
	settings.amode = amode
	settings.art = aset
end

local function infoPanel(frame)
	local wt = '== Obecne ustawienia ==\n' ..
		'=== Wyróżniony artykuł ===\n' ..
		'* Tryb: ' .. settings.amode .. '\n' ..
		'* Więcej informacji: ' .. settings.art.readable .. '\n'
	return frame:preprocess(wt)
end

function p.main(frame)
	parseSettings(frame)
	return infoPanel(frame)
end

return p