From 9c10726d9d984014835feaba7a86ec1f031b114a Mon Sep 17 00:00:00 2001 From: ElectricalBoy <15651807+ElectricalBoy@users.noreply.github.com> Date: Tue, 3 Mar 2026 21:22:39 +0900 Subject: [PATCH 1/5] automatically fetch bracket page --- lua/wikis/commons/MatchPage/Base.lua | 39 ++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/lua/wikis/commons/MatchPage/Base.lua b/lua/wikis/commons/MatchPage/Base.lua index a298d248890..8314213f1cf 100644 --- a/lua/wikis/commons/MatchPage/Base.lua +++ b/lua/wikis/commons/MatchPage/Base.lua @@ -18,6 +18,7 @@ local I18n = Lua.import('Module:I18n') local Logic = Lua.import('Module:Logic') local Links = Lua.import('Module:Links') local MatchTable = Lua.import('Module:MatchTable') +local Namespace = Lua.import('Module:Namespace') local Operator = Lua.import('Module:Operator') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') @@ -29,6 +30,13 @@ local HighlightConditions = Lua.import('Module:HighlightConditions') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util/Custom') local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper') +local Condition = Lua.import('Module:Condition') +local ConditionTree = Condition.Tree +local ConditionNode = Condition.Node +local Comparator = Condition.Comparator +local BooleanOperator = Condition.BooleanOperator +local ColumnName = Condition.ColumnName + local Opponent = Lua.import('Module:Opponent/Custom') local OpponentDisplay = Lua.import('Module:OpponentDisplay/Custom') @@ -325,6 +333,9 @@ function BaseMatchPage:render() local tournamentContext = self:getMatchContext() return Div{ classes = {'match-bm'}, + attributes = { + ['data-matchPage-bracket-page'] = self:_queryBracketPage() + }, children = WidgetUtil.collect( Header { countdownBlock = self:getCountdownBlock(), @@ -347,6 +358,30 @@ function BaseMatchPage:render() } end +---@private +---@return string? +function BaseMatchPage:_queryBracketPage() + local bracketId = Array.sub(Array.parseCommaSeparatedString(self.matchData.matchId, '_'), 2, -2) + if Logic.isEmpty(bracketId) then + return + end + + local namespaceName = Array.sub(bracketId, 1, -1)[1] + + local conditions = ConditionTree(BooleanOperator.all) + :add(ConditionNode(ColumnName('match2bracketid'), Comparator.eq, table.concat(bracketId, '_'))) + :add(namespaceName and ConditionNode( + ColumnName('namespace'), Comparator.eq, Namespace.idFromName(namespaceName) + ) or nil) + + local data = mw.ext.LiquipediaDB.lpdb('match2', { + conditions = tostring(conditions), + count = 1, + query = 'pagename' + })[1] + return (namespaceName and (namespaceName .. ':') or '') .. data.pagename +end + ---@protected ---@return string|Html|Widget? function BaseMatchPage:renderGames() @@ -379,9 +414,9 @@ function BaseMatchPage:renderGames() local mapName = self.games[gameIndex].map return { label = 'Game ' .. gameIndex .. ( - Logic.isNotEmpty(mapName) and (': ' .. mapName) or '' + Logic.isNotEmpty(mapName) and (': ' .. apName) or '' ), - content = game + content = gam } end) ), From 3fbe11fd199b702b4426e0f5f103ab4a40efb419 Mon Sep 17 00:00:00 2001 From: ElectricalBoy <15651807+ElectricalBoy@users.noreply.github.com> Date: Tue, 3 Mar 2026 21:32:16 +0900 Subject: [PATCH 2/5] fully automate tournament page purge --- javascript/Main.js | 1 + javascript/commons/MatchPage.js | 36 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 javascript/commons/MatchPage.js diff --git a/javascript/Main.js b/javascript/Main.js index 5f5c0853d8d..09efc89f713 100644 --- a/javascript/Main.js +++ b/javascript/Main.js @@ -21,6 +21,7 @@ const jsModules = [ 'FilterButtons', 'Liquipedia_links', 'Mainpage', + 'MatchPage', 'Miscellaneous', 'PanelBoxCollapsible', 'Prizepooltable', diff --git a/javascript/commons/MatchPage.js b/javascript/commons/MatchPage.js new file mode 100644 index 00000000000..c3ebee91cce --- /dev/null +++ b/javascript/commons/MatchPage.js @@ -0,0 +1,36 @@ +/******************************************************************************* + * Template(s): MatchPage + ******************************************************************************/ +liquipedia.matchpage = { + init: function() { + if ( mw.config.get( 'wgUserId' ) === null ) { + return; + } else if ( mw.config.get( 'wgPostEdit' ) === null ) { + return; + } else if ( mw.config.get( 'wgNamespaceNumber' ) !== 130 ) { + return; + } + const matchPage = document.querySelector( '.match-bm' ); + if ( !matchPage ) { + return; + } + const bracketPage = matchPage.getAttribute( 'data-matchPage-bracket-page' ); + if ( !bracketPage ) { + return; + } + mw.loader.using( [ 'mediawiki.api' ] ).then( () => { + const api = new mw.Api(); + api.post( { + action: 'purge', + format: 'json', + titles: bracketPage, + forcelinkupdate: true + } ).then( () => { + mw.notify( 'Tournament page purged' ); + } ).catch( () => { + mw.notify( 'Tournament page purge failed' ); + } ); + } ); + } +}; +liquipedia.core.modules.push( 'matchpage' ); From 16300df2783e7b68afbccd2e8ea5c34ffa7f0997 Mon Sep 17 00:00:00 2001 From: ElectricalBoy <15651807+ElectricalBoy@users.noreply.github.com> Date: Tue, 3 Mar 2026 21:32:40 +0900 Subject: [PATCH 3/5] typing for mw Api --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 8b71d2fd5ed..e9293c9dc00 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,8 @@ "sass": "^1.97.3", "stylelint": "^17.4.0", "stylelint-config-wikimedia": "^0.18.0", - "stylelint-scss": "^7.x.x" + "stylelint-scss": "^7.x.x", + "types-mediawiki": "2.0.0" }, "jest": { "reporters": [ From 08a20740453df51a6e8abb33979c7822bac85661 Mon Sep 17 00:00:00 2001 From: ElectricalBoy <15651807+ElectricalBoy@users.noreply.github.com> Date: Tue, 3 Mar 2026 21:40:07 +0900 Subject: [PATCH 4/5] restore characters that intellisense ate up --- lua/wikis/commons/MatchPage/Base.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/wikis/commons/MatchPage/Base.lua b/lua/wikis/commons/MatchPage/Base.lua index 8314213f1cf..83bd869ea8f 100644 --- a/lua/wikis/commons/MatchPage/Base.lua +++ b/lua/wikis/commons/MatchPage/Base.lua @@ -414,9 +414,9 @@ function BaseMatchPage:renderGames() local mapName = self.games[gameIndex].map return { label = 'Game ' .. gameIndex .. ( - Logic.isNotEmpty(mapName) and (': ' .. apName) or '' + Logic.isNotEmpty(mapName) and (': ' .. mapName) or '' ), - content = gam + content = game } end) ), From 9d49e1a40566bf4418cfe9a900c025079070d03c Mon Sep 17 00:00:00 2001 From: ElectricalBoy <15651807+ElectricalBoy@users.noreply.github.com> Date: Tue, 3 Mar 2026 22:13:01 +0900 Subject: [PATCH 5/5] check for match namespace --- lua/wikis/commons/MatchPage/Base.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/wikis/commons/MatchPage/Base.lua b/lua/wikis/commons/MatchPage/Base.lua index 83bd869ea8f..78411c0d26d 100644 --- a/lua/wikis/commons/MatchPage/Base.lua +++ b/lua/wikis/commons/MatchPage/Base.lua @@ -361,6 +361,9 @@ end ---@private ---@return string? function BaseMatchPage:_queryBracketPage() + if mw.title.getCurrentTitle().namespace ~= Namespace.matchNamespaceId() then + return + end local bracketId = Array.sub(Array.parseCommaSeparatedString(self.matchData.matchId, '_'), 2, -2) if Logic.isEmpty(bracketId) then return