Koha Test Wiki MW Canasta on Koha Portainer

Test major Koha Wiki changes or bug fixes here without fear of breaking the production wiki.

For the current Koha Wiki, visit https://wiki.koha-community.org .

Module:No ping/sandbox

From Koha Test Wiki MW Canasta on Koha Portainer
Jump to navigation Jump to search

Documentation for this module may be created at Module:No ping/sandbox/doc

-- 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 upage = mw.title.makeTitle( "User", username )
		local url = fullUrl(mw.site.namespaces.User.name .. ':' .. username)
		url = tostring(url)
		local label = args['label' .. tostring(i)] or username
		if not upage.exists then
			label = '<span style="color:#BA0000;">' .. label .. '</span>'
		end
		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