Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

Jump to content

Module:Phabricator/sandbox

From Wikipedia, the free encyclopedia
local yesno = require('Module:Yesno')
local parens = function(v) return ((v or '') ~= '') and (" (" .. v .. ")") or "" end
local p = {}

p._task = function(args)
	local art = (yesno(args.art) or yesno(args.article)) and
		"[[Wikipedia:Phabricator|Phabricator]]''':''' " or ""
	
	local rows = {}
	for k, v in pairs(args) do
		if tonumber(k) ~= nil then table.insert(rows, tonumber(k)) end
	end
	table.sort(rows)
	
	if #rows == 0 then return art .. "[[Phabricator:|Phabricator]]" end
	
	local output = {}
	for k, v in ipairs(rows) do
		local taskId = mw.text.trim(args[k])
		taskId = ((tonumber(taskId) ~= nil) and "T" or "") .. taskId
		if not (string.find(taskId, '^T%d+$')) then
			return require('Module:Error')._error{"Invalid task ID: " .. args[k]}
		end
		output[k] = ((k > 1) and " • " or "") ..
			"[[Phabricator:" .. taskId .. "|" .. taskId .. "]]" ..
			parens(args['label' .. k])
	end

	return art .. table.concat(output) .. parens(args.label)
end
p.task = function(frame)
	return p._task(require('Module:Arguments').getArgs(frame))
end

return p