Modul:Vorlage:Phab: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
2015-03-26
wp>PerfektesChaos (2015-03-25) |
wp>PerfektesChaos (2015-03-26) |
||
Zeile 1: | Zeile 1: | ||
--[=[ 2015-03- | --[=[ 2015-03-26 | ||
{{Template:Phab}} | {{Template:Phab}} | ||
]=] | ]=] | ||
Zeile 32: | Zeile 32: | ||
-- Precondition: | -- Precondition: | ||
-- args -- table; assignments | -- args -- table; assignments | ||
-- .File | |||
-- .Show | |||
-- Postcondition: | -- Postcondition: | ||
-- Returns string with bracketed external link, if fine | -- Returns string with bracketed external link, if fine | ||
-- Throws error on failure | -- Throws error on failure | ||
local r = args. | local r = args.File | ||
local j = r:find( ",", 1, true ) | local j = r:find( ",", 1, true ) | ||
local n, params, show | local n, params, show | ||
Zeile 171: | Zeile 173: | ||
-- Precondition: | -- Precondition: | ||
-- args -- table; assignments | -- args -- table; assignments | ||
-- .Mock | |||
-- .Show | |||
-- Postcondition: | -- Postcondition: | ||
-- Returns string with bracketed external link, if fine | -- Returns string with bracketed external link, if fine | ||
-- Throws error on failure | -- Throws error on failure | ||
local r = args. | local r = args.Mock | ||
local n = r:match( "^[Mm]?([0-9]+)$" ) | local n = r:match( "^[Mm]?([0-9]+)$" ) | ||
local show | local show | ||
Zeile 226: | Zeile 230: | ||
-- args -- table; assignments | -- args -- table; assignments | ||
-- .Engage | -- .Engage | ||
-- .Show | |||
-- string; single ID | -- string; single ID | ||
-- Postcondition: | -- Postcondition: | ||
Zeile 234: | Zeile 239: | ||
if type( args.Engage ) == "string" then | if type( args.Engage ) == "string" then | ||
tags = args.Engage | tags = args.Engage | ||
if args. | if args.Show and ( args.Show ~= "" ) then | ||
show = args. | show = args.Show | ||
end | end | ||
end | end | ||
else | |||
tags = | if s == "string" then | ||
tags = args | |||
end | |||
if not tags or tags == "" then | |||
tags = "MediaWiki-General-or-Unknown" | |||
end | |||
end | end | ||
if tags then | if tags then | ||
Zeile 372: | Zeile 382: | ||
local r, shortcut | local r, shortcut | ||
if translate then | if translate then | ||
if assembly:match( "^%u%u%u?%u?$" ) then | if assembly:match( "^%u%u%u?%u?$" ) then | ||
shortcut = assembly | shortcut = assembly | ||
Zeile 436: | Zeile 445: | ||
-- args -- table; assignments | -- args -- table; assignments | ||
-- .User | -- .User | ||
-- .Show | |||
-- frame -- object or nil | -- frame -- object or nil | ||
-- Postcondition: | -- Postcondition: | ||
-- Returns string URL, if fine | -- Returns string URL, if fine | ||
-- Uses: | |||
-- mw.text.trim() | |||
local r | local r | ||
local single = args.User | local single = args.User | ||
if type( single ) == "string" then | |||
single = mw.text.trim( single ) | |||
end | |||
if type( single ) == "string" and single ~= "" then | if type( single ) == "string" and single ~= "" then | ||
local show = args. | local show = args.Show | ||
if not show or show == "" then | if not show or show == "" then | ||
show = "@" .. single | show = "@" .. single | ||
Zeile 454: | Zeile 469: | ||
single ), | single ), | ||
show ) | show ) | ||
else | |||
r = string.format( "Missing User :-(" ) | |||
error( r, 0 ) | |||
end | end | ||
return r | return r | ||
Zeile 471: | Zeile 489: | ||
-- lonely() | -- lonely() | ||
-- id40() | -- id40() | ||
-- phabDiffusion() | -- phabDiffusion() | ||
-- git() | -- git() | ||
Zeile 482: | Zeile 499: | ||
local source = false | local source = false | ||
local swift = "dir" | local swift = "dir" | ||
local load, r | local lapsus, load, r | ||
r = lonely( args, | r = lonely( args, | ||
{ "branch", "commit", "commitdiff", "diff" } ) | { "branch", "commit", "commitdiff", "diff" } ) | ||
Zeile 548: | Zeile 565: | ||
if show then | if show then | ||
show = "r" .. show | show = "r" .. show | ||
lapsus = ( not args.project ) | |||
else | else | ||
show = "GIT:" | show = "GIT:" | ||
Zeile 556: | Zeile 574: | ||
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 ) | ||
lapsus = true | |||
end | |||
r = string.format( "[%s %s]", r, show ) | |||
if lapsus then | |||
r = r | |||
.. "[[Category:Wikipedia:Vorlagenfehler/Vorlage:Phab/Diffusion]]" | .. "[[Category:Wikipedia:Vorlagenfehler/Vorlage:Phab/Diffusion]]" | ||
end | end | ||
return | return r | ||
end -- sourcing() | end -- sourcing() | ||
Zeile 568: | Zeile 591: | ||
-- Precondition: | -- Precondition: | ||
-- args -- table; assignments | -- args -- table; assignments | ||
-- .Task | |||
-- .Anchor | |||
-- .Show | |||
-- Postcondition: | -- Postcondition: | ||
-- Returns string with bracketed external link, if fine | -- Returns string with bracketed external link, if fine | ||
Zeile 712: | Zeile 738: | ||
-- unified() | -- unified() | ||
-- sourcing() | -- sourcing() | ||
local defaults = { Bugzilla = "", | |||
Engage = true, | |||
User = true } | |||
local got = { } | local got = { } | ||
local mode = 0 | local mode = 0 | ||
Zeile 740: | Zeile 769: | ||
title = 2, | title = 2, | ||
callsigns = 3 } | callsigns = 3 } | ||
local gr | local gr, s | ||
for k, v in pairs( args ) do | for k, v in pairs( args ) do | ||
mode = params[ k ] | mode = params[ k ] | ||
Zeile 753: | Zeile 782: | ||
r = got[ -1 ] | r = got[ -1 ] | ||
if r then | if r then | ||
if #r == 1 then | if #r == 1 then | ||
s = "" | s = "" | ||
Zeile 775: | Zeile 803: | ||
got = got[ mode ] | got = got[ mode ] | ||
for k, v in pairs( got ) do | for k, v in pairs( got ) do | ||
if v | s = type( v ) | ||
if s == "number" then | |||
v = tostring( v ) | |||
elseif s == "string" then | |||
if #v == 0 then | |||
v = defaults[ k ] | |||
end | |||
elseif v == true then | |||
v = defaults[ k ] | |||
else | |||
v = nil | |||
end | |||
if v then | |||
got[ k ] = v | |||
else | |||
got[ k ] = nil | got[ k ] = nil | ||
end | end |