Module:Infobox/Social

-- this is handled separately so that it can be easily cloned between wikis local wiki = require('Module:Wiki') local sep = '%s*,%s*'

local SETTINGS = { order = { 'cdl', 'cdlplayer', 'website', 'askfm', 'discord', 'facebook', 'gapo', 'esl', 'lolpros', 'instagram', 'reddit', 'subreddit', 'snapchat', 'stream', 'twitch-team', 'twitter', 'vk', 'weibo', 'youtube', 'videoarchive', 'fanpage', 'gamebattles', 'umg', 'cmg', 'site' }, data = { website = { display = 'Homepage', prefix = '' }, askfm = { display = 'ask.fm', prefix = 'https://ask.fm/' }, discord = { display = 'Discord Server', prefix = '' }, facebook = { display = 'Facebook Fanpage', prefix = '' }, instagram = { display = 'Instagram', prefix = 'https://instagram.com/' }, irc = { display = 'IRC Channel', prefix = '' }, lolpros = { display = 'LOLPros', prefix = '' }, subreddit = { display = 'Subreddit', prefix = 'http://www.reddit.com/r/' }, reddit = { display = 'reddit', prefix = 'https://www.reddit.com/user/' }, snapchat = { display = 'Snapchat', prefix = 'https://www.snapchat.com/add/' }, stream = { display = , prefix =  }, ['twitch-team'] = { display = 'Twitch Team', prefix = '' }, twitter = { display = 'Twitter', prefix = 'https://www.twitter.com/' }, vk = { display = 'VKontakte', prefix = '' }, weibo = { display = 'Weibo', prefix = '' }, youtube = { display = 'Youtube', prefix = '' }, videoarchive = { display = 'Video Archive', prefix = '' }, fanpage = { display = 'Fan Page', prefix = '' }, esl = { display = 'ESL', prefix = '' }, gapo = { display = 'Gapo', prefix = 'https://gapo.vn/' }, gamebattles = { display = 'GameBattles', prefix = 'http://profile.majorleaguegaming.com/' }, umg = { display = 'UMG', prefix = 'http://umggaming.com/u/' }, cmg = { display = 'CMG', prefix = '' }, site = { display = 'Homepage', prefix = '' },

} }

local STREAMLIST = { ['twitch.tv/'] = 'Twitch', ['azubu.tv/'] = 'Azubu', ['hitbox.tv/'] = 'Hitbox', ['afreecatv.com/'] = 'Afreeca', ['douyu.com/'] = 'Douyu', ['cube.tv/'] = 'CubeTV', ['mobcrush.com/'] = 'Mobcrush', ['gaming.youtube.tv/'] = 'Youtube Gaming', ['openrec.tv'] = 'OPENREC', ['fb.gg'] = 'Facebook Gaming', ['facebook'] = 'Facebook Gaming', ['nimo.tv'] = 'NimoTV', }

local p = {} local h = {}

function p.makeSocialSection(args) tbl = {} for k, v in ipairs(SETTINGS.order) do		if args[v] then local data = SETTINGS.data[v] if v == 'stream' then tbl[#tbl+1] = h.stream(args.stream) elseif data.hover then tbl[#tbl+1] = tostring(h.makeHoverIcon(args, data, v)) else tbl[#tbl+1] = h.makeStandardIcon(data.display, data.display, data.prefix, args[v]) end end end if args.otherwikis then for _, v in ipairs(mw.text.split(args.otherwikis,sep)) do			tbl[#tbl+1] = wiki.onlyimagelinked(v, { titletarget = args.id }) end end return tbl end

function h.stream(link) local platform = 'Livestream' for k, v in pairs(STREAMLIST) do		if string.find(link, k, 1, true) then platform = v			break end end return h.makeStandardIcon('Stream', platform, '', link) end

function h.makeStandardIcon(name, image, prefix, link) return string.format(		' ',		name,		image,		prefix,		link:gsub(' ', '_')	) end

function h.makeHoverIcon(args, data, v)	local span = mw.html.create('span') :attr('title',data.display) local outer = span:tag('div') :addClass('popup-content-outer') :css('margin-left','0') :wikitext(h.makeStandardIcon(data.display, data.display, data.prefix, '')) local inner = outer:tag('div') :addClass('popup-content-inner') :addClass('popup-content-inner-pretty') :addClass('toggle-section-hidden') :css({			['margin-left'] = '-56px',			width = '120px'		}) :wikitext(args[v]) return span end

return p