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

Module:Cargo banner: Difference between revisions

From Sekaipedia
Content added Content deleted
No edit summary
No edit summary
Line 36: Line 36:
local tableLinks = {}
local tableLinks = {}
for i, tbl in ipairs(tables) do
for i, tbl in ipairs(tables) do
tableLinks[i] = string.format('[[Special:CargoTables/%s]]', tbl)
tableLinks[i] = string.format('[[Special:CargoTables/%s|%s]]', tbl, tbl)
end
end

Revision as of 16:30, 19 April 2022

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

local List = require('Module:List')
local TableTools = require('Module:TableTools')
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._main(args)
	local modules = TableTools.compressSparseArray(args)
	local box = p.renderBox(modules)
	-- local trackingCategories = p.renderTrackingCategories(args, modules)
	local trackingCategories = ''
	
	return box .. trackingCategories
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|%s]]', tbl, 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.