Modul:Wikipedia:GadgetsAll

Vorlagenprogrammierung Diskussionen Lua Unterseiten
Modul Deutsch

Modul: Dokumentation

Diese Seite enthält Code in der Programmiersprache Lua. Einbindungszahl Cirrus


--[==[
Generiere Liste für [[Wikipedia:Technik/Skin/Gadgets/!Alle Gadgets]]
]==]
local SkinGadgets = { seek    = "^/Skin/Gadgets/([^!].+)$",
                      slipped = "FEHLT @@@@@@@@@@@@@@@ FEHLT",
                      stack   = "Modul:PageTree/WP:Technik/bot",
                      start   = "Technik/Skin/Gadgets",
                      sub     = "Unterseite von" }



local function fill( all, add, frame )
    local s   = string.format( "%s/%s", SkinGadgets.start, add )
    local got = mw.title.makeTitle( 4, s )
    if got.exists then
        local dd  = mw.html.create( "dd" )
        local dt  = mw.html.create( "dt" )
        got = mw.message.new( "Gadget-" .. add )
        dt:wikitext( string.format( "[[../%s/]]", add ) )
        if got:exists() then
            s = got:plain()
            dd:wikitext( frame:preprocess( s ) )
        elseif add:find( "/", 1, true ) then
            s = add:match( "^([^/]+)/" )
            dd:wikitext( string.format( "''%s [[../%s/]]''",
                                        SkinGadgets.sub, s ) )
        else
            dd:addClass( "error" )
              :wikitext( SkinGadgets.slipped )
        end
        all:node( dt )
           :newline()
           :node( dd )
           :newline()
    end
end -- fill()



local function first( a1, a2 )                
    return mw.ustring.lower( a1 ) < mw.ustring.lower( a2 )
end -- first()



local function f( frame )
    local lucky, pages = pcall( mw.loadData, SkinGadgets.stack )
    local r, scream
    if type( pages ) == "table" then
        pages = pages.pages
        if type( pages ) == "table" then
            local gadgets = { }
            local s
            for k, v in pairs( pages ) do
                e = pages[ i ]
                if type( v ) == "string" then
                    s =  mw.ustring.match( v, SkinGadgets.seek )
                    if s then
                        table.insert( gadgets, s )
                    end
                end
            end -- for i
            if #gadgets > 0 then
                table.sort( gadgets, first )
                r = mw.html.create( "dl" )
                for i = 1, #gadgets do
                    fill( r, gadgets[ i ], frame )
                end -- for i
            else
                scream = "Komponente 'pages' leer"
            end
        else
            scream = "Komponente 'pages' fehlt in "
            scream = scream .. SkinGadgets.stack
        end
    else
        scream = pages
    end
    if scream then
        r = mw.html.create( "div" )
        r:addClass( "error" )
         :wikitext( scream )
    end
    return tostring( r )
end -- f()



-- Export
local p = { }
p.f = function ( frame )
    return f( frame )
end -- p.f

return p

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.