[checked revision] | [checked revision] |
m (Protected "Module:Team": Aligning page content across wikis ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))) |
m (Syncing content across wikis) |
||
Line 3: | Line 3: | ||
function p.team ( frame ) |
function p.team ( frame ) |
||
local args = frame |
local args = frame |
||
− | local text = '' |
||
if frame == mw.getCurrentFrame() then |
if frame == mw.getCurrentFrame() then |
||
args = require( 'Module:ProcessArgs' ).merge( true ) |
args = require( 'Module:ProcessArgs' ).merge( true ) |
||
Line 9: | Line 8: | ||
frame = mw.getCurrentFrame() |
frame = mw.getCurrentFrame() |
||
end |
end |
||
+ | |||
− | |||
local teaminput = mw.ustring.lower(args[1] or '') |
local teaminput = mw.ustring.lower(args[1] or '') |
||
− | local teamstyle = mw.ustring.lower(args[2] or ' |
+ | local teamstyle = mw.ustring.lower(args[2] or 'rightlonglinked') |
+ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
--Empty |
--Empty |
||
Line 22: | Line 20: | ||
--Special Cases |
--Special Cases |
||
elseif exceptionCases[teaminput] then |
elseif exceptionCases[teaminput] then |
||
− | + | namevars = exceptionCases[teaminput] |
|
− | + | Styles = require('Module:Teamexceptionstyles') |
|
− | + | settings = Styles.styleNames(teamstyle) |
|
− | if |
+ | if args['size'] then settings.size = args['size'] end |
− | text = text:gsub("REPLACESIZE","") |
||
− | else |
||
− | text = text:gsub("REPLACESIZE(%d+)px",size) |
||
− | end |
||
− | |||
− | text = text:gsub("REPLACE(%u+)", { ["TEXT"] = exception["text"], ["SHORT"] = exception["text"], ["FILE"] = exception["image"], ["TITLE"] = exception["hover"] }) |
||
+ | return Styles[settings.style](namevars, settings) |
||
− | return text |
||
-- Normal Teams |
-- Normal Teams |
||
else |
else |
||
− | local tnames = mw.loadData( |
+ | local tnames = mw.loadData('Module:Teamnames') |
⚫ | |||
local namevars = tnames[teaminput] |
local namevars = tnames[teaminput] |
||
− | local |
+ | local settings = { |
⚫ | |||
+ | suffix = args.suffix and ('/' .. args.suffix) or '', |
||
⚫ | |||
if not namevars then |
if not namevars then |
||
− | namevars = {link = args[1], long = args[1], medium = args[1], short = args['short'] or args[1] } |
+ | namevars = { link = args[1], long = args[1], medium = args[1], short = args['short'] or args[1] } |
+ | settings.logo = "" |
||
elseif type(namevars) == 'string' then |
elseif type(namevars) == 'string' then |
||
namevars = tnames[namevars] |
namevars = tnames[namevars] |
||
− | logo = namevars.link:gsub("+", " ") |
||
− | else |
||
− | logo = namevars.link:gsub("+", " ") |
||
− | end |
||
− | |||
⚫ | |||
− | |||
− | text = tstyles[teamstyle] |
||
− | |||
− | if not size then |
||
− | text = text:gsub("REPLACESIZE","") |
||
− | else |
||
− | text = text:gsub("REPLACESIZE(%d+)px",size) |
||
end |
end |
||
+ | return Styles[teamstyle](namevars, settings) |
||
− | text = text:gsub("REPLACE(%u+)", { ["LINK"] = namevars.link, ["LONG"] = namevars.long, ["MEDIUM"] = namevars.medium, ["SHORT"] = namevars.short, ["FILE"] = logo }) |
||
− | return text |
||
− | |||
− | |||
end |
end |
||
end |
end |
Revision as of 05:06, 13 August 2018
Documentation for this module may be created at Module:Team/doc
local p = {}
function p.team ( frame )
local args = frame
if frame == mw.getCurrentFrame() then
args = require( 'Module:ProcessArgs' ).merge( true )
else
frame = mw.getCurrentFrame()
end
local teaminput = mw.ustring.lower(args[1] or '')
local teamstyle = mw.ustring.lower(args[2] or 'rightlonglinked')
local exceptionCases = mw.loadData('Module:Teamexceptions')
--Empty
if not args[1] or args[1] == '' then
return ''
--Special Cases
elseif exceptionCases[teaminput] then
namevars = exceptionCases[teaminput]
Styles = require('Module:Teamexceptionstyles')
settings = Styles.styleNames(teamstyle)
if args['size'] then settings.size = args['size'] end
return Styles[settings.style](namevars, settings)
-- Normal Teams
else
local tnames = mw.loadData('Module:Teamnames')
local Styles = require('Module:Teamstyles')
local namevars = tnames[teaminput]
local settings = {
size = args['size'],
suffix = args.suffix and ('/' .. args.suffix) or '',
}
if not namevars then
namevars = { link = args[1], long = args[1], medium = args[1], short = args['short'] or args[1] }
settings.logo = ""
elseif type(namevars) == 'string' then
namevars = tnames[namevars]
end
return Styles[teamstyle](namevars, settings)
end
end
return p