|
|
(One intermediate revision by the same user not shown) |
Line 1: |
Line 1: |
| require('strict')
| | <templatestyles src="Tracked/styles.css" /><div role="note" class="tracked plainlinks {{#if:{{{1|}}}|mw-trackedTemplate}}">Tracked in [[phabricator:|Phabricator]]<br />{{#if:{{{1|}}}|<span class="tracked-url">[[phabricator:{{ #ifeq: {{padleft: | 1 | {{ uc: {{{1}}} }} }} | T | {{ uc: {{{1}}} }} | T{{ #expr: {{{1}}} + 2000 }} }}|<span class="trakfab-{{ #ifeq: {{padleft: | 1 | {{ uc: {{{1}}} }} }} | T | {{ uc: {{{1}}} }} | T{{ #expr: {{{1}}} + 2000 }} }}"> Task {{ #ifeq: {{padleft: | 1 | {{ uc: {{{1}}} }} }} | T | {{ uc: {{{1}}} }} | T{{ #expr: {{{1}}} + 2000 }} }}</span>]]</span>}}<br>{{#switch:{{lc:{{{2|}}}}} |
| | | |resolved|fixed=<span class="tracked-closure tracked-resolved">Resolved</span> |
| local getArgs = require('Module:Arguments').getArgs
| | |invalid=<span class="tracked-closure">Invalid</span> |
| local p = {}
| | |duplicate=<span class="tracked-closure">Duplicate</span> |
| | | |declined|wontfix=<span class="tracked-closure">Declined</span> |
| -- Entry point when #invoke'ed by a template or wikipage. | | |stalled|later=<span class="tracked-closure">Stalled</span> |
| function p.main(frame)
| | |open=<span class="tracked-closure">Open</span> |
| local args = getArgs(frame)
| | }}</div><noinclude> |
| return p._main(args)
| | {{documentation}} |
| end
| | </noinclude> |
| | |
| -- Entry point when called from other Lua modules.
| |
| function p._main(args)
| |
| -- Check if the template provided a status
| |
| local manual_status
| |
| if args[2] ~= nil and args[2] ~= '' then
| |
| manual_status = args[2]
| |
| end
| |
| | |
| -- Check if the template provided a tracker number
| |
| local task
| |
| if args[1] ~= nil and args[1] ~= '' then
| |
| if string.match(args[1], "^[Tt]%d+$") then
| |
| -- It's a Phab task, so just use it as is (minus the "T")
| |
| task = string.gsub(args[1], "^[Tt]", "")
| |
| elseif string.match(args[1], "^%d+$") then
| |
| -- It's a bzImport, so massage it first
| |
| task = args[1] + 2000
| |
| else
| |
| -- Tracking arg given, but doesn't match our patterns
| |
| -- FIXME: Emit a visible error for this? Tracking cat?
| |
| end
| |
| else
| |
| -- No tracking number provided.
| |
| -- FIXME: Emit a visible error for this? Tracking cat?
| |
| end
| |
| | |
| -- Now create the top level container
| |
| local box = mw.html.create('div')
| |
| :attr("role", "note")
| |
| :addClass('tracked')
| |
| :addClass('plainlinks')
| |
| box:tag('span')
| |
| :addClass('tracked-header')
| |
| :wikitext('Tracked in [[phabricator:|Phabricator]]')
| |
| if task then
| |
| box:addClass('mw-trackedTemplate')
| |
| :addClass("phab-T" .. task) -- Easily find the task in JS
| |
| :attr('data-phab-task', task) -- Task ID for easy access in JS
| |
| local linktext = mw.html.create('span')
| |
| :addClass('tracked-linktext')
| |
| :wikitext("Task T" .. task)
| |
| local wikitext_link = '[[phabricator:T' .. task .. '|' .. tostring(linktext) .. ']]'
| |
| box:tag('span')
| |
| :addClass('tracked-link')
| |
| :wikitext(wikitext_link)
| |
| end
| |
| | |
| local s = {
| |
| resolved = "Resolved",
| |
| fixed = "Resolved",
| |
| invalid = "Invalid",
| |
| duplicate = "Duplicate",
| |
| declined = "Declined",
| |
| wontfix = "Declined",
| |
| stalled = "Stalled",
| |
| open = "Open"
| |
| }
| |
| | |
| if manual_status then
| |
| local status_text = "Unknown"
| |
| local status_span = box:tag('span')
| |
| status_span:addClass('tracked-closure')
| |
| if manual_status == "resolved" or manual_status == "fixed" then
| |
| status_span:addClass('tracked-resolved')
| |
| end
| |
| if s[manual_status] ~= nil then
| |
| status_text = s[manual_status]
| |
| end
| |
| status_span:wikitext(status_text)
| |
| end
| |
| return tostring(box)
| |
| end
| |
| | |
| return p
| |
Page Template:Tracked/styles.css has no content.
Lua error in package.lua at line 80: module 'Module:Yesno' not found.
Implements {{tracked}}.