Modul:Vorlage:Phab: Unterschied zwischen den Versionen
2015-03-25
wp>PerfektesChaos (2015-03-23) |
wp>PerfektesChaos (2015-03-25) |
||
Zeile 1: | Zeile 1: | ||
--[=[ 2015-03- | --[=[ 2015-03-25 | ||
{{Template:Phab}} | {{Template:Phab}} | ||
]=] | ]=] | ||
-- local globals | |||
local Site = "https://phabricator.wikimedia.org/" | |||
Zeile 47: | Zeile 52: | ||
error( r, 0 ) | error( r, 0 ) | ||
end | end | ||
r = string.format( " | r = string.format( "%sF%d", Site, n ) | ||
if args.Show then | if args.Show then | ||
show = args.Show | show = args.Show | ||
Zeile 178: | Zeile 183: | ||
error( r, 0 ) | error( r, 0 ) | ||
end | end | ||
r = string.format( " | r = string.format( "%sM%d", Site, n ) | ||
if args.Show then | if args.Show then | ||
show = args.Show | show = args.Show | ||
Zeile 213: | Zeile 218: | ||
return r | return r | ||
end -- phabAssigned() | end -- phabAssigned() | ||
local function phabBoards( args ) | |||
-- Link to a board, project, team: tag | |||
-- Precondition: | |||
-- args -- table; assignments | |||
-- .Engage | |||
-- string; single ID | |||
-- Postcondition: | |||
-- Returns string URL, if fine | |||
local s = type( args ) | |||
local r, show, tags | |||
if s == "table" then | |||
if type( args.Engage ) == "string" then | |||
tags = args.Engage | |||
if args.title and ( args.title ~= "" ) then | |||
show = args.title | |||
end | |||
end | |||
elseif s == "string" then | |||
tags = args | |||
end | |||
if tags then | |||
local n | |||
tags = mw.text.split( tags, "%s+" ) | |||
n = #tags | |||
if show and n > 1 then | |||
show = false | |||
end | |||
for i = 1, n do | |||
s = tags[ i ] | |||
if r then | |||
r = r .. " | " | |||
else | |||
r = "" | |||
end | |||
if not show then | |||
show = "#" .. s | |||
end | |||
r = string.format( "%s[%stag/%s %s]", | |||
r, Site, s:lower(), show ) | |||
end -- for i | |||
end | |||
return r | |||
end -- phabBoards() | |||
Zeile 229: | Zeile 280: | ||
local callsigns = { } | local callsigns = { } | ||
local order = { } | local order = { } | ||
local sub = "diffusion/" | |||
local sub | |||
local details, pages, s, sign, support | local details, pages, s, sign, support | ||
r = "{| class='wikitable sortable'\n" .. | r = "{| class='wikitable sortable'\n" .. | ||
Zeile 264: | Zeile 314: | ||
show = callsigns[ sign ] | show = callsigns[ sign ] | ||
r = string.format( "%s|-\n|[%s%s%s %s]||%s\n", | r = string.format( "%s|-\n|[%s%s%s %s]||%s\n", | ||
r, | r, Site, sub, sign, sign, show ) | ||
pages = { } | pages = { } | ||
details = connect[ sign ] | details = connect[ sign ] | ||
Zeile 275: | Zeile 325: | ||
details.support ) ) | details.support ) ) | ||
end | end | ||
if type( details. | if type( details.tags ) == "table" then | ||
for k, v in pairs( details. | for k, v in pairs( details.tags ) do | ||
table.insert( pages, | table.insert( pages, phabBoards( v ) ) | ||
end -- for k, v | end -- for k, v | ||
end | end | ||
Zeile 289: | Zeile 337: | ||
end | end | ||
end | end | ||
if support then | if support and support ~= "" then | ||
table.insert( pages, | table.insert( pages, | ||
string.format( "[[mw:%s]]", support ) ) | string.format( "[[mw:%s]]", support ) ) | ||
Zeile 317: | Zeile 365: | ||
-- frame -- object or nil | -- frame -- object or nil | ||
-- Postcondition: | -- Postcondition: | ||
-- Return URL, if identified, or nil | -- Return 1 -- URL, if identified, or nil | ||
-- 2 -- callsign, or nil | |||
-- Uses: | -- Uses: | ||
-- phabAssigned() | -- phabAssigned() | ||
local translate = phabAssigned( frame ) | local translate = phabAssigned( frame ) | ||
local r | local r, shortcut | ||
if translate then | if translate then | ||
local shortcut | local shortcut | ||
Zeile 336: | Zeile 385: | ||
end | end | ||
if shortcut then | if shortcut then | ||
local state, sub, swift | local state, sub, swift | ||
if adopt ~= "master" and adopt ~= "HEAD" then | if adopt ~= "master" and adopt ~= "HEAD" then | ||
Zeile 375: | Zeile 423: | ||
end | end | ||
end | end | ||
r = | r = Site .. sub | ||
end | end | ||
end | |||
return r, shortcut | |||
end -- phabDiffusion() | |||
local function phabUser( args, frame ) | |||
-- Link to a user | |||
-- Precondition: | |||
-- args -- table; assignments | |||
-- .User | |||
-- frame -- object or nil | |||
-- Postcondition: | |||
-- Returns string URL, if fine | |||
local r | |||
local single = args.User | |||
if type( single ) == "string" and single ~= "" then | |||
local show = args.title | |||
if not show or show == "" then | |||
show = "@" .. single | |||
end | |||
if not frame then | |||
frame = mw.getCurrentFrame() | |||
end | |||
r = string.format( "[%sp/%s %s]", | |||
Site, | |||
frame:callParserFunction( "urlencode", | |||
single ), | |||
show ) | |||
end | end | ||
return r | return r | ||
end -- | end -- phabUser() | ||
Zeile 455: | Zeile 532: | ||
if last then | if last then | ||
swift = "history" | swift = "history" | ||
end | end | ||
end | end | ||
if args.title then | r, show = phabDiffusion( swift, scope, slot, source, jump, since, | ||
frame ) | |||
if args.title and ( args.title ~= "" ) then | |||
show = args.title | show = args.title | ||
elseif last then | elseif last then | ||
Zeile 468: | Zeile 546: | ||
end | end | ||
elseif load then | elseif load then | ||
show = "GIT:" .. slot:sub( 1, 7 ) | if show then | ||
show = "r" .. show | |||
else | |||
show = "GIT:" | |||
end | |||
show = show .. slot:sub( 1, 7 ) | |||
else | else | ||
show = scope .. "/*" | show = scope .. "/*" | ||
end | end | ||
if not r then | if not r then | ||
r = git( swift, scope, slot, source, jump, since ) | r = git( swift, scope, slot, source, jump, since ) | ||
.. "[[Category:Wikipedia:Vorlagenfehler/Vorlage:Phab/Diffusion]]" | |||
end | end | ||
return string.format( "[%s %s]", r, show ) | return string.format( "[%s %s]", r, show ) | ||
Zeile 507: | Zeile 589: | ||
error( r, 0 ) | error( r, 0 ) | ||
end | end | ||
r = string.format( " | r = string.format( "%sT%d", Site, n ) | ||
if args.Anchor then | if args.Anchor then | ||
r = string.format( "%s#anchor-%s", r, args.Anchor ) | r = string.format( "%s#anchor-%s", r, args.Anchor ) | ||
Zeile 573: | Zeile 655: | ||
local function unified( args ) | local function unified( args, frame ) | ||
-- Link to a management issue | -- Link to a management issue | ||
-- Precondition: | -- Precondition: | ||
Zeile 584: | Zeile 666: | ||
-- taskBugzilla() | -- taskBugzilla() | ||
-- task() | -- task() | ||
-- phabBoards() | |||
-- phabUser() | |||
local r | local r | ||
lonely( args, | lonely( args, | ||
{ "Bugzilla", "Countdown", "Differential", "File", "Gerrit", | { "Bugzilla", "Countdown", "Differential", "Engage", | ||
"File", "Gerrit", "Join", "Mock", "Paste", "Review", | |||
"Task", "User" } ) | |||
if args.Bugzilla then | if args.Bugzilla then | ||
r = taskBugzilla( args ) | r = taskBugzilla( args ) | ||
elseif args.Engage then | |||
r = phabBoards( args ) | |||
elseif args.File then | elseif args.File then | ||
r = file( args ) | r = file( args ) | ||
Zeile 596: | Zeile 683: | ||
elseif args.Task then | elseif args.Task then | ||
r = task( args ) | r = task( args ) | ||
elseif args.User then | |||
r = phabUser( args, frame ) | |||
else | else | ||
r = "NOT YET READY" | r = "NOT YET READY" | ||
Zeile 606: | Zeile 695: | ||
-- Paste | -- Paste | ||
-- Review | -- Review | ||
-- Leerzeichen-getrennte Liste | |||
return r | return r | ||
end -- unified() | end -- unified() | ||
Zeile 628: | Zeile 718: | ||
Countdown = 1, | Countdown = 1, | ||
Differential = 1, | Differential = 1, | ||
Engage = 1, | |||
File = 1, | File = 1, | ||
-- Gerrit = 1, | -- Gerrit = 1, | ||
Zeile 636: | Zeile 727: | ||
Show = 1, | Show = 1, | ||
Task = 1, | Task = 1, | ||
User = 1, | |||
branch = 2, | branch = 2, | ||
commit = 2, | commit = 2, |