[checked revision] | [checked revision] |
No edit summary |
Tag: Undo |
||
Line 1: | Line 1: | ||
− | local |
+ | local p = {} |
− | local util_table = require('Module:TableUtil') |
||
− | local lang = mw.getLanguage('en') |
||
⚫ | |||
⚫ | |||
+ | local args = frame |
||
− | |||
⚫ | |||
− | function h.getInfo(str, settings) |
||
+ | if frame == mw.getCurrentFrame() then |
||
⚫ | |||
+ | args = require( 'Module:ProcessArgs' ).merge( true ) |
||
⚫ | |||
+ | else |
||
− | vars = { |
||
+ | frame = mw.getCurrentFrame() |
||
− | link = str, |
||
− | long = str, |
||
− | short = str, |
||
⚫ | |||
− | } |
||
end |
end |
||
⚫ | |||
− | settings.vars = util_table.shallowClone(vars) |
||
⚫ | |||
⚫ | |||
⚫ | |||
− | settings.vars.link = settings.link |
||
⚫ | |||
⚫ | |||
⚫ | |||
+ | local Leaguestyles = mw.loadData('Module:Leaguestyles') |
||
⚫ | |||
+ | local namevars = Leaguenames[leagueinput] |
||
⚫ | |||
⚫ | |||
⚫ | |||
+ | elseif type(namevars) == 'string' then |
||
+ | namevars = Leaguenames[namevars] |
||
end |
end |
||
+ | |||
⚫ | |||
+ | text = Leaguestyles[leaguestyle] |
||
+ | |||
⚫ | |||
+ | text = text:gsub("REPLACESIZE","") |
||
+ | else |
||
+ | text = text:gsub("REPLACESIZE(%d+)px",size) |
||
⚫ | |||
+ | |||
+ | text = text:gsub("REPLACE(%u+)", { ["LINK"] = (args["link"] or namevars.link), ["LONG"] = namevars.long, ["SHORT"] = namevars.short, ["FILE"] = namevars.image }) |
||
+ | |||
⚫ | |||
+ | |||
end |
end |
||
− | |||
− | function h.getClass(str) |
||
− | if not str then return '' end |
||
− | return ('|class=%s-logo-std'):format(str) |
||
⚫ | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | local args = util_args.merge(true) |
||
⚫ | |||
⚫ | |||
− | return p[style](str, args) |
||
− | end |
||
− | |||
− | function p.main(frame) |
||
− | local args = util_args.merge(true) |
||
⚫ | |||
− | local style = lang:lc(args[2] or 'onlyimage') |
||
− | return p[style](str, args) |
||
− | end |
||
− | |||
− | function p.newsitem(str, settings) |
||
− | if not settings then settings = {} end |
||
− | h.getInfo(str, settings) |
||
− | return('<div class="news-league-icon">[[File:%s|link=%s|%spx%s]]</div> [[%s|%s]]'):format( |
||
− | settings.vars.image, |
||
− | settings.vars.link, |
||
− | settings.size or 25, |
||
− | h.getClass(settings.vars.class), |
||
− | settings.vars.link, |
||
− | settings.vars.short |
||
⚫ | |||
− | end |
||
− | |||
− | function p.onlyimage(str, settings) |
||
− | if not settings then settings = {} end |
||
− | h.getInfo(str, settings) |
||
− | return ('[[File:%s|link=|%spx%s]]'):format( |
||
− | settings.vars.image, |
||
− | settings.size or 25, |
||
− | h.getClass(settings.vars.class) |
||
⚫ | |||
− | end |
||
− | |||
− | function p.leaguename(str, settings) |
||
− | if not settings then settings = {} end |
||
− | h.getInfo(str, settings) |
||
− | return settings.vars.long |
||
− | end |
||
− | |||
− | function p.leagueshortname(str, settings) |
||
− | if not settings then settings = {} end |
||
− | h.getInfo(str, settings) |
||
− | return settings.vars.short |
||
− | end |
||
− | |||
− | function p.onlyimagelinked(str, settings) |
||
− | if not settings then settings = {} end |
||
− | h.getInfo(str, settings) |
||
− | return ('[[File:%s|link=%s|%spx%s]]'):format( |
||
− | settings.vars.image, |
||
− | settings.vars.link, |
||
− | settings.size or 25, |
||
− | h.getClass(settings.vars.class) |
||
⚫ | |||
− | end |
||
− | |||
return p |
return p |
Revision as of 22:41, 17 February 2020
To edit the documentation or categories for this module, click here.
local p = {}
function p.league ( frame )
local args = frame
local text = ''
if frame == mw.getCurrentFrame() then
args = require( 'Module:ProcessArgs' ).merge( true )
else
frame = mw.getCurrentFrame()
end
local leagueinput = mw.ustring.lower(args[1] or '')
local leaguestyle = mw.ustring.lower(args[2] or 'default')
local size = args['size']
local text = ""
local Leaguenames = mw.loadData('Module:Leaguenames')
local Leaguestyles = mw.loadData('Module:Leaguestyles')
local namevars = Leaguenames[leagueinput]
if not namevars then
namevars = {link = args[1], long = args[1], short = args[1], image = "Unknown Infobox Image - Tournament.png"}
elseif type(namevars) == 'string' then
namevars = Leaguenames[namevars]
end
text = Leaguestyles[leaguestyle]
if not size then
text = text:gsub("REPLACESIZE","")
else
text = text:gsub("REPLACESIZE(%d+)px",size)
end
text = text:gsub("REPLACE(%u+)", { ["LINK"] = (args["link"] or namevars.link), ["LONG"] = namevars.long, ["SHORT"] = namevars.short, ["FILE"] = namevars.image })
return text
end
return p