Nicht angemeldeter Benutzer - Bearbeiten von Seiten ist nur als angemeldeter Benutzer möglich.

Änderungen

Zur Navigation springen Zur Suche springen
2.880 Bytes hinzugefügt ,  15:11, 6. Nov. 2019
2019-11-04, s. https://de.wikipedia.org/w/index.php?title=Wikipedia:Administratoren/Anfragen&curid=6974524&diff=193809804&oldid=193802072
Zeile 1: Zeile 1:  
local WLink = { suite  = "WLink",
 
local WLink = { suite  = "WLink",
                 serial = "2019-06-17",
+
                 serial = "2019-11-04",
 
                 item  = 19363224 };
 
                 item  = 19363224 };
 
--[=[
 
--[=[
Zeile 12: Zeile 12:  
getFragment()
 
getFragment()
 
getLanguage()
 
getLanguage()
 +
getLinktextProblem()
 
getNamespace()
 
getNamespace()
 
getNamespaced()
 
getNamespaced()
Zeile 43: Zeile 44:     
-- local globals
 
-- local globals
local URLutil = false;
+
local URLutil   = false;
 +
local Failsafe  = WLink;
 +
local GlobalMod = WLink;
          
local htmlInline = { b      = true,
 
local htmlInline = { b      = true,
 +
                    bdi    = true,
 +
                    bdo    = true,
 
                     big    = true,
 
                     big    = true,
 
                     code  = true,
 
                     code  = true,
Zeile 58: Zeile 63:  
                     span  = true,
 
                     span  = true,
 
                     strong = true,
 
                     strong = true,
 +
                    style  = true,
 
                     sub    = true,
 
                     sub    = true,
 
                     sup    = true,
 
                     sup    = true,
 
                     tt    = true,
 
                     tt    = true,
 
                     var    = true };
 
                     var    = true };
 +
 +
 +
 +
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 71: Zeile 130:  
     --    Throws error, if not available
 
     --    Throws error, if not available
 
     if not URLutil then
 
     if not URLutil then
         local lucky, util = pcall( require, "Module:URLutil" );
+
         local util = foreignModule( "URLutil", true, false, 10859193 );
         if lucky then
+
         if type( util ) == "table" then
            if type( util ) == "table" then
+
            URLutil = util.URLutil();
                URLutil = util.URLutil();
+
        else
            end
   
             util = "library URLutil invalid";
 
             util = "library URLutil invalid";
 
         end
 
         end
Zeile 418: Zeile 476:       −
function WLink.formatURL( adjust )
+
function WLink.formatURL( adjust, assure )
 
     -- Create bracketed link, if not yet
 
     -- Create bracketed link, if not yet
 
     -- Precondition:
 
     -- Precondition:
Zeile 663: Zeile 721:       −
function WLink.getNamespace( attempt )
+
function WLink.getLinktextProblem( attempt )
     -- Retrieve namespace number
+
     -- Which problem has this presumable link text?
 
     -- Precondition:
 
     -- Precondition:
     --    attempt  -- string, with wikilink or page title
+
     --    attempt  -- string, with presumable linktext
 
     -- Postcondition:
 
     -- Postcondition:
     --    Returns  number, of detected namespace
+
     --    Returns  string, with error message, or false
    --              false if no namespace found
+
     local r;
     local r = false;
+
     if attempt:find( "]", 1, true ) then
     local s, m = WLink.getTarget( attempt );
+
        r = "]";
     if m == 2 then
+
    elseif mw.text.unstrip( attempt ) ~= attempt then
        local w = WLink.wikilink( s );
+
        r = "<wiki>";
        if w and  not w.lang  and not w.project  and  w.ns then
+
     elseif attempt:find( "\n", 1, true ) then
             r = w.ns;
+
        r = "\n";
 +
    else
 +
        local i = attempt:find( "<", 1, true );
 +
        if i then
 +
            local s = mw.ustring.lower( attempt:sub( i ) );
 +
            local sign = true;
 +
            local skip;
 +
            while sign and  not r do
 +
                skip, sign = s:match( "^([^<]*< *)(%l[%l%d]*)[ /]*.*>" );
 +
                if sign then
 +
                    if htmlInline[ sign ] then
 +
                        i = skip:len() + sign:len() + 1;
 +
                        s = s:sub( i );
 +
                    else
 +
                        r = string.format( "&lt;%s&gt;", sign );
 +
                    end
 +
                end
 +
            end    -- while sign and not r
 +
        end
 +
        if not r then
 +
            local s = attempt .. " ";
 +
            if s:find( "ISBN ", 1, true ) then
 +
                r = s:match( "(ISBN %d[%-%d]+[%dxX])%W" );
 +
             end
 +
            if not r then
 +
                if s:find( "PMID ", 1, true ) then
 +
                    r = s:match( "(PMID [1-9]%d*)%W" );
 +
                end
 +
                if not r then
 +
                    if s:find( "RFC ", 1, true ) then
 +
                        r = s:match( "(RFC [1-9]%d?%d?%d?)%W" );
 +
                    end
 +
                end
 +
            end
 
         end
 
         end
 
     end
 
     end
     return r;
+
     return r or false;
end -- WLink.getNamespace()
+
end -- WLink.getLinktextProblem()
         −
function WLink.getNamespaced( area, attempt )
+
function WLink.getNamespace( attempt )
     -- Retrieve page in namespace
+
     -- Retrieve namespace number
 
     -- Precondition:
 
     -- Precondition:
     --    area    -- string or number, with some namespace spec
+
    --    attempt  -- string, with wikilink or page title
     --    attempt  -- string, with wikilink or page title or page name
+
    -- Postcondition:
 +
    --    Returns  number, of detected namespace
 +
    --              false if no namespace found
 +
    local r = false;
 +
    local s, m = WLink.getTarget( attempt );
 +
    if m == 2 then
 +
        local w = WLink.wikilink( s );
 +
        if w  and  not w.lang  and  not w.project  and  w.ns then
 +
            r = w.ns;
 +
        end
 +
    end
 +
    return r;
 +
end -- WLink.getNamespace()
 +
 
 +
 
 +
 
 +
function WLink.getNamespaced( area, attempt )
 +
    -- Retrieve page in namespace
 +
    -- Precondition:
 +
     --    area    -- string or number, with some namespace spec
 +
     --    attempt  -- string, with wikilink or page title or page name
 
     -- Postcondition:
 
     -- Postcondition:
 
     --    Returns  page prefixed by namespace,
 
     --    Returns  page prefixed by namespace,
Zeile 1.227: Zeile 1.338:  
     -- Postcondition:
 
     -- Postcondition:
 
     --    Returns  boolean
 
     --    Returns  boolean
     local r = true;
+
     local s;
     local i = attempt:find( "]", 1, true );
+
     if allow  and  s:find( "\n", 1, true ) then
    if i then
+
         s = attempt:gsub( "\n", " " );
         r = false;
   
     else
 
     else
         r = ( mw.text.unstrip( attempt ) == attempt );
+
         s = attempt;
 
     end
 
     end
     if r  and not allow  and  attempt:find( "\n", 1, true ) then
+
     return not WLink.getLinktextProblem( s );
        r = false;
+
end -- WLink.isValidLinktext()
    end
+
 
    if r then
  −
        i = attempt:find( "<", 1, true );
  −
        if i then
  −
            local s = mw.ustring.lower( attempt:sub( i ) );
  −
            local sign, skip;
  −
            while i and r do
  −
                skip, sign = s:match( "^([^<]*< *)(%l[%l%d]*)[ /]*.*>" );
  −
                if sign then
  −
                    r = htmlInline[ sign ];
  −
                    if r then
  −
                        i = skip:len() + sign:len() + 1;
  −
                        s = s:sub( i );
  −
                    end
  −
                else
  −
                    i = false;
  −
                end
  −
            end    -- while i and r
  −
        end
  −
    end
  −
    if r then
  −
        local s = attempt .. " ";
  −
        i = s:find( "ISBN ", 1, true );
  −
        if i then
  −
            r = not s:match( "ISBN %d[%-%d]+[%dxX]%W" );
  −
        end
  −
        if r then
  −
            i = s:find( "PMID ", 1, true );
  −
            if i then
  −
                r = not s:match( "PMID %d+%W" );
  −
            end
  −
            if r then
  −
                i = s:find( "RFC ", 1, true );
  −
                if i then
  −
                    r = not s:match( "RFC [1-6]%d?%d?%d?%W" );
  −
                end
  −
            end
  −
        end
  −
    end
  −
    return r or false;
  −
end -- WLink.isValidLinktext()
  −
 
        Zeile 1.424: Zeile 1.493:  
     --              false if nothing found
 
     --              false if nothing found
 
     local s = contentWikilink( attempt or "" );
 
     local s = contentWikilink( attempt or "" );
     local got, n, r;
+
     local got, i, n, r;
 
     if not s then
 
     if not s then
 
         s = attempt;
 
         s = attempt;
Zeile 1.509: Zeile 1.578:       −
function WLink.failsafe( assert )
+
Failsafe.failsafe = function ( atleast )
 
     -- Retrieve versioning and check for compliance
 
     -- Retrieve versioning and check for compliance
 
     -- Precondition:
 
     -- Precondition:
     --    assert -- string, with required version or "wikidata",
+
     --    atleast -- string, with required version or "wikidata" or "~"
     --               or false
+
     --                 or false
 
     -- Postcondition:
 
     -- Postcondition:
     --    Returns  string with appropriate version, or false
+
     --    Returns  string -- with queried version, also if problem
     local since = assert;
+
    --              false   -- if appropriate
 +
    local last  = ( atleast == "~" );
 +
     local since = atleast;
 
     local r;
 
     local r;
     if since == "wikidata" then
+
     if last  or  since == "wikidata" then
         local item = WLink.item;
+
         local item = Failsafe.item;
 
         since = false;
 
         since = false;
 
         if type( item ) == "number"  and  item > 0 then
 
         if type( item ) == "number"  and  item > 0 then
Zeile 1.529: Zeile 1.600:  
                   type( vsn.value ) == "string"  and
 
                   type( vsn.value ) == "string"  and
 
                   vsn.value ~= "" then
 
                   vsn.value ~= "" then
                     r = vsn.value;
+
                     if last  and  vsn.value == Failsafe.serial then
 +
                        r = false;
 +
                    else
 +
                        r = vsn.value;
 +
                    end
 
                 end
 
                 end
 
             end
 
             end
 
         end
 
         end
 
     end
 
     end
     if not r then
+
     if type( r ) == "nil" then
         if not since  or  since <= WLink.serial then
+
         if not since  or  since <= Failsafe.serial then
             r = WLink.serial;
+
             r = Failsafe.serial;
 
         else
 
         else
 
             r = false;
 
             r = false;
Zeile 1.542: Zeile 1.617:  
     end
 
     end
 
     return r;
 
     return r;
end -- WLink.failsafe()
+
end -- Failsafe.failsafe()
      Zeile 1.622: Zeile 1.697:     
p.ansiPercent = function ( frame )
 
p.ansiPercent = function ( frame )
     return Template( frame, "ansiPercent" );
+
     return Template( frame, "ansiPercent" );
end
+
end
p.formatURL = function ( frame )
+
p.formatURL = function ( frame )
     return Template( frame, "formatURL" );
+
     return Template( frame, "formatURL" );
end
+
end
p.getArticleBase = function ( frame )
+
p.getArticleBase = function ( frame )
     return Template( frame, "getArticleBase", false, true );
+
     return Template( frame, "getArticleBase", false, true );
end
+
end
p.getBaseTitle = function ( frame )
+
p.getBaseTitle = function ( frame )
     return Template( frame, "getBaseTitle" );
+
     return Template( frame, "getBaseTitle" );
end
+
end
p.getEscapedTitle = function ( frame )
+
p.getEscapedTitle = function ( frame )
     return Template( frame, "getEscapedTitle" );
+
     return Template( frame, "getEscapedTitle" );
end
+
end
p.getExtension = function ( frame )
+
p.getExtension = function ( frame )
     return Template( frame, "getExtension" );
+
     return Template( frame, "getExtension" );
end
+
end
p.getFile = function ( frame )
+
p.getFile = function ( frame )
     return Template( frame, "getFile" );
+
     return Template( frame, "getFile" );
end
+
end
p.getFragment = function ( frame )
+
p.getFragment = function ( frame )
     return Template( frame, "getFragment" );
+
     return Template( frame, "getFragment" );
 +
end
 +
p.getInterwiki = function ( frame )
 +
    return Template( frame, "getInterwiki" );
 +
end
 +
p.getLanguage = function ( frame )
 +
    return Template( frame, "getLanguage" );
 
end
 
end
p.getInterwiki = function ( frame )
+
p.getLinktextProblem = function ( frame )
     return Template( frame, "getInterwiki" );
+
     return Template( frame, "getLinktextProblem" );
end
  −
p.getLanguage = function ( frame )
  −
    return Template( frame, "getLanguage" );
   
end
 
end
 
p.getNamespace = function ( frame )
 
p.getNamespace = function ( frame )
Zeile 1.737: Zeile 1.815:  
         end
 
         end
 
     end
 
     end
     return WLink.failsafe( since ) or "";
+
     return Failsafe.failsafe( since ) or "";
end
+
end -- p.failsafe
 
p.WLink = function ()
 
p.WLink = function ()
 
     return WLink;
 
     return WLink;
Anonymer Benutzer
Cookies helfen uns bei der Bereitstellung von imedwiki. Durch die Nutzung von imedwiki erklärst du dich damit einverstanden, dass wir Cookies speichern.

Navigationsmenü