diff --git a/lua/wikis/ageofempires/Match/Legacy.lua b/lua/wikis/ageofempires/Match/Legacy.lua index 51cd2a521fa..47710329b40 100644 --- a/lua/wikis/ageofempires/Match/Legacy.lua +++ b/lua/wikis/ageofempires/Match/Legacy.lua @@ -14,6 +14,7 @@ local Json = Lua.import('Module:Json') local Operator = Lua.import('Module:Operator') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper') local MatchLegacyUtil = Lua.import('Module:MatchGroup/Legacy/Util') @@ -131,7 +132,7 @@ function MatchLegacy._convertParameters(match2) match[prefix .. 'flag'] = player.flag match.extradata[prefix .. 'name'] = player.displayname elseif opponent.type == Opponent.team then - match[prefix] = mw.ext.TeamTemplate.raw(opponent.template).page + match[prefix] = TeamTemplate.getRaw(opponent.template).page match[prefix..'score'] = (tonumber(opponent.score) or 0) > 0 and opponent.score or 0 local opponentplayers = {} for i, player in pairs(opponentmatch2players) do diff --git a/lua/wikis/ageofempires/MatchGroup/Input/Custom.lua b/lua/wikis/ageofempires/MatchGroup/Input/Custom.lua index 5271f7b6145..b5af7facf98 100644 --- a/lua/wikis/ageofempires/MatchGroup/Input/Custom.lua +++ b/lua/wikis/ageofempires/MatchGroup/Input/Custom.lua @@ -18,6 +18,7 @@ local Operator = Lua.import('Module:Operator') local Page = Lua.import('Module:Page') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local Variables = Lua.import('Module:Variables') local MatchGroupInputUtil = Lua.import('Module:MatchGroup/Input/Util') @@ -94,7 +95,7 @@ function MatchFunctions.readOpponent(match, opponentIndex, options) local manualPlayersInput = MatchGroupInputUtil.extractManualPlayersInput(match, opponentIndex, opponentInput) substitutions = manualPlayersInput.substitutions -- Change compared to commons MatchGroupInputUtil.readOpponent - local template = mw.ext.TeamTemplate.raw(opponent.template or '') or {} + local template = TeamTemplate.getRawOrNil(opponent.template) or {} opponent.players = MatchGroupInputUtil.readPlayersOfTeam( template.page or '', manualPlayersInput, diff --git a/lua/wikis/apexlegends/Infobox/Person/Player/Custom.lua b/lua/wikis/apexlegends/Infobox/Person/Player/Custom.lua index bb6f32ca0b0..52d9872efbd 100644 --- a/lua/wikis/apexlegends/Infobox/Person/Player/Custom.lua +++ b/lua/wikis/apexlegends/Infobox/Person/Player/Custom.lua @@ -16,6 +16,7 @@ local Logic = Lua.import('Module:Logic') local Page = Lua.import('Module:Page') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local UpcomingMatches = Lua.import('Module:Matches Player') local Injector = Lua.import('Module:Widget/Injector') @@ -112,7 +113,7 @@ function CustomPlayer:adjustLPDB(lpdbData, args) end if String.isNotEmpty(args.team2) then - lpdbData.extradata.team2 = mw.ext.TeamTemplate.raw(args.team2).page + lpdbData.extradata.team2 = TeamTemplate.getPageName(args.team2) end return lpdbData diff --git a/lua/wikis/arenafps/Match/Legacy.lua b/lua/wikis/arenafps/Match/Legacy.lua index 9478ad92256..ba8ecd64835 100644 --- a/lua/wikis/arenafps/Match/Legacy.lua +++ b/lua/wikis/arenafps/Match/Legacy.lua @@ -14,6 +14,7 @@ local Json = Lua.import('Module:Json') local Operator = Lua.import('Module:Operator') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local MatchLegacyUtil = Lua.import('Module:MatchGroup/Legacy/Util') @@ -68,7 +69,7 @@ function MatchLegacy._convertParameters(match2) local opponent = match2.match2opponents[index] or {} local opponentmatch2players = opponent.match2players or {} if opponent.type == 'team' then - match[prefix] = mw.ext.TeamTemplate.teampage(opponent.template) + match[prefix] = TeamTemplate.getRaw(opponent.template).page match[prefix .. 'score'] = (tonumber(opponent.score) or 0) > 0 and opponent.score or 0 local opponentplayers = {} Array.forEach(opponentmatch2players, function(player) diff --git a/lua/wikis/battalion/Match/Legacy.lua b/lua/wikis/battalion/Match/Legacy.lua index d796ba5b5d0..1d273b882aa 100644 --- a/lua/wikis/battalion/Match/Legacy.lua +++ b/lua/wikis/battalion/Match/Legacy.lua @@ -14,6 +14,7 @@ local Json = Lua.import('Module:Json') local Operator = Lua.import('Module:Operator') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local MatchLegacyUtil = Lua.import('Module:MatchGroup/Legacy/Util') @@ -74,7 +75,7 @@ function MatchLegacy._convertParameters(match2) local opponent = match2.match2opponents[opponentIndex] or {} local opponentmatch2players = opponent.match2players or {} if opponent.type == 'team' then - match[prefix] = mw.ext.TeamTemplate.teampage(opponent.template) + match[prefix] = TeamTemplate.getRaw(opponent.template).page match[prefix..'score'] = (tonumber(opponent.score) or 0) > 0 and opponent.score or 0 local opponentplayers = {} for playerIndex = 1, 10 do diff --git a/lua/wikis/brawlstars/Match/Legacy.lua b/lua/wikis/brawlstars/Match/Legacy.lua index cc312721884..ed7082ce428 100644 --- a/lua/wikis/brawlstars/Match/Legacy.lua +++ b/lua/wikis/brawlstars/Match/Legacy.lua @@ -14,6 +14,7 @@ local Json = Lua.import('Module:Json') local Operator = Lua.import('Module:Operator') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local MatchLegacyUtil = Lua.import('Module:MatchGroup/Legacy/Util') local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper') @@ -107,7 +108,7 @@ function MatchLegacy._convertParameters(match2) local opponentmatch2players = opponent.match2players or {} if opponent.type == 'team' then match.extradata['team' .. index .. 'icon'] = opponent.icon - match[prefix] = mw.ext.TeamTemplate.teampage(opponent.template) + match[prefix] = TeamTemplate.getRaw(opponent.template).page match[prefix .. 'score'] = (tonumber(opponent.score) or 0) > 0 and opponent.score or 0 local opponentplayers = {} diff --git a/lua/wikis/callofduty/Match/Legacy.lua b/lua/wikis/callofduty/Match/Legacy.lua index 2178354370f..374e334f77f 100644 --- a/lua/wikis/callofduty/Match/Legacy.lua +++ b/lua/wikis/callofduty/Match/Legacy.lua @@ -14,6 +14,7 @@ local Json = Lua.import('Module:Json') local Operator = Lua.import('Module:Operator') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper') local MatchLegacyUtil = Lua.import('Module:MatchGroup/Legacy/Util') @@ -101,7 +102,7 @@ function MatchLegacy._convertParameters(match2) local opponent = match2.match2opponents[index] or {} local opponentmatch2players = opponent.match2players or {} if opponent.type == 'team' then - match[prefix] = mw.ext.TeamTemplate.teampage(opponent.template) + match[prefix] = TeamTemplate.getRaw(opponent.template).page match[prefix..'score'] = (tonumber(opponent.score) or 0) > 0 and opponent.score or 0 local opponentplayers = {} for i = 1,10 do diff --git a/lua/wikis/commons/AutomaticPointsTable/Display.lua b/lua/wikis/commons/AutomaticPointsTable/Display.lua index 59e1600ffd1..95c89d183cf 100644 --- a/lua/wikis/commons/AutomaticPointsTable/Display.lua +++ b/lua/wikis/commons/AutomaticPointsTable/Display.lua @@ -10,6 +10,7 @@ local Lua = require('Module:Lua') local Array = Lua.import('Module:Array') local Class = Lua.import('Module:Class') local Logic = Lua.import('Module:Logic') +local OpponentDisplay = Lua.import('Module:OpponentDisplay/Custom') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') @@ -144,7 +145,7 @@ end function TableRow:nameCell(team) local lastAlias = team.aliases[#team.aliases] - local teamDisplay = team.display and team.display or mw.ext.TeamTemplate.team(lastAlias) + local teamDisplay = team.display and team.display or OpponentDisplay.InlineTeamContainer{template = lastAlias} local nameCell = self:baseCell(teamDisplay, team.bg):addClass('name-cell') table.insert(self.cells, nameCell) return self diff --git a/lua/wikis/commons/AutomaticPointsTable/MinifiedDisplay.lua b/lua/wikis/commons/AutomaticPointsTable/MinifiedDisplay.lua index 37168822776..0a3db504e2f 100644 --- a/lua/wikis/commons/AutomaticPointsTable/MinifiedDisplay.lua +++ b/lua/wikis/commons/AutomaticPointsTable/MinifiedDisplay.lua @@ -9,6 +9,7 @@ local Lua = require('Module:Lua') local Array = Lua.import('Module:Array') local Class = Lua.import('Module:Class') +local OpponentDisplay = Lua.import('Module:OpponentDisplay/Custom') local PointsDivTable = Class.new( function(self, pointsData, tournaments, positionBackgrounds, limit) @@ -123,7 +124,7 @@ end function TableRow:nameCell(team) local lastAlias = team.aliases[#team.aliases] - local teamDisplay = team.display and team.display or mw.ext.TeamTemplate.team(lastAlias) + local teamDisplay = team.display and team.display or OpponentDisplay.InlineTeamContainer{template = lastAlias} local nameCell = self:baseCell(teamDisplay, team.bg):addClass('name-cell') table.insert(self.cells, nameCell) return self diff --git a/lua/wikis/commons/Infobox/Person.lua b/lua/wikis/commons/Infobox/Person.lua index 5730bc24795..73406c6711b 100644 --- a/lua/wikis/commons/Infobox/Person.lua +++ b/lua/wikis/commons/Infobox/Person.lua @@ -15,9 +15,11 @@ local Logic = Lua.import('Module:Logic') local Lpdb = Lua.import('Module:Lpdb') local Namespace = Lua.import('Module:Namespace') local NameOrder = Lua.import('Module:NameOrder') +local OpponentDisplay = Lua.import('Module:OpponentDisplay/Custom') local Page = Lua.import('Module:Page') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local Variables = Lua.import('Module:Variables') local AgeCalculation = Lua.import('Module:AgeCalculation') @@ -40,6 +42,7 @@ local Center = Widgets.Center local Builder = Widgets.Builder local Customizable = Widgets.Customizable local TeamHistoryWidget = Lua.import('Module:Widget/Infobox/TeamHistory') +local WidgetUtil = Lua.import('Module:Widget/Util') ---@class Person: BasicInfobox ---@operator call(Frame): Person @@ -325,7 +328,7 @@ end function Person:_setLpdbData(args, links, status, personType) local teamLink, teamTemplate local team = args.teamlink or args.team - local teamRaw = team and mw.ext.TeamTemplate.raw(team) or nil + local teamRaw = team and TeamTemplate.getRawOrNil(team) or nil if teamRaw then teamLink = teamRaw.page teamTemplate = teamRaw.templatename @@ -369,7 +372,7 @@ function Person:_setLpdbData(args, links, status, personType) for teamKey, otherTeam, teamIndex in Table.iter.pairsByPrefix(args, 'team', {requireIndex = false}) do if teamIndex > 1 then otherTeam = args[teamKey .. 'link'] or otherTeam - lpdbData.extradata[teamKey] = (mw.ext.TeamTemplate.raw(otherTeam) or {}).templatename + lpdbData.extradata[teamKey] = TeamTemplate.resolve(otherTeam) end end @@ -456,27 +459,23 @@ end --- Allows for overriding this functionality --- e.g. to add faction icons to the display for SC2, SC, WC ---@param args table ----@return string +---@return Renderable[] function Person:nameDisplay(args) local team = string.lower(args.teamicon or args.ttlink or args.teamlink or args.team or '') - local icon = mw.ext.TeamTemplate.teamexists(team) - and mw.ext.TeamTemplate.teamicon(team) or '' + local icon = TeamTemplate.exists(team) + and OpponentDisplay.InlineTeamContainer{template = team, style = 'icon'} or nil local team2 = string.lower(args.team2icon or args.ttlink2 or args.team2link or args.team2 or '') - local icon2 = mw.ext.TeamTemplate.teamexists(team2) - and mw.ext.TeamTemplate.teamicon(team2) or '' + local icon2 = TeamTemplate.exists(team2) + and OpponentDisplay.InlineTeamContainer{template = team2, style = 'icon'} or nil local name = args.id or mw.title.getCurrentTitle().text - local display = name - if not String.isEmpty(icon) then - display = icon .. ' ' .. name - end - if not String.isEmpty(icon2) then - display = display .. ' ' .. icon2 - end - return display + return Array.interleave( + WidgetUtil.collect(icon, name, icon2), + ' ' + ) end --- Allows for overriding this functionality @@ -545,7 +544,7 @@ function Person:_createTeam(team, link) end ---@cast link -nil - local teamRaw = mw.ext.TeamTemplate.raw(link) + local teamRaw = TeamTemplate.getRawOrNil(link) if teamRaw then link, team = teamRaw.page, teamRaw.name end @@ -602,7 +601,7 @@ function Person:getCategories(args, birthDisplay, personType, status) table.insert(categories, personType .. 's with unknown birth date') end - if String.isNotEmpty(team) and not mw.ext.TeamTemplate.teamexists(team) then + if String.isNotEmpty(team) and not TeamTemplate.exists(team) then table.insert(categories, 'Players with invalid team') end diff --git a/lua/wikis/commons/Infobox/Person/User.lua b/lua/wikis/commons/Infobox/Person/User.lua index 143640e0234..0af5c21c856 100644 --- a/lua/wikis/commons/Infobox/Person/User.lua +++ b/lua/wikis/commons/Infobox/Person/User.lua @@ -9,23 +9,21 @@ local Lua = require('Module:Lua') local Array = Lua.import('Module:Array') local Class = Lua.import('Module:Class') +local OpponentDisplay = Lua.import('Module:OpponentDisplay/Custom') local Person = Lua.import('Module:Infobox/Person') ---@class InfoboxUser: Person +---@operator call(Frame): InfoboxUser local User = Class.new(Person) ----@return string +---@return VNode[] function User:_getFavouriteTeams() local foundArgs = self:getAllArgsForBase(self.args, 'fav-team-') - local display = '' - for _, item in ipairs(foundArgs) do - local team = item:lower():gsub('_', ' ') - display = display .. mw.ext.TeamTemplate.teamicon(team) - end - - return display + return Array.map(foundArgs, function (favouriteTeam) + return OpponentDisplay.InlineTeamContainer{template = favouriteTeam, style = 'icon'} + end) end ---@param base string diff --git a/lua/wikis/commons/Infobox/Person/User/Custom.lua b/lua/wikis/commons/Infobox/Person/User/Custom.lua index 338255c7f58..2d82f441dc6 100644 --- a/lua/wikis/commons/Infobox/Person/User/Custom.lua +++ b/lua/wikis/commons/Infobox/Person/User/Custom.lua @@ -56,7 +56,7 @@ function CustomInjector:parse(id, widgets) if not String.isEmpty(args['fav-team-1']) then Array.appendWith(widgets, Title{children = 'Favorite Teams'}, - Center{children = {self.caller:_getFavouriteTeams()}} + Center{children = self.caller:_getFavouriteTeams()} ) end elseif diff --git a/lua/wikis/commons/PlayerIntroduction.lua b/lua/wikis/commons/PlayerIntroduction.lua index 131742c47e4..db6494a163b 100644 --- a/lua/wikis/commons/PlayerIntroduction.lua +++ b/lua/wikis/commons/PlayerIntroduction.lua @@ -16,6 +16,7 @@ local Flags = Lua.import('Module:Flags') local Logic = Lua.import('Module:Logic') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local Roles = Lua.import('Module:Roles') @@ -607,7 +608,7 @@ end function PlayerIntroduction._displayTeam(team, date) team = team:gsub('_', ' ') - local rawTeam = mw.ext.TeamTemplate.raw(team, date) + local rawTeam = TeamTemplate.getRawOrNil(team, date) if rawTeam then return ' [[' .. rawTeam.page .. '|' .. rawTeam.name .. ']]' end diff --git a/lua/wikis/commons/PortalPlayers.lua b/lua/wikis/commons/PortalPlayers.lua index 9203e143825..d3b56266708 100644 --- a/lua/wikis/commons/PortalPlayers.lua +++ b/lua/wikis/commons/PortalPlayers.lua @@ -15,6 +15,7 @@ local Logic = Lua.import('Module:Logic') local Links = Lua.import('Module:Links') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local Opponent = Lua.import('Module:Opponent/Custom') local OpponentDisplay = Lua.import('Module:OpponentDisplay/Custom') @@ -264,7 +265,7 @@ function PortalPlayers:row(player, isPlayer) :wikitext(self.showLocalizedName and (' (' .. player.localizedname .. ')') or nil) local role = not isPlayer and mw.language.getContentLanguage():ucfirst((player.extradata or {}).role or '') or '' - local teamText = mw.ext.TeamTemplate.teamexists(player.team) and tostring(OpponentDisplay.InlineTeamContainer{ + local teamText = TeamTemplate.exists(player.team) and tostring(OpponentDisplay.InlineTeamContainer{ template = player.team, displayType = 'standard' }) or '' if String.isNotEmpty(role) and String.isEmpty(teamText) then diff --git a/lua/wikis/commons/PrizePool/Award/Placement.lua b/lua/wikis/commons/PrizePool/Award/Placement.lua index b64c29a90e2..e89134f5d4b 100644 --- a/lua/wikis/commons/PrizePool/Award/Placement.lua +++ b/lua/wikis/commons/PrizePool/Award/Placement.lua @@ -9,6 +9,7 @@ local Lua = require('Module:Lua') local Class = Lua.import('Module:Class') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local BasePlacement = Lua.import('Module:PrizePool/Placement/Base') @@ -55,7 +56,7 @@ function AwardPlacement:_getLpdbData(...) local opponentType = opponent.opponentData.type if opponentType == Opponent.team then - local teamTemplate = mw.ext.TeamTemplate.raw(opponent.opponentData.template) or {} + local teamTemplate = TeamTemplate.getRawOrNil(opponent.opponentData.template) or {} participant = teamTemplate.page or '' if self.parent.options.resolveRedirect then diff --git a/lua/wikis/commons/PrizePool/Placement.lua b/lua/wikis/commons/PrizePool/Placement.lua index 3e11a0935b8..47918a58306 100644 --- a/lua/wikis/commons/PrizePool/Placement.lua +++ b/lua/wikis/commons/PrizePool/Placement.lua @@ -16,6 +16,7 @@ local Ordinal = Lua.import('Module:Ordinal') local PlacementInfo = Lua.import('Module:Placement') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local BasePlacement = Lua.import('Module:PrizePool/Placement/Base') @@ -223,7 +224,7 @@ function Placement:_getLpdbData(...) local opponentType = opponent.opponentData.type if opponentType == Opponent.team then - local teamTemplate = mw.ext.TeamTemplate.raw(opponent.opponentData.template) or {} + local teamTemplate = TeamTemplate.getRawOrNil(opponent.opponentData.template) or {} image = teamTemplate.image imageDark = teamTemplate.imagedark elseif opponentType == Opponent.solo then diff --git a/lua/wikis/commons/Ratings.lua b/lua/wikis/commons/Ratings.lua index 759242a31dc..de990648241 100644 --- a/lua/wikis/commons/Ratings.lua +++ b/lua/wikis/commons/Ratings.lua @@ -14,6 +14,7 @@ local FnUtil = Lua.import('Module:FnUtil') local Json = Lua.import('Module:Json') local Lpdb = Lua.import('Module:Lpdb') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local String = Lua.import('Module:StringUtils') --- Liquipedia Ratings (LPR) @@ -409,16 +410,10 @@ end function Ratings.transfer(frame) local args = Arguments.getArgs(frame) local date = os.time(Date.parseIsoDate(args.date)) - local from = mw.ext.TeamTemplate.teampage(args.from, args.date) - local to = String.isNotEmpty(args.to) and mw.ext.TeamTemplate.teampage(args.to, args.date) or '' - if String.startsWith(from, '
' .. args.date .. ': ' .. from .. ' --> ' .. to .. '
' + local from = TeamTemplate.getRaw(args.from, args.date) + local to = String.isNotEmpty(args.to) and TeamTemplate.getRaw(args.to, args.date) or {} + Ratings._storeTransfer(from.page, to.page, date, tonumber(args.mod)) + return '' .. args.date .. ': ' .. from.page .. ' --> ' .. (to.page or '') .. '
' end return Ratings diff --git a/lua/wikis/commons/SeriesMedalStats/Participant.lua b/lua/wikis/commons/SeriesMedalStats/Participant.lua index c9c8923c978..125b06ac1ec 100644 --- a/lua/wikis/commons/SeriesMedalStats/Participant.lua +++ b/lua/wikis/commons/SeriesMedalStats/Participant.lua @@ -12,6 +12,7 @@ local Array = Lua.import('Module:Array') local Class = Lua.import('Module:Class') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local Opponent = Lua.import('Module:Opponent/Custom') local OpponentDisplay = Lua.import('Module:OpponentDisplay/Custom') @@ -48,7 +49,7 @@ function MedalStats:_processData() ---@param teamTemplate string ---@return string? local resolveTeamToIdentifier = function(teamTemplate) - local rawData = mw.ext.TeamTemplate.raw(teamTemplate) + local rawData = TeamTemplate.getRawOrNil(teamTemplate) if not rawData or not rawData.page then return end diff --git a/lua/wikis/commons/SeriesMedalStats/ParticipantTeam.lua b/lua/wikis/commons/SeriesMedalStats/ParticipantTeam.lua index f3e22849ce2..1358ab1fdb2 100644 --- a/lua/wikis/commons/SeriesMedalStats/ParticipantTeam.lua +++ b/lua/wikis/commons/SeriesMedalStats/ParticipantTeam.lua @@ -12,8 +12,10 @@ local Array = Lua.import('Module:Array') local Class = Lua.import('Module:Class') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local Opponent = Lua.import('Module:Opponent/Custom') +local OpponentDisplay = Lua.import('Module:OpponentDisplay/Custom') local MedalStatsBase = Lua.import('Module:SeriesMedalStats') @@ -40,7 +42,7 @@ function MedalStats:create() self:_processData() local nameDisplay = function(identifier) - return mw.ext.TeamTemplate.team(identifier) + return OpponentDisplay.InlineTeamContainer{template = identifier} end local display = self:defaultBuild(nameDisplay, 'Team', 'Teams') @@ -60,7 +62,7 @@ function MedalStats:_processData() ---@param teamTemplate string ---@return string? local resolveTeamToIdentifier = function(teamTemplate) - local rawData = mw.ext.TeamTemplate.raw(teamTemplate) + local rawData = TeamTemplate.getRawOrNil(teamTemplate) if not rawData or not rawData.page then return end diff --git a/lua/wikis/commons/Service/Team.lua b/lua/wikis/commons/Service/Team.lua index faadc3c61ae..91d32348b7a 100644 --- a/lua/wikis/commons/Service/Team.lua +++ b/lua/wikis/commons/Service/Team.lua @@ -12,6 +12,7 @@ local DateExt = Lua.import('Module:Date/Ext') local Logic = Lua.import('Module:Logic') local Page = Lua.import('Module:Page') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local TeamService = {} @@ -48,11 +49,7 @@ local LPDB_TEAM_FIELDS = { ---@param teamTemplate string ---@return StandardTeam? function TeamService.getTeamByTemplate(teamTemplate) - if not teamTemplate or not mw.ext.TeamTemplate.teamexists(teamTemplate) then - return nil - end - - local team = mw.ext.TeamTemplate.raw(teamTemplate) + local team = TeamTemplate.getRawOrNil(teamTemplate) if not team then return nil diff --git a/lua/wikis/commons/Standings/Storage.lua b/lua/wikis/commons/Standings/Storage.lua index eeb1152b714..d8a3b25ac54 100644 --- a/lua/wikis/commons/Standings/Storage.lua +++ b/lua/wikis/commons/Standings/Storage.lua @@ -14,6 +14,7 @@ local Logic = Lua.import('Module:Logic') local Lpdb = Lua.import('Module:Lpdb') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local Variables = Lua.import('Module:Variables') local Opponent = Lua.import('Module:Opponent/Custom') @@ -296,11 +297,11 @@ function StandingsStorage.fromTemplateEntry(frame) local team -- Input contains an actual team - if data.team and mw.ext.TeamTemplate.teamexists(data.team) then - team = mw.ext.TeamTemplate.raw(data.team, date) + if data.team and TeamTemplate.exists(data.team) then + team = TeamTemplate.getRaw(data.team, date) -- Input is link (possiblity with icon etc), and we managed to parse it - elseif teamPage and mw.ext.TeamTemplate.teamexists(teamPage) then - team = mw.ext.TeamTemplate.raw(teamPage, date) + elseif teamPage and TeamTemplate.exists(teamPage) then + team = TeamTemplate.getRaw(teamPage, date) end opponentArgs = {type = Opponent.team} diff --git a/lua/wikis/commons/TeamLogoGallery.lua b/lua/wikis/commons/TeamLogoGallery.lua index 41c6c2716c6..57a3324ce2e 100644 --- a/lua/wikis/commons/TeamLogoGallery.lua +++ b/lua/wikis/commons/TeamLogoGallery.lua @@ -25,7 +25,7 @@ function TeamLogoGallery.run(args) args = args or {} local name = (args.name or mw.title.getCurrentTitle().prefixedText):gsub('_', ' '):lower() - assert(mw.ext.TeamTemplate.teamexists(name), 'Missing team template "' .. name .. '"') + assert(TeamTemplate.exists(name), TeamTemplate.noTeamMessage(name)) local imageData = TeamLogoGallery._getImageData(name, Logic.readBool(args.showPresentLogo)) @@ -42,7 +42,7 @@ function TeamLogoGallery._getImageData(name, showPresentLogo) for startDate, teamTemplate in Table.iter.spairs(historicalTeamTemplates) do table.insert(imageDatas, { startDate = startDate, - raw = mw.ext.TeamTemplate.raw(teamTemplate) + raw = TeamTemplate.getRaw(teamTemplate) }) end diff --git a/lua/wikis/commons/TeamTemplate.lua b/lua/wikis/commons/TeamTemplate.lua index fea51c9a51b..2d2d35ea3d8 100644 --- a/lua/wikis/commons/TeamTemplate.lua +++ b/lua/wikis/commons/TeamTemplate.lua @@ -8,7 +8,6 @@ local Lua = require('Module:Lua') local Array = Lua.import('Module:Array') -local FnUtil = Lua.import('Module:FnUtil') local Logic = Lua.import('Module:Logic') local Page = Lua.import('Module:Page') @@ -60,12 +59,13 @@ Returns the resolved page name of a team template that has been resolved to a date. Returns nil if the team does not exist, or if the page is not specified. ]] ---@param resolvedTemplate string +---@param date string|number? ---@return string|nil -TeamTemplate.getPageName = FnUtil.memoize(function(resolvedTemplate) - local raw = TeamTemplate.getRawOrNil(resolvedTemplate) +function TeamTemplate.getPageName(resolvedTemplate, date) + local raw = TeamTemplate.getRawOrNil(resolvedTemplate, date) local pageName = raw and mw.ext.TeamLiquidIntegration.resolve_redirect(raw.page) or nil return Page.applyUnderScoresIfEnforced(pageName) -end) +end --[[ Returns raw data of a team template for a team on a given date. Throws if the @@ -88,6 +88,9 @@ does not exist. ---@param date string|number? ---@return teamTemplateData? function TeamTemplate.getRawOrNil(team, date) + if Logic.isEmpty(team) then + return + end team = team:gsub('_', ' '):lower() -- return mw.ext.TeamTemplate.raw(team, date) diff --git a/lua/wikis/commons/TransferList.lua b/lua/wikis/commons/TransferList.lua index f659b46713d..bd358790ff7 100644 --- a/lua/wikis/commons/TransferList.lua +++ b/lua/wikis/commons/TransferList.lua @@ -135,8 +135,8 @@ function TransferList:_getTeams(args) local teamList = {} Array.forEach(teams, function(team) - if not mw.ext.TeamTemplate.teamexists(team) then - mw.log('Missing team teamplate: ' .. team) + if not TeamTemplate.exists(team) then + mw.log(TeamTemplate.noTeamMessage(team)) end Array.extendWith(teamList, TeamTemplate.queryHistoricalNames(team)) end) diff --git a/lua/wikis/commons/TransferRow.lua b/lua/wikis/commons/TransferRow.lua index 4e215bb3708..34cad319179 100644 --- a/lua/wikis/commons/TransferRow.lua +++ b/lua/wikis/commons/TransferRow.lua @@ -19,6 +19,7 @@ local Lpdb = Lua.import('Module:Lpdb') local Namespace = Lua.import('Module:Namespace') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local Variables = Lua.import('Module:Variables') local Platform = Lua.import('Module:Platform') @@ -123,7 +124,7 @@ function TransferRow:_readBaseData() ---@param teamInput string ---@return {name: string?, template: string?} local checkTeam = function(dateInput, teamInput) - local teamData = Logic.isNotEmpty(teamInput) and mw.ext.TeamTemplate.raw(teamInput, dateInput) + local teamData = Logic.isNotEmpty(teamInput) and TeamTemplate.getRawOrNil(teamInput, dateInput) if not teamData then return {} end diff --git a/lua/wikis/counterstrike/Match/Legacy.lua b/lua/wikis/counterstrike/Match/Legacy.lua index 0c84c750381..236919571d3 100644 --- a/lua/wikis/counterstrike/Match/Legacy.lua +++ b/lua/wikis/counterstrike/Match/Legacy.lua @@ -13,6 +13,7 @@ local Logic = Lua.import('Module:Logic') local Operator = Lua.import('Module:Operator') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local TextSanitizer = Lua.import('Module:TextSanitizer') local MatchLegacyUtil = Lua.import('Module:MatchGroup/Legacy/Util') @@ -109,8 +110,8 @@ function MatchLegacy.convertParameters(match2) if opponent.type == Opponent.team then if String.isEmpty(opponent.template) then match[prefix] = 'TBD' - elseif mw.ext.TeamTemplate.teamexists(opponent.template) then - match[prefix] = mw.ext.TeamTemplate.teampage(opponent.template) + elseif TeamTemplate.exists(opponent.template) then + match[prefix] = TeamTemplate.getRaw(opponent.template).page else match[prefix] = opponent.template end diff --git a/lua/wikis/criticalops/Match/Legacy.lua b/lua/wikis/criticalops/Match/Legacy.lua index dfaf60946ac..0e6e8b7fd97 100644 --- a/lua/wikis/criticalops/Match/Legacy.lua +++ b/lua/wikis/criticalops/Match/Legacy.lua @@ -13,6 +13,7 @@ local Logic = Lua.import('Module:Logic') local Operator = Lua.import('Module:Operator') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local TextSanitizer = Lua.import('Module:TextSanitizer') local MatchLegacyUtil = Lua.import('Module:MatchGroup/Legacy/Util') @@ -109,8 +110,8 @@ function MatchLegacy.convertParameters(match2) if opponent.type == Opponent.team then if String.isEmpty(opponent.template) then match[prefix] = 'TBD' - elseif mw.ext.TeamTemplate.teamexists(opponent.template) then - match[prefix] = mw.ext.TeamTemplate.teampage(opponent.template) + elseif TeamTemplate.exists(opponent.template) then + match[prefix] = TeamTemplate.getRaw(opponent.template).page else match[prefix] = opponent.template end diff --git a/lua/wikis/crossfire/Match/Legacy.lua b/lua/wikis/crossfire/Match/Legacy.lua index 2178354370f..374e334f77f 100644 --- a/lua/wikis/crossfire/Match/Legacy.lua +++ b/lua/wikis/crossfire/Match/Legacy.lua @@ -14,6 +14,7 @@ local Json = Lua.import('Module:Json') local Operator = Lua.import('Module:Operator') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper') local MatchLegacyUtil = Lua.import('Module:MatchGroup/Legacy/Util') @@ -101,7 +102,7 @@ function MatchLegacy._convertParameters(match2) local opponent = match2.match2opponents[index] or {} local opponentmatch2players = opponent.match2players or {} if opponent.type == 'team' then - match[prefix] = mw.ext.TeamTemplate.teampage(opponent.template) + match[prefix] = TeamTemplate.getRaw(opponent.template).page match[prefix..'score'] = (tonumber(opponent.score) or 0) > 0 and opponent.score or 0 local opponentplayers = {} for i = 1,10 do diff --git a/lua/wikis/dota2/Infobox/Person/User/Custom.lua b/lua/wikis/dota2/Infobox/Person/User/Custom.lua index 457c28389a2..5e8020c36b3 100644 --- a/lua/wikis/dota2/Infobox/Person/User/Custom.lua +++ b/lua/wikis/dota2/Infobox/Person/User/Custom.lua @@ -26,6 +26,9 @@ local SIZE_HERO = '44x25px' ---@class Dota2InfoboxUser: InfoboxUser local CustomUser = Class.new(User) +---@class Dota2InfoboxUserWidgetInjector: WidgetInjector +---@operator call(Dota2InfoboxUser): Dota2InfoboxUserWidgetInjector +---@field caller Dota2InfoboxUser local CustomInjector = Class.new(Injector) ---@param frame Frame @@ -57,7 +60,7 @@ function CustomInjector:parse(id, widgets) if not String.isEmpty(args['fav-team-1']) then Array.appendWith(widgets, Title{children = 'Favorite teams'}, - Center{children = {self.caller:_getFavouriteTeams()}} + Center{children = self.caller:_getFavouriteTeams()} ) end elseif diff --git a/lua/wikis/easportsfc/PortalPlayers/Custom.lua b/lua/wikis/easportsfc/PortalPlayers/Custom.lua index cc562dfab5b..a1a35e41d25 100644 --- a/lua/wikis/easportsfc/PortalPlayers/Custom.lua +++ b/lua/wikis/easportsfc/PortalPlayers/Custom.lua @@ -14,6 +14,7 @@ local Date = Lua.import('Module:Date/Ext') local Links = Lua.import('Module:Links') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local AgeCalculation = Lua.import('Module:AgeCalculation') local PortalPlayers = Lua.import('Module:PortalPlayers') @@ -86,7 +87,7 @@ function CustomPortalPlayers:row(player, isPlayer) row:tag('td'):node(CustomPortalPlayers._getAge(player)) local role = not isPlayer and mw.language.getContentLanguage():ucfirst((player.extradata or {}).role or '') or '' - local teamText = mw.ext.TeamTemplate.teamexists(player.team) and tostring(OpponentDisplay.InlineTeamContainer{ + local teamText = TeamTemplate.exists(player.team) and tostring(OpponentDisplay.InlineTeamContainer{ template = player.team, displayType = 'standard' }) or '' if String.isNotEmpty(role) and String.isEmpty(teamText) then diff --git a/lua/wikis/esports/Widget/EwcTeamsOverview.lua b/lua/wikis/esports/Widget/EwcTeamsOverview.lua index fa3ffd38a89..bd32d49734f 100644 --- a/lua/wikis/esports/Widget/EwcTeamsOverview.lua +++ b/lua/wikis/esports/Widget/EwcTeamsOverview.lua @@ -11,6 +11,7 @@ local Array = Lua.import('Module:Array') local Class = Lua.import('Module:Class') local Logic = Lua.import('Module:Logic') local Json = Lua.import('Module:Json') +local OpponentDisplay = Lua.import('Module:OpponentDisplay/Custom') local Page = Lua.import('Module:Page') local Template = Lua.import('Module:Template') @@ -181,7 +182,7 @@ function EwcTeamsOverview:render() return HtmlWidgets.Tr{ children = WidgetUtil.collect( HtmlWidgets.Td{ - children = mw.ext.TeamTemplate.team(club.name), + children = OpponentDisplay.InlineTeamContainer{template = club.name}, css = {['text-align'] = 'left', ['text-wrap'] = 'nowrap'} }, HtmlWidgets.Td{children = club.club and Template.safeExpand(mw.getCurrentFrame(), 'LeagueIconSmall/ewc') or nil}, diff --git a/lua/wikis/formula1/PortalPlayers/Custom.lua b/lua/wikis/formula1/PortalPlayers/Custom.lua index 453eef8b6a8..09e7b14943a 100644 --- a/lua/wikis/formula1/PortalPlayers/Custom.lua +++ b/lua/wikis/formula1/PortalPlayers/Custom.lua @@ -14,6 +14,7 @@ local Date = Lua.import('Module:Date/Ext') local Links = Lua.import('Module:Links') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local AgeCalculation = Lua.import('Module:AgeCalculation') local PortalPlayers = Lua.import('Module:PortalPlayers') @@ -86,7 +87,7 @@ function CustomPortalPlayers:row(player, isPlayer) row:tag('td'):node(CustomPortalPlayers._getAge(player)) local role = not isPlayer and mw.language.getContentLanguage():ucfirst((player.extradata or {}).role or '') or '' - local teamText = mw.ext.TeamTemplate.teamexists(player.team) and tostring(OpponentDisplay.InlineTeamContainer{ + local teamText = TeamTemplate.exists(player.team) and tostring(OpponentDisplay.InlineTeamContainer{ template = player.team, displayType = 'standard' }) or '' if String.isNotEmpty(role) and String.isEmpty(teamText) then diff --git a/lua/wikis/freefire/Infobox/Person/Player/Custom.lua b/lua/wikis/freefire/Infobox/Person/Player/Custom.lua index 5bb1c9c7c69..f24953964ea 100644 --- a/lua/wikis/freefire/Infobox/Person/Player/Custom.lua +++ b/lua/wikis/freefire/Infobox/Person/Player/Custom.lua @@ -10,6 +10,7 @@ local Lua = require('Module:Lua') local Class = Lua.import('Module:Class') local String = Lua.import('Module:StringUtils') local Page = Lua.import('Module:Page') +local TeamTemplate = Lua.import('Module:TeamTemplate') local Template = Lua.import('Module:Template') local Injector = Lua.import('Module:Widget/Injector') @@ -59,7 +60,7 @@ function CustomPlayer:adjustLPDB(lpdbData, args, personType) local team2 = args.team2link or args.team2 if String.isNotEmpty(team2) then - lpdbData.extradata.team2 = (mw.ext.TeamTemplate.raw(team2) or {}).page or team2 + lpdbData.extradata.team2 = TeamTemplate.getPageName(team2) or team2 end return lpdbData end diff --git a/lua/wikis/halo/Match/Legacy.lua b/lua/wikis/halo/Match/Legacy.lua index e10157e242b..c6088c31634 100644 --- a/lua/wikis/halo/Match/Legacy.lua +++ b/lua/wikis/halo/Match/Legacy.lua @@ -14,6 +14,7 @@ local Json = Lua.import('Module:Json') local Operator = Lua.import('Module:Operator') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local MatchLegacyUtil = Lua.import('Module:MatchGroup/Legacy/Util') @@ -68,7 +69,7 @@ function MatchLegacy._convertParameters(match2) local opponent = match2.match2opponents[index] or {} local opponentmatch2players = opponent.match2players or {} if opponent.type == 'team' then - match[prefix] = mw.ext.TeamTemplate.teampage(opponent.template) + match[prefix] = TeamTemplate.getRaw(opponent.template).page match[prefix .. 'score'] = (tonumber(opponent.score) or 0) > 0 and opponent.score or 0 local opponentplayers = {} for i = 1, MAX_NUM_PLAYERS do diff --git a/lua/wikis/leagueoflegends/Match/Legacy.lua b/lua/wikis/leagueoflegends/Match/Legacy.lua index 2c0fe59e684..d168709134f 100644 --- a/lua/wikis/leagueoflegends/Match/Legacy.lua +++ b/lua/wikis/leagueoflegends/Match/Legacy.lua @@ -12,6 +12,7 @@ local Lua = require('Module:Lua') local Json = Lua.import('Module:Json') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper') local MatchLegacyUtil = Lua.import('Module:MatchGroup/Legacy/Util') @@ -93,7 +94,7 @@ function MatchLegacy._convertParameters(match2) local opponent = match2.match2opponents[index] or {} local opponentmatch2players = opponent.match2players or {} if opponent.type == 'team' then - match[prefix] = mw.ext.TeamTemplate.teampage(opponent.template) + match[prefix] = TeamTemplate.getRaw(opponent.template).page match[prefix..'score'] = (tonumber(opponent.score) or 0) > 0 and opponent.score or 0 local opponentplayers = {} for i = 1, _NUMBER_OF_PLAYERS_TO_STORE do diff --git a/lua/wikis/overwatch/Infobox/Person/Player/Custom.lua b/lua/wikis/overwatch/Infobox/Person/Player/Custom.lua index 3c23b89b52a..ae74503d521 100644 --- a/lua/wikis/overwatch/Infobox/Person/Player/Custom.lua +++ b/lua/wikis/overwatch/Infobox/Person/Player/Custom.lua @@ -94,7 +94,7 @@ function CustomPlayer:adjustLPDB(lpdbData, args) lpdbData.region = Template.safeExpand(mw.getCurrentFrame(), 'Player region', {args.country}) if String.isNotEmpty(args.team2) then - lpdbData.extradata.team2 = mw.ext.TeamTemplate.raw(args.team2).page + lpdbData.extradata.team2 = TeamTemplate.getPageName(args.team2) end return lpdbData diff --git a/lua/wikis/overwatch/Infobox/Person/User/Custom.lua b/lua/wikis/overwatch/Infobox/Person/User/Custom.lua index fea3c2afea6..d66109fe26f 100644 --- a/lua/wikis/overwatch/Infobox/Person/User/Custom.lua +++ b/lua/wikis/overwatch/Infobox/Person/User/Custom.lua @@ -24,8 +24,12 @@ local Center = Widgets.Center local SIZE_HERO = '25x25px' ---@class OverwatchInfoboxUser: InfoboxUser +---@operator call(Frame): OverwatchInfoboxUser local CustomUser = Class.new(User) +---@class OverwatchInfoboxUserWidgetInjector: WidgetInjector +---@operator call(OverwatchInfoboxUser): OverwatchInfoboxUserWidgetInjector +---@field caller OverwatchInfoboxUser local CustomInjector = Class.new(Injector) ---@param frame Frame @@ -77,7 +81,7 @@ function CustomUser:addCustomCells(widgets) if not String.isEmpty(args['fav-team-1']) then table.insert(widgets, Title{children = 'Favorite teams'}) - table.insert(widgets, Center{children = {self:_getFavouriteTeams()}}) + table.insert(widgets, Center{children = self:_getFavouriteTeams()}) end if not String.isEmpty(args.s1high) then diff --git a/lua/wikis/overwatch/Match/Legacy.lua b/lua/wikis/overwatch/Match/Legacy.lua index b8d64d8cd87..62a26f6f29d 100644 --- a/lua/wikis/overwatch/Match/Legacy.lua +++ b/lua/wikis/overwatch/Match/Legacy.lua @@ -14,6 +14,7 @@ local Json = Lua.import('Module:Json') local Operator = Lua.import('Module:Operator') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper') local MatchLegacyUtil = Lua.import('Module:MatchGroup/Legacy/Util') @@ -102,7 +103,7 @@ function MatchLegacy._convertParameters(match2) local opponent = match2.match2opponents[index] or {} local opponentmatch2players = opponent.match2players or {} if opponent.type == 'team' then - match[prefix] = mw.ext.TeamTemplate.teampage(opponent.template) + match[prefix] = TeamTemplate.getRaw(opponent.template).page match[prefix..'score'] = (tonumber(opponent.score) or 0) > 0 and opponent.score or 0 local opponentplayers = {} for i = 1,10 do diff --git a/lua/wikis/pubg/Infobox/Person/Player/Custom.lua b/lua/wikis/pubg/Infobox/Person/Player/Custom.lua index 22ecfc26b82..b555542b4df 100644 --- a/lua/wikis/pubg/Infobox/Person/Player/Custom.lua +++ b/lua/wikis/pubg/Infobox/Person/Player/Custom.lua @@ -9,6 +9,7 @@ local Lua = require('Module:Lua') local Class = Lua.import('Module:Class') local String = Lua.import('Module:StringUtils') +local TeamTemplate = Lua.import('Module:TeamTemplate') local Injector = Lua.import('Module:Widget/Injector') local Player = Lua.import('Module:Infobox/Person') @@ -54,7 +55,7 @@ end ---@return table function CustomPlayer:adjustLPDB(lpdbData, args) if String.isNotEmpty(args.team2) then - lpdbData.extradata.team2 = mw.ext.TeamTemplate.raw(args.team2).page + lpdbData.extradata.team2 = TeamTemplate.getPageName(args.team2) end return lpdbData diff --git a/lua/wikis/pubgmobile/Infobox/Person/Player/Custom.lua b/lua/wikis/pubgmobile/Infobox/Person/Player/Custom.lua index e2b0c60c19c..7104c8d7f84 100644 --- a/lua/wikis/pubgmobile/Infobox/Person/Player/Custom.lua +++ b/lua/wikis/pubgmobile/Infobox/Person/Player/Custom.lua @@ -10,6 +10,7 @@ local Lua = require('Module:Lua') local Class = Lua.import('Module:Class') local Page = Lua.import('Module:Page') local String = Lua.import('Module:StringUtils') +local TeamTemplate = Lua.import('Module:TeamTemplate') local Injector = Lua.import('Module:Widget/Injector') local Player = Lua.import('Module:Infobox/Person') @@ -60,7 +61,7 @@ end ---@return table function CustomPlayer:adjustLPDB(lpdbData, args, personType) if String.isNotEmpty(args.team2) then - lpdbData.extradata.team2 = mw.ext.TeamTemplate.raw(args.team2).page + lpdbData.extradata.team2 = TeamTemplate.getPageName(args.team2) end return lpdbData diff --git a/lua/wikis/rainbowsix/Match/Legacy.lua b/lua/wikis/rainbowsix/Match/Legacy.lua index a0664db404c..8432d1ccd89 100644 --- a/lua/wikis/rainbowsix/Match/Legacy.lua +++ b/lua/wikis/rainbowsix/Match/Legacy.lua @@ -14,6 +14,7 @@ local Json = Lua.import('Module:Json') local Operator = Lua.import('Module:Operator') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper') local MatchLegacyUtil = Lua.import('Module:MatchGroup/Legacy/Util') @@ -144,7 +145,7 @@ function MatchLegacy._convertParameters(match2) local opponent = match2.match2opponents[index] or {} local opponentmatch2players = opponent.match2players or {} if opponent.type == 'team' then - match[prefix] = mw.ext.TeamTemplate.teampage(opponent.template) + match[prefix] = TeamTemplate.getRaw(opponent.template).page local firstGame = (match2.match2games or {})[1] if match2.bestof == 1 and firstGame then local opponents = Json.parseIfString(firstGame.opponents) or {} diff --git a/lua/wikis/rocketleague/Infobox/Person/Player/Custom.lua b/lua/wikis/rocketleague/Infobox/Person/Player/Custom.lua index 59a9ed2a2d5..3c74d527cbc 100644 --- a/lua/wikis/rocketleague/Infobox/Person/Player/Custom.lua +++ b/lua/wikis/rocketleague/Infobox/Person/Player/Custom.lua @@ -17,6 +17,7 @@ local Matches = Lua.import('Module:Matches_Player') local Namespace = Lua.import('Module:Namespace') local Page = Lua.import('Module:Page') local String = Lua.import('Module:StringUtils') +local TeamTemplate = Lua.import('Module:TeamTemplate') local Variables = Lua.import('Module:Variables') local Injector = Lua.import('Module:Widget/Injector') @@ -224,7 +225,7 @@ function CustomPlayer:getCategories(args, birthDisplay, personType, status) end local team = args.teamlink or args.team - if team and not mw.ext.TeamTemplate.teamexists(team) then + if team and not TeamTemplate.exists(team) then table.insert(categories, 'Players with invalid team') end diff --git a/lua/wikis/rocketleague/Ratings/Display.lua b/lua/wikis/rocketleague/Ratings/Display.lua index d1619298cb3..976f3758414 100644 --- a/lua/wikis/rocketleague/Ratings/Display.lua +++ b/lua/wikis/rocketleague/Ratings/Display.lua @@ -10,6 +10,7 @@ local Lua = require('Module:Lua') local Arguments = Lua.import('Module:Arguments') local Array = Lua.import('Module:Array') local RatingsStorageLpdb = Lua.import('Module:Ratings/Storage/Lpdb') +local TeamTemplate = Lua.import('Module:TeamTemplate') local RatingsDisplay = {} @@ -78,8 +79,8 @@ function RatingsDisplay._getTeamInfo(teamName) return { region = teamInfo.region or '???', - shortName = mw.ext.TeamTemplate.teamexists(teamInfo.template or '') - and mw.ext.TeamTemplate.raw(teamInfo.template).shortname or teamName + shortName = TeamTemplate.exists(teamInfo.template) + and TeamTemplate.getRaw(teamInfo.template).shortname or teamName } end diff --git a/lua/wikis/rocketleague/Ratings/Display/List.lua b/lua/wikis/rocketleague/Ratings/Display/List.lua index f9958b2d0ad..582a47e8fe9 100644 --- a/lua/wikis/rocketleague/Ratings/Display/List.lua +++ b/lua/wikis/rocketleague/Ratings/Display/List.lua @@ -9,6 +9,7 @@ local Lua = require('Module:Lua') local Array = Lua.import('Module:Array') local Operator = Lua.import('Module:Operator') +local OpponentDisplay = Lua.import('Module:OpponentDisplay/Custom') local Template = Lua.import('Module:Template') ---@class RatingsDisplayList: RatingsDisplayInterface @@ -67,7 +68,7 @@ function RatingsDisplayList.build(teamRankings) local popup = Template.expandTemplate(mw.getCurrentFrame(), 'Popup', { label = 'show', - title = 'Details for ' .. mw.ext.TeamTemplate.team(team.name), + title = 'Details for ' .. tostring(OpponentDisplay.InlineTeamContainer{template = team.name}), content = chart, }) @@ -78,7 +79,7 @@ function RatingsDisplayList.build(teamRankings) htmlTable:tag('tr') :tag('td'):css('font-weight', 'bold'):wikitext(rank):done() - :tag('td'):css('text-align', 'left'):wikitext(mw.ext.TeamTemplate.team(team.name)):done() + :tag('td'):css('text-align', 'left'):node(OpponentDisplay.InlineTeamContainer{template = team.name}):done() :tag('td'):wikitext(math.floor(team.rating + 0.5)):done() :tag('td'):wikitext(string.upper(team.region or '')):done() :tag('td'):wikitext(team.matches):done() diff --git a/lua/wikis/runeterra/Match/Legacy.lua b/lua/wikis/runeterra/Match/Legacy.lua index 899d71f3975..825ef41b2ed 100644 --- a/lua/wikis/runeterra/Match/Legacy.lua +++ b/lua/wikis/runeterra/Match/Legacy.lua @@ -12,6 +12,7 @@ local Lua = require('Module:Lua') local Json = Lua.import('Module:Json') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local MatchLegacyUtil = Lua.import('Module:MatchGroup/Legacy/Util') @@ -48,7 +49,7 @@ function MatchLegacy._convertParameters(match2) local opponent = match2.match2opponents[opponentIndex] or {} local opponentmatch2players = opponent.match2players or {} if opponent.type == 'team' then - match[prefix] = mw.ext.TeamTemplate.teampage(opponent.template) + match[prefix] = TeamTemplate.getRaw(opponent.template).page match[prefix..'score'] = (tonumber(opponent.score) or 0) > 0 and opponent.score or 0 local opponentplayers = {} for playerIndex = 1, 10 do diff --git a/lua/wikis/sideswipe/Match/Legacy.lua b/lua/wikis/sideswipe/Match/Legacy.lua index 3fb69052f56..5a533be28f3 100644 --- a/lua/wikis/sideswipe/Match/Legacy.lua +++ b/lua/wikis/sideswipe/Match/Legacy.lua @@ -14,6 +14,7 @@ local Json = Lua.import('Module:Json') local Operator = Lua.import('Module:Operator') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local MatchLegacyUtil = Lua.import('Module:MatchGroup/Legacy/Util') @@ -68,7 +69,7 @@ function p._convertParameters(match2) local opponent = match2.match2opponents[index] or {} local opponentmatch2players = opponent.match2players or {} if opponent.type == 'team' then - match[prefix] = mw.ext.TeamTemplate.teampage(opponent.template) + match[prefix] = TeamTemplate.getRaw(opponent.template).page match[prefix .. 'score'] = (tonumber(opponent.score) or 0) > 0 and opponent.score or 0 local opponentplayers = {} for i = 1, MAX_NUM_PLAYERS do diff --git a/lua/wikis/splatoon/Match/Legacy.lua b/lua/wikis/splatoon/Match/Legacy.lua index 091f6fafb98..347c6a1b289 100644 --- a/lua/wikis/splatoon/Match/Legacy.lua +++ b/lua/wikis/splatoon/Match/Legacy.lua @@ -14,6 +14,7 @@ local Json = Lua.import('Module:Json') local Operator = Lua.import('Module:Operator') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper') local MatchLegacyUtil = Lua.import('Module:MatchGroup/Legacy/Util') @@ -97,7 +98,7 @@ function MatchLegacy._convertParameters(match2) local opponentmatch2players = opponent.match2players or {} if opponent.type == 'team' then match.extradata['team' .. index .. 'icon'] = opponent.icon - match[prefix] = mw.ext.TeamTemplate.teampage(opponent.template) + match[prefix] = TeamTemplate.getRaw(opponent.template).page match[prefix .. 'score'] = (tonumber(opponent.score) or 0) > 0 and opponent.score or 0 local opponentplayers = {} diff --git a/lua/wikis/squadrons/Match/Legacy.lua b/lua/wikis/squadrons/Match/Legacy.lua index 899d71f3975..825ef41b2ed 100644 --- a/lua/wikis/squadrons/Match/Legacy.lua +++ b/lua/wikis/squadrons/Match/Legacy.lua @@ -12,6 +12,7 @@ local Lua = require('Module:Lua') local Json = Lua.import('Module:Json') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local MatchLegacyUtil = Lua.import('Module:MatchGroup/Legacy/Util') @@ -48,7 +49,7 @@ function MatchLegacy._convertParameters(match2) local opponent = match2.match2opponents[opponentIndex] or {} local opponentmatch2players = opponent.match2players or {} if opponent.type == 'team' then - match[prefix] = mw.ext.TeamTemplate.teampage(opponent.template) + match[prefix] = TeamTemplate.getRaw(opponent.template).page match[prefix..'score'] = (tonumber(opponent.score) or 0) > 0 and opponent.score or 0 local opponentplayers = {} for playerIndex = 1, 10 do diff --git a/lua/wikis/trackmania/Match/Legacy.lua b/lua/wikis/trackmania/Match/Legacy.lua index f57a3dbc5f0..d3e878d331a 100644 --- a/lua/wikis/trackmania/Match/Legacy.lua +++ b/lua/wikis/trackmania/Match/Legacy.lua @@ -14,6 +14,7 @@ local Json = Lua.import('Module:Json') local Operator = Lua.import('Module:Operator') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local Opponent = Lua.import('Module:Opponent/Custom') @@ -78,7 +79,7 @@ function MatchLegacy._convertParameters(match2) local opponent = match2.match2opponents[index] or {} local opponentMatch2Players = opponent.match2players or {} if opponent.type == Opponent.team then - match[prefix] = mw.ext.TeamTemplate.teampage(opponent.template) + match[prefix] = TeamTemplate.getRaw(opponent.template).page match[prefix .. 'score'] = (tonumber(opponent.score) or 0) > 0 and opponent.score or 0 local opponentPlayers = {} for playerIndex, player in ipairs(opponentMatch2Players) do diff --git a/lua/wikis/wildrift/Infobox/Person/Player/Custom.lua b/lua/wikis/wildrift/Infobox/Person/Player/Custom.lua index 4ad2b8e198b..43ee58e6d3b 100644 --- a/lua/wikis/wildrift/Infobox/Person/Player/Custom.lua +++ b/lua/wikis/wildrift/Infobox/Person/Player/Custom.lua @@ -119,7 +119,7 @@ function CustomPlayer:adjustLPDB(lpdbData, args, personType) lpdbData.region = Template.safeExpand(mw.getCurrentFrame(), 'Player region', {args.country}) if String.isNotEmpty(args.team2) then - lpdbData.extradata.team2 = mw.ext.TeamTemplate.raw(args.team2).page + lpdbData.extradata.team2 = TeamTemplate.getPageName(args.team2) end return lpdbData diff --git a/lua/wikis/zula/Match/Legacy.lua b/lua/wikis/zula/Match/Legacy.lua index cc79d54bd6d..17ea061b938 100644 --- a/lua/wikis/zula/Match/Legacy.lua +++ b/lua/wikis/zula/Match/Legacy.lua @@ -13,6 +13,7 @@ local Logic = Lua.import('Module:Logic') local Operator = Lua.import('Module:Operator') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local TextSanitizer = Lua.import('Module:TextSanitizer') local MatchLegacyUtil = Lua.import('Module:MatchGroup/Legacy/Util') @@ -109,8 +110,8 @@ function MatchLegacy.convertParameters(match2) if opponent.type == Opponent.team then if String.isEmpty(opponent.template) then match[prefix] = 'TBD' - elseif mw.ext.TeamTemplate.teamexists(opponent.template) then - match[prefix] = mw.ext.TeamTemplate.teampage(opponent.template) + elseif TeamTemplate.exists(opponent.template) then + match[prefix] = TeamTemplate.getRaw(opponent.template).page else match[prefix] = opponent.template end