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
23 changes: 22 additions & 1 deletion lua/wikis/commons/MatchGroup/Display/Helper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ local Page = Lua.import('Module:Page')
local PlayerDisplay = Lua.import('Module:Player/Display')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
local Template = Lua.import('Module:Template')
local TeamTemplate = Lua.import('Module:TeamTemplate')

local Info = Lua.import('Module:Info', {loadData = true})
Expand Down Expand Up @@ -98,6 +99,7 @@ function DisplayHelper.createSubstitutesComment(match)
if Logic.isEmpty(substitutions) then
return
end
---@cast substitutions MatchGroupInputSubstituteInformation[]

Array.forEach(substitutions, function(substitution)
if Logic.isEmpty(substitution.substitute) then
Expand Down Expand Up @@ -131,13 +133,32 @@ function DisplayHelper.createSubstitutesComment(match)
table.insert(subString, string.format('due to %s', substitution.reason))
end

table.insert(comment, table.concat(subString, ' ') .. '.')
table.insert(
comment,
table.concat(subString, ' ') .. '.' .. DisplayHelper._createSubstituteReferences(substitution.references)
)
end)
end)

return comment
end

---@private
---@param references table[]?
---@return string
function DisplayHelper._createSubstituteReferences(references)
if Logic.isEmpty(references) then
return ''
end
---@cast references -nil
local frame = mw.getCurrentFrame()
return table.concat(Array.map(references, function (reference)
return frame:extensionTag('ref', Template.safeExpand(
frame, 'Cite web', reference
))
end))
end

---Creates display components for caster(s).
---@param casters {name: string?, displayName: string?, flag: string?}[]
---@return (string|Widget|nil)[]
Expand Down
2 changes: 2 additions & 0 deletions lua/wikis/commons/MatchGroup/Input/Util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ local contentLanguage = mw.getContentLanguage()
---@field player standardPlayer?
---@field games string[]
---@field reason string?
---@field references table[]?

---@param dateString string?
---@param dateFallbacks string[]?
Expand Down Expand Up @@ -406,6 +407,7 @@ function MatchGroupInputUtil.extractManualPlayersInput(match, opponentIndex, opp
player = makeStandardPlayer(substitution.out),
games = Logic.nilIfEmpty(Array.parseCommaSeparatedString(substitution.games, ';')),
reason = substitution.reason,
references = substitution.references,
}
end)

Expand Down
Loading