Skip to content
Open
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
1 change: 1 addition & 0 deletions javascript/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const jsModules = [
'FilterButtons',
'Liquipedia_links',
'Mainpage',
'MatchPage',
'Miscellaneous',
'PanelBoxCollapsible',
'Prizepooltable',
Expand Down
36 changes: 36 additions & 0 deletions javascript/commons/MatchPage.js
Original file line number Diff line number Diff line change
@@ -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' );
38 changes: 38 additions & 0 deletions lua/wikis/commons/MatchPage/Base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')

Expand Down Expand Up @@ -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(),
Expand All @@ -347,6 +358,33 @@ function BaseMatchPage:render()
}
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
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()
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Loading