From Wikipedia, the free encyclopedia

local yesno = require("Module:Yesno")

local _style = {

	'3' = 'style="width: 30%;',

	'c' = 'style="text-align: center;',

	'v' = 'vertical-align: middle;',

	'bd' = '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' = table.concat({'style="width: 55%; max-width: 50em; margin:0.5em auto; font-size:95%; clear:both;',

		_style't'], _style'0'],

		'border-collapse: separate;" cellspacing="0" cellpadding="-1"'

	}),

	'header leftcell' = table.concat({_style'3'], _style'v'],

		_style'bd'], _style'1'],

		_style'L'], _style'n'],

		_style'bb'], _style'n'],

		'"|'

	}),

	'header banner' = table.concat({'style="',

		_style'bd'], _style'n'],

		_style't'], _style'1'],

		'"|'

	}),

	'header midcell' = table.concat({'colspan="3" style="', _style'v'],

		_style'bd'], _style'n'],

		_style't'], _style'1'],

		'"|'

	}),

	'header rightcell' = table.concat({_style'3'], _style'v'],

		_style'bd'], _style'1'],

		_style'r'], _style'n'],

		_style'bb'], _style'n'],

		'"|'

	}),

	'body leftcell' = table.concat({_style'c'], _style'v'],

		_style'L'], _style'0'],

		_style'bb'], _style'0'],

		_style'r'], _style'1'],

		_style't'], _style'1'],

		'"|'

	}),

	'body banner' = table.concat({_style'c'],

		_style'L'], _style'0'],

		_style'bb'], _style'0'],

		_style'r'], _style'0'],

		_style't'], _style'1'],

		'width: 8px; min-width: 8px; background-color: #'

	}),

	'body midcell' = table.concat({_style'c'], _style'v'],

		_style'bb'], _style'0'],

		'"|'

	}),

	'body rightcell' = table.concat({_style'c'], _style'v'],

		_style'L'], _style'1'],

		_style'bb'], _style'0'],

		_style'r'], _style'0'],

		_style't'], _style'1'],

		'"|'

	})

}



local function subFormat(s)

	return '<div style="font-size: smaller; font-style: italic">' .. s .. '</div>'

end



local p = {}



function p.top()

	return table.concat({'{| class="wikitable" ', style'table']})

end



function p.line(args, index, data)

	local lineTitle = {}

	local colour = {}

	local left = {}

	local right = {}

	local note = {}

	local leftTerminus = {}

	local rightTerminus = {}

	

	local t = {}

	

	for i, v in ipairs(index) do

		if args.systemv then

			table.insert(t, table.concat({'\n|-',

				'\n!', style'header leftcell'], 'Preceding station',

				'\n!', style'header midcell'], datav][1]['system title'],

				'\n!', style'header rightcell'], 'Following station'

			}))

			table.insert(t, '')

			table.insert(t, '')

			table.insert(t, '')

		end

		

		if args.linev or args.leftv or args.rightv then

			if not args.linev then args.linev = args.lineindexi-1]] end

			local _line = datav][args.linev]]

			lineTitlev = _line'line title'

			colourv = _line.colour

			notev = args.notev or ''

			

			if type(_line'left terminus']) == 'string' then

				_leftTerminus = _line'left terminus'

			elseif type(_line'left terminus']) == 'table' then

				_leftTerminus = _line'left terminus'][args.TypeLv or 1

			end

			if type(_line'right terminus']) == 'string' then

				_rightTerminus = _line'right terminus'

			elseif type(_line'right terminus']) == 'table' then

				_rightTerminus = _line'right terminus'][args.TypeRv or 1

			end

			

			local function station(s)

				if _line'station link' then

					return _line'station link'][s or datav][1]['station link'][s or mw.ustring.gsub(_line'station link'][1 or datav][1]['station link'][1], '%%s', s)

				else

					return datav][1]['station link'][s or mw.ustring.gsub(datav][1]['station link'][1], '%%s', s)

				end

			end

			

			if not args.leftv then

				leftv = "''Terminus''"

				leftTerminusv = ''

			elseif args.leftv == _leftTerminus then

				leftv = station(args.leftv])

				leftTerminusv = subFormat('Terminus')

			else

				leftv = station(args.leftv])

				if args.onewayLv == true then

					leftTerminusv = subFormat('One-way operation')

				else

					leftTerminusv = subFormat('towards ' .. station(_leftTerminus))

				end

			end

			

			if not args.rightv then

				rightv = "''Terminus''"

				rightTerminusv = ''

			elseif args.rightv == _rightTerminus then

				rightv = station(args.rightv])

				rightTerminusv = subFormat('Terminus')

			else

				rightv = station(args.rightv])

				if args.onewayRv == true then

					rightTerminusv = subFormat('One-way operation')

				else

					rightTerminusv = subFormat('towards ' .. station(_rightTerminus))

				end

			end

			table.insert(t, '\n|-')

			table.insert(t, table.concat({'\n|', style'body leftcell'], leftv], leftTerminusv]}))

			table.insert(t, table.concat({'\n|', style'body banner'], colourv], '"|',

				'\n|', style'body midcell'], lineTitlev], '<div style="font-size: smaller">', notev], '</div>',

				'\n|', style'body banner'], colourv], '"|'}))

			table.insert(t, table.concat({'\n|', style'body rightcell'], rightv], rightTerminusv]}))

		end

	end

	

	local function combine(t, i)

		if ti+4 ~= '' and ti+4 == ti then

			local tmp = i+4

			ti+4 = ''

			local rowspan = 2

			while ttmp == ttmp+4 do

				ttmp+4 = ''

				rowspan = rowspan+1

				tmp = tmp+4

			end

			ti = mw.ustring.gsub(ti], '\n|style="', table.concat({'\n|rowspan="', rowspan, '" style="'}))

		end

	end

	

	local max = #t

	for i = 2, max-2, 4 do combine(t, i) end

	for i = 3, max-1, 4 do combine(t, i) end

	for i = 4, max, 4 do combine(t, i) end

	

	return table.concat(t)

