gemeinsam neue Wege der Erkenntnis gehen
Eine freie Initiative von Menschen bei anthrowiki.at anthrowiki.at, anthro.world anthro.world, biodyn.wiki biodyn.wiki und steiner.wiki steiner.wiki
mit online Lesekreisen, Übungsgruppen, Vorträgen ...
Wie Sie die Entwicklung von AnthroWiki durch Ihre Spende unterstützen können, erfahren Sie hier.

Use Google Translate for a raw translation of our pages into more than 100 languages.
Please note that some mistranslations can occur due to machine translation.
Alle Banner auf einen Klick
Die Erbauung des Neuen Jerusalem in uns
Vortragsreihe rund um die «Apokalypse des Johannes» von Wolfgang Peter
Siebentes apokalyptisches Siegel
Das Neue Jerusalem

Jeden Dienstag live ab 19h. Die Vorträge sind frei zugänglich und können wenig später auch als Video, Audio und als transkripierter Text abgerufen werden.

Neuer Link: https://sichere-videokonferenz.de/Ahuameo6JnF5h (läuft ohne Zeitlimit auf einem deutschen Server mit der gewohnten Jitsi-Software). Wenn du "neu" bist, bitte kontaktiere Wolfgang oder François im Voraus über die dir bekannten Kontaktmöglichkeiten oder übers Kontaktformular. Um Störungen zu vermeiden: Bitte schalte das Mikrofon vor Eintreten stumm. Unser Miteinander ist persönlich- bitte mit Kamera und Vornamen einloggen.

Alternativ kannst du hier live im youtube schauen:
https://www.youtube.com/@AnthroWorld_Anthroposophie
Mehr Infos dazu auf auf anthro.world anthro.world
Der neue Glomer Katalog 2025/26 ist da!

Aktuelle Neuerscheinungen und alle lieferbaren Bücher anthroposophischer Verlage
Anthroposophie, Waldorf, Jugend & Kinderbücher, Gesundheit, Lebensphasen, Wissenschaften mit mehr als 7.500 Titeln aus über 80 Verlagen.


Modul:LuaWiki

Aus AnthroWiki

LuaWiki – Modul mit Funktionen zur Lua-Programmierung im Wiki-Projekt.

Funktionen für Vorlagen

Keine Nutzung in Vorlagen sinnvoll.


--[=[ 2013-05-07
LuaWiki - Support Lua programming in Wiki environment
* .getArg()
* .initVariables()
* .getVariable()
* .isExisting()
* .setFrame()
* .transclude()
]=]



-- Module globals
local wikiVariables
local LuaWiki = {}



LuaWiki.error = function ( about )
    -- Enclose errorMsg with <span>
    -- Precondition:
    --     about  -- string
    local r = about
    if type( about ) == "string" then
        if #about == 0 then
            r = "Error in Lua"
        end
    else
        r = tostring( about )
    end
    return "<span class='error'>" .. error( r, 3 ) .. "</span>"
end -- LuaWiki.error()



LuaWiki.getArg = function ( arg, assign )
    -- Retrieve template argument
    -- Precondition:
    --     arg     -- string or number; argument identifier
    --     assign  -- any, optional; default value
    -- Uses:
    --     mw.getCurrentFrame()
    local r = mw.getCurrentFrame().args[ arg ]
    if type( r ) ~= "string" then
        if type( assign ) == nil then
            r = "{{{<" .. arg .. ">}}}"
        else
            r = assign
        end
    end
    return r
end -- LuaWiki.getArg()



LuaWiki.getVariable = function ( seek, numeric )
    -- Retrieve item from wikiVariables; populate if not yet present
    -- Precondition:
    --     seek     -- string; name of variable
    --     numeric  -- true: seek is numeric (else string)
    -- Uses:
    --     >< wikiVariables
    --     mw.getCurrentFrame()
    local g, i, n
    local r = false
    if type( wikiVariables ) == "table" then
        n = #wikiVariables
        for i = 1, n do
            g = wikiVariables[ i ]
            if g then
                if g[ 1 ] == seek then
                    r = g[ 2 ]
                    break;
                end
            end
        end -- for i
    else
        wikiVariables = { }
        n = 0
    end
    if not r then
        g = mw.getCurrentFrame():preprocess( "{{" .. seek .. "}}" )
        r = mw.ustring.match( g, "^(.*)$" )
        if numeric then
            r = tonumber( g )
        end
        table.insert( wikiVariables,  n + 1,  { seek, r } )
    end
    return r
end -- LuaWiki.getVariable()



LuaWiki.initVariables = function ( request )
    -- Initialize wikiVariables
    -- Precondition:
    --     request  -- table; every element either
    --                        * string; name of variable
    --                        * table; name string and true, if numeric
    -- Uses:
    --      < wikiVariables
    --     mw.getCurrentFrame()
    local g, i, n, s
    local src = "|"
    wikiVariables = { }
    for i = 1, #request do
         s = request[ i ]
         if type( s ) == "table" then
             s = s[ 1 ]
         end
         src = src .. s .. "={{" .. s .. "}}|"
    end -- for i
    src = mw.getCurrentFrame():preprocess( src )
    for i = 1, #request do
        s = request[ i ]
        n = ( type( s ) == "table" )
        if n then
            n = s[ 2 ]
        end
        if n then
            g = "-?%d+"
            s = s[ 1 ]
        else
            g = "[^|]*"
        end
        g = mw.ustring.match( src,  "|" .. s .. "=(" .. g .. ")|" )
        if n then
            g = tonumber( g )
        end
        table.insert( wikiVariables,  i,  { s, g } )
    end -- for i
end -- LuaWiki.initVariables()



LuaWiki.isExisting = function ( seek )
    -- Return true if page exists, else false
    -- Precondition:
    --     seek  -- string; full page name
    -- Uses:
    --     mw.getCurrentFrame()
    local g = mw.getCurrentFrame():callParserFunction( "#ifexist",
                                                       { seek,
                                                         "1",
                                                         "0" } )
    return ( g == "1" )
end -- LuaWiki.isExisting()



LuaWiki.transclude = function ( s, args )
    -- Save transclusion of a page, or error message
    -- Precondition:
    --     s     -- string; page name
    --     args  -- table or nil; arguments
    -- Uses:
    --     mw.getCurrentFrame()
    --     error()
    local r = { s, "1" }
    local frame = mw.getCurrentFrame()
    if frame:callParserFunction( "#ifexist", r ) == "1" then
        if args then
            r = frame:expandTemplate{ title = s, args = args }
        else
            r = frame:expandTemplate{ title = s }
        end
    else
        r = error( "No transclude page '" .. s .. "'" )
    end
    return r
end -- LuaWiki.transclude()



return LuaWiki