Documentation for this module may be created at Module:Infobox/Widget/Links/doc
-- local Class = require('Module:Class') -- local Widget = require('Module:Infobox/Widget') local UtilLinks = require('Module:Links') local Table = require('Module:Table') local Links = {} -- local Links = Class.new( -- Widget, -- function(self, input) -- self.links = Table.copy(input.content) -- self.variant = input.variant -- end -- ) 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' }, 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('infobox-center') :addClass('infobox-icons') 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 = Links._removeAppendedNumber(key) local link = UtilLinks.makeFullLink(key, value, variant) return '[[Image:' .. (_ICON_KEYS_TO_RENAME[key] or key) .. '.png|40px|link=' .. link .. '|' .. (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 Links._removeAppendedNumber(key) return string.gsub(key, '%d$', '') end return Links