No edit summary |
No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local format = mw.ustring.format | local format = mw.ustring.format | ||
| Line 6: | Line 5: | ||
DEU = "200", | DEU = "200", | ||
} | } | ||
local function cleanName(name) | |||
name = mw.text.trim(name or '') | |||
name = name:gsub('^[Ff]ile:', '') | |||
name = name:gsub('^[Ii]mage:', '') | |||
return name | |||
end | |||
function p._map(args) | function p._map(args) | ||
local map = args.map or '' | local map = args.map or '' | ||
if args.map_custom == "yes" then | if args.map_custom == "yes" then | ||
if mw.text.trim(map) == '' then | |||
return nil | |||
end | |||
return format('<div style="white-space:nowrap;">%s</div>', map) | return format('<div style="white-space:nowrap;">%s</div>', map) | ||
end | end | ||
local mapsize = mapsizes[args.country] or ' | |||
map = cleanName(map) | |||
if map == '' then | |||
return nil | |||
end | |||
local mapsize = mapsizes[args.country] or '290' | |||
local alt = args.map_alt or '' | local alt = args.map_alt or '' | ||
return format( | return format('[[File:%s|%spx|alt=%s]]', map, mapsize, alt) | ||
end | end | ||
function p.map(frame) | function p.map(frame) | ||
local | local args = require('Module:Arguments').getArgs(frame) | ||
local state = args.state or args.province | local state = args.state or args.province | ||
if not args.country then | if not args.country and state and state ~= '' then | ||
local countryMask = mw.loadData | local ok, countryMask = pcall(mw.loadData, 'Module:Road data/countrymask') | ||
args.country = countryMask[state] | if ok and countryMask then | ||
args.country = countryMask[state] | |||
end | |||
end | end | ||
return p._map(args) | return p._map(args) | ||
Latest revision as of 21:30, 6 September 2026
Documentation for this module may be created at Module:Infobox road/map/doc
local p = {}
local format = mw.ustring.format
local mapsizes = {
DEU = "200",
}
local function cleanName(name)
name = mw.text.trim(name or '')
name = name:gsub('^[Ff]ile:', '')
name = name:gsub('^[Ii]mage:', '')
return name
end
function p._map(args)
local map = args.map or ''
if args.map_custom == "yes" then
if mw.text.trim(map) == '' then
return nil
end
return format('<div style="white-space:nowrap;">%s</div>', map)
end
map = cleanName(map)
if map == '' then
return nil
end
local mapsize = mapsizes[args.country] or '290'
local alt = args.map_alt or ''
return format('[[File:%s|%spx|alt=%s]]', map, mapsize, alt)
end
function p.map(frame)
local args = require('Module:Arguments').getArgs(frame)
local state = args.state or args.province
if not args.country and state and state ~= '' then
local ok, countryMask = pcall(mw.loadData, 'Module:Road data/countrymask')
if ok and countryMask then
args.country = countryMask[state]
end
end
return p._map(args)
end
return p