Modul:Archívumlista
A modult a Modul:Archívumlista/doc lapon tudod dokumentálni
local p = {}
local function rel2abs(rel)
return mw.getCurrentFrame():callParserFunction('#rel2abs', rel)
end
local function formatlink(format, displayformat, i)
return string.format('[[%s|%s]]', string.format(format, i), string.format(displayformat, i))
end
function p._main(format, displayformat, min)
local archives = {}
local i = 1
while i <= min do
table.insert(archives, formatlink(format, displayformat, i))
i = i + 1
end
local success, exists
repeat
local title = mw.title.new(rel2abs(string.format(format, i)))
success, exists = pcall(function () return title and title.exists end)
exists = success and exists
if exists then
table.insert(archives, formatlink(format, displayformat, i))
end
i = i + 1
until not exists
return archives
end
function p.main(frame)
local args = require('Modul:Arguments').getArgs(frame)
local format = args['formátum'] or args.format or '/Archívum/Archív%02d'
local displayformat = args['megjelenő formátum'] or args.displayformat or '%02d'
local min = tonumber(args.min) or 0
local sep = args['elválasztó'] or args.sep or ', '
return table.concat(p._main(format, displayformat, min), sep)
end
return p