Modul:Vorlage:LuaModuleDoc: Unterschied zwischen den Versionen

(2016-11-12)
(2016-11-15)
Zeile 1: Zeile 1:
local Serial = "2016-11-12"
local Serial = "2016-11-15"
--[=[
--[=[
Support {{LuaModuleDoc}}
Support {{LuaModuleDoc}}
Zeile 10: Zeile 10:


-- Module globals
-- Module globals
local lucky, LuaWiki = pcall( require, "Module:LuaWiki" )
local Lucky, LuaWiki = pcall( require, "Module:LuaWiki" )
local currentTitle
local CurrentTitle
local Frame
 
 
 
local function globalRepos( script )
    -- Check for global dissemination
    --    script  -- string; module name (main)
    -- Uses:
    --    LuaWiki.getArg()
    --    >< CurrentTitle
    local entity = mw.wikibase.getEntity()
    local r
    if entity then
        local repo = entity:formatPropertyValues( "P1324" )
        local s = LuaWiki.getArg( "categoryWikiData", "" )
        local t
        if #s > 0 then
            t = mw.title.makeTitle( "Category", s )
            if t.exists then
                r = string.format( "[[%s|%s]]",
                                  t.prefixedText, script )
            end
        end
        if repo and repo.value then
            local leader
            repo = mw.uri.new( repo.value )
            if repo  and  repo.path:match( "^/wiki/" ) then
                local space
                space, s = mw.ustring.match( repo.path:sub( 7 ),
                                            "^([^:]+):(.+)$" )
                if space and source then
                    t      = mw.title.makeTitle( space, source )
                    leader = ( mw.title.equals( CurrentTitle, t )
                              and
                              mw.site.server  ==  "//" .. repo.host )
                end
            end
            s = LuaWiki.getArg( "templateGlobal", "" )
            if #s > 0 then
                local params
                if not leader then
                    params = { [1] = string.format( "[%s %s]",
                                                    tostring( repo ),
                                                    repo.host ) }
                end
                r = r or ""
                r = r .. Frame:expandTemplate{ title=s,
                                              args=params }
            end
        end
    end
    return r or ""
end -- globalRepos()




Zeile 182: Zeile 235:
     --    lead    -- true: Module: namespace;  false: text namespace
     --    lead    -- true: Module: namespace;  false: text namespace
     -- Uses:
     -- Uses:
     --    >< currentTitle
     --    >< CurrentTitle
     --    navLangs()
     --    navLangs()
     --    LuaWiki.transclude()
     --    LuaWiki.transclude()
Zeile 199: Zeile 252:
     if ns == nsDocs then
     if ns == nsDocs then
         s = string.format( "%s/%s", start, script )
         s = string.format( "%s/%s", start, script )
         if currentTitle.text == s then
         if CurrentTitle.text == s then
             super = currentTitle.text .. "/"
             super = CurrentTitle.text .. "/"
         elseif sub then
         elseif sub then
             collect.subDoc = sub
             collect.subDoc = sub
             collect.subModule = sub
             collect.subModule = sub
             s = string.format( "%s/%s/%s", start, script, sub )
             s = string.format( "%s/%s/%s", start, script, sub )
             if currentTitle.text == s then
             if CurrentTitle.text == s then
                 s = string.format( "%s/%s", s, collect[ 3 ] )
                 s = string.format( "%s/%s", s, collect[ 3 ] )
                 t = mw.title.makeTitle( nsDocs, s )
                 t = mw.title.makeTitle( nsDocs, s )
                 if t.exists then
                 if t.exists then
                     super = currentTitle.text .. "/"
                     super = CurrentTitle.text .. "/"
                 end
                 end
             end
             end
Zeile 221: Zeile 274:
     end
     end
     r = LuaWiki.transclude( swift, collect )
     r = LuaWiki.transclude( swift, collect )
     t = currentTitle.talkPageTitle
     t = CurrentTitle.talkPageTitle
     if t then
     if t then
         s = t.exists
         s = t.exists
Zeile 240: Zeile 293:
     end
     end
     if super then
     if super then
        local i
         local d  = "{{%s*[lL]uaModuleDoc[^}]*}}%s*"
         local d  = "{{%s*[lL]uaModuleDoc[^}]*}}%s*"
         local p1 = "^%s*" .. d .. "<onlyinclude>"
         local p1 = "^%s*" .. d .. "<onlyinclude>"
Zeile 282: Zeile 334:
     end
     end
     if lead then
     if lead then
         local entity = mw.wikibase.getEntity()
         r = r .. globalRepos( script )
        if entity then
            s = LuaWiki.getArg( "categoryWikiData", "" )
            if #s > 0 then
                i = mw.title.makeTitle( "Category", s )
                if i.exists then
                    r = string.format( "%s[[%s|%s]]",
                                      r, i.prefixedText, script )
                end
            end
        end
     end
     end
     return r
     return r
Zeile 307: Zeile 349:
     --    nsDocs  -- number; namespace for doc
     --    nsDocs  -- number; namespace for doc
     -- Uses:
     -- Uses:
     --    >< currentTitle
     --    >< CurrentTitle
     --    LuaWiki.getArg()
     --    LuaWiki.getArg()
     --    navError()
     --    navError()
Zeile 320: Zeile 362:
         end
         end
         s = s .. "([^/]+)/(.*/?)$"
         s = s .. "([^/]+)/(.*/?)$"
         script, s = mw.ustring.match( currentTitle.text .. "/",  s )
         script, s = mw.ustring.match( CurrentTitle.text .. "/",  s )
         if type( script ) == "string" then
         if type( script ) == "string" then
             local sub  = false
             local sub  = false
Zeile 341: Zeile 383:
             end
             end
         else
         else
             r = navError( "BadPage" ) .. currentTitle.text
             r = navError( "BadPage" ) .. CurrentTitle.text
         end
         end
     else
     else
Zeile 354: Zeile 396:
     -- Start execution; return navigation text; analyze namespace
     -- Start execution; return navigation text; analyze namespace
     -- Uses:
     -- Uses:
     --    >< currentTitle
     --    >< CurrentTitle
     --    LuaWiki.getArg()
     --    LuaWiki.getArg()
     --    mw.title.getCurrentTitle()
     --    mw.title.getCurrentTitle()
Zeile 362: Zeile 404:
     local nsDocs = LuaWiki.getArg( "nsDocs" )
     local nsDocs = LuaWiki.getArg( "nsDocs" )
     if nsDocs then
     if nsDocs then
         currentTitle = mw.title.getCurrentTitle()
         CurrentTitle = mw.title.getCurrentTitle()
         local ns  = currentTitle.namespace
         local ns  = CurrentTitle.namespace
         local lead = ( ns == mw.site.namespaces.Module.id )
         local lead = ( ns == mw.site.namespaces.Module.id )
         nsDocs = tonumber( nsDocs )
         nsDocs = tonumber( nsDocs )
Zeile 389: Zeile 431:
     local r
     local r
     if type( LuaWiki ) == "table" then
     if type( LuaWiki ) == "table" then
         local lucky
         Frame = frame
         lucky, r = pcall( navigation )
         Lucky, r = pcall( navigation )
         r = r or ""
         r = r or ""
     else
     else