end



function p.bottom()

	return '\n|}'

end



function p.main(frame)

	local _args = frame:getParent().args

	local args = {

		system = {},

		line = {},

		left = {},

		right = {},

		TypeL = {},

		TypeR = {},

		note = {},

		onewayL = {},

		onewayR = {},

		circular = {},

		circularL = {},

		circularR = {}

	}

	

	local _index = {}

	for k, v in pairs(_args) do

		local a = string.match(k, '(%a+)%d+')

		if not a then

			a = k

		end

		local b = tonumber(string.match(k, '%a+(%d+)'))

		if not b then

			b = 1

		end

		

		if a == 'system' then

			args.systemb = v

			_indexb = true

		elseif a == 'line' then

			args.lineb = v

			_indexb = true

		elseif a == 'left' then

			args.leftb = v

			_indexb = true

		elseif a == 'right' then

			args.rightb = v

			_indexb = true

		elseif a == 'typeL' then

			args.TypeLb = v

		elseif a == 'typeR' then

			args.TypeRb = v

		elseif a == 'note' then

			args.noteb = v

		elseif a == 'onewayL' then

			args.onewayLb = yesno(v)

		elseif a == 'onewayR' then

			args.onewayRb = yesno(v)

		elseif a == 'circular' then

			args.circularb = yesno(v)

		elseif a == 'circularL' then

			args.circularLb = yesno(v)

		elseif a == 'circularR' then

			args.circularRb = yesno(v)

		elseif a == 'throughL' then

			args.throughL = yesno(v)

		elseif a == 'throughR' then

			args.throughR = yesno(v)

		end

	end

	

	local index = {}

	for k, v in pairs(_index) do

		table.insert(index, k)

	end

	table.sort(index)

	

	local data = {}

	for i, v in ipairs(index) do

		if args.systemv then

			datav = require('Module:Sandbox/Szqecs/L-rail/' .. args.systemv])

		else

			datav = dataindexi-1]]

		end

	end

	

	local rows = { -- To be removed. Included for backwards compatibility.

		'all' = table.concat({p.top(), p.line(args, index, data), p.bottom()}),

		'top' = table.concat({p.top(), p.line(args, index, data)}),

		'mid' = table.concat({p.line(args, index, data)}),

		'bottom' = table.concat({p.line(args, index, data), p.bottom()})

	}

	

	return rows_args.rows or rows'all'

end



return p
From Wikipedia, the free encyclopedia

local yesno = require("Module:Yesno")

