Fortnite Esports Wiki

Power Rankings of Brazil and Oceania at the moment are not updated to the last two competitive seasons, so the current positions of the players are not 100% accurate.

READ MORE

Fortnite Esports Wiki
Advertisement

To edit the documentation or categories for this module, click here.


local util_args = require("Module:ArgsUtil")
local util_table = require('Module:TableUtil')
local util_text = require("Module:TextUtil")
local util_vars = require('Module:VarsUtil')
local i18n = require('Module:i18nUtil')

local p = {}
local h = {}

function p.fullURL(formInfo, args)
	local tbl = {}
	for k, v in pairs(args) do
		if v and v ~= 'No' then
			tbl[#tbl+1] = ('%s%%5B%s%%5D=%s'):format(formInfo.template, k, tostring(v))
		end
	end
	local form_args = h.escape(table.concat(tbl,'&'))
	return ('%s/Special:RunQuery/%s?%s&pfRunQueryFormName=%s'):format(
		mw.site.server,
		formInfo.form,
		form_args,
		formInfo.form
	)
end

function p.permalink(output, args, formInfo)
	output:wikitext(i18n.print('Permalink'), p.fullURL(formInfo, args))
	output:wikitext('<br>')
	output:wikitext(i18n.print('TemplateArgs'))
	output:tag('div')
		:css('display', 'inline-block')
		:wikitext(mw.text.tag{
		name = 'code',
		content = h.templateArgs(formInfo, args)
	})
end

function h.escape(str)
	local lookup = {
		[' '] = '%%20',
		['"'] = '%%22',
		['>'] = '%%3E',
		['<'] = '%%3C',
		['+'] = '%%2B',
	}
	for k, v in pairs(lookup) do
		str = str:gsub(k, v)
	end
	return str
end

function h.templateArgs(formInfo, args)
	local formInfo = util_table.guaranteeTable(formInfo)
	local tbl = {}
	for k, v in pairs(args) do
		tbl[#tbl+1] = '|' .. k .. '=' .. v
	end
	return mw.text.nowiki(('{{%s%s}}'):format(formInfo.template, util_table.concat(tbl, '')))
end

function p.printLog(output)
	local log = util_vars.getVar('log')
	if not log then return end
	output:tag('br')
	output:wikitext(log)
end

function p.makeIntroSentence(formInfo, args, formArgs)
	if not util_args.castAsBool(args.showformlink) then return '' end
	return util_text.extLink(
		p.fullURL(formInfo, formArgs),
		i18n.print('introSentence')
	)
end

function p.makeTableCellFilterLink(formInfo, formArgs, class)
	local output = mw.html.create('span')
		:addClass('table-cell-filter-link')
		:addClass(class)
		:wikitext(util_text.extLink(p.fullURL(formInfo, formArgs), '&nbsp;'))
	return tostring(output)
end

return p
Advertisement