Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions lua/wikis/commons/MatchGroup/Display/Helper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,12 @@ function DisplayHelper.DefaultGameSummaryContainer(props)
return GameSummaryModule.getGameByMatchId(props)
end

---@param props table
---@return Html
---@param props {match: MatchGroupUtilMatch}
---@return Widget
function DisplayHelper.DefaultMatchPageContainer(props)
local MatchPageModule = Lua.import('Module:MatchPage')

assert(MatchPageModule.getByMatchId, 'Expected MatchPage.getByMatchId to be a function')

return MatchPageModule.getByMatchId(props)
return MatchPageModule(props.match):render()
end

---Retrieves the wiki specific global bracket config.
Expand Down
10 changes: 5 additions & 5 deletions lua/wikis/commons/MatchGroup/Display/MatchPage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ local WikiSpecific = Lua.import('Module:Brkts/WikiSpecific')
local MatchPageDisplay = {}

---@class MatchPageConfigOptions
---@field MatchPageContainer function?
---@field MatchPageContainer? fun(props: {match: MatchGroupUtilMatch}): Widget

---Display component for a MatchPage. The MatchPage is specified by matchID.
---The component fetches the match data from LPDB or page variables.
---@param props {matchId: string, config: MatchPageConfigOptions}
---@return Html
---@return Widget|Html
function MatchPageDisplay.MatchPageContainer(props)
local bracketId, _ = MatchGroupUtil.splitMatchId(props.matchId)

Expand All @@ -38,7 +38,7 @@ end

---Display component for a singleMatch. Match data is specified in the input.
---@param props {config: MatchPageConfigOptions, match: MatchGroupUtilMatch}
---@return Html
---@return Widget|Html
function MatchPageDisplay.SingleMatch(props)
local propsConfig = props.config or {}
local config = {
Expand All @@ -52,8 +52,8 @@ function MatchPageDisplay.SingleMatch(props)
end

---Display component for a matcch. Consists of the match page.
---@param props {MatchPageContainer: function, match: MatchGroupUtilMatch}
---@return Html
---@param props {MatchPageContainer: (fun(props: {match: MatchGroupUtilMatch}): Widget), match: MatchGroupUtilMatch}
---@return Widget|Html
function MatchPageDisplay.Match(props)
local bracketId = MatchGroupUtil.splitMatchId(props.match.matchId)

Expand Down
5 changes: 1 addition & 4 deletions lua/wikis/commons/MatchGroup/Input.lua
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,7 @@ end
---@param matchInput table
---@return table[]
function MatchGroupInput.readMatchpage(bracketId, matchId, matchInput)
local matchArgs = {}
for key, value in pairs(matchInput) do
matchArgs[key] = Json.parseIfTable(value) or value
end
local matchArgs = Json.parseStringifiedArgs(matchInput)

local function setMatchPageContext()
local tournamentPage = (mw.ext.LiquipediaDB.lpdb('match2', {
Expand Down
11 changes: 2 additions & 9 deletions lua/wikis/commons/MatchPage/Base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ local WidgetUtil = Lua.import('Module:Widget/Util')
---@field teamTemplateData teamTemplateData
---@field seriesDots string[]

---@class BaseMatchPage
---@operator call(MatchPageMatch): BaseMatchPage
---@class BaseMatchPage: BaseClass
---@operator call(MatchGroupUtilMatch): BaseMatchPage
---@field matchData MatchPageMatch
---@field games MatchPageGame[]
---@field opponents MatchPageOpponent[]
Expand All @@ -89,13 +89,6 @@ local BaseMatchPage = Class.new(
BaseMatchPage.NOT_PLAYED = 'notplayed'
BaseMatchPage.NO_CHARACTER = 'default'

---@param props {match: MatchGroupUtilMatch}
---@return Widget
function BaseMatchPage.getByMatchId(props)
local matchPage = BaseMatchPage(props.match)
return matchPage:render()
end

function BaseMatchPage:addCategories()
local matchPhase = MatchGroupUtil.computeMatchPhase(self.matchData)

Expand Down
9 changes: 1 addition & 8 deletions lua/wikis/dota2/MatchPage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,14 @@ local VetoRow = Lua.import('Module:Widget/Match/Page/VetoRow')
local WidgetUtil = Lua.import('Module:Widget/Util')

---@class Dota2MatchPage: BaseMatchPage
---@operator call(MatchGroupUtilMatch): Dota2MatchPage
local MatchPage = Class.new(BaseMatchPage)

local GOLD_ICON = IconFa{iconName = 'gold', hover = 'Gold'}
local ITEM_IMAGE_SIZE = '64px'
local KDA_ICON = IconFa{iconName = 'kda', hover = 'KDA'}
local SPAN_SLASH = HtmlWidgets.Span{classes = {'slash'}, children = '/'}

---@param props {match: MatchGroupUtilMatch}
---@return Widget
function MatchPage.getByMatchId(props)
local matchPage = MatchPage(props.match)

return matchPage:render()
end

function MatchPage:populateGames()
Array.forEach(self.games, function(game)
game.finished = game.winner ~= nil and game.winner ~= -1
Expand Down
10 changes: 1 addition & 9 deletions lua/wikis/leagueoflegends/MatchPage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ local WidgetUtil = Lua.import('Module:Widget/Util')

---@class LoLMatchPage: BaseMatchPage
---@field games LoLMatchPageGame[]
---@operator call(MatchGroupUtilMatch): BaseMatchPage
---@operator call(MatchGroupUtilMatch): LoLMatchPage
local MatchPage = Class.new(BaseMatchPage)

local KEYSTONES = Table.map({
Expand Down Expand Up @@ -83,14 +83,6 @@ local KP_ICON = IconFa{iconName = 'leagueoflegends_killparticipation', hover = '
local GOLD_ICON = IconFa{iconName = 'gold', hover = 'Gold'}
local SPAN_SLASH = HtmlWidgets.Span{classes = {'slash'}, children = '/'}

---@param props {match: MatchGroupUtilMatch}
---@return Widget
function MatchPage.getByMatchId(props)
local matchPage = MatchPage(props.match)

return matchPage:render()
end

function MatchPage:populateGames()
Array.forEach(self.games, function(game)
local vetoPhase = game.extradata.vetophase or {}
Expand Down
10 changes: 1 addition & 9 deletions lua/wikis/valorant/MatchPage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper')
local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/All')

---@class ValorantMatchPage: BaseMatchPage
---@operator call(MatchPageMatch): ValorantMatchPage
---@operator call(MatchGroupUtilMatch): ValorantMatchPage
local MatchPage = Class.new(BaseMatchPage)

local SPAN_SLASH = HtmlWidgets.Span{classes = {'slash'}, children = '/'}
Expand Down Expand Up @@ -65,14 +65,6 @@ local WIN_TYPES = {
}
}

---@param props {match: MatchGroupUtilMatch}
---@return Widget
function MatchPage.getByMatchId(props)
local matchPage = MatchPage(props.match)

return matchPage:render()
end

function MatchPage:populateGames()
Array.forEach(self.games, function(game)
game.finished = game.winner ~= nil and game.winner ~= -1
Expand Down
Loading