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

Änderungen

Zur Navigation springen Zur Suche springen
739 Bytes hinzugefügt ,  00:09, 19. Sep. 2020
K
1 Version importiert: Import der Seite Biografiearbeit mit Vorlagen aus der deutschsprachigen Wikipedia
Zeile 1: Zeile 1:  
local URLutil = { suite  = "URLutil",
 
local URLutil = { suite  = "URLutil",
                   serial = "2019-05-19",
+
                   serial = "2020-07-01",
 
                   item  = 10859193 }
 
                   item  = 10859193 }
 
--[=[
 
--[=[
Zeile 45: Zeile 45:  
IPv6 URL (bracketed) not yet implemented; might need Wikintax escaping anyway.
 
IPv6 URL (bracketed) not yet implemented; might need Wikintax escaping anyway.
 
]=]
 
]=]
 +
local Failsafe  = URLutil
      Zeile 906: Zeile 907:  
         local s = URLutil.getAuthority( url )
 
         local s = URLutil.getAuthority( url )
 
         local pat = "[%[|%]" ..
 
         local pat = "[%[|%]" ..
                     mw.ustring.char( 8201, 45, 8207,
+
                     mw.ustring.char( 34,
 +
                                    8201, 45, 8207,
 
                                     8234, 45, 8239,
 
                                     8234, 45, 8239,
 
                                     8288 )
 
                                     8288 )
Zeile 961: Zeile 963:       −
function URLutil.failsafe( atleast )
+
Failsafe.failsafe = function ( atleast )
 
     -- Retrieve versioning and check for compliance
 
     -- Retrieve versioning and check for compliance
 
     -- Precondition:
 
     -- Precondition:
     --    atleast  -- 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
 +
    --              false   -- if appropriate
 +
    -- 2019-10-15
 +
    local last  = ( atleast == "~" )
 
     local since = atleast
 
     local since = atleast
 
     local r
 
     local r
     if since == "wikidata" then
+
     if last  or  since == "wikidata" then
         local item = URLutil.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
             local ent = mw.wikibase.getEntity( string.format( "Q%d",
+
             local entity = mw.wikibase.getEntity( string.format( "Q%d",
                                                              item ) )
+
                                                                item ) )
             if type( ent ) == "table" then
+
             if type( entity ) == "table" then
                 local vsn = ent:formatPropertyValues( "P348" )
+
                local seek = Failsafe.serialProperty or "P348"
 +
                 local vsn = entity:formatPropertyValues( seek )
 
                 if type( vsn ) == "table"  and
 
                 if type( vsn ) == "table"  and
                   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 <= URLutil.serial then
+
         if not since  or  since <= Failsafe.serial then
             r = URLutil.serial
+
             r = Failsafe.serial
 
         else
 
         else
 
             r = false
 
             r = false
Zeile 994: Zeile 1.004:  
     end
 
     end
 
     return r
 
     return r
end -- URLutil.failsafe()
+
end -- Failsafe.failsafe()
         −
-- Provide template access and expose URLutil table to require
+
local function Template( frame, action, amount )
 +
    -- Run actual code from template transclusion
 +
    -- Precondition:
 +
    --    frame  -- object
 +
    --    action  -- string, with function name
 +
    --    amount  -- number, of args if > 1
 +
    -- Postcondition:
 +
    --    Return string or not
 +
    local n = amount or 1
 +
    local v = { }
 +
    local r, s
 +
    for i = 1, n do
 +
        s = frame.args[ i ]
 +
        if s then
 +
            s = mw.text.trim( s )
 +
            if s ~= "" then
 +
                v[ i ] = s
 +
            end
 +
        end
 +
    end -- for i
 +
    if v[ 1 ] then
 +
        r = URLutil[ action ](  v[ 1 ], v[ 2 ], v[ 3 ] )
 +
    end
 +
    return r
 +
end -- Template()
 +
 
 +
 
    
local p = {}
 
local p = {}
    
function p.decode( frame )
 
function p.decode( frame )
     return URLutil.decode( frame.args[ 1 ]  or  "",
+
     return Template( frame, "decode", 2 ) or ""
                          frame.args[ 2 ] )
   
end
 
end
 
function p.encode( frame )
 
function p.encode( frame )
     return URLutil.encode( frame.args[ 1 ]  or  "",
+
     return Template( frame, "encode", 2 ) or ""
                          frame.args[ 2 ] )
   
end
 
end
 
function p.getAuthority( frame )
 
function p.getAuthority( frame )
     return URLutil.getAuthority( frame.args[ 1 ] ) or ""
