Modul:Vorlage:Phab: Unterschied zwischen den Versionen
2015-03-30
wp>PerfektesChaos (2015-03-28) |
wp>PerfektesChaos (2015-03-30) |
||
Zeile 1: | Zeile 1: | ||
--[=[ 2015-03- | --[=[ 2015-03-30 | ||
{{Template:Phab}} | {{Template:Phab}} | ||
]=] | ]=] | ||
Zeile 40: | Zeile 40: | ||
local r = args.File | local r = args.File | ||
local j = r:find( ",", 1, true ) | local j = r:find( ",", 1, true ) | ||
local n, params | local n, params | ||
if j then | if j then | ||
params = r:sub( j + 1 ) | params = r:sub( j + 1 ) | ||
Zeile 55: | Zeile 55: | ||
error( r, 0 ) | error( r, 0 ) | ||
end | end | ||
if args.Show then | if args.Show then | ||
r = string.format( "[[phab:F%d|%s]]", n, args.Show ) | |||
else | else | ||
r = string.format( "[[phab:F%d]]", n ) | |||
end | end | ||
return r | return r | ||
end -- file() | end -- file() | ||
Zeile 181: | Zeile 179: | ||
local r = args.Mock | local r = args.Mock | ||
local n = r:match( "^[Mm]?([0-9]+)$" ) | local n = r:match( "^[Mm]?([0-9]+)$" ) | ||
if n then | if n then | ||
n = tonumber( n ) -- discard leading zeros | n = tonumber( n ) -- discard leading zeros | ||
Zeile 188: | Zeile 185: | ||
error( r, 0 ) | error( r, 0 ) | ||
end | end | ||
if args.Show then | if args.Show then | ||
r = string.format( "[[phab:M%d|%s]]", n, args.Show ) | |||
else | else | ||
r = string.format( "[[phab:M%d]]", n ) | |||
end | end | ||
return r | return r | ||
end -- mock() | end -- mock() | ||
Zeile 265: | Zeile 260: | ||
show = "#" .. s | show = "#" .. s | ||
end | end | ||
r = string.format( "%s[ | r = string.format( "%s[[phab:tag/%s|%s]]", | ||
r | r, s:lower(), show ) | ||
end -- for i | end -- for i | ||
return r | return r | ||
Zeile 286: | Zeile 281: | ||
local callsigns = { } | local callsigns = { } | ||
local order = { } | local order = { } | ||
local sub = "diffusion/" | local sub = "phab:diffusion/" | ||
local details, pages, s, sign, support | local details, pages, s, sign, support | ||
r = "{| class='wikitable sortable'\n" .. | r = "{| class='wikitable sortable'\n" .. | ||
Zeile 319: | Zeile 314: | ||
sign = order[ i ] | sign = order[ i ] | ||
show = callsigns[ sign ] | show = callsigns[ sign ] | ||
r = string.format( "%s|- id='%s'\n|[%s%s%s | r = string.format( "%s|- id='%s'\n|[[%s%s|%s]]||%s\n", | ||
r, sign | r, sign, sub, sign, sign, show ) | ||
pages = { } | pages = { } | ||
details = connect[ sign ] | details = connect[ sign ] | ||
Zeile 355: | Zeile 350: | ||
end | end | ||
end -- for i | end -- for i | ||
r = | r = string.format( "%s|}\n%d ", | ||
r, #order ) | |||
end | end | ||
return r | return r | ||
Zeile 364: | Zeile 360: | ||
local function phabDiffusion( action, assembly, adopt, attach, | local function phabDiffusion( action, assembly, adopt, attach, | ||
anchor, against, frame ) | anchor, against, frame ) | ||
-- Create | -- Create path for Phabricator Diffusion since 2015-03 | ||
-- Precondition: | -- Precondition: | ||
-- action -- string; kind of request | -- action -- string; kind of request | ||
Zeile 431: | Zeile 427: | ||
end | end | ||
end | end | ||
r = | r = "phab:" .. sub | ||
end | end | ||
end | end | ||
Zeile 463: | Zeile 459: | ||
frame = mw.getCurrentFrame() | frame = mw.getCurrentFrame() | ||
end | end | ||
r = string.format( "[ | r = string.format( "[[phab:p/%s|%s]]", | ||
frame:callParserFunction( "urlencode", | frame:callParserFunction( "urlencode", | ||
single ), | single ), | ||
Zeile 571: | Zeile 566: | ||
show = scope .. "/*" | show = scope .. "/*" | ||
end | end | ||
if | if r then | ||
r = string.format( "[[%s|%s]]", r, show ) | |||
else | |||
if not scope:find( "/", 3, true ) then | if not scope:find( "/", 3, true ) then | ||
error( "Unknown project: " .. scope, 0 ) | error( "Unknown project: " .. scope, 0 ) | ||
end | end | ||
r | r = git( swift, scope, slot, source, jump, since ) | ||
r = string.format( "[%s %s]", r, show ) | |||
lapsus = true | lapsus = true | ||
end | end | ||
if lapsus then | if lapsus then | ||
r = string.format( "%s[[%s/Diffusion]]", | r = string.format( "%s[[%s/Diffusion]]", | ||
Zeile 598: | Zeile 595: | ||
-- 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.Task | local r = args.Task | ||
local j = r:find( "#", 1, true ) | local j = r:find( "#", 1, true ) | ||
local sub = args.Anchor | |||
local n, show | local n, show | ||
if j then | if j then | ||
Zeile 605: | Zeile 603: | ||
r = r:sub( 1, j - 1 ) | r = r:sub( 1, j - 1 ) | ||
scroll = scroll:match( "^([0-9]+)$" ) | scroll = scroll:match( "^([0-9]+)$" ) | ||
if scroll and not | if scroll and not sub then | ||
sub = scroll | |||
end | end | ||
end | end | ||
Zeile 616: | Zeile 614: | ||
error( r, 0 ) | error( r, 0 ) | ||
end | end | ||
if sub then | |||
if | sub = string.format( "#anchor-%s", sub ) | ||
else | |||
sub = "" | |||
end | end | ||
if args.Show then | if args.Show then | ||
Zeile 624: | Zeile 623: | ||
else | else | ||
show = string.format( "phab:T%d", n ) | show = string.format( "phab:T%d", n ) | ||
if | if sub then | ||
show = string.format( "%s #%s", show, | show = string.format( "%s #%s", show, sub ) | ||
end | end | ||
end | end | ||
r = string.format( "[%s %s]", | r = string.format( "[[phab:T%d%s|%s]]", n, sub, show ) | ||
return r | return r | ||
end -- task() | end -- task() |