Module:Sandbox/BrandonXLF/4: Difference between revisions

Content deleted Content added
Allow any custom template
Fix errors
 
(21 intermediate revisions by the same user not shown)
Line 1:
-- Sandbox, do not delete
local config = require('Module:Authority control/config').config
local sc = require('Module:Suppress categories')
local p = {}
 
local roadDataModule = require('Module:Road data/sandbox') -- REMOVE SANDBOX
function p.main(frame)
 
local args = { state = frame.args.state }
function p._shieldmain(args)
local template = frame.args.template or 'Template:Authority control'
local shields = {}
local routeCount = 1
while args[routeCount * 2 - 1] do
for _, conf in pairs(config) do
local route = {
local statement = mw.wikibase.getBestStatements('P' .. conf.property, 'P1855')[1]
country = args['country' .. routeCount] or args.country,
state = args['state' .. routeCount] or args['province' .. routeCount] or args.state or args.province,
type = args[routeCount * 2 - 1],
route = args[routeCount * 2]
}
if statementnot route.country then
local countryModule = mw.loadData('Module:Road data/countrymask')
args[conf[1]] = statement.qualifiers['P' .. conf.property][1].datavalue.value
route.country = countryModule[route.state] or 'UNK'
end
 
local shield = roadDataModule.shield(route, 'main', 'infobox', true)
table.insert(shields, shield)
 
routeCount = routeCount + 1
end
 
return table.concat(shields, ' ')
return sc.main(frame:expandTemplate{ title = template, args = args })
end
 
function p.mainshieldmain(frame)
local scargs = require('Module:Suppress categoriesArguments').getArgs(frame)
return p._shieldmain(args)
end