+
     return Template( frame, "getAuthority" ) or ""
 
end
 
end
 
function p.getFragment( frame )
 
function p.getFragment( frame )
     local r = URLutil.getFragment( frame.args[ 1 ], frame.args[ 2 ] )
+
     local r = Template( frame, "getFragment", 2 )
 
     if r then
 
     if r then
 
         r = "#" .. r
 
         r = "#" .. r
Zeile 1.023: Zeile 1.057:  
end
 
end
 
function p.getHost( frame )
 
function p.getHost( frame )
     return URLutil.getHost( frame.args[ 1 ] ) or ""
+
     return Template( frame, "getHost" ) or ""
 
end
 
end
 
function p.getLocation( frame )
 
function p.getLocation( frame )
     return URLutil.getLocation( frame.args[ 1 ] ) or ""
+
     return Template( frame, "getLocation" ) or ""
 
end
 
end
 
function p.getNormalized( frame )
 
function p.getNormalized( frame )
     return URLutil.getNormalized( frame.args[ 1 ] ) or ""
+
     return Template( frame, "getNormalized" ) or ""
 
end
 
end
 
function p.getPath( frame )
 
function p.getPath( frame )
     return URLutil.getPath( frame.args[ 1 ] ) or ""
+
     return Template( frame, "getPath" ) or ""
 
end
 
end
 
function p.getPort( frame )
 
function p.getPort( frame )
     return URLutil.getPort( frame.args[ 1 ] ) or ""
+
     return Template( frame, "getPort" ) or ""
 
end
 
end
 
function p.getQuery( frame )
 
function p.getQuery( frame )
     local r
+
     local r = Template( frame, "getQuery", 3 )
     local key = frame.args[ 2 ]
+
     if r then
    if key then
+
        local key = frame.args[ 2 ]
        key = mw.text.trim( key )
+
        if key then
        if key == "" then
+
            key = mw.text.trim( key )
            key = nil
+
            if key == "" then
 +
                key = nil
 +
            end
 
         end
 
         end
    end
  −
    r = URLutil.getQuery( frame.args[ 1 ], key, frame.args[ 3 ] )
  −
    if r then
   
         if not key then
 
         if not key then
 
             r = "?" .. r
 
             r = "?" .. r
Zeile 1.057: Zeile 1.090:  
end
 
end
 
function p.getRelativePath( frame )
 
function p.getRelativePath( frame )
     return URLutil.getRelativePath( frame.args[ 1 ] ) or ""
+
     return Template( frame, "getRelativePath" ) or ""
 
end
 
end
 
function p.getScheme( frame )
 
function p.getScheme( frame )
     return URLutil.getScheme( frame.args[ 1 ] ) or ""
+
     return Template( frame, "getScheme" ) or ""
 
end
 
end
 
function p.getSortkey( frame )
 
function p.getSortkey( frame )
     return URLutil.getSortkey( frame.args[ 1 ] ) or ""
+
     return Template( frame, "getSortkey" ) or ""
 
end
 
end
 
function p.getTLD( frame )
 
function p.getTLD( frame )
     return URLutil.getTLD( frame.args[ 1 ] ) or ""
+
     return Template( frame, "getTLD" ) or ""
 
end
 
end
 
function p.getTop2domain( frame )
 
function p.getTop2domain( frame )
     return URLutil.getTop2domain( frame.args[ 1 ] ) or ""
+
     return Template( frame, "getTop2domain" ) or ""
 
end
 
end
 
function p.getTop3domain( frame )
 
function p.getTop3domain( frame )
     return URLutil.getTop3domain( frame.args[ 1 ] ) or ""
+
     return Template( frame, "getTop3domain" ) or ""
 
end
 
end
 
function p.isAuthority( frame )
 
function p.isAuthority( frame )
     return URLutil.isAuthority( frame.args[ 1 ] ) and "1" or ""
+
     return Template( frame, "isAuthority" ) and "1" or ""
 
end
 
end
 
function p.isDomain( frame )
 
function p.isDomain( frame )
     return URLutil.isDomain( frame.args[ 1 ] ) and "1" or ""
+
     return Template( frame, "isDomain" ) and "1" or ""
 
end
 
end
 
function p.isDomainExample( frame )
 
function p.isDomainExample( frame )
     return URLutil.isDomainExample( frame.args[ 1 ] ) and "1" or ""
+
     return Template( frame, "isDomainExample" ) and "1" or ""
 
end
 
end
 
function p.isDomainInt( frame )
 
function p.isDomainInt( frame )
     return URLutil.isDomainInt( frame.args[ 1 ] ) and "1" or ""
