Documentation for this module may be created at Module:Sandbox/Szqecs/L-rail/Version 2/doc
local p = {}
local s = {
['w'] = 'style="width: 30%; '
,['c'] = 'style="text-align: center; '
,['br'] = 'border: '
,['t'] = 'border-top: '
,['bb'] = 'border-bottom: '
,['L'] = 'border-left: '
,['r'] = 'border-right: '
,['n'] = 'none; '
,['0'] = '0px none; '
,['1'] = '1px solid #aaa; '
}
local style = {
['table'] = 'align="center" style="margin:0.5em auto; font-size:95% clear:both; '
.. s['t'] .. s['0']
.. 'border-collapse: separate;" cellspacing="0" cellpadding="-1"'
,['header leftcell'] = s['w']
.. s['br'] .. s['1']
.. s['L'] .. s['n']
.. s['bb'] .. s['n']
.. '"| '
,['header midcell'] = 'colspan="3" style="'
.. s['br'] .. s['n']
.. s['t'] .. s['1']
.. '"| '
,['header rightcell'] = s['w']
.. s['br'] .. s['1']
.. s['r'] .. s['n']
.. s['bb'] .. s['n']
.. '"| '
,['body leftcell'] = s['c']
.. s['L'] .. s['0']
.. s['bb'] .. s['0']
.. s['r'] .. s['1']
.. s['t'] .. s['1']
.. '"| '
,['body banner'] = s['c']
.. s['L'] .. s['0']
.. s['bb'] .. s['0']
.. s['r'] .. s['0']
.. s['t'] .. s['1']
.. 'width: 8px; background-color: #'
,['body midcell'] = s['c']
.. s['bb'] .. s['0']
.. '"| '
,['body rightcell'] = s['c']
.. s['L'] .. s['1']
.. s['bb'] .. s['0']
.. s['r'] .. s['0']
.. s['t'] .. s['1']
.. '"| '
}
function p.top()
return '{| class="wikitable" ' .. style['table']
end
function p.rail(system)
return '|-'
.. '\n! ' .. style['header leftcell'] .. 'Preceding station'
.. '\n! ' .. style['header midcell'] .. system
.. '\n! ' .. style['header rightcell'] .. 'Following station'
end
function p.line(line, color, left, right, leftToward, rightToward)
return '|-'
.. '\n| ' .. style['body leftcell'] .. left .. leftToward
.. '\n| ' .. style['body banner'] .. color .. '" |'
.. '\n| ' .. style['body midcell'] .. line
.. '\n| ' .. style['body banner'] .. color .. '" |'
.. '\n| ' .. style['body rightcell'] .. right .. rightToward
end
function p.bottom()
return '|}'
end
function p.main(frame)
local a = frame.args
local d = require('Module:Sandbox/Szqecs/L-rail/' .. a.system)
local function link(s1, s2)
if s1 and s2 then
return '\[\[' .. s1 .. '|' .. s2 .. '\]\]'
elseif s1 then
return '\[\[' .. s1 .. '\]\]'
else
return ''
end
end
local function subFormat(s)
if s ~= '' then
return '<div style="font-size: smaller; font-style: italic;">' .. s .. '</div>'
else
return ''
end
end
local system = link(d['system'])
local line = link(d[a.line]['lines'])
local color = d[a.line]['color']
if not left then
left = "''Terminus''"
else
left = link(d[a.line]['stations'][a.left])
end
if not right then
right = "''Terminus''"
else
right = link(d[a.line]['stations'][a.right])
end
if not a.left then
leftToward = ''
elseif a.left == d[a.line]['leftToward'] then
leftToward = subFormat('Terminus')
else
leftToward = subFormat('toward ' .. link(d[a.line]['leftTowardLink'], d[a.line]['leftToward']))
end
if not a.right then
rightToward = ''
elseif a.right == d[a.line]['rightToward'] then
rightToward = subFormat('Terminus')
else
rightToward = subFormat('toward ' .. link(d[a.line]['rightTowardLink'], d[a.line]['rightToward']))
end
return p.line(line, color, left, right, leftToward, rightToward)
-- return line(a.System, a.Line, a.Previous, a.Next, a.Type, a.Type2, a.Note, a.Note2, a.Notemid, a.Oneway2, a.Row1, a.hide)
end
return p