local _style = {

	'3' = 'style="width: 30%;',

	'c' = 'style="text-align: center;',

	'v' = 'vertical-align: middle;',

	'bd' = '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' = table.concat({'style="width: 55%; max-width: 50em; margin:0.5em auto; font-size:95%; clear:both;',

		_style't'], _style'0'],

		'border-collapse: separate;" cellspacing="0" cellpadding="-1"'

	}),

	'header leftcell' = table.concat({_style'3'], _style'v'],

		_style'bd'], _style'1'],

		_style'L'], _style'n'],

		_style'bb'], _style'n'],

		'"|'

	}),

	'header banner' = table.concat({'style="',

		_style'bd'], _style'n'],

		_style't'], _style'1'],

		'"|'

	}),

	'header midcell' = table.concat({'colspan="3" style="', _style'v'],

		_style'bd'], _style'n'],

		_style't'], _style'1'],

		'"|'

	}),

	'header rightcell' = table.concat({_style'3'], _style'v'],

		_style'bd'], _style'1'],

		_style'r'], _style'n'],

		_style'bb'], _style'n'],

		'"|'

	}),

	'body leftcell' = table.concat({_style'c'], _style'v'],

		_style'L'], _style'0'],

		_style'bb'], _style'0'],

		_style'r'], _style'1'],

		_style't'], _style'1'],

		'"|'

	}),

	'body banner' = table.concat({_style'c'],

		_style'L'], _style'0'],

		_style'bb'], _style'0'],

		_style'r'], _style'0'],

		_style't'], _style'1'],

		'width: 8px; min-width: 8px; background-color: #'

	}),

	'body midcell' = table.concat({_style'c'], _style'v'],

		_style'bb'], _style'0'],

		'"|'

	}),

	'body rightcell' = table.concat({_style'c'], _style'v'],

		_style'L'], _style'1'],

		_style'bb'], _style'0'],

		_style'r'], _style'0'],

		_style't'], _style'1'],

		'"|'

	})

}



local function subFormat(s)

	return '<div style="font-size: smaller; font-style: italic">' .. s .. '</div>'

end



local p = {}



function p.top()

	return table.concat({'{| class="wikitable" ', style'table']})

end



function p.line(args, index, data)

	local lineTitle = {}

	local colour = {}

	local left = {}

	local right = {}

	local note = {}

	local leftTerminus = {}

	local rightTerminus = {}

	

	local t = {}

	

	for i, v in ipairs(index) do

		if args.systemv then

			table.insert(t, table.concat({'\n|-',

				'\n!', style'header leftcell'], 'Preceding station',

				'\n!', style'header midcell'], datav][1]['system title'],

				'\n!', style'header rightcell'], 'Following station'

			}))

			table.insert(t, '')

			table.insert(t, '')

			table.insert(t, '')

		end

		

		if args.linev or args.leftv or args.rightv then

			if not args.linev then args.linev = args.lineindexi-1]] end

			local _line = datav][args.linev]]

			lineTitlev = _line'line title'

			colourv = _line.colour

			notev = args.notev or ''

			

			if type(_line'left terminus']) == 'string' then

				_leftTerminus = _line'left terminus'

			elseif type(_line'left terminus']) == 'table' then

				_leftTerminus = _line'left terminus'][args.TypeLv or 1

			end

			if type(_line'right terminus']) == 'string' then

				_rightTerminus = _line'right terminus'

			elseif type(_line'right terminus']) == 'table' then

				_rightTerminus = _line'right terminus'][args.TypeRv or 1

			end

			

			local function station(s)

				if _line'station link' then

					return _line'station link'][s or datav][1]['station link'][s or mw.ustring.gsub(_line'station link'][1 or datav][1]['station link'][1], '%%s', s)

				else

					return datav][1]['station link'][s or mw.ustring.gsub(datav][1]['station link'][1], '%%s', s)

				end

			end

			

			if not args.leftv then

				leftv = "''Terminus''"

				leftTerminusv = ''

			elseif args.leftv == _leftTerminus then

				leftv = station(args.leftv])

				leftTerminusv = subFormat('Terminus')

			else

				leftv = station(args.leftv])

				if args.onewayLv == true then

					leftTerminusv = subFormat('One-way operation')

				else

					leftTerminusv = subFormat('towards ' .. station(_leftTerminus))

				end

			end

			

			if not args.rightv then

				rightv = "''Terminus''"

				rightTerminusv = ''

			elseif args.rightv == _rightTerminus then

				rightv = station(args.rightv])

				rightTerminusv = subFormat('Terminus')

			else

				rightv = station(args.rightv])

				if args.onewayRv == true then

					rightTerminusv = subFormat('One-way operation')

				else

					rightTerminusv = subFormat('towards ' .. station(_rightTerminus))

				end

			end

			table.insert(t, '\n|-')

			table.insert(t, table.concat({'\n|', style'body leftcell'], leftv], leftTerminusv]}))

			table.insert(t, table.concat({'\n|', style'body banner'], colourv], '"|',

				'\n|', style'body midcell'], lineTitlev], '<div style="font-size: smaller">', notev], '</div>',

				'\n|', style'body banner'], colourv], '"|'}))

			table.insert(t, table.concat({'\n|', style'body rightcell'], rightv], rightTerminusv]}))

		end

	end

	

	local function combine(t, i)

		if ti+4 ~= '' and ti+4 == ti then

			local tmp = i+4

			ti+4 = ''

			local rowspan = 2

			while ttmp == ttmp+4 do

				ttmp+4 = ''

				rowspan = rowspan+1

				tmp = tmp+4

			end

			ti = mw.ustring.gsub(ti], '\n|style="', table.concat({'\n|rowspan="', rowspan, '" style="'}))

		end

	end

	

	local max = #t

	for i = 2, max-2, 4 do combine(t, i) end

	for i = 3, max-1, 4 do combine(t, i) end

	for i = 4, max, 4 do combine(t, i) end

	

	return table.concat(t)

