Módulo:Notícia Grande

De RuneScape Wiki
Ir para: navegação, pesquisa

A documentação para este módulo pode ser criada em Módulo:Notícia Grande/doc

-- <nowiki>
local paramtest = require('Module:Paramtest')
local p = {}

local defaultSize = {
	['achievements'] = '27x27px',
	['anachronia'] = '27x27px',
	['audio'] = '27x27px',
	['bgh'] = '27x27px',
	['bosses1'] = '27x27px',
	['bounty hunter'] = '22x27px',
	['cape of legends'] = 'x32px',
	['clues'] = '22x27px',
	['chat'] = '22x27px',
	['combat'] = '27x27px',
	['divine fire spirits'] = '22x27px',
	['fire spirit'] = '22x27px',
	['grand exchange'] = '22x27px',
	['graphics'] = 'x24px',
	['grouping system'] = '22x27px',
	['huge parcel'] = '27x27px',
	['incense sticks'] = '27x27px',
	['interface'] = '27x27px',
	['keyboard'] = '27x27px',
	['life refresh'] = '27x27px',
	['mallory'] = 'x32px',
	['markus'] = '27x27px',
	['minigames'] = '27x27px',
	['mining'] = '27x27px',
	['mobile'] = '22x27px',
	['nex'] = '22x27px',
	['nxt'] = '22x27px',
	['ninja'] = 'x22px',
	['obsidian cape'] = 'x32px',
	['ports'] = '22x27px',
	['quests'] = '27x27px',
	['ring of death'] = '24x24px',
	['skilling'] = '27x27px',
	['smithing'] = '27x27px', 
	['solomon'] = '27x27px',
	['teleport'] = '24x24px',
	['trimmed masterwork'] = '27x27px',
	['wilderness'] = '27x27px',
	['zanaris'] = '24x24px',
}

function p.main(frame)
	return p._main(frame:getParent().args)
end

function p._main(args)
	local icons = ''
	if paramtest.has_content(args.icons) then
		local iconList = {}

		for icon in mw.text.gsplit(args.icons, ';') do
			icon = mw.text.split(icon, ',')
			local name = mw.ustring.lower(mw.text.trim(icon[1]))
			local size = icon[2]
			if paramtest.is_empty(size) then
				size = paramtest.default_to(defaultSize[name], '')
			else
				size = mw.text.trim(size)
				if tonumber(size) then
					size = string.format('x%spx', size)
				end
			end

			table.insert(iconList, string.format('[[File:Patch notes %s header icon.png|link=|%s]]', name, size))
		end

		table.insert(iconList, ' ')

		icons = table.concat(iconList)
	end

	local title = ''

	-- hacky way of letting a literal pipe character replace syntax pipes
	-- functionality preserved for backwards-compatibility with usage of {{UB}}
	local anonymous_args = {}
	for _, v in ipairs(args) do
		table.insert(anonymous_args, v)
	end

	title = table.concat(anonymous_args, ' | ')
	
	local headerLevel = tonumber(args.header) or 2
	local headerTag = string.rep('=', headerLevel)
	return string.format(headerTag .. '%s%s' .. headerTag, icons, title)
end

return p

-- </nowiki>