Module:Phabricator/sandbox
Appearance
![]() | This is the module sandbox page for Module:Phabricator (diff). See also the companion subpage for test cases (run). |
This module has been created to replace the current template code in Template:Phabricator. It supports the template's documented behavior of any combination of including a "T" or not in the task ID, titling the link, or having a link to Wikipedia:Phabricator.
The |art=
and |article=
params support both y and yes as a value.
{{#invoke:Phabricator|task}}
{{#invoke:Phabricator|task|T1234}}
{{#invoke:Phabricator|task|1234}}
{{#invoke:Phabricator|task|T1234|Lorem ipsum dolor sit amet}}
{{#invoke:Phabricator|task|T1234|art=y}}
{{#invoke:Phabricator|task|T1234|article=yes}}
{{#invoke:Phabricator|task|T1234|Lorem ipsum dolor sit amet|article=yes}}
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) 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