Jump to content

Module:Phabricator/sandbox

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Hex (talk | contribs) at 20:44, 26 December 2024 (Return error message if task ID is bad). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local p = {}

p.task = function(frame)
	if (frame.args == nil or frame.args[1] == nil) then
		return '[[phab:|Phabricator]]'
	end

	local paramId, paramTitle = unpack(frame.args)

	local output = ''
	local taskId

	if (string.find(paramId, '^T%d+$')) then
		taskId = paramId
	elseif (string.find(paramId, '^%d+$')) then
		taskId = 'T' .. paramId
	else
		return '{{strongbad|Not a task ID: ' .. paramId .. '}}'
	end

	output = p.makePhabWikiLink(taskId, taskId)

	if (paramTitle) then
		output = output .. ' • ' .. p.makePhabWikiLink(taskId, paramTitle)
	end

	local articleLink = false

	if ((frame.args.art or frame.args.article) == 'y') then
		output = '[[Wikipedia:Phabricator|Phabricator]]: ' .. output
	end

	return output
end

function p.makePhabWikiLink(taskId, linkTitle)
	return '[[Phabricator:' .. taskId .. '|' .. linkTitle .. ']]'
end

return p