Module:Timeline of release years: Difference between revisions

Content deleted Content added
Implement compressempty
move styles to _main, local for module:arguments rename classes because I'm bothered by underscore names which are not quite entirely unconventional, move caption class off to css, retarget tstyles to module version
Line 1:
require('Module:No globals')
local getArgs = require('Module:Arguments').getArgs
local p = {}
 
Line 68 ⟶ 67:
-- if itemNum >= 2
builder:tag('td')
:addClass('rt_firstrt-first')
:wikitext(itemList[1])
 
Line 74 ⟶ 73:
builder = builder:tag('tr')
:tag('td')
:addClass('rt_nextrt-next')
:wikitext(itemList[key])
end
Line 80 ⟶ 79:
builder = builder:tag('tr')
:tag('td')
:addClass('rt_lastrt-last')
:wikitext(itemList[itemNum])
 
Line 88 ⟶ 87:
local itemNum, itemList = items(args, year)
 
-- If compressempty is set, check for empty items, track empty years, and
-- put out a compressed range when next year is found.
if args.compressempty then
-- If we're compressing and there's no items, return this year for tracking.
Line 115:
return nil
end
 
 
--------------------------------------------------------------------------------
 
function p.main(frame)
local args = getArgs(frame)
return frame:extensionTag{ name = 'templatestyles', args = { src = 'Timeline of release years/styles.css'} } .. tostring(p._main(args))
end
 
Line 134 ⟶ 126:
 
ret = mw.html.create( 'table' )
:addClass(args.align == 'left'release-timeline and 'wikitable release_timeline rt_left' or 'wikitable release_timeline')
:addClass(args.align == 'left' and 'rt-left' or nil)
 
ret:tag('caption')
:wikitext((args.title or 'Release timeline') ..
:addClass('rt_caption')
:wikitext((args.title or 'Release timeline').. (args.subtitle and ('<div class="rt_subtitlert-subtitle">'..args.subtitle..'</div>') or ''))
:addClass('nowrap')
:wikitext((args.title or 'Release timeline')..(args.subtitle and ('<div class="rt_subtitle">'..args.subtitle..'</div>') or ''))
 
if tonumber(args.first) then
Line 177 ⟶ 169:
end
 
return mw.getCurrentFrame():extensionTag{
return ret
return frame:extensionTag{ name = 'templatestyles', args = { src = 'Module:Timeline of release years/styles.css'} } .. tostring(p._main(args))
} .. tostring(ret)
end
 
function p.main(frame)
local getArgsargs = require('Module:Arguments').getArgs(frame)
return p._main(args)
end