Modul:Vorlage:Anker: Unterschied zwischen den Versionen

2.098 Bytes hinzugefügt ,  26. Dezember 2019
2019-12-25
(2019-12-24)
(2019-12-25)
Zeile 1: Zeile 1:
local Anchor = { suite  = "AnchorTemplate",
local Anchor = { suite  = "AnchorTemplate",
                 serial  = "2019-12-24",
                 serial  = "2019-12-25",
                 item    = 79414611
                 item    = 79414611,
                globals = { TemplUtl = 52364930 }
               }
               }
--[=[
--[=[
Template:Anchor  {{Anker}}
Template:Anchor  {{Anker}}
]=]
]=]
local Failsafe = Anchor
local Failsafe   = Anchor
local GlobalMod  = Anchor






local Config = {
local Config = {
     badPattern    = "[%%#'\"%[%]<>]",
     badPattern    = "[%%#'\"%[%]<>|]",
     globalPage    = { "bodyContent",
     globalPage    = { "bodyContent",
                       "catlinks",
                       "catlinks",
Zeile 46: Zeile 48:
                       de = "Parameter unbekannt:" }
                       de = "Parameter unbekannt:" }
}
}
local foreignModule = function ( access, advanced, append, alt, alert )
    -- Fetch global module
    -- Precondition:
    --    access    -- string, with name of base module
    --    advanced  -- true, for require(); else mw.loadData()
    --    append    -- string, with subpage part, if any; or false
    --    alt      -- number, of wikidata item of root; or false
    --    alert    -- true, for throwing error on data problem
    -- Postcondition:
    --    Returns whatever, probably table
    -- 2019-10-29
    local storage = access
    local finer = function ()
                      if append then
                          storage = string.format( "%s/%s",
                                                  storage,
                                                  append )
                      end
                  end
    local fun, lucky, r, suited
    if advanced then
        fun = require
    else
        fun = mw.loadData
    end
    GlobalMod.globalModules = GlobalMod.globalModules or { }
    suited = GlobalMod.globalModules[ access ]
    if not suited then
        finer()
        lucky, r = pcall( fun,  "Module:" .. storage )
    end
    if not lucky then
        if not suited  and
          type( alt ) == "number"  and
          alt > 0 then
            suited = string.format( "Q%d", alt )
            suited = mw.wikibase.getSitelink( suited )
            GlobalMod.globalModules[ access ] = suited or true
        end
        if type( suited ) == "string" then
            storage = suited
            finer()
            lucky, r = pcall( fun, storage )
        end
        if not lucky and alert then
            error( "Missing or invalid page: " .. storage, 0 )
        end
    end
    return r
end -- foreignModule()




Zeile 124: Zeile 179:
     local scope = Config.errClass
     local scope = Config.errClass
     local story = factory( alert )
     local story = factory( alert )
     local lucky, TemplUtl = pcall( require, "Module:TemplUtl" )
     local TemplUtl = foreignModule( "TemplUtl",
                                    true,
                                    false,
                                    Anchor.globals.TemplUtl )
     local r, scope, style
     local r, scope, style
     if type( TemplUtl ) == "table" then
     if type( TemplUtl ) == "table"  and
      type( TemplUtl.TemplUtl ) == "function" then
         TemplUtl = TemplUtl.TemplUtl()
         TemplUtl = TemplUtl.TemplUtl()
    else
        TemplUtl = false
     end
     end
     if Config.self then
     if Config.self then
Zeile 143: Zeile 204:
         story = string.format( "%s %s", story, about )
         story = string.format( "%s %s", story, about )
     end
     end
     if type( TemplUtl ) == "table" then
     if TemplUtl then
         r = TemplUtl.failure( story,
         r = TemplUtl.failure( story,
                               not Config.errHide,
                               not Config.errHide,
Zeile 260: Zeile 321:
                 s = tocheck[ i ]
                 s = tocheck[ i ]
                 if s:match( "^%d" )  or
                 if s:match( "^%d" )  or
                  s:sub( 1, 1 ) == "-"  or
                   s:match( Config.badPattern )  or
                   s:match( Config.badPattern )  or
                   s:match( "&#%a+;" ) then
                   s:match( "&#%w+;" ) then
                     legal = false
                     legal = false
                 else
                 else
Anonymer Benutzer