Content deleted Content added
rm |
use sandbox subtemplate |
||
(47 intermediate revisions by 4 users not shown) | |||
Line 1:
local p = {}
local getArgs = require('Module:Arguments').getArgs
local util = require("Module:Road data/util")
local yesno = require('Module:Yesno')
local langModule = require('Module:Lang')
local routeModule = require("Module:Infobox road/route/sandbox")
local parserModule = require("Module:Road data/parser")
local parser = parserModule.parser
Line 23 ⟶ 21:
-- HEADER COLORS
function p.
local args = getArgs(frame)
local header
header = args.header_type
else
header = string.lower(args.header_type)
end
local deleted = args.decommissioned or args.deleted or header == "former"
local uc = header == "under construction" or header == "const" or header == "uc"
local minor = header == "minor"
local hist = header == "hist" or header == "historic" or header == "historical" or header == "scenic"
local color = parser(args, 'color') or args['header_color']
local freeway = header == "freeway"
if
return "header-MUTCDblue"
elseif uc then
return "header-uc"
elseif minor then
return "header-minor"
elseif deleted and header == 'hist' or deleted and color == 'hist' then
return "header-deleted-hist"
elseif deleted then
return "header-deleted"
Line 46 ⟶ 57:
return "header-default"
end
end
Line 79 ⟶ 85:
local lang = parser(args, 'lang') or args.lang or 'none'
local translation = args.translation or parser(args, 'translation') or ''
local route = args.route
if route ~= nil then
local arabicModule = require( "Module:Convert to eastern arabic numerals" )
local arabic = arabicModule._convert({route})
local translated = string.gsub( translation, route, arabic)
return frame:expandTemplate{title = 'Nastaliq', args = {translated}}
else
return frame:expandTemplate{title = 'Nastaliq', args = {translation}}
end
elseif translation ~= '' and lang == 'none' then
return translation
elseif country(args) == "CHN" and args.type == "Expwy" then
local trans = require( "Module:Road data/masks/CHN/Expwy translations" )
local route = args.route
return langModule._lang({lang, trans[route]})
elseif country(args) == "HUN" then
local nominal = require( "Module:Road data/masks/HUN" )
local routeNum
local leading
if string.len(args.route) > 2 then
routeNum = string.match(args.route, "%d%d$", 0)
leading = string.match(args.route, "(%d*)%d%d$", 0)
else
routeNum = args.route
leading = ''
end
if args.type == "M" then
return langModule._lang({"hu", "M" .. leading .. nominal[routeNum] .. " autópálya"})
elseif args.type == "Mb" then
return langModule._lang({"hu", "M" .. leading .. nominal[routeNum] .. " autóút"})
elseif args.type == "MR" then
return langModule._lang({"hu", leading .. nominal[routeNum] .. " főút"})
elseif args.type == "Mb" then
return langModule._lang({"hu", leading .. nominal[routeNum] .. " közút"})
end
elseif lang == "ar" and translation ~= '' then
local route = args.route
local arabicModule = require( "Module:Convert to eastern arabic numerals" )
local arabic = arabicModule._convert({route})
local translated = string.gsub( translation, route, arabic)
return langModule._lang({lang, translated})
elseif translation ~= '' and lang ~= 'none' then
return langModule._lang({lang, translation})
else
return nil
Line 100 ⟶ 153:
local function maint(args)
local maint = args.maint or parser(args, 'maint') or
if maint == "none" or
return nil
else
return "Maintained by " .. maint
end
end
Line 116 ⟶ 169:
local function law(args)
local law = parser(args, 'law') or
if
return nil
else
return "Defined by " .. law
end
end
Line 132 ⟶ 185:
function p._existed(args)
local formed = args.established or args.formed or
local deleted = args.decommissioned or args.deleted or
if formed ==
return nil
elseif deleted ==
return formed .. "–present"
else
Line 157 ⟶ 210:
infobox_args['bodystyle'] = 'display:inline-table;'
infobox_args['child'] = 'yes'
infobox_args['decat'] = 'yes'
infobox_args['label1'] = "Time period"
infobox_args['data1'] = args.time_period
Line 253 ⟶ 307:
infobox_args['bodystyle'] = 'display:inline-table;'
infobox_args['child'] = 'yes'
infobox_args['decat'] = 'yes'
if args["e-road"] then
Line 264 ⟶ 319:
if args.tahn then
local tshield = args["tahn-shield"] or ''
infobox_args['
end
if args.mrn then
local mshield = args["mrn-shield"] or ''
infobox_args['
end
Line 284 ⟶ 339:
--BROWSE LINKS
local function
if args.nobrowse then return nil end
local
local
if previousRoute or nextRoute then
local boxModule = require "Module:Road data/browse/sandbox"
local primary = boxModule._browse(args)
local tblModule = require "Module:Road data/browsetable"
return tblModule._browsetable(primary)
end
end
function p.browse(frame)
local args = getArgs(frame)
return browse(args)
end
local function extended(args)
local extended = args.browse
if args.nobrowse or extended == nil then
return nil
else
local tblModule = require "Module:Road data/browsetable"
-- Negative margin to counteract infobox border-spacing
return tblModule._browsetable(extended, 'margin-top:-3px')
end
end
function p.extended(frame)
local args = getArgs(frame)
return extended(args)
-- HIGHWAY SYSTEM LINKS
local function system(args)
if args.system1 then
local infobox_args = {
['child'] = "yes",
['decat'] = "yes",
['bodystyle'] = "border-collapse:collapse;"
}
local i = 1
while (1) do
local systemClassn = "class" .. i
local systemDatan = "data" .. i
local systemArgn = args['system' .. i]
infobox_args[systemClassn] = "hlist"
infobox_args[systemDatan] = systemArgn
if i == 10 then
break
else
i = i + 1
end
end
return frame:expandTemplate ({title='Infobox', args = infobox_args})
end
end
function p.
local args = getArgs(frame)
return
end
Line 334 ⟶ 416:
local law = law(args)
local period = period_params(args)
local existed =
local spur =
local part = partOf(args)
Line 352 ⟶ 434:
-- HIGHWAY SYSTEM HEADER
local function
if args.nobrowse then return nil end
local country = country(args) or args.countries
if country == nil then
Line 367 ⟶ 449:
end
function p.
local args = getArgs(frame)
return
end
|