모듈:Tracked
보이기
위 설명은 모듈:Tracked/설명문서의 내용을 가져와 보여주고 있습니다. (편집 | 역사) 연습장 (생성 | 복제) 및 시험장 (생성) 문서에서 이 모듈을 실험할 수 있습니다. 이 모듈에 딸린 문서. |
require('strict')
local getArgs = require('Module:Arguments').getArgs
local p = {}
-- Entry point when #invoke'ed by a template or wikipage.
function p.main(frame)
local args = getArgs(frame)
return p._main(args)
end
-- 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('[[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 = "해결",
fixed = "해결",
['해결'] = "해결",
['해결됨'] = "해결",
invalid = "유효하지 않음",
['유효하지 않음'] = "유효하지 않음",
['잘못됨'] = "유효하지 않음",
duplicate = "중복",
['중복'] = "중복",
['중복됨'] = "중복",
declined = "거부",
wontfix = "거부",
['거부'] = "거부",
['거부됨'] = "거부",
stalled = "중단",
['중단'] = "중단",
['중단됨'] = "중단",
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" or manual_status == "해결" or manual_status == "해결됨" 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