+
     return Template( frame, "isDomainInt" ) and "1" or ""
 
end
 
end
 
function p.isHost( frame )
 
function p.isHost( frame )
     return URLutil.isHost( frame.args[ 1 ] ) and "1" or ""
+
     return Template( frame, "isHost" ) and "1" or ""
 
end
 
end
 
function p.isHostPathResource( frame )
 
function p.isHostPathResource( frame )
     return URLutil.isHostPathResource( frame.args[ 1 ] ) and "1" or ""
+
     return Template( frame, "isHostPathResource" ) and "1" or ""
 
end
 
end
 
function p.isIP( frame )
 
function p.isIP( frame )
     return URLutil.isIP( frame.args[ 1 ] ) or ""
+
     return Template( frame, "isIP" ) or ""
 
end
 
end
 
function p.isIPlocal( frame )
 
function p.isIPlocal( frame )
     return URLutil.isIPlocal( frame.args[ 1 ] ) and "1" or ""
+
     return Template( frame, "isIPlocal" ) and "1" or ""
 
end
 
end
 
function p.isIPv4( frame )
 
function p.isIPv4( frame )
     return URLutil.isIPv4( frame.args[ 1 ] ) and "1" or ""
+
     return Template( frame, "isIPv4" ) and "1" or ""
 
end
 
end
 
function p.isIPv6( frame )
 
function p.isIPv6( frame )
     return URLutil.isIPv6( frame.args[ 1 ] ) and "1" or ""
+
     return Template( frame, "isIPv6" ) and "1" or ""
 
end
 
end
 
function p.isMailAddress( frame )
 
function p.isMailAddress( frame )
     return URLutil.isMailAddress( frame.args[ 1 ] ) and "1" or ""
+
     return Template( frame, "isMailAddress" ) and "1" or ""
 
end
 
end
 
function p.isMailLink( frame )
 
function p.isMailLink( frame )
     return URLutil.isMailLink( frame.args[ 1 ] ) and "1" or ""
+
     return Template( frame, "isMailLink" ) and "1" or ""
 
end
 
end
 
function p.isProtocolDialog( frame )
 
function p.isProtocolDialog( frame )
     return URLutil.isProtocolDialog( frame.args[ 1 ] ) and "1" or ""
+
     return Template( frame, "isProtocolDialog" ) and "1" or ""
 
end
 
end
 
function p.isProtocolWiki( frame )
 
function p.isProtocolWiki( frame )
     return URLutil.isProtocolWiki( frame.args[ 1 ] ) and "1" or ""
+
     return Template( frame, "isProtocolWiki" ) and "1" or ""
 
end
 
end
 
function p.isResourceURL( frame )
 
function p.isResourceURL( frame )
     return URLutil.isResourceURL( frame.args[ 1 ] ) and "1" or ""
+
     return Template( frame, "isResourceURL" ) and "1" or ""
 
end
 
end
 
function p.isSuspiciousURL( frame )
 
function p.isSuspiciousURL( frame )
     return URLutil.isSuspiciousURL( frame.args[ 1 ] ) and "1" or ""
+
     return Template( frame, "isSuspiciousURL" ) and "1" or ""
 
end
 
end
 
function p.isUnescapedURL( frame )
 
function p.isUnescapedURL( frame )
     return URLutil.isUnescapedURL( frame.args[ 1 ], frame.args[ 2 ] ) and "1" or ""
+
     return Template( frame, "isUnescapedURL", 2 ) and "1" or ""
 
end
 
end
 
function p.isWebURL( frame )
 
function p.isWebURL( frame )
     return URLutil.isWebURL( frame.args[ 1 ] ) and "1" or ""
+
     return Template( frame, "isWebURL" ) and "1" or ""
 
end
 
end
 
function p.wikiEscapeURL( frame )
 
function p.wikiEscapeURL( frame )
     return URLutil.wikiEscapeURL( frame.args[ 1 ] )
+
     return Template( frame, "wikiEscapeURL" )
 
end
 
end
 
p.failsafe = function ( frame )
 
p.failsafe = function ( frame )
Zeile 1.145: Zeile 1.178:  
         end
 
         end
 
     end
 
     end
     return URLutil.failsafe( since ) or ""
+
     return Failsafe.failsafe( since ) or ""
 
end
 
end
 
function p.URLutil()
 
function p.URLutil()
Cookies helfen uns bei der Bereitstellung von imedwiki. Durch die Nutzung von imedwiki erklärst du dich damit einverstanden, dass wir Cookies speichern.

Navigationsmenü