Module:Infobox company: Difference between revisions

From TwogPedia
mNo edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 27: Line 27:
end
end
local container = mw.html.create('div')
local container = mw.html.create('div'):addClass('ib grid-infobox')
:addClass('ib')
local titleContainer = mw.html.create('div')
        :addClass('carousel-image-container')
        :attr('id', 'image-container-small')
        :node(headerNode)
 
    container:node(titleContainer)
local infoContainer = mw.html.create('div'):addClass('info-container grid')
-- local titleParts = mw.text.split(mw.title.getCurrentTitle().text, "/")
-- local companyName = titleParts[2] or mw.title.getCurrentTitle().text
-- local companyRow = mw.html.create('div'):addClass('ib-row')
-- local labelDiv = mw.html.create('div'):addClass('ib-rowName')
-- local valueDiv = mw.html.create('div')
--    :wikitext(companyName)
--    :css('font-weight', '700')
--    :css('font-size', '24px')
--    :css('color', '#ECEBEB')
-- companyRow:node(labelDiv)
-- companyRow:node(valueDiv)
-- infoContainer:node(companyRow)
local infoContainer = mw.html.create('div'):addClass('info-container grid')
local titleParts = mw.text.split(mw.title.getCurrentTitle().text, "/")
local companyName = titleParts[2] or mw.title.getCurrentTitle().text
container:node(headerNode):node(Subheader.make('Company Information'))
local companyRow = mw.html.create('div')
    :addClass('ib-row')
    :css('column-gap', '0', 'important')
local labelDiv = mw.html.create('div'):addClass('ib-rowName')
local valueDiv = mw.html.create('div')
    :wikitext(companyName)
    :css('font-weight', '700')
    :css('font-size', '20px')
    :css('color', '#ECEBEB')
companyRow:node(labelDiv)
companyRow:node(valueDiv)
infoContainer:node(companyRow)
 
if args.country then
if args.country then
container:node(RowWidget.make('Headquarter', LocationWidget.make(args.country, args.city, 'Companies')))
infoContainer:node(RowWidget.make('Headquarter', LocationWidget.make(args.country, args.city, 'Companies')))
end
end
if args.founded then
if args.founded then
container:node(RowWidget.make('Founded', args.founded))
infoContainer:node(RowWidget.make('Founded', args.founded))
end
end
if args.employees then  
if args.employees then  
container:node(RowWidget.make('Employees', args.employees))
infoContainer:node(RowWidget.make('Employees', args.employees))
end
end
if args.sponsors then
if args.sponsors then
container:node(RowWidget.make('Sponsors', SponsorsWidget.make(args.sponsors, frame) ))
infoContainer:node(RowWidget.make('Sponsors', SponsorsWidget.make(args.sponsors, frame)))
end
end
if args.type then
if args.type then
container:node(RowWidget.make('Type', args.type))
infoContainer:node(RowWidget.make('Type', args.type))
end
end
if args.parentcompany then
if args.parentcompany then
container:node(RowWidget.make('Parent company', args.parentcompany, frame, 'Companies/'))
infoContainer:node(RowWidget.make('Parent company', args.parentcompany, frame, 'Companies/'))
end
end
if args.subsidiaries then
if args.subsidiaries then
container:node(RowWidget.make('Subsidiaries', ListWidget.make(args.subsidiaries, 'Companies/')))
infoContainer:node(RowWidget.make('Subsidiaries', ListWidget.make(args.subsidiaries, 'Companies/')))
end
 
    -- Check if there is a "links" argument and then do magic to add them all to arguments
if args.links then
local splitLinks = mw.text.split(args.links, ',')
for i = 1, #splitLinks do
local split = mw.text.split(splitLinks[i], '=')
args[split[1]] = split[2]
end
end
end
local linksContainer = mw.html.create('div'):addClass('ib-links-container')
local transformedLinks = Links.transform(args)
local transformedLinks = Links.transform(args)
local fullLinks = LinksWidget.make(transformedLinks, 'team')
local fullLinks = LinksWidget.make(transformedLinks, 'team')
if fullLinks then
if fullLinks then
container:node(Subheader.make('Links'))
linksContainer:node(fullLinks)
container:node(fullLinks)
end
end
container:node(infoContainer)
    container:node(linksContainer)
   
