Changes
Jump to navigation
Jump to search
Line 177:
Line 177:
− +
Line 191:
Line 191:
− +
Line 237:
Line 237:
− +
Line 254:
Line 254:
− +
Line 262:
Line 262:
− elseif Type['background color'] then+
− background_color = Type['background color']
− color = line['color'] or default['color'] or ''
− +
+
Line 276:
Line 275:
+
Line 344:
Line 344:
− +
Line 390:
Line 390:
+
+
+
+
+
+
+
+
+
Line 453:
Line 462:
− +
− +
− +
− +
− +
Line 484:
Line 493:
− +
Line 517:
Line 526:
− +
Line 523:
Line 532:
− +
− +
Line 535:
Line 544:
− +
− +
Line 666:
Line 675:
+
Line 699:
Line 709:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Line 733:
Line 804:
+
fix text color in dark mode; this generally works but may cause problems, in which case revert or try specifying a different CSS value. Some of these icons and boxes don't even have text, but the Linter complains, making it difficult to find actual problems amid the noise.
['header midcell'] = 'colspan="3" class="hmA"|',
['header midcell'] = 'colspan="3" class="hmA"|',
['body cell'] = 'class="bcA"|',
['body cell'] = 'class="bcA"|',
['body banner'] = 'class="bbA" style="background-color:#',
['body banner'] = 'class="bbA notheme" style="color:inherit;background-color:#',
}
}
local data = {} -- A table of data modules for each address
local data = {} -- A table of data modules for each address
local noclearclass = (((_args.noclear or '') ~= '') and ' adjacent-stations-noclear' or '')
local noclearclass = (((_args.noclear or '') ~= '') and ' adjacent-stations-noclear' or '')
local wikitable = {'{| class="wikitable adjacent-stations' .. noclearclass .. '"'}
local wikitable = {'{| class="wikitable adjacent-stations' .. noclearclass .. '"'}
for i, v in ipairs(index) do
for i, v in ipairs(index) do
local line = data[v]['lines'] and (mw.clone(data[v]['lines'][lineN]) or error(i18n[lang]['error_unknown'](args[v]['line']))) or error(i18n[lang]['error_line'])
local line = data[v]['lines'] and (mw.clone(data[v]['lines'][lineN]) or error(i18n[lang]['error_unknown'](args[v]['line']))) or error(i18n[lang]['error_line'])
local default = data[v]['lines']['_default'] or {}
local default = data[v]['lines']['_default'] or {}
line['title'] = line['title'] or default['title']
line['title'] = line['title'] or default['title'] or ''
line['title'] = mw.ustring.gsub(line['title'], '%%1', lineN)
line['title'] = mw.ustring.gsub(line['title'], '%%1', lineN)
local Format = data[v]['station format'] or i18n[lang]['error_format']
local Format = data[v]['station format'] or i18n[lang]['error_format']
local color, background_color, circular
local color, color_2, background_color, circular
local Type = line['types'] and line['types'][typeN] -- get the line type table
local Type = line['types'] and line['types'][typeN] -- get the line type table
background_color = Type['background color'] or line['color']
background_color = Type['background color'] or line['color']
color = Type['color']
color = Type['color']
color_2 = Type['color2'] or color
else
else
background_color = line['background color']
background_color = Type['background color'] or line['background color']
color = line['color'] or default['color'] or ''
color = line['color'] or default['color'] or ''
color_2 = line['color2'] or color
end
end
if Type['circular'] then
if Type['circular'] then
background_color = line['background color']
background_color = line['background color']
color = line['color'] or default['color'] or ''
color = line['color'] or default['color'] or ''
color_2 = line['color2'] or color
circular = line['circular']
circular = line['circular']
end
end
(args[v]['transfer'] and small('transfer at ' .. getTerminusText(args[v]['transfer'], Format), true) or ''),
(args[v]['transfer'] and small('transfer at ' .. getTerminusText(args[v]['transfer'], Format), true) or ''),
'\n|', style['body banner'], color, '"|'}))
'\n|', style['body banner'], color_2, '"|'}))
table.insert(wikitable, '\n|' .. style['body cell'] .. sideCell[2])
table.insert(wikitable, '\n|' .. style['body cell'] .. sideCell[2])
end
end
return function (frame)
return function (frame)
local args = getArgs(frame, {parentOnly = true})
local args = getArgs(frame, {parentOnly = true})
return p[funcName](args, frame)
end
end
local function makeTemplateFunction(funcName)
-- makes a function that can be returned from #invoke, using
-- [[Module:Arguments]]
return function (frame)
local args = getArgs(frame, {frameOnly = true})
return p[funcName](args, frame)
return p[funcName](args, frame)
end
end
if not inline then -- [[Template:Legend]]
if not inline then -- [[Template:Legend]]
result = '<div class="legend" style="page-break-inside:avoid;break-inside:avoid-column"><span class="legend-color" style="display:inline-block;min-width:1.25em;height:1.25em;line-height:1.25;margin:1px 0;border:1px solid black;background-color:#' .. color .. '"> </span> ' .. line .. result .. '</div>'
result = '<div class="legend" style="page-break-inside:avoid;break-inside:avoid-column"><span class="legend-color" style="display:inline-block;min-width:1.25em;height:1.25em;line-height:1.25;margin:1px 0;border:1px solid black;color:inherit;background-color:#' .. color .. '"> </span> ' .. line .. result .. '</div>'
elseif inline == 'yes' then
elseif inline == 'yes' then
result = '<span style="background-color:#' .. color .. ';border:1px solid #000"> </span> ' .. line .. result
result = '<span style="color:inherit;background-color:#' .. color .. ';border:1px solid #000"> </span> ' .. line .. result
elseif inline == 'box' then
elseif inline == 'box' then
result = '<span style="background-color:#' .. color .. ';border:1px solid #000"> </span>' .. result
result = '<span style="color:inherit;background-color:#' .. color .. ';border:1px solid #000"> </span>' .. result
elseif inline == 'link' then
elseif inline == 'link' then
local link = args.link or mw.ustring.match(line, '%[%[([^%[:|%]]+)[|%]]')
local link = args.link or mw.ustring.match(line, '%[%[([^%[:|%]]+)[|%]]')
if link then
if link then
result = '[[' .. link .. '|<span style="background-color:#' .. color .. ';border:1px solid #000"> </span>]]' .. result
result = '[[' .. link .. '|<span style="color:inherit;background-color:#' .. color .. ';border:1px solid #000"> </span>]]' .. result
else
else
result = '<span style="background-color:#' .. color .. ';border:1px solid #000"> </span>' .. result
result = '<span style="color:inherit;background-color:#' .. color .. ';border:1px solid #000"> </span>' .. result
end
end
elseif inline == 'square' then
elseif inline == 'square' then
end
end
elseif inline == 'small' then
elseif inline == 'small' then
result = '<span style="background-color:#' .. color .. '"> </span>' .. ' ' .. line .. result
result = '<span style="color:inherit;background-color:#' .. color .. '"> </span>' .. ' ' .. line .. result
else
else
local yesno = require("Module:Yesno")
local yesno = require("Module:Yesno")
if inline == 'route' then -- [[Template:RouteBox]]
if inline == 'route' then -- [[Template:RouteBox]]
if link then
if link then
result = '<span style="background-color:#' .. color .. ';border:.075em solid #' .. border_color .. ';padding:0 .3em">[[' .. link .. '|<span style="color:' .. text_color .. bold .. ';font-size:inherit;white-space:nowrap">' .. lineN .. '</span>]]</span>'
result = '<span style="color:inherit;background-color:#' .. color .. ';border:.075em solid #' .. border_color .. ';padding:0 .3em">[[' .. link .. '|<span style="color:' .. text_color .. bold .. ';font-size:inherit;white-space:nowrap">' .. lineN .. '</span>]]</span>'
else
else
result = '<span style="background-color:#' .. color .. ';border:.075em solid #' .. border_color .. ';padding:0 .3em;color:' .. text_color .. bold .. ';font-size:inherit;white-space:nowrap">' .. lineN .. '</span>'
result = '<span style="background-color:#' .. color .. ';border:.075em solid #' .. border_color .. ';padding:0 .3em;color:' .. text_color .. bold .. ';font-size:inherit;white-space:nowrap">' .. lineN .. '</span>'
elseif inline == 'croute' then -- [[Template:Bahnlinie]]
elseif inline == 'croute' then -- [[Template:Bahnlinie]]
if link then
if link then
result = '<span style="background-color:#' .. color .. ';border:.075em solid #' .. border_color .. ';border-radius:.5em;padding:0 .3em">[[' .. link .. '|<span style="color:' .. text_color .. bold .. ';font-size:inherit;white-space:nowrap">' .. lineN .. '</span>]]</span>'
result = '<span style="color:inherit;background-color:#' .. color .. ';border:.075em solid #' .. border_color .. ';border-radius:.5em;padding:0 .3em">[[' .. link .. '|<span style="color:' .. text_color .. bold .. ';font-size:inherit;white-space:nowrap">' .. lineN .. '</span>]]</span>'
else
else
result = '<span style="background-color:#' .. color .. ';border:.075em solid #' .. border_color .. ';border-radius:.5em;padding:0 .3em;color:' .. text_color .. bold .. ';font-size:inherit;white-space:nowrap">' .. lineN .. '</span>'
result = '<span style="color:inherit;background-color:#' .. color .. ';border:.075em solid #' .. border_color .. ';border-radius:.5em;padding:0 .3em;color:' .. text_color .. bold .. ';font-size:inherit;white-space:nowrap">' .. lineN .. '</span>'
end
end
elseif inline == 'xroute' then -- [[Template:Bahnlinie]]
elseif inline == 'xroute' then -- [[Template:Bahnlinie]]
elseif inline == 'broute' then
elseif inline == 'broute' then
if link then
if link then
result = '<span style="background-color:#' .. color .. ';border:.075em solid #000;padding:0 .3em">[[' .. link .. '|<span style="color:' .. text_color .. bold .. ';font-size:inherit;white-space:nowrap">' .. lineN .. '</span>]]</span>'
result = '<span style="color:inherit;background-color:#' .. color .. ';border:.075em solid #000;padding:0 .3em">[[' .. link .. '|<span style="color:' .. text_color .. bold .. ';font-size:inherit;white-space:nowrap">' .. lineN .. '</span>]]</span>'
else
else
result = '<span style="background-color:#' .. color .. ';border:.075em solid #000;padding:0 .3em;color:' .. text_color .. bold .. ';font-size:inherit;white-space:nowrap">' .. lineN .. '</span>'
result = '<span style="background-color:#' .. color .. ';border:.075em solid #000;padding:0 .3em;color:' .. text_color .. bold .. ';font-size:inherit;white-space:nowrap">' .. lineN .. '</span>'
end
end
else -- [[Template:Legend]] (fallback; duplication to simplify logic)
else -- [[Template:Legend]] (fallback; duplication to simplify logic)
result = '<div class="legend" style="page-break-inside:avoid;break-inside:avoid-column"><span class="legend-color" style="display:inline-block;min-width:1.25em;height:1.25em;line-height:1.25;margin:1px 0;border:1px solid black;background-color:#' .. color .. '"> </span> ' .. line .. result .. '</div>'
result = '<div class="legend" style="page-break-inside:avoid;break-inside:avoid-column"><span class="legend-color" style="display:inline-block;min-width:1.25em;height:1.25em;line-height:1.25;margin:1px 0;border:1px solid black;color:inherit;background-color:#' .. color .. '"> </span> ' .. line .. result .. '</div>'
end
end
end
end
p.icon = makeInvokeFunction('_icon')
p.icon = makeInvokeFunction('_icon')
p['rail icon'] = makeTemplateFunction('_icon')
function p._line(args, frame)
function p._line(args, frame)
p.line = makeInvokeFunction('_line')
p.line = makeInvokeFunction('_line')
function p._shortline(args, frame)
local system = args[1] or args.system
lineN = args[2] or args.line
if not (system or lineN) then return '' end
local line, Type, line_data
typeN = args.type
local data = args.data
if system or data then
data = data or getData(system, true)
if data then
local default = data['lines']['_default'] or {}
line, lineN = getLine(data, lineN)
if typeN then
typeN = data['aliases'] and data['aliases'][mw.ustring.lower(typeN)] or typeN
Type = line['types'] and line['types'][typeN] and line['types'][typeN]['title'] or typeN
end
line_data = line or error(i18n[lang]['error_unknown'](lineN))
line = line_data['title'] or default['title'] or error(i18n[lang]['error_missing']('title'))
line = mw.ustring.gsub(line, '%%1', lineN)
else
line = frame:expandTemplate{ title = system .. ' lines', args = {lineN, ['branch'] = typeN} }
if mw.text.trim(line) == '' then return error(i18n[lang]['error_unknown'](lineN)) end
Type = typeN
end
local result
if Type and Type ~= '' then
if line == '' then
line = Type
else
result = ' – ' .. Type
end
end
if args.note then result = (result or '') .. ' ' .. args.note end
result = result or ''
local link = args.link or mw.ustring.match(line, '%[%[([^%[:|%]]+)[|%]]')
if line_data then
if line_data['types'] and line_data['types'][typeN] then
local Type_data = line_data['types'][typeN]
lineN = Type_data['short name'] or line_data['short name'] or lineN
else
lineN = line_data['short name'] or lineN
end
end
if link then
result = '[[' .. link .. '|' .. lineN .. ']]'
else
result = lineN
end
result = mw.ustring.gsub(result, ':%s*#transparent', ':transparent')
return result
end
end
p.shortline = makeInvokeFunction('_shortline')
function p._station(args, frame)
function p._station(args, frame)
p.station = makeInvokeFunction('_station')
p.station = makeInvokeFunction('_station')
p['station link'] = makeTemplateFunction('_station')
function p._terminusTable(args, frame)
function p._terminusTable(args, frame)