No edit summary |
No edit summary |
||
Line 80: | Line 80: | ||
'vk', | 'vk', | ||
'weibo', | 'weibo', | ||
'email' | 'email', | ||
'linkedin' | |||
}, | }, | ||
streams = { | streams = { |
Revision as of 15:20, 11 October 2022
Documentation for this module may be created at Module:Infobox/Widget/Links/doc
local UtilLinks = require('Module:Links')
local Table = require('Module:Table')
local Links = {}
local _ICON_KEYS_TO_RENAME = {
['bilibili-stream'] = 'bilibili',
daumcafe = 'cafe-daum',
['esea-d'] = 'esea-league',
['faceit-c'] = 'faceit',
['faceit-c2'] = 'faceit',
['faceit-hub'] = 'faceit',
['faceit-org'] = 'faceit',
matcherinolink = 'matcherino',
playlist = 'music',
privsteam = 'steam',
pubsteam = 'steam',
steamalternative = 'steam',
tlpdint = 'tlpd',
tlpdkr = 'tlpd-wol-korea',
tlpdsospa = 'tlpd-sospa',
}
local _PRIORITY_GROUPS = {
core = {
'home',
'site',
'website'
},
league = {
'5ewin',
'abiosgaming',
'aligulac',
'battlefy',
'b5csgo',
'challengermode',
'challonge',
'cybergamer',
'datdota',
'dotabuff',
'esea',
'esea-d',
'esl',
'esportal',
'faceit',
'faceit-c',
'faceit-hub',
'faceit-org',
'factor',
'gamersclub',
'halodatahive',
'letsplaylive',
'matcherino',
'matcherinolink',
'siege-gg',
'sk',
'smash-gg',
'sostronk',
'stratz',
'toornament',
'trackmania-io',
'vlr',
'bracket',
'rules',
'rulebook',
},
social = {
'discord',
'facebook',
'instagram',
'privsteam',
'pubsteam',
'reddit',
'snapchat',
'steam',
'steamalternative',
'telegram',
'tiktok',
'twitter',
'vk',
'weibo',
'email',
'linkedin'
},
streams = {
'twitch',
'youtube',
'stream',
'afreeca',
'dlive',
'facebook-gaming',
'vidio',
'booyah',
'douyu',
'huyatv',
'zhangyutv',
'bilibili-stream',
'kuaishou',
}
}
function Links.make(links, variant)
local infoboxLinks = mw.html.create('div')
infoboxLinks :addClass('ib-links')
for _, group in Table.iter.spairs(_PRIORITY_GROUPS) do
for _, key in ipairs(group) do
if links[key] ~= nil then
infoboxLinks:wikitext(' ' .. _makeLink(key, links[key]))
-- Remove link from the collection
links[key] = nil
local index = 2
while links[key .. index] ~= nil do
infoboxLinks:wikitext(' ' .. _makeLink(key, links[key .. index]))
-- Remove link from the collection
links[key .. index] = nil
index = index + 1
end
end
end
end
for key, value in Table.iter.spairs(links) do
infoboxLinks:wikitext(' ' .. _makeLink(key, value, variant))
end
return mw.html.create('div'):node(infoboxLinks)
end
function _makeLink(key, value, variant)
key = _removeAppendedNumber(key)
local link = UtilLinks.makeFullLink(key, value, variant)
return '[[Image:' .. (_ICON_KEYS_TO_RENAME[key] or key) .. '.png|40px|link=' .. link[1] ..
'|' .. (link[2] or '' ) .. ']]'
-- ' <i class="lp-icon lp-' .. (_ICON_KEYS_TO_RENAME[key] or key) .. '></i>]'
end
--remove appended number
--needed because the link icons require e.g. 'esl' instead of 'esl2'
function _removeAppendedNumber(key)
return string.gsub(key, '%d$', '')
end
return Links