end



function p.bottom()

	return '\n|}'

end



function p.main(frame)

	local _args = frame:getParent().args

	local args = {

		system = {},

		line = {},

		left = {},

		right = {},

		TypeL = {},

		TypeR = {},

		note = {},

		onewayL = {},

		onewayR = {},

		circular = {},

		circularL = {},

		circularR = {}

	}

	

	local _index = {}

	for k, v in pairs(_args) do

		local a = string.match(k, '(%a+)%d+')

		if not a then

			a = k

		end

		local b = tonumber(string.match(k, '%a+(%d+)'))

		if not b then

			b = 1

		end

		

		if a == 'system' then

			args.systemb = v

			_indexb = true

		elseif a == 'line' then

			args.lineb = v

			_indexb = true

		elseif a == 'left' then

			args.leftb = v

			_indexb = true

		elseif a == 'right' then

			args.rightb = v

			_indexb = true

		elseif a == 'typeL' then

			args.TypeLb = v

		elseif a == 'typeR' then

			args.TypeRb = v

		elseif a == 'note' then

			args.noteb = v

		elseif a == 'onewayL' then

			args.onewayLb = yesno(v)

		elseif a == 'onewayR' then

			args.onewayRb = yesno(v)

		elseif a == 'circular' then

			args.circularb = yesno(v)

		elseif a == 'circularL' then

			args.circularLb = yesno(v)

		elseif a == 'circularR' then

			args.circularRb = yesno(v)

		elseif a == 'throughL' then

			args.throughL = yesno(v)

		elseif a == 'throughR' then

			args.throughR = yesno(v)

		end

	end

	

	local index = {}

	for k, v in pairs(_index) do

		table.insert(index, k)

	end

	table.sort(index)

	

	local data = {}

	for i, v in ipairs(index) do

		if args.systemv then

			datav = require('Module:Sandbox/Szqecs/L-rail/' .. args.systemv])

		else

			datav = dataindexi-1]]

		end

	end

	

	local rows = { -- To be removed. Included for backwards compatibility.

		'all' = table.concat({p.top(), p.line(args, index, data), p.bottom()}),

		'top' = table.concat({p.top(), p.line(args, index, data)}),

		'mid' = table.concat({p.line(args, index, data)}),

		'bottom' = table.concat({p.line(args, index, data), p.bottom()})

	}

	

	return rows_args.rows or rows'all'

end



return p

Videos

Youtube | Vimeo | Bing

Websites

Google | Yahoo | Bing

Encyclopedia

Google | Yahoo | Bing

Facebook