Jump to content

Module:No ping/sandbox

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Þjarkur (talk | contribs) at 01:38, 19 December 2019. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
-- This module implements {{noping}}.

local p = {}

function p.main(frame)
	local args = frame:getParent().args
	return p._main(args)
end

function p._main(args)
	local ret = {}
	local fullUrl = mw.uri.fullUrl
	local format = string.format
	for i, username in ipairs(args) do
		local url = fullUrl(mw.site.namespaces.User.name .. ':' .. username)
		url = tostring(url)
		local label = args['label' .. tostring(i)] or username
		label = '<span style="color:green">' .. label .. '</span>'
		url = format('[%s %s]', url, label)
		ret[#ret + 1] = url
	end
	ret = mw.text.listToText(ret)
	ret = '<span class="plainlinks">' .. ret .. '</span>'
	return ret
end

return p