Module:Update history navbox
Appearance
(Redirected from Module:Version history navbox)
Documentation for this module may be created at Module:Update history navbox/doc
local p = {}
local months = {
'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December'
}
function p.render()
local index = mw.title.new('Update history'):getContent() or ''
local region = index:match('<!%-%- bconomy:begin version%-index %-%->(.-)<!%-%- bconomy:end version%-index %-%->')
if not region then
return '[[Update history|Browse the chronological index]]'
end
local root = mw.html.create('table'):addClass('bc-navbox-table bc-navbox-years')
local year, month, monthTable, list
for y, m, link in region:gmatch('| data%-sort%-value="(%d%d%d%d)%-(%d%d)%-%d%d"[^\n]*\n| (%[%[[^\n]+%]%])\n') do
if year ~= y then
year, month = y, nil
local row = root:tag('tr')
row:tag('th'):attr('scope', 'row'):addClass('bc-navbox-year'):wikitext(y)
monthTable = row:tag('td'):addClass('bc-navbox-year-body')
:tag('table'):addClass('bc-navbox-months')
end
if month ~= m then
month = m
local monthRow = monthTable:tag('tr')
monthRow:tag('th'):attr('scope', 'row'):wikitext(months[tonumber(m)] or m)
list = monthRow:tag('td'):tag('ul'):addClass('bc-release-links')
end
local target, label = link:match('^%[%[([^|%]]+)|?([^%]]*)%]%]$')
if target then
label = (label ~= '' and label or target):gsub('^V(%d)', 'v%1')
list:tag('li'):wikitext('[[' .. target .. '|' .. label .. ']]')
end
end
if not year then
return '[[Update history|Browse the chronological index]]'
end
return tostring(root)
end
return p