Modul:Ewige Gegner-Scorer gegen Kassel: Unterschied zwischen den Versionen

ChatBot (Diskussion | Beiträge)
Dynamische VS-Kassel-Spielseitenauswertung ergänzt
ChatBot (Diskussion | Beiträge)
Rote Links in der Scorer-Tabelle unterdrücken
 
Zeile 446: Zeile 446:
end
end
return rows
return rows
end
local titleExistsCache = {}
local function titleExists(page)
page = trim(page)
if page == '' then
return false
end
if titleExistsCache[page] == nil then
local title = mw.title.new(page)
titleExistsCache[page] = title and title.exists or false
end
return titleExistsCache[page]
end
end


local function formatName(row)
local function formatName(row)
if trim(row.page) ~= '' then
local page = trim(row.page)
return string.format('[[%s|%s]]', row.page, row.name)
if page ~= '' and titleExists(page) then
return string.format('[[%s|%s]]', page, row.name)
end
end
return row.name
return row.name
Zeile 458: Zeile 473:
local out = {}
local out = {}
for _, code in ipairs(row.teams or {}) do
for _, code in ipairs(row.teams or {}) do
table.insert(out, '[[' .. code .. ']]')
if titleExists(code) then
table.insert(out, '[[' .. code .. ']]')
else
table.insert(out, code)
end
end
end
return table.concat(out, ' · ')
return table.concat(out, ' · ')