Module:Infobox team: Difference between revisions
From TwogPedia
No edit summary Tag: Reverted |
No edit summary Tag: Reverted |
||
Line 13: | Line 13: | ||
local Flags = require('Module:Flags') | local Flags = require('Module:Flags') | ||
local Infobox = {} | local Infobox = {} | ||
-- function Infobox.main(frame) | |||
-- local args = getArgs(frame) | |||
-- local currentTitle = mw.title.getCurrentTitle().text | |||
-- local currentTitleSplit = mw.text.split(currentTitle, '/') | |||
-- local headerNode | |||
-- if args.logos then end | |||
-- if args.displaytitles then end | |||
-- local logoLight = VariablesLua.varexists('logoLight') and VariablesLua.var('logoLight') or nil | |||
-- local logoDark = VariablesLua.varexists('logoDark') and VariablesLua.var('logoDark') or nil | |||
-- local logoAll = VariablesLua.varexists('logoAll') and VariablesLua.var('logoAll') or nil | |||
-- if logoAll then | |||
-- headerNode = Header.make(args.title or currentTitle, nil, nil, logoAll) | |||
-- elseif logoLight or logoDark then | |||
-- headerNode = Header.make(args.title or currentTitle, logoLight, logoDark) | |||
-- elseif args.org then | |||
-- local currentDate = os.date('%Y-%m-%d') | |||
-- local tables = 'Logos' | |||
-- local fields = '_pageName, logoLight, logoDark, logoAll, start, end' | |||
-- local cargoArgs = { | |||
-- where = '_pageName="Companies/' .. args.org .. '" AND (start is NULL OR start < "' .. currentDate .. '") AND (end is NULL OR end > "' .. currentDate .. '")' | |||
-- } | |||
-- local results = cargo.query(tables, fields, cargoArgs) | |||
-- if #results > 0 then | |||
-- if results[1].logoAll then | |||
-- headerNode = Header.make(args.title or currentTitle, nil, nil, results[1].logoAll) | |||
-- else | |||
-- headerNode = Header.make(args.title or currentTitle, results[1].logoLight, results[1].logoDark) | |||
-- end | |||
-- end | |||
-- end | |||
-- local container = mw.html.create('div') | |||
-- :addClass('ib grid-infobox') | |||
-- :attr('id', 'grid-infobox-teams') | |||
-- 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 overlayContainer = mw.html.create('div'):addClass('info-row'):tag('div'):addClass('text-overlay') | |||
-- if args.roster then | |||
-- overlayContainer:node(RowWidget.make('Roster', LocationWidget.make(args.roster, args.city, currentTitleSplit[1] .. '/Teams'))) | |||
-- end | |||
-- if args.region then | |||
-- overlayContainer:node(RowWidget.make('Region', LocationWidget.make(args.region, nil, currentTitleSplit[1] .. '/Teams'))) | |||
-- end | |||
-- infoContainer:node(overlayContainer) | |||
-- local tables = 'Squads' | |||
-- local fields = '_pageName, captain, coach, manager, analyst' | |||
-- local cargoArgs = { where = '_pageName = "' .. currentTitle .. '"' } | |||
-- local results = cargo.query(tables, fields, cargoArgs) | |||
-- if #results > 0 then | |||
-- tables = 'People' | |||
-- fields = '_pageName, nationality, name, romanized' | |||
-- if results[1].captain then | |||
-- infoContainer:node(Infobox.personRow(results[1].captain, 'Captain', tables, fields, cargoArgs)) | |||
-- end | |||
-- if results[1].coach then | |||
-- infoContainer:node(Infobox.personRow(results[1].coach, 'Coach', tables, fields, cargoArgs)) | |||
-- end | |||
-- if results[1].manager then | |||
-- infoContainer:node(Infobox.personRow(results[1].manager, 'Manager', tables, fields, cargoArgs)) | |||
-- end | |||
-- if results[1].analyst then | |||
-- infoContainer:node(Infobox.personRow(results[1].analyst, 'Analyst', tables, fields, cargoArgs)) | |||
-- end | |||
-- end | |||
-- if args.founded then | |||
-- infoContainer:node(RowWidget.make('Founded', stringifyDate(args.founded))) | |||
-- end | |||
-- if args.org then | |||
-- infoContainer:node(RowWidget.make('Organization', 'Companies/' .. args.org, frame)) | |||
-- local sponsorTables = 'Sponsors' | |||
-- local sponsorFields = 'id, startRef, startRefName, endRef, endRefName' | |||
-- local sponsorArgs = { where = '_pageName="Companies/' .. args.org .. '"' } | |||
-- local sponsorResults = cargo.query(sponsorTables, sponsorFields, sponsorArgs) | |||
-- if #sponsorResults > 0 then | |||
-- infoContainer:node(RowWidget.make('Sponsors', SponsorsWidget.make(sponsorResults, frame))) | |||
-- end | |||
-- end | |||
-- if args.sponsors and not args.org then | |||
-- infoContainer:node(RowWidget.make('Sponsors', SponsorsWidget.make(args.sponsors, frame))) | |||
-- end | |||
-- if args.gamesponsors then | |||
-- infoContainer:node(RowWidget.make('Sponsors', SponsorsWidget.make(args.gamesponsors, frame))) | |||
-- end | |||
-- if args.coach then | |||
-- infoContainer:node(RowWidget.make('Coach', args.coach, frame)) | |||
-- end | |||
-- if args.manager then | |||
-- infoContainer:node(RowWidget.make('Manager', args.manager, frame)) | |||
-- end | |||
-- if args.captain then | |||
-- infoContainer:node(RowWidget.make('Captain', args.captain, frame)) | |||
-- end | |||
-- 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 | |||
-- if args.api_id then | |||
-- args.datdota = args.api_id | |||
-- args.dotabuff = args.api_id | |||
-- args.stratz = args.api_id | |||
-- end | |||
-- 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 | |||
-- container:node(infoContainer) | |||
-- local transformedLinks = Links.transform(args) | |||
-- local fullLinks = LinksWidget.make(transformedLinks, 'team') | |||
-- if fullLinks then | |||
-- local linksContainer = mw.html.create('div'):addClass('ib-links-container') | |||
-- :node(fullLinks) | |||
-- container:node(linksContainer) | |||
-- end | |||
-- return container | |||
-- end | |||
function Infobox.main(frame) | function Infobox.main(frame) | ||
Line 21: | Line 175: | ||
local headerNode | local headerNode | ||
-- sua lógica atual de logos (mantive igual) | |||
local logoLight = VariablesLua.varexists('logoLight') and VariablesLua.var('logoLight') or nil | local logoLight = VariablesLua.varexists('logoLight') and VariablesLua.var('logoLight') or nil | ||
local logoDark = VariablesLua.varexists('logoDark') and VariablesLua.var('logoDark') or nil | local logoDark = VariablesLua.varexists('logoDark') and VariablesLua.var('logoDark') or nil | ||
Line 61: | Line 213: | ||
container:node(titleContainer) | container:node(titleContainer) | ||
local | -- Criar o container info-image (imagem + texto sobreposto) | ||
local infoImage = mw.html.create('div'):addClass('info-image') | |||
-- Div da imagem | |||
local ibImage = mw.html.create('div'):addClass('ib-image relative') | |||
-- Aqui coloca a imagem, pegando a logo, ou se já tiver headerNode com a imagem, adaptar, mas vou supor que logoAll tem a url | |||
if logoAll then | |||
local imgLink = mw.html.create('a'):attr('href', logoAll):addClass('image') | |||
local imgTag = mw.html.create('img') | |||
:attr('src', logoAll) | |||
:attr('alt', args.title or currentTitle) | |||
:attr('decoding', 'async') | |||
:attr('width', '250') | |||
:attr('height', '250') | |||
imgLink:node(imgTag) | |||
ibImage:node(imgLink) | |||
elseif logoLight then | |||
local imgLink = mw.html.create('a'):attr('href', logoLight):addClass('image') | |||
local imgTag = mw.html.create('img') | |||
:attr('src', logoLight) | |||
:attr('alt', args.title or currentTitle) | |||
:attr('decoding', 'async') | |||
:attr('width', '250') | |||
:attr('height', '250') | |||
imgLink:node(imgTag) | |||
ibImage:node(imgLink) | |||
end | |||
infoImage:node(ibImage) | |||
-- Div do texto sobreposto | |||
local textOverlay = mw.html.create('div'):addClass('text-overlay') | |||
-- Título | |||
local ibTitle = mw.html.create('div'):addClass('ib-title'):wikitext(args.title or currentTitle) | |||
textOverlay:node(ibTitle) | |||
local | -- Info-row dentro do text-overlay, com roster e region | ||
local infoRow = mw.html.create('div'):addClass('info-row') | |||
if args.roster then | if args.roster then | ||
infoRow:node(RowWidget.make('Roster', LocationWidget.make(args.roster, args.city, currentTitleSplit[1] .. '/Teams'))) | |||
end | end | ||
if args.region then | if args.region then | ||
infoRow:node(RowWidget.make('Region', LocationWidget.make(args.region, nil, currentTitleSplit[1] .. '/Teams'))) | |||
end | end | ||
textOverlay:node(infoRow) | |||
infoContainer: | |||
infoImage:node(textOverlay) | |||
container:node(infoImage) | |||
-- Continue o infoContainer abaixo, para o resto dos dados (pessoa, founded, org, etc) | |||
local infoContainer = mw.html.create('div'):addClass('info-container grid') | |||
local tables = 'Squads' | local tables = 'Squads' | ||
Line 130: | Line 322: | ||
if args.captain then | if args.captain then | ||
infoContainer:node(RowWidget.make('Captain', args.captain, frame)) | infoContainer:node(RowWidget.make('Captain', args.captain, frame)) | ||
end | end | ||
Revision as of 23:22, 5 June 2025
Documentation for this module may be created at Module:Infobox team/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 SponsorsWidget = require('Module:Infobox/Widget/Sponsors')
local LocationWidget = require('Module:Infobox/Widget/Location')
local RowWidget = require('Module:Infobox/Widget/Row')
local stringifyDate = require('Module:Functions').stringifyDate
local cargo = mw.ext.cargo
VariablesLua = mw.ext.VariablesLua
local Flags = require('Module:Flags')
local Infobox = {}
-- function Infobox.main(frame)
-- local args = getArgs(frame)
-- local currentTitle = mw.title.getCurrentTitle().text
-- local currentTitleSplit = mw.text.split(currentTitle, '/')
-- local headerNode
-- if args.logos then end
-- if args.displaytitles then end
-- local logoLight = VariablesLua.varexists('logoLight') and VariablesLua.var('logoLight') or nil
-- local logoDark = VariablesLua.varexists('logoDark') and VariablesLua.var('logoDark') or nil
-- local logoAll = VariablesLua.varexists('logoAll') and VariablesLua.var('logoAll') or nil
-- if logoAll then
-- headerNode = Header.make(args.title or currentTitle, nil, nil, logoAll)
-- elseif logoLight or logoDark then
-- headerNode = Header.make(args.title or currentTitle, logoLight, logoDark)
-- elseif args.org then
-- local currentDate = os.date('%Y-%m-%d')
-- local tables = 'Logos'
-- local fields = '_pageName, logoLight, logoDark, logoAll, start, end'
-- local cargoArgs = {
-- where = '_pageName="Companies/' .. args.org .. '" AND (start is NULL OR start < "' .. currentDate .. '") AND (end is NULL OR end > "' .. currentDate .. '")'
-- }
-- local results = cargo.query(tables, fields, cargoArgs)
-- if #results > 0 then
-- if results[1].logoAll then
-- headerNode = Header.make(args.title or currentTitle, nil, nil, results[1].logoAll)
-- else
-- headerNode = Header.make(args.title or currentTitle, results[1].logoLight, results[1].logoDark)
-- end
-- end
-- end
-- local container = mw.html.create('div')
-- :addClass('ib grid-infobox')
-- :attr('id', 'grid-infobox-teams')
-- 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 overlayContainer = mw.html.create('div'):addClass('info-row'):tag('div'):addClass('text-overlay')
-- if args.roster then
-- overlayContainer:node(RowWidget.make('Roster', LocationWidget.make(args.roster, args.city, currentTitleSplit[1] .. '/Teams')))
-- end
-- if args.region then
-- overlayContainer:node(RowWidget.make('Region', LocationWidget.make(args.region, nil, currentTitleSplit[1] .. '/Teams')))
-- end
-- infoContainer:node(overlayContainer)
-- local tables = 'Squads'
-- local fields = '_pageName, captain, coach, manager, analyst'
-- local cargoArgs = { where = '_pageName = "' .. currentTitle .. '"' }
-- local results = cargo.query(tables, fields, cargoArgs)
-- if #results > 0 then
-- tables = 'People'
-- fields = '_pageName, nationality, name, romanized'
-- if results[1].captain then
-- infoContainer:node(Infobox.personRow(results[1].captain, 'Captain', tables, fields, cargoArgs))
-- end
-- if results[1].coach then
-- infoContainer:node(Infobox.personRow(results[1].coach, 'Coach', tables, fields, cargoArgs))
-- end
-- if results[1].manager then
-- infoContainer:node(Infobox.personRow(results[1].manager, 'Manager', tables, fields, cargoArgs))
-- end
-- if results[1].analyst then
-- infoContainer:node(Infobox.personRow(results[1].analyst, 'Analyst', tables, fields, cargoArgs))
-- end
-- end
-- if args.founded then
-- infoContainer:node(RowWidget.make('Founded', stringifyDate(args.founded)))
-- end
-- if args.org then
-- infoContainer:node(RowWidget.make('Organization', 'Companies/' .. args.org, frame))
-- local sponsorTables = 'Sponsors'
-- local sponsorFields = 'id, startRef, startRefName, endRef, endRefName'
-- local sponsorArgs = { where = '_pageName="Companies/' .. args.org .. '"' }
-- local sponsorResults = cargo.query(sponsorTables, sponsorFields, sponsorArgs)
-- if #sponsorResults > 0 then
-- infoContainer:node(RowWidget.make('Sponsors', SponsorsWidget.make(sponsorResults, frame)))
-- end
-- end
-- if args.sponsors and not args.org then
-- infoContainer:node(RowWidget.make('Sponsors', SponsorsWidget.make(args.sponsors, frame)))
-- end
-- if args.gamesponsors then
-- infoContainer:node(RowWidget.make('Sponsors', SponsorsWidget.make(args.gamesponsors, frame)))
-- end
-- if args.coach then
-- infoContainer:node(RowWidget.make('Coach', args.coach, frame))
-- end
-- if args.manager then
-- infoContainer:node(RowWidget.make('Manager', args.manager, frame))
-- end
-- if args.captain then
-- infoContainer:node(RowWidget.make('Captain', args.captain, frame))
-- end
-- 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
-- if args.api_id then
-- args.datdota = args.api_id
-- args.dotabuff = args.api_id
-- args.stratz = args.api_id
-- end
-- 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
-- container:node(infoContainer)
-- local transformedLinks = Links.transform(args)
-- local fullLinks = LinksWidget.make(transformedLinks, 'team')
-- if fullLinks then
-- local linksContainer = mw.html.create('div'):addClass('ib-links-container')
-- :node(fullLinks)
-- container:node(linksContainer)
-- end
-- return container
-- end
function Infobox.main(frame)
local args = getArgs(frame)
local currentTitle = mw.title.getCurrentTitle().text
local currentTitleSplit = mw.text.split(currentTitle, '/')
local headerNode
-- sua lógica atual de logos (mantive igual)
local logoLight = VariablesLua.varexists('logoLight') and VariablesLua.var('logoLight') or nil
local logoDark = VariablesLua.varexists('logoDark') and VariablesLua.var('logoDark') or nil
local logoAll = VariablesLua.varexists('logoAll') and VariablesLua.var('logoAll') or nil
if logoAll then
headerNode = Header.make(args.title or currentTitle, nil, nil, logoAll)
elseif logoLight or logoDark then
headerNode = Header.make(args.title or currentTitle, logoLight, logoDark)
elseif args.org then
local currentDate = os.date('%Y-%m-%d')
local tables = 'Logos'
local fields = '_pageName, logoLight, logoDark, logoAll, start, end'
local cargoArgs = {
where = '_pageName="Companies/' .. args.org .. '" AND (start is NULL OR start < "' .. currentDate .. '") AND (end is NULL OR end > "' .. currentDate .. '")'
}
local results = cargo.query(tables, fields, cargoArgs)
if #results > 0 then
if results[1].logoAll then
headerNode = Header.make(args.title or currentTitle, nil, nil, results[1].logoAll)
else
headerNode = Header.make(args.title or currentTitle, results[1].logoLight, results[1].logoDark)
end
end
end
local container = mw.html.create('div')
:addClass('ib grid-infobox')
:attr('id', 'grid-infobox-teams')
local titleContainer = mw.html.create('div')
:addClass('carousel-image-container')
:attr('id', 'image-container-small')
:node(headerNode)
container:node(titleContainer)
-- Criar o container info-image (imagem + texto sobreposto)
local infoImage = mw.html.create('div'):addClass('info-image')
-- Div da imagem
local ibImage = mw.html.create('div'):addClass('ib-image relative')
-- Aqui coloca a imagem, pegando a logo, ou se já tiver headerNode com a imagem, adaptar, mas vou supor que logoAll tem a url
if logoAll then
local imgLink = mw.html.create('a'):attr('href', logoAll):addClass('image')
local imgTag = mw.html.create('img')
:attr('src', logoAll)
:attr('alt', args.title or currentTitle)
:attr('decoding', 'async')
:attr('width', '250')
:attr('height', '250')
imgLink:node(imgTag)
ibImage:node(imgLink)
elseif logoLight then
local imgLink = mw.html.create('a'):attr('href', logoLight):addClass('image')
local imgTag = mw.html.create('img')
:attr('src', logoLight)
:attr('alt', args.title or currentTitle)
:attr('decoding', 'async')
:attr('width', '250')
:attr('height', '250')
imgLink:node(imgTag)
ibImage:node(imgLink)
end
infoImage:node(ibImage)
-- Div do texto sobreposto
local textOverlay = mw.html.create('div'):addClass('text-overlay')
-- Título
local ibTitle = mw.html.create('div'):addClass('ib-title'):wikitext(args.title or currentTitle)
textOverlay:node(ibTitle)
-- Info-row dentro do text-overlay, com roster e region
local infoRow = mw.html.create('div'):addClass('info-row')
if args.roster then
infoRow:node(RowWidget.make('Roster', LocationWidget.make(args.roster, args.city, currentTitleSplit[1] .. '/Teams')))
end
if args.region then
infoRow:node(RowWidget.make('Region', LocationWidget.make(args.region, nil, currentTitleSplit[1] .. '/Teams')))
end
textOverlay:node(infoRow)
infoImage:node(textOverlay)
container:node(infoImage)
-- Continue o infoContainer abaixo, para o resto dos dados (pessoa, founded, org, etc)
local infoContainer = mw.html.create('div'):addClass('info-container grid')
local tables = 'Squads'
local fields = '_pageName, captain, coach, manager, analyst'
local cargoArgs = { where = '_pageName = "' .. currentTitle .. '"' }
local results = cargo.query(tables, fields, cargoArgs)
if #results > 0 then
tables = 'People'
fields = '_pageName, nationality, name, romanized'
if results[1].captain then
infoContainer:node(Infobox.personRow(results[1].captain, 'Captain', tables, fields, cargoArgs))
end
if results[1].coach then
infoContainer:node(Infobox.personRow(results[1].coach, 'Coach', tables, fields, cargoArgs))
end
if results[1].manager then
infoContainer:node(Infobox.personRow(results[1].manager, 'Manager', tables, fields, cargoArgs))
end
if results[1].analyst then
infoContainer:node(Infobox.personRow(results[1].analyst, 'Analyst', tables, fields, cargoArgs))
end
end
if args.founded then
infoContainer:node(RowWidget.make('Founded', stringifyDate(args.founded)))
end
if args.org then
infoContainer:node(RowWidget.make('Organization', 'Companies/' .. args.org, frame))
local sponsorTables = 'Sponsors'
local sponsorFields = 'id, startRef, startRefName, endRef, endRefName'
local sponsorArgs = { where = '_pageName="Companies/' .. args.org .. '"' }
local sponsorResults = cargo.query(sponsorTables, sponsorFields, sponsorArgs)
if #sponsorResults > 0 then
infoContainer:node(RowWidget.make('Sponsors', SponsorsWidget.make(sponsorResults, frame)))
end
end
if args.sponsors and not args.org then
infoContainer:node(RowWidget.make('Sponsors', SponsorsWidget.make(args.sponsors, frame)))
end
if args.gamesponsors then
infoContainer:node(RowWidget.make('Sponsors', SponsorsWidget.make(args.gamesponsors, frame)))
end
if args.coach then
infoContainer:node(RowWidget.make('Coach', args.coach, frame))
end
if args.manager then
infoContainer:node(RowWidget.make('Manager', args.manager, frame))
end
if args.captain then
infoContainer:node(RowWidget.make('Captain', args.captain, frame))
end
container:node(infoContainer)
local transformedLinks = Links.transform(args)
local fullLinks = LinksWidget.make(transformedLinks, 'team')
if fullLinks then
local linksContainer = mw.html.create('div'):addClass('ib-links-container')
:node(fullLinks)
container:node(linksContainer)
end
return container
end
function Infobox.personRow(resultStr, rowName, tables, fields, cargoArgs)
local stringSplit = mw.text.split(resultStr, ',')
local personDiv = mw.html.create('div')
local flag = nil
for j = 1, #stringSplit do
local singleDiv = mw.html.create('div'):attr('style', 'display: flex; gap: 0.5rem;')
cargoArgs.where = '_pageName="' .. stringSplit[j] .. '"'
local personResults = cargo.query(tables, fields, cargoArgs)
if #personResults > 0 and personResults[1].nationality then
flag = Flags.icon(personResults[1].nationality)
end
personDiv:node(singleDiv:wikitext(flag):wikitext('[[' .. stringSplit[j] .. '|' .. string.gsub( stringSplit[j], 'People/' , '') .. ']]'))
end
return RowWidget.make(rowName, personDiv)
end
return Infobox
No categories