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 15:41, 20 March 2025 (Empty param, not all whitespace). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local yesno = require('Module:Yesno')

local p = {}

p.task = function(frame)
	if (frame.args == nil or frame.args[1] == nil or string.match(frame.args[1], "^%s+$")) then
		return '[[phab:|Phabricator]]'
	end

	local paramId = string.gsub(frame.args[1], "%s", "")
	local paramTitle = frame.args[2]

	local output = ''
	local taskId

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

	output = p.makePhabWikiLink(taskId, taskId)

	if not (paramTitle == nil or string.match(paramTitle, "")) then
		output = output .. ' • ' .. p.makePhabWikiLink(taskId, paramTitle)
	end

	local articleLink = false
    local argArt = yesno(frame.args.art)
    local argArticle = yesno(frame.args.article)

	if (argArt or argArticle) then
		output = '[[Wikipedia:Phabricator|Phabricator]]: ' .. output
	end

	return output
end

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

return p