Changes

Jump to navigation Jump to search
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.
Line 177: Line 177:  
['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:#',
 
}
 
}
   Line 191: Line 191:  
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
Line 237: Line 237:  
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)
   Line 254: Line 254:  
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
   Line 262: Line 262:  
background_color = Type['background color'] or line['color']
 
background_color = Type['background color'] or line['color']
 
color = Type['color']
 
color = Type['color']
elseif Type['background color'] then
+
color_2 = Type['color2'] or color
background_color = Type['background color']
  −
color = line['color'] or default['color'] or ''
   
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
Line 276: Line 275:  
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
Line 344: Line 344:  
(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
Line 390: Line 390:  
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
Line 453: Line 462:     
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>&nbsp;' .. line .. result
+
result = '<span style="color:inherit;background-color:#' .. color .. ';border:1px solid #000">    </span>&nbsp;' .. 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
Line 484: Line 493:  
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")
Line 517: Line 526:  
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>'
Line 523: Line 532:  
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]]
Line 535: Line 544:  
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
Line 666: Line 675:     
p.icon = makeInvokeFunction('_icon')
 
p.icon = makeInvokeFunction('_icon')
 +
p['rail icon'] = makeTemplateFunction('_icon')
    
function p._line(args, frame)
 
function p._line(args, frame)
Line 699: Line 709:     
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)
Line 733: Line 804:     
p.station = makeInvokeFunction('_station')
 
p.station = makeInvokeFunction('_station')
 +
p['station link'] = makeTemplateFunction('_station')
    
function p._terminusTable(args, frame)
 
function p._terminusTable(args, frame)
Anonymous user

Navigation menu