local p = local getArgs = require('Module:Arguments').getArgslocal util = require("Module:Road data/util")local yesno = require('Module:Yesno')local langModule = require('Module:Lang')local routeModule = require("Module:Infobox road/route")local parserModule = require("Module:Road data/parser")local parser = parserModule.parserlocal format = mw.ustring.formatlocal frame = mw.getCurrentFrame
local function country(args) local state = args.state or args.province local country local countryModule = mw.loadData("Module:Road data/countrymask") local country = args.country or countryModule[state] return countryend
-- HEADER COLORS
function p.headerStyle(frame) local args = getArgs(frame) local header if args.header_type
"former" local uc = header
"const" or header
"minor" local hist = header
"historic" or header
"scenic" local color = parser(args, 'color') or args['header_color'] local freeway = header
'hist' or deleted and color
-- SECOND IMAGE
local function photo(args) local country = country(args) local photo = args.photo or args.image local width = args.photo_wide or args.image_width or "290px" local alt = args.photo_alt or args.image_alt or photo if photo
"USA" then return nil else return string.format('', photo, width, alt) endend
function p.photo(frame) local args = getArgs(frame) return photo(args)end
-- TRANSLATION
local function translate(args, lang) local lang = parser(args, 'lang') or args.lang or 'none' local translation = args.translation or parser(args, 'translation') or if country(args)
'none' then return translation elseif country(args)
"Expwy" then local trans = require("Module:Road data/masks/CHN/Expwy translations") local route = args.route return langModule._lang() elseif country(args)
"M" then return langModule._lang elseif args.type
"MR" then return langModule._lang elseif args.type
"ar" and translation ~= then local route = args.route local arabicModule = require("Module:Convert to eastern arabic numerals") local arabic = arabicModule._convert local translated = string.gsub(translation, route, arabic) return langModule._lang() elseif translation ~= and lang ~= 'none' then return langModule._lang() else return nil endend
function p.translate(frame) local pframe = frame:getParent local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself local args = pframe.args -- the arguments passed TO the template, in the wikitext that transcludes the template local lang = config.lang return translate(args, lang)end
-- MAINTAINED BY
local function maint(args) local maint = args.maint or parser(args, 'maint') or if maint
then return nil else return "Maintained by " .. maint endend
function p.maint(frame) local args = getArgs(frame) return maint(args)end
-- DEFINED BY LAW
local function law(args) local law = parser(args, 'law') or if args.section
function p.law(frame) local args = getArgs(frame) return law(args)end
-- EXISTED
function p._existed(args) local formed = args.established or args.formed or local deleted = args.decommissioned or args.deleted or if formed
then return formed .. "–present" else return formed .. "–" .. deleted endend
function p.existed(frame) local args = getArgs(frame) return p._existed(args)end
-- TIME PERIOD
local function period(args) local infobox_args = 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 if args.time_period then infobox_args['label2'] = "Cultural significance" infobox_args['data2'] = args.significance infobox_args['label3'] = "Known for" infobox_args['data3'] = args.known_for infobox_args['label4'] = "Related routes" infobox_args['data4'] = args.related else infobox_args['label3'] = "Known for" infobox_args['data3'] = args.known_for end
return frame:expandTemplate end
local function period_params(args)
if args.time_period or args.known_for then return true else return false endend
function p.period(frame) local args = getArgs(frame) if period_params(args)
-- ALLOCATION
local function allocation(args) local country = country(args) if country
function p.allocation(frame) local args = getArgs(frame) return allocation(args)end
-- SPUR OF
local function spurOf(args) local state = args.state or args.province local country = args.country local county = args.county local parentType = args.spur_type local parentRoute = args.spur_of local aux = parser(args, 'aux') or "Auxiliary route" or nil local jct = frame:expandTemplate
if not parentType and not parentRoute then return nil elseif type(aux)
function p.spurOf(frame) local args = getArgs(frame) return spurOf(args)end
-- PART OF
local function partOf(args) if args["e-road"] or args.ahn or args.tahn or args.mrn then
local infobox_args = infobox_args['bodystyle'] = 'display:inline-table;' infobox_args['child'] = 'yes' infobox_args['decat'] = 'yes'
if args["e-road"] then local eshield = args["e-road-shield"] or infobox_args['data1'] = eshield .. " Part of " .. args["e-road"] end if args.ahn then local ashield = args["ahn-shield"] or infobox_args['data2'] = ashield .. " Part of " .. args.ahn end if args.tahn then local tshield = args["tahn-shield"] or infobox_args['data3'] = tshield .. " Part of " .. args.tahn end if args.mrn then local mshield = args["mrn-shield"] or infobox_args['data4'] = mshield .. " Part of " .. args.mrn end return frame:expandTemplate else return nil end end
function p.partOf(frame) local args = getArgs(frame) return partOf(args)end
--BROWSE LINKS
local function browse(args) if args.nobrowse then return nil end local previousRoute = args.previous_route local nextRoute = args.next_route 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) endend
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
function p.extended(frame) local args = getArgs(frame) return extended(args)end
-- HIGHWAY SYSTEM LINKS
local function system(args) if args.system1 then local infobox_args = 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
function p.system(frame) local args = getArgs(frame) return system(args)end
-- ROUTE INFORMATION HEADER
local function info(args) local maint = maint(args) local law = law(args) local period = period_params(args) local existed = args.established or args.formed or nil local spur = args.spur_type or args.spur_of or nil local part = partOf(args) if period
function p.info(frame) local args = getArgs(frame) return info(args)end
-- HIGHWAY SYSTEM HEADER
local function highwaySystem(args) if args.nobrowse then return nil end local country = country(args) or args.countries if country
"GBR" or country
"NIR" or country
"WLS" or country
"IMN" or country
"AIA" or country
"IOT" or country
"CYM" or country
"GIB" or country
"PCN" or country
"SGS" or country
function p.highwaySystem(frame) local args = getArgs(frame) return highwaySystem(args)end
return p