return container
return container
end
end


return Infobox
return Infobox

Latest revision as of 02:09, 26 April 2025

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 SponsorsWidget = require('Module:Infobox/Widget/Sponsors')
local LocationWidget = require('Module:Infobox/Widget/Location')
local RowWidget = require('Module:Infobox/Widget/Row')

VariablesLua = mw.ext.VariablesLua

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

function Infobox.main(frame)
	local args = getArgs(frame)
	local headerNode
	
	if args.logos then
		local logoAll = VariablesLua.varexists( 'logoAll' ) and VariablesLua.var('logoAll') or nil
		local logoLight = VariablesLua.varexists( 'logoLight' ) and VariablesLua.var('logoLight') or nil
		local logoDark = VariablesLua.varexists( 'logoDark' ) and VariablesLua.var('logoDark') or nil
		headerNode = Header.make(args.title or mw.title.getCurrentTitle().text, logoLight, logoDark, logoAll)
	elseif args.logoAll or args.logoLight or args.logoDark then
		 headerNode = Header.make(args.title or mw.title.getCurrentTitle().text, args.logoLight, args.logoDark, args.logoAll)
	end
	
	local container = mw.html.create('div'):addClass('ib grid-infobox')
	
	local titleContainer = mw.html.create('div')
        :addClass('carousel-image-container')
        :attr('id', 'image-container-small')
        :node(headerNode)

    container:node(titleContainer)
	
	local infoContainer = mw.html.create('div'):addClass('info-container grid')
	
	-- local titleParts = mw.text.split(mw.title.getCurrentTitle().text, "/")
	-- local companyName = titleParts[2] or mw.title.getCurrentTitle().text
	
	-- local companyRow = mw.html.create('div'):addClass('ib-row')
	-- local labelDiv = mw.html.create('div'):addClass('ib-rowName')
	-- local valueDiv = mw.html.create('div')
	--     :wikitext(companyName)
	--     :css('font-weight', '700')
	--     :css('font-size', '24px')
	--     :css('color', '#ECEBEB')
	-- companyRow:node(labelDiv)
	-- companyRow:node(valueDiv)
	-- infoContainer:node(companyRow)
	
	local infoContainer = mw.html.create('div'):addClass('info-container grid')
	
	local titleParts = mw.text.split(mw.title.getCurrentTitle().text, "/")
	local companyName = titleParts[2] or mw.title.getCurrentTitle().text
		
	local companyRow = mw.html.create('div')
	    :addClass('ib-row')
	    :css('column-gap', '0', 'important')
	local labelDiv = mw.html.create('div'):addClass('ib-rowName')
	local valueDiv = mw.html.create('div')
	    :wikitext(companyName)
	    :css('font-weight', '700')
	    :css('font-size', '20px')
	    :css('color', '#ECEBEB')
	companyRow:node(labelDiv)
	companyRow:node(valueDiv)
	infoContainer:node(companyRow)

	if args.country then
		infoContainer:node(RowWidget.make('Headquarter', LocationWidget.make(args.country, args.city, 'Companies')))
	end
	
	if args.founded then
		infoContainer:node(RowWidget.make('Founded', args.founded))
	end
	
	if args.employees then 
		infoContainer:node(RowWidget.make('Employees', args.employees))
	end
	
	if args.sponsors then
		infoContainer:node(RowWidget.make('Sponsors', SponsorsWidget.make(args.sponsors, frame)))
	end
	
	if args.type then
		infoContainer:node(RowWidget.make('Type', args.type))
	end
	
	if args.parentcompany then
		infoContainer:node(RowWidget.make('Parent company', args.parentcompany, frame, 'Companies/'))
	end
	
	if args.subsidiaries then
		infoContainer:node(RowWidget.make('Subsidiaries', ListWidget.make(args.subsidiaries, 'Companies/')))
	end
	
	local linksContainer = mw.html.create('div'):addClass('ib-links-container')
	local transformedLinks = Links.transform(args)
	local fullLinks = LinksWidget.make(transformedLinks, 'team')
	
	if fullLinks then
		linksContainer:node(fullLinks)
	end
	
	container:node(infoContainer)
    container:node(linksContainer)
    
	return container
end

return Infobox