Module:Update history navbox: Difference between revisions
Appearance
Match the Main Page navigation style sitewide and keep update navigation expanded |
Update archive and navigation references after the page moves |
||
| (One intermediate revision by the same user not shown) | |||
| Line 8: | Line 8: | ||
function p.render() | function p.render() | ||
local index = mw.title.new(' | local index = mw.title.new('Update history'):getContent() or '' | ||
local region = index:match('<!%-%- bconomy:begin version%-index %-%->(.-)<!%-%- bconomy:end version%-index %-%->') | local region = index:match('<!%-%- bconomy:begin version%-index %-%->(.-)<!%-%- bconomy:end version%-index %-%->') | ||
if not region then | if not region then | ||
return '[[ | return '[[Update history|Browse the chronological index]]' | ||
end | end | ||
| Line 37: | Line 37: | ||
end | end | ||
if not year then | if not year then | ||
return '[[ | return '[[Update history|Browse the chronological index]]' | ||
end | end | ||
return tostring(root) | return tostring(root) | ||
Latest revision as of 23:57, 3 November 2026
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