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

From Wikipedia, the free encyclopedia

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