Modul:Vorlage:Phab: Unterschied zwischen den Versionen

Zur Navigation springen Zur Suche springen
2015-03-30
wp>PerfektesChaos
(2015-03-28)
wp>PerfektesChaos
(2015-03-30)
Zeile 1: Zeile 1:
--[=[ 2015-03-28
--[=[ 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, show
     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
    r = string.format( "%sF%d", Site, n )
     if args.Show then
     if args.Show then
         show = args.Show
         r = string.format( "[[phab:F%d|%s]]", n, args.Show )
     else
     else
         show = string.format( "phab:F%d", n )
         r = string.format( "[[phab:F%d]]", n )
     end
     end
    r = string.format( "[%s %s]", r, show )
     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]+)$" )
    local show
     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
    r = string.format( "%sM%d", Site, n )
     if args.Show then
     if args.Show then
         show = args.Show
         r = string.format( "[[phab:M%d|%s]]", n, args.Show )
     else
     else
         show = string.format( "phab:M%d", n )
         r = string.format( "[[phab:M%d]]", n )
     end
     end
    r = string.format( "[%s %s]", r, show )
     return r
     return r
end -- mock()
end -- mock()
Zeile 265: Zeile 260:
             show = "#" .. s
             show = "#" .. s
         end
         end
         r = string.format( "%s[%stag/%s %s]",
         r = string.format( "%s[[phab:tag/%s|%s]]",
                           r, Site, s:lower(), show )
                           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 %s]||%s\n",
             r    = string.format( "%s|- id='%s'\n|[[%s%s|%s]]||%s\n",
                                   r, sign, Site, sub, sign, sign, show )
                                   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 .. "|}\n"
         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 URL for Phabricator Diffusion since 2015-03
     -- 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 = Site .. sub
             r = "phab:" .. sub
         end
         end
     end
     end
Zeile 463: Zeile 459:
             frame = mw.getCurrentFrame()
             frame = mw.getCurrentFrame()
         end
         end
         r = string.format( "[%sp/%s %s]",
         r = string.format( "[[phab:p/%s|%s]]",
                          Site,
                           frame:callParserFunction( "urlencode",
                           frame:callParserFunction( "urlencode",
                                                     single ),
                                                     single ),
Zeile 571: Zeile 566:
         show = scope .. "/*"
         show = scope .. "/*"
     end
     end
     if not r then
     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     = git( swift, scope, slot, source, jump, since )
         r = git( swift, scope, slot, source, jump, since )
        r = string.format( "[%s %s]", r, show )
         lapsus = true
         lapsus = true
     end
     end
    r = string.format( "[%s %s]", r, show )
     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 args.Anchor then
         if scroll  and  not sub then
             args.Anchor = scroll
             sub = scroll
         end
         end
     end
     end
Zeile 616: Zeile 614:
         error( r, 0 )
         error( r, 0 )
     end
     end
    r = string.format( "%sT%d", Site, n )
     if sub then
     if args.Anchor then
         sub = string.format( "#anchor-%s", sub )
         r = string.format( "%s#anchor-%s", r, args.Anchor )
    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 args.Anchor then
         if sub then
             show = string.format( "%s #%s", show, args.Anchor )
             show = string.format( "%s #%s", show, sub )
         end
         end
     end
     end
     r = string.format( "[%s %s]", r, show )
     r = string.format( "[[phab:T%d%s|%s]]", n, sub, show )
     return r
     return r
end -- task()
end -- task()
Anonymer Benutzer

Navigationsmenü