Module:Wiki

local lang = mw.getLanguage('en') local LOOKUP = mw.loadData('Module:Wikinames')

function lookup(str) local namevars = LOOKUP.wikis[lang:lc(str)] if type(namevars) == 'table' then return namevars elseif type(namevars) == 'string' then return LOOKUP.wikis[namevars] else return { long = 'Unknown Wiki', short = 'Unknown', image = '', url = 'esports' } end end

function addTarget(target) if not target then return '' end return (LOOKUP.url[3] .. target):gsub(' ','_') or '' end

function makeURL(url, target) local output = { LOOKUP.url[1], url, LOOKUP.url[2], addTarget(target) }	return table.concat(output,'') end

local p = {} function p.main(frame) if frame == mw.getCurrentFrame then args = require('Module:ProcessArgs').merge(true) else frame = mw.getCurrentFrame end if not args[1] then args[1] = '' end if args[2] then return p[args[2]](args[1], args) else return p.wikilongname(args[1]) end end

function p.wikilongname(str) return lookup(str).long end

function p.wikiurl(str, args) return makeURL(lookup(str).url, args.target) end

function p.longlinked(str, args) local namevars = lookup(str) return string.format(		'[%s %s]',		makeURL(namevars.url, args.target),		namevars.long	) end

function p.onlyimagelinked(str, args) local namevars = lookup(str) return string.format(		' ',		args.title or string.format( '%s on the %s wiki', args.titletarget or args.target, namevars.long ),		namevars.image,		LOOKUP.url[1],		namevars.url,		LOOKUP.url[2],		addTarget(args.target)	) end

return p