Module:Updates
Jump to navigation
Jump to search
Module:Updates
Determines previous and next update versions, relative to a specified version string, using the manually-ordered dataset defined in Module:Updates/data.
Usage
Inside Template:UpdateInfobox
The module is invoked by the template to render navigation buttons.
{{#invoke:Updates|get|{{{version|{{PAGENAME}}}}
The version parameter defaults to the current page name if not specified. The module returns two rows containing the previous and next update links, formatted for insertion into an infobox.
Parameters
get
- 1
- The version string corresponding to an entry in Module:Updates/data.
Notes
- Version ordering is determined entirely by the sequence defined in Module:Updates/data, thus the dataset must remain sorted in ascending version order for navigation to function correctly.
- If the provided version does not exist in the dataset, a warning message is returned that will display in the infobox.
local p = {}
local data = require("Module:Updates/data")
local outputRow = '<div style="display:flex; justify-content:space-between;"><span>%s</span><span>%s</span></div>'
function p.get(frame)
local currentVer = mw.text.trim(frame.args[1] or "")
if currentVer == "" then
return "'''NO VERSION SPECIFIED'''"
end
for i, v in ipairs(data) do
if v == currentVer then
local prevVer = data[i-1]
local nextVer = data[i+1]
local labelRow = string.format(outputRow,
prevVer and "'''Previous'''" or "",
nextVer and "'''Next'''" or ""
)
local linkRow = string.format(outputRow,
prevVer and "[[" .. prevVer .. "]]" or "",
nextVer and "[[" .. nextVer .. "]]" or ""
)
return labelRow .. "\n" .. linkRow
end
end
return "'''SPECIFIED VERSION NOT PRESENT IN [[Module:Updates/data]]'''"
end
return p