Modul:Vorlage:LuaModuleDoc: Unterschied zwischen den Versionen

update
(update)
(update)
Zeile 1: Zeile 1:
--[=[ 2013-05-10
--[=[ 2013-05-13
Support {{LuaModuleDoc}}
Support {{LuaModuleDoc}}
* nav()
* nav()
Zeile 21: Zeile 21:
     --    LuaWiki.getArg()
     --    LuaWiki.getArg()
     --    LuaWiki.transclude()
     --    LuaWiki.transclude()
    --    LuaWiki.error()
     local show = LuaWiki.getArg( "pageErr" )
     local show = LuaWiki.getArg( "pageErr" )
     local r
     local r
Zeile 30: Zeile 31:
         r = LuaWiki.transclude( show, pars )
         r = LuaWiki.transclude( show, pars )
     else
     else
         r = "<span class='error'>arg 'pageErr' missing</span>"
         r = LuaWiki.error( "arg 'pageErr' missing" )
     end
     end
     return r
     return r
Zeile 61: Zeile 62:
     --    navError()
     --    navError()
     local r = LuaWiki.transclude( swift, collect )
     local r = LuaWiki.transclude( swift, collect )
     local s = false
     local s = false
     local t = currentTitle.talkPageTitle
     local t = currentTitle.talkPageTitle
     if t then
     if t then
         s = t.exists
         s = t.exists
     end
     end
    r = "<!-- LuaModuleDoc::b -->" .. r .. "<!-- LuaModuleDoc::e -->"
     if not s then
     if not s then
         if super then
         if super then
Zeile 83: Zeile 85:
             s = super .. collect[ i ]
             s = super .. collect[ i ]
             if LuaWiki.isExisting( s ) then
             if LuaWiki.isExisting( s ) then
                 r   = r .. LuaWiki.transclude( s )
                s = LuaWiki.transclude( s )
                 r = r .. s:gsub( "<!-- LuaModuleDoc::b -->.*<!-- LuaModuleDoc::e -->", "" )
                 break
                 break
             end
             end
Zeile 96: Zeile 99:
         s = LuaWiki.getArg( "categoryDocs", "" )
         s = LuaWiki.getArg( "categoryDocs", "" )
         if #s > 0 then
         if #s > 0 then
             s = "Category:" .. s
             i = mw.title.makeTitle( "Category", s )
             if LuaWiki.isExisting( s ) then
             if i.exists then
                 r = r .. "[[" .. s .. "|" .. collect[ 1 ] .. "]]"
                 r = r .. "[[" .. i.prefixedText
                      .. "|" .. collect[ 1 ] .. "]]"
             end
             end
         end
         end
Zeile 142: Zeile 146:




local function navLangs( script, super )
local function navLangs( space, start, script )
     -- Analyze languages
     -- Analyze languages
     -- Precondition:
     -- Precondition:
     --    current page is supposed to transclude LuaModuleDoc
     --    current page is supposed to transclude LuaModuleDoc
    --    space  -- string; central documentation namespace
    --    start  -- string; central documentation root
     --    script  -- string; basic module name
     --    script  -- string; basic module name
    --    super  -- string; central documentation root
     -- Return:
     -- Return:
     --    table:  args for navigation template
     --    table:  args for navigation template
Zeile 158: Zeile 163:
     --    LuaWiki.getArg()
     --    LuaWiki.getArg()
     --    navLang()
     --    navLang()
    --    LuaWiki.isExisting()
     --    navError()
     --    navError()
     local e, i, s
     local e, i, s, t
     local r = { }
     local r = { }
     local specified = LuaWiki.getArg( "langsRequest", false )
     local specified = LuaWiki.getArg( "langsRequest", false )
    local super    = start .. "/" .. script .. "/"
     if type( specified ) == "string" then
     if type( specified ) == "string" then
         if specified:match( "^%s*$" ) then
         if specified:match( "^%s*$" ) then
Zeile 168: Zeile 173:
         end
         end
     end
     end
     navLang( LuaWiki.getArg( "langsDefault" ),
     navLang( LuaWiki.getArg( "langsDefault" ), r, specified )
            r,
            specified )
     navLang( specified, r, false )
     navLang( specified, r, false )
     if #r < 1 then
     if #r < 1 then
Zeile 179: Zeile 182:
         s = e[ 1 ]
         s = e[ 1 ]
         if e[ 2 ] then
         if e[ 2 ] then
             if not LuaWiki.isExisting( super .. "/" .. s ) then
             t = mw.title.makeTitle( space,  super .. s )
            if not t.exists then
                 s = false
                 s = false
             end
             end
Zeile 204: Zeile 208:
     --    nsDocs  -- number; namespace for doc
     --    nsDocs  -- number; namespace for doc
     -- Uses:
     -- Uses:
    --    >< currentTitle
     --    LuaWiki.getArg()
     --    LuaWiki.getArg()
     --    navError()
     --    navError()
Zeile 212: Zeile 217:
     if type( start ) == "string" then
     if type( start ) == "string" then
         local light  = false
         local light  = false
        local story  = currentTitle.text .. "/"
         local script
         local script
        local story  = currentTitle.text .. "/"
         if lead then
         if lead then
            -- any template transclusion happens on a doc page
             script = currentTitle.baseText
             script = mw.ustring.match( story, "^([^/]+)/" )
         else
         else
             local sub = "/([^/]+)/(.*)$"
             local sub = "/([^/]+)/(.*)$"
             script, sub = mw.ustring.match( story, "^" .. start .. sub )
             script, sub = mw.ustring.match( story,
                                            "^" .. start .. sub )
             if type( script ) == "string" then
             if type( script ) == "string" then
                 light = ( #sub > 0 )
                 light = ( #sub > 0 )
Zeile 231: Zeile 236:
             if type( swift ) == "string" then
             if type( swift ) == "string" then
                 -- nsDocs is valid, since it equals ns
                 -- nsDocs is valid, since it equals ns
                 local super = mw.site.namespaces[ nsDocs ].name
                 local space = mw.site.namespaces[ nsDocs ].name
                 super = super .. ":" .. start
                 local super
                 local collect = navLangs( script, super )
                 local collect = navLangs( space, start, script )
                 if ns == nsDocs and
                 if ns == nsDocs and
                   story == start .. "/" .. script .. "/" then
                   story == start .. "/" .. script .. "/" then
                     super = super .. "/" .. script .. "/"
                     super = space .. ":" .. start .. "/" .. script .. "/"
                 else
                 else
                     super = false
                     super = false
Anonymer Benutzer