Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Cargo banner

From Sekaipedia
Revision as of 16:27, 19 April 2022 by ChaoticShadow (talk | contribs)

Documentation for this module may be created at Module:Cargo banner/doc

local List = require('Module:List')
local MessageBox = require('Module:Message box')

local p = {}

function p.main(frame)
	local origArgs = frame:getParent().args
	local args = {}
	for k, v in pairs(origArgs) do
		v = v:match('^%s*(.-)%s*$')
		if v ~= '' then
			args[k] = v
		end
	end
	
	return p._main(args)
end

function p.renderBox(tables)
	local boxArgs = {}
	
	if #tables < 1 then
		boxArgs.text = '<strong class="error">Error: no tables specified</strong>'
	else
		local tableLinks = {}
		for i, tbl in ipairs(tables) do
			tableLinks[i] = string.format('[[Special:CargoTables/%s]]', tbl)
		end
		
		local tableList = List.makeList('bulleted', tableLinks)
		local title = mw.title.getCurrentTitle()
		if title.subpageText == "doc" then
			title = title.basePageTitle
		end
		
		if title.contentModel == "Scribunto" then
			boxArgs.text = 'This module uses the following [[mw:Extension:Cargo|Cargo]] tables:' .. tableList
		else
			boxArgs.text = 'This template uses the following [[mw:Extension:Cargo|Cargo]] tables:\n' .. tableList
		end
	end
	
	boxArgs.type = 'notice'
	boxArgs.small = true
	boxArgs.image = '[[File:Cargo logo.png|30px|alt=|link=]]'
	
	return MessageBox.main('mbox', boxArgs)
end

return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies.