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 19:45, 26 December 2024 (Tables can use dot notation for string keys; parentheses around tests in or condition not necessary). 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)
	local paramId = frame.args[1]
	local paramTitle = frame.args[2]

	if not paramId then
		return '[[phab:|Phabricator]]'
	end

	local output = ''
	local taskId

	if (string.find(paramId, '^T%d+$')) then
		taskId = paramId
	elseif (string.find(paramId, '^%d+$')) then
		taskId = 'T' .. paramId
	end

	output = p.makePhabWikiLink(taskId, taskId)

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

	if (frame.args.art == 'y' 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