Module:Infobox company: Difference between revisions

From TwogPedia
(Created page with "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 Flags = require('Module:Flags') local Infobox = {} function Infobox.main(frame) local args = getArgs(frame) local currentTitleSplit = mw.text.split(mw.title.getCurrentTitle().text, '/') local head...")
 
No edit summary
Line 4: Line 4:
local Subheader = require('Module:Infobox/Widget/Subheader')
local Subheader = require('Module:Infobox/Widget/Subheader')
local LinksWidget = require('Module:Infobox/Widget/Links')
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 Flags = require('Module:Flags')
Line 18: Line 21:
:addClass('ib')
:addClass('ib')
container:node(headerNode):node(Subheader.make(args.variant .. ' Information'))
container:node(headerNode):node(Subheader.make('Tournament Information'))
if args.location then
if args.headquarter then
local countryName = Flags.CountryName(args.location)
container:node(RowWidget.make('Headquarter', LocationWidget.make(args.headquarter, args.city)))
local flag = Flags.icon(args.location, currentTitleSplit[1])
end
local location = mw.html.create('div')
:addClass('ib-row')
if args.founded then
local link = ':Category:' .. currentTitleSplit[1]  .. '/' .. countryName
container:node(RowWidget.make('Founded', args.founded))
local locationName = mw.html.create('span')
:wikitext('[[' .. link .. '|' .. countryName .. ']]')
local name = mw.html.create('div')
:addClass('ib-rowName')
:wikitext('Location: ')
local value = mw.html.create('div')
:wikitext(flag)
:node(locationName)
if args.location2 then
countryName = Flags.CountryName(args.location2)
flag = Flags.icon(args.location2, currentTitleSplit[1])
link = ':Category:' .. currentTitleSplit[1]  .. '/' .. countryName
local location2Name = mw.html.create('span')
:wikitext('[[' .. link .. '|' .. countryName .. ']]')
local location2 = mw.html.create('div')
:wikitext(flag)
:node(location2Name)
value:wikitext('<br>'):node(location2)
end
container:node(location:node(name):node(value))
end
end
if args.region then
if args.employees then  
local countryName = Flags.CountryName(args.region)
container:node(RowWidget.make('Employees', args.employees))
local flag = Flags.icon(args.region, currentTitleSplit[1])
local region = mw.html.create('div')
:addClass('ib-row')
local link = ':Category:' .. currentTitleSplit[1]  .. '/' .. countryName
local regionName = mw.html.create('span')
:wikitext('[[' .. link .. '|' .. countryName .. ']]')
local name = mw.html.create('div')
:addClass('ib-rowName')
:wikitext('Region: ')
local value = mw.html.create('div')
:wikitext(flag)
:node(regionName)
container:node(region:node(name):node(value))
end
end
if args.founded then
if args.sponsors then
local founded = mw.html.create('div')
container:node(RowWidget.make('Sponsors', ListWidget.make(args.sponsors)))
:addClass('ib-row')
local name = mw.html.create('div')
:addClass('ib-rowName')
:wikitext('Founded: ')
local value = mw.html.create('div')
:wikitext(args.founded)
container:node(founded:node(name):node(value))
end
end
if args.coach then
if args.type then
local coach = mw.html.create('div')
container:node(RowWidget.make('Type', args.type))
:addClass('ib-row')
local name = mw.html.create('div')
:addClass('ib-rowName')
:wikitext('Coach: ')
local value = mw.html.create('div')
local pageExists = frame:callParserFunction('#ifexist', args.coach, 'yes', 'no' )
if ( pageExists == 'yes' ) then
value:wikitext('<span>[[' .. args.coach .. '|' .. args.coach .. ']]</span>')
else
value:wikitext(args.coach)
end
container:node(coach:node(name):node(value))
end
end
if args.manager then
if args.parent then
local manager = mw.html.create('div')
container:node(RowWidget.make('Parent', args.parent))
:addClass('ib-row')
local name = mw.html.create('div')
:addClass('ib-rowName')
:wikitext('Manager: ')
local value = mw.html.create('div')
local pageExists = frame:callParserFunction('#ifexist', args.manager, 'yes', 'no' )
if ( pageExists == 'yes' ) then
value:wikitext('<span>[[' .. args.manager .. '|' .. args.manager .. ']]</span>')
else
value:wikitext(args.manager)
end
container:node(manager:node(name):node(value))
end
end
if args.captain then
if args.subsidiaries then
local captain = mw.html.create('div')
container:node(RowWidget.make('Sponsors', ListWidget.make(args.subsidiaries)))
:addClass('ib-row')
local name = mw.html.create('div')
:addClass('ib-rowName')
:wikitext('Manager: ')
local value = mw.html.create('div')
local pageExists = frame:callParserFunction('#ifexist', args.captain, 'yes', 'no' )
if ( pageExists == 'yes' ) then
value:wikitext('<span>[[' .. args.captain .. '|' .. args.captain .. ']]</span>')
else
value:wikitext(args.captain)
end
container:node(captain:node(name):node(value))
end
end
Line 135: Line 58:
container:node(fullLinks)
container:node(fullLinks)
return container
return container
end
end


return Infobox
return Infobox

Revision as of 19:51, 31 August 2022

Documentation for this module may be created at Module:Infobox company/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 currentTitleSplit = mw.text.split(mw.title.getCurrentTitle().text, '/')
	
	local headerNode = Header.make(args.title or currentTitleSplit[2], args.image or '')
	
	local container = mw.html.create('div')
		:addClass('ib')
		
	container:node(headerNode):node(Subheader.make('Tournament Information'))
	
	if args.headquarter then
		container:node(RowWidget.make('Headquarter', LocationWidget.make(args.headquarter, args.city)))
	end
	
	if args.founded then
		container:node(RowWidget.make('Founded', args.founded))
	end
	
	if args.employees then 
		container:node(RowWidget.make('Employees', args.employees))
	end
	
	if args.sponsors then
		container:node(RowWidget.make('Sponsors', ListWidget.make(args.sponsors)))
	end
	
	if args.type then
		container:node(RowWidget.make('Type', args.type))
	end
	
	if args.parent then
		container:node(RowWidget.make('Parent', args.parent))
	end
	
	if args.subsidiaries then
		container:node(RowWidget.make('Sponsors', ListWidget.make(args.subsidiaries)))
	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