Module:Infobox location

From TwogPedia
Revision as of 14:19, 4 September 2022 by Couchor (talk | contribs)

Documentation for this module may be created at Module:Infobox location/doc

local getArgs = require('Module:Arguments').getArgs
local Links = require('Module:Links')
local Header = require('Module:Infobox/Widget/Header')
local Subheader = require('Module:Infobox/Widget/Subheader')
local LinksWidget = require('Module:Infobox/Widget/Links')
local ListWidget = require('Module:Infobox/Widget/List')
local LocationWidget = require('Module:Infobox/Widget/Location')
local RowWidget = require('Module:Infobox/Widget/Row')

local Flags = require('Module:Flags')
local Infobox = {}

function Infobox.main(frame)
	local args = getArgs(frame)
	
	local headerNode = Header.make(args.title or mw.title.getCurrentTitle(), args.image or '')
	
	local container = mw.html.create('div')
		:addClass('ib')
		
	container:node(headerNode):node(Subheader.make('Location Information'))
	
	if args.opened then
		container:node(RowWidget.make('Opened', args.opened))
	end
	
	if args.type then
		container:node(RowWidget.make('Type', args.type))
	end
	
	if args.country then
		container:node(RowWidget.make('Location', LocationWidget.make(args.country, args.city, 'Locations')))
	end
	
	if args.address then
		container:node(RowWidget.make('Address', args.address))
	end
	
	if args.capacity then
		container:node(RowWidget.make('Capacity', args.capacity))
	end
	if args.franchise then
		container:node(RowWidget.make('Franchise', args.franchise, frame))
	end
	
	if args.sponsors then
		container:node(RowWidget.make('Sponsors', ListWidget.make(args.sponsors)))
	end
	
	container:node(Subheader.make('Links'))
	
	local transformedLinks = Links.transform(args)
	local fullLinks = LinksWidget.make(transformedLinks, 'team')
	
	container:node(fullLinks)
	return container
end

return Infobox