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

Änderungen

Zur Navigation springen Zur Suche springen
11.207 Bytes hinzugefügt ,  03:40, 8. Feb. 2022
Links to ISBN and ISSN to wikipedia
Zeile 1: Zeile 1:  
local URIutil = { suite  = "URIutil",
 
local URIutil = { suite  = "URIutil",
                   serial = "2016-03-24" };
+
                   serial = "2020-05-09",
 +
                  item  = 19644443 };
 
--[=[
 
--[=[
 
Utilities for URI etc.
 
Utilities for URI etc.
Zeile 22: Zeile 23:  
* linkISSN()
 
* linkISSN()
 
* linkLCCN()
 
* linkLCCN()
 +
* linkPMID()
 
* linkURN()
 
* linkURN()
 
* mayDOI()
 
* mayDOI()
Zeile 31: Zeile 33:  
* mayURN()
 
* mayURN()
 
* plainISBN()
 
* plainISBN()
 +
* targetISSN()
 
* uriDOI()
 
* uriDOI()
 
* uriHandle()
 
* uriHandle()
Zeile 38: Zeile 41:  
loadData: URIutil/config URIutil/isbn URIutil/urn
 
loadData: URIutil/config URIutil/isbn URIutil/urn
 
]=]
 
]=]
 +
local Failsafe = URIutil
 +
local CurrentPageName
      Zeile 152: Zeile 157:       −
local function fault( alert )
+
local fault = function ( alert )
 
     -- Format error message by class=error
 
     -- Format error message by class=error
 
     -- Parameter:
 
     -- Parameter:
Zeile 158: Zeile 163:  
     -- Returns:
 
     -- Returns:
 
     --    string, HTML span
 
     --    string, HTML span
     return string.format( "<span class=\"error\">%s</span>", alert );
+
     return tostring( mw.html.create( "span" )
 +
                            :addClass( "error" )
 +
                            :wikitext( alert ) );
 
end -- fault()
 
end -- fault()
   Zeile 179: Zeile 186:  
     end
 
     end
 
     if not r then
 
     if not r then
         local lucky;
+
         local lucky, storage;
         lucky, r = pcall( mw.loadData,  "Module:URIutil/" .. acquire );
+
        storage = "Module:URIutil/" .. acquire;
 +
         lucky, r = pcall( mw.loadData, storage );
 +
        if not lucky then
 +
            if not URIutil.suited and
 +
              type( URIutil.item ) == "number" then
 +
                local suited = string.format( "Q%d", URIutil.item );
 +
                URIutil.suited = mw.wikibase.getSitelink( suited )
 +
                                or  true;
 +
            end
 +
            if type( URIutil.suited ) == "string" then
 +
                storage = string.format( "%s/%s",
 +
                                        URIutil.suited, acquire );
 +
                lucky, r = pcall( mw.loadData, storage );
 +
            end
 +
        end
 
         if type( r ) ~= "table" then
 
         if type( r ) ~= "table" then
 
             r = { };
 
             r = { };
Zeile 198: Zeile 219:  
     --    Returns  link, or false
 
     --    Returns  link, or false
 
     local r;
 
     local r;
     if type( alert ) == "string"  and  alert ~= "" then
+
     if type( alert ) == "string"  and
 +
      alert ~= "-" and
 +
      alert ~= "" then
 
         r = string.format( "[[Category:%s]]", alert );
 
         r = string.format( "[[Category:%s]]", alert );
 
     end
 
     end
Zeile 226: Zeile 249:  
     return r;
 
     return r;
 
end -- format()
 
end -- format()
 +
 +
 +
 +
local fullPageName = function ()
 +
    -- Retrieve current page name
 +
    -- Postcondition:
 +
    --    Returns  string: current page name
 +
    if not CurrentPageName then
 +
        CurrentPageName = mw.title.getCurrentTitle().fullText;
 +
    end
 +
    return CurrentPageName;
 +
end -- fullPageName()
      Zeile 263: Zeile 298:  
             lead = false;
 
             lead = false;
 
         else    -- even
 
         else    -- even
             r = r + k + k;
+
             r   = r + k + k;
 
             lead = true;
 
             lead = true;
 
         end
 
         end
Zeile 302: Zeile 337:  
     local r;
 
     local r;
 
     if type( attempt ) == "string" then
 
     if type( attempt ) == "string" then
 +
        local s;
 
         r = factory( attempt, 10 );
 
         r = factory( attempt, 10 );
         if type( r ) == "table" then
+
        s = type( r );
 +
         if s == "number"  and  r ~= 10  and  r > 6  and  r < 13 then
 +
            r = factory( attempt, r );
 +
            s = type( r );
 +
        end
 +
        if s == "table" then
 
             if r.type == 13 then
 
             if r.type == 13 then
 
                 if r[1] ~= 9  or
 
                 if r[1] ~= 9  or
Zeile 435: Zeile 476:  
     else
 
     else
 
         k = 2;
 
         k = 2;
         if assigned[ j + 1 ] > 4 then
+
         if assigned[ j ] == 9  and
 +
          assigned[ j + 1 ] > 4 then
 
             k = 3;
 
             k = 3;
 
             if assigned[ j + 1 ] > 8 then
 
             if assigned[ j + 1 ] > 8 then
 
                 k = 4;
 
                 k = 4;
 
                 if assigned[ j + 2 ] > 8 then
 
                 if assigned[ j + 2 ] > 8 then
                     k = false;   -- invalid
+
                     k = 5;
 
                 end
 
                 end
 
             end
 
             end
Zeile 517: Zeile 559:  
     local r;
 
     local r;
 
     if assert.type == 8 then
 
     if assert.type == 8 then
         r = ( fair( assert )  ==  assert[ 8 ] );
+
         local k = fair( assert );
 +
        if k == 11 then
 +
            r = ( assert[ 8 ] ==  0 );
 +
        else
 +
            r = ( assert[ 8 ] ==  k );
 +
        end
 
     elseif assert.type == 13 then
 
     elseif assert.type == 13 then
 
         r = GTINfaith( assert );
 
         r = GTINfaith( assert );
Zeile 721: Zeile 768:  
                 s = r;
 
                 s = r;
 
             end
 
             end
             r = string.format( "[http://lccn.loc.gov/%s %s]", r, s );
+
             r = string.format( "[https://lccn.loc.gov/%s %s]", r, s );
 
         end
 
         end
 
     else
 
     else
Zeile 739: Zeile 786:  
     --    Returns  false if no problem detected
 
     --    Returns  false if no problem detected
 
     --              string with violation
 
     --              string with violation
    local s = fetch( "urn" ).sns;
   
     local r;
 
     local r;
     if type( s ) == "string" then
+
     if area == "urn" then
        r = string.format( ":%s:", area );
+
        r = "urn:";
        if s:match( r ) then
+
    else
            s = "[^%w%(%)%+,%-%.:=@;%$_!%*'].*$";
+
        local s = fetch( "urn" ).sns;
            r = acquire:match( s );
+
        if type( s ) == "string" then
        else
+
            r = string.format( ":%s:", area );
            r = string.format( "&#58;%s:", area );
+
            if s:match( r ) then
        end
+
                s = "[^%w%(%)%+,%-%.:=/@;%$_!%*'].*$";
        if not r then
+
                r = acquire:match( s );
            r = false;
+
            else
            if area == "isbn" then
+
                r = string.format( "&#58;%s:", area );
                if not URIutil.isISBNvalid( acquire ) then
+
            end
                    r = acquire;
+
            if not r then
                end
+
                r = false;
            elseif area == "issn" then
+
                if area == "isbn" then
                if not URIutil.isISSNvalid( acquire ) then
+
                    if not URIutil.isISBNvalid( acquire ) then
                    r = acquire;
+
                        r = acquire;
 +
                    end
 +
                elseif area == "issn" then
 +
                    if not URIutil.isISSNvalid( acquire ) then
 +
                        r = acquire;
 +
                    end
 
                 end
 
                 end
 
             end
 
             end
Zeile 906: Zeile 957:  
     --    attempt  -- string with any presumable DNB code
 
     --    attempt  -- string with any presumable DNB code
 
     --    also    -- string or nil; optional requirement DMA GND SWD
 
     --    also    -- string or nil; optional requirement DMA GND SWD
     --                currently not implemented
+
     --                "ZDB"  -- permit hyphen, but use >2011 rule
 
     --                DMA starting with 3 and no hyphen
 
     --                DMA starting with 3 and no hyphen
 
     --                GND not DNB2011
 
     --                GND not DNB2011
Zeile 913: Zeile 964:  
     --    Returns  number of digits or 2011, if valid
 
     --    Returns  number of digits or 2011, if valid
 
     --              false if not correct, bad data or check digit wrong
 
     --              false if not correct, bad data or check digit wrong
    -- 2013-09-01
   
     local s = mw.text.trim( attempt );
 
     local s = mw.text.trim( attempt );
 
     local j = s:find( "/", 5, true );
 
     local j = s:find( "/", 5, true );
Zeile 925: Zeile 975:  
         if j > 3  and  j <= 8 then
 
         if j > 3  and  j <= 8 then
 
             if s:match( "^[0-9]+-[0-9xX]$" ) then
 
             if s:match( "^[0-9]+-[0-9xX]$" ) then
                 dnb = factory( s, #s );
+
                 dnb = factory( s, true );
 
             end
 
             end
 
         end
 
         end
     elseif #s > 7 then
+
     elseif #s > 6 then
 
         if s:match( "^[0-9]+[0-9xX]$" ) then
 
         if s:match( "^[0-9]+[0-9xX]$" ) then
 
             dnb = factory( s, #s );
 
             dnb = factory( s, #s );
Zeile 937: Zeile 987:  
             if DNBfaith( dnb, true ) then
 
             if DNBfaith( dnb, true ) then
 
                 r = 2011;
 
                 r = 2011;
 +
            elseif type( also ) == "string" then
 +
                s = mw.text.trim( also );
 +
                if s == "ZDB" then
 +
                    if DNBfaith( dnb, false ) then
 +
                        r = dnb.type;
 +
                    end
 +
                end
 
             end
 
             end
 
         else
 
         else
 
             if DNBfaith( dnb, false ) then
 
             if DNBfaith( dnb, false ) then
 
                 r = dnb.type;
 
                 r = dnb.type;
 +
            elseif type( also ) == "string" then
 +
                s = mw.text.trim( also );
 +
                if s == "ZDB" then
 +
                    if DNBfaith( dnb, true ) then
 +
                        r = dnb.type;
 +
                    end
 +
                end
 
             end
 
             end
 
         end
 
         end
Zeile 962: Zeile 1.026:  
         if k >= 1000  and  k < 100000000 then
 
         if k >= 1000  and  k < 100000000 then
 
             local pc = "^[0-9A-Za-z%(%[<%./]"
 
             local pc = "^[0-9A-Za-z%(%[<%./]"
                       .. "[%-0-9/A-Z%.a-z%(%)_%[%];:<>%+]*"
+
                       .. "[%-0-9/A-Z%.a-z%(%)_%[%];,:<>%+]*"
 
                       .. "[0-9A-Za-z%)%]>%+#]$"
 
                       .. "[0-9A-Za-z%)%]>%+#]$"
 
             s = mw.uri.decode( mw.text.decode( s ), "PATH" );
 
             s = mw.uri.decode( mw.text.decode( s ), "PATH" );
Zeile 1.074: Zeile 1.138:  
     --              false if not an ISBN
 
     --              false if not an ISBN
 
     --        2  -- internal table, if (1)
 
     --        2  -- internal table, if (1)
 +
    --              number; no string or bad length or data
 +
    --                      0  -- no string
 +
    --                      >0  -- unexpected char at position (trimmed)
 +
    --                      -1  -- bad digit count
 +
    --                      -2  -- bad bookland
 
     local r;
 
     local r;
 
     local isbn = ISBNfactory( attempt );
 
     local isbn = ISBNfactory( attempt );
Zeile 1.096: Zeile 1.165:  
     --              false if not correct, bad data or check digit wrong
 
     --              false if not correct, bad data or check digit wrong
 
     --        2  -- internal table, if (1)
 
     --        2  -- internal table, if (1)
 +
    --              number; no string or bad length or data
 +
    --                      0  -- no string
 +
    --                      >0  -- unexpected char at position (trimmed)
 +
    --                      -1  -- bad digit count
 +
    --                      -2  -- bad bookland
 
     local r    = false;
 
     local r    = false;
 
     local isbn = ISBNfactory( attempt );
 
     local isbn = ISBNfactory( attempt );
Zeile 1.146: Zeile 1.220:       −
function URIutil.linkDNBopac( attempt, about, any1, any2, alert )
+
function URIutil.linkDNBopac( attempt, about, allow, abbr, alert )
 
     -- Retrieve bracketed titled external DNB opac link
 
     -- Retrieve bracketed titled external DNB opac link
 
     -- Precondition:
 
     -- Precondition:
 
     --    attempt  -- string with presumable DNB ID
 
     --    attempt  -- string with presumable DNB ID
 
     --    about    -- title, or false
 
     --    about    -- title, or false
     --    any1    -- intentionally dummy parameter
+
     --    allow    -- true: permit invalid ID
     --    any2     -- intentionally dummy parameter
+
     --    abbr     -- true: link DNB abbreviation
 
     --    alert    -- string with title of maintenance category, or nil
 
     --    alert    -- string with title of maintenance category, or nil
 
     -- Postcondition:
 
     -- Postcondition:
     --    Returns  link, or false if bad DNB
+
     --    Returns  link, or plain string if bad DNB
     local r = URIutil.isDNBvalid( attempt );
+
     local r = allow  or  URIutil.isDNBvalid( attempt );
 +
    local s = "DNB";
 +
    if abbr  and  not about then
 +
        local cnf = fetch( "config" );
 +
        if cnf.supportDNB  and  cnf.supportDNB ~= fullPageName() then
 +
            s = string.format( "[[%s|DNB]]", cnf.supportDNB );
 +
        end
 +
    end
 
     if r then
 
     if r then
        local s = about;
   
         if about then
 
         if about then
             s = about;
+
             r = about;
 
         else
 
         else
             s = "DNB&nbsp;" .. attempt;
+
             r = attempt;
 
         end
 
         end
         r = string.format( "[%s%s%s %s]",
+
         r = string.format( "%s&nbsp;[%s%s%s%s%s %s]",
                           "//portal.dnb.de/",
+
                          s,
                           "opac.htm?method=simpleSearch&query=",
+
                           "https://portal.dnb.de/opac.htm",
                           r,
+
                           "?referrer=Wikipedia",
                           s );
+
                          "&method=simpleSearch&cqlMode=true",
 +
                          "&query=idn%3D",
 +
                           attempt,
 +
                           r );
 
     else
 
     else
         r = flop( alert );
+
         r = string.format( "%s&nbsp;%s", s, attempt );
 +
        if about then
 +
            r = string.format( "%s %s", r, about );
 +
        end
 +
        if alert then
 +
            r = r .. flop( alert );
 +
        end
 
     end
 
     end
 
     return r;
 
     return r;
Zeile 1.189: Zeile 1.278:  
     local r = URIutil.isDOI( attempt );
 
     local r = URIutil.isDOI( attempt );
 
     if r then
 
     if r then
         r = mw.text.decode( mw.text.trim( attempt ), "PATH" );
+
         local e = mw.html.create( "span" )
         r = string.format( "[%s%s %s]",
+
                        :addClass( "uri-handle" );
                           "https://dx.doi.org/",
+
        local s;
 +
        s, r = attempt:match( "^%s*(10%.[1-9][0-9]+/)(.+)%s*$" );
 +
        r = mw.text.decode( r, "PATH" );
 +
         r = string.format( "[%s/%s%s %s%s]",
 +
                           "https://doi.org",
 +
                          s,
 
                           mw.uri.encode( r ),
 
                           mw.uri.encode( r ),
 +
                          s,
 
                           mw.text.encode( r, "<>&%]" ) );
 
                           mw.text.encode( r, "<>&%]" ) );
         r = string.format( "<span class='uri-handle'>%s</span>",  r );
+
         r = tostring( e:wikitext( r ) );
 
     else
 
     else
 
         r = flop( alert );
 
         r = flop( alert );
Zeile 1.215: Zeile 1.310:  
     local r = URIutil.isHandle( attempt );
 
     local r = URIutil.isHandle( attempt );
 
     if r then
 
     if r then
 +
        local e = mw.html.create( "span" )
 +
                        :addClass( "uri-handle" );
 
         r = mw.text.decode( mw.text.trim( attempt ),  "PATH" );
 
         r = mw.text.decode( mw.text.trim( attempt ),  "PATH" );
 
         r = string.format( "[%s%s %s]",
 
         r = string.format( "[%s%s %s]",
Zeile 1.220: Zeile 1.317:  
                           mw.uri.encode( r ),
 
                           mw.uri.encode( r ),
 
                           mw.text.encode( r, "<>&%]" ) );
 
                           mw.text.encode( r, "<>&%]" ) );
         r = string.format( "<span class='uri-handle'>%s</span>",  r );
+
         r = tostring( e:wikitext( r ) );
 
     else
 
     else
 
         r = flop( alert );
 
         r = flop( alert );
Zeile 1.233: Zeile 1.330:  
     -- Precondition:
 
     -- Precondition:
 
     --    attempt  -- string with presumable ISBN
 
     --    attempt  -- string with presumable ISBN
     --    allow    -- true: permit invalid check digit
+
     --    allow    -- true: permit invalid check digit or digit count
 
     --    abbr    -- true or string: link ISBN abbreviation
 
     --    abbr    -- true or string: link ISBN abbreviation
 
     --    adhere  -- true: use &nbsp;  else: use simple space
 
     --    adhere  -- true: use &nbsp;  else: use simple space
Zeile 1.257: Zeile 1.354:  
         r = r .. ISBNformat( attempt, isbn );
 
         r = r .. ISBNformat( attempt, isbn );
 
     else
 
     else
         lapsus = true;
+
         lapsus = not allow;
 
         r      = r .. source;
 
         r      = r .. source;
 
     end
 
     end
 
     r = r .. "]]";
 
     r = r .. "]]";
 
     if lapsus then
 
     if lapsus then
         r = string.format( "<span class='invalid-ISBN'>%s</span>%s",
+
         local e = mw.html.create( "span" )
                          rfault( "(?!?!)" ) );
+
                        :addClass( "invalid-ISBN" )
 +
                        :wikitext( r );
 +
        r = tostring( e ) .. fault( "(?!?!)" );
 
         if alert then
 
         if alert then
 
             r = r .. flop( alert );
 
             r = r .. flop( alert );
Zeile 1.278: Zeile 1.377:  
         if s then
 
         if s then
 
             if type( s ) ~= "string"
 
             if type( s ) ~= "string"
 +
              or  s == "-"
 
               or  s == "" then
 
               or  s == "" then
 
                 s = false;
 
                 s = false;
Zeile 1.284: Zeile 1.384:  
             s = "International Standard Book Number";
 
             s = "International Standard Book Number";
 
         end
 
         end
         if s then
+
         if s and  s ~= fullPageName() then
             s = string.format( "[[%s|ISBN]]", s );
+
             s = string.format( "[[wikipedia:%s|ISBN]]", s );
 
         else
 
         else
 
             s = "ISBN";
 
             s = "ISBN";
Zeile 1.308: Zeile 1.408:  
     -- Postcondition:
 
     -- Postcondition:
 
     --    Returns  link
 
     --    Returns  link
     local cnf  = fetch( "config" );
+
     local r = URIutil.targetISSN( attempt, allow, nil, nil, alert );
    local issn = ISSNfactory( attempt );
+
     if adhere then
    local lapsus, r;
+
         r = "&#160;" .. r;
    if type( issn ) == "table" then
+
     else
        local lenient;
+
         r = " " .. r;
        if type( allow ) == "string" then
+
     end
            lenient = ( allow ~= "0" );
+
     if abbr then
        else
+
        local cnf  = fetch( "config" );
            lenient = allow;
+
         local s = cnf.supportISSN;
        end
  −
        if lenient then
  −
            lapsus = false;
  −
        else
  −
            lapsus = ( not ISSNfaith( issn ) );
  −
        end
  −
        r = ISSNformat( issn, issn.type );
  −
        if type( cnf.issn ) == "string" then
  −
            r = string.format( "[%s %s]",
  −
                              cnf.issn:gsub( "%$1", r ),
  −
                              r );
  −
        end
  −
    else
  −
        lapsus = true;
  −
        r      = attempt;
  −
    end
  −
    if lapsus then
  −
        r = string.format( "<span class='invalid-ISSN'>%s</span>%s",
  −
                          r, fault( "(?!?!)" ) );
  −
        if alert then
  −
            r = r .. flop( alert );
  −
        end
  −
    end
  −
     if adhere then
  −
         r = "&nbsp;" .. r;
  −
     else
  −
         r = " " .. r;
  −
     end
  −
     if abbr then
  −
         local s = cnf.supportISSN;
   
         if s then
 
         if s then
 
             if type( s ) ~= "string"
 
             if type( s ) ~= "string"
 +
              or  s == "-"
 
               or  s == "" then
 
               or  s == "" then
 
                 s = false;
 
                 s = false;
Zeile 1.355: Zeile 1.426:  
             s = "International Standard Serial Number";
 
             s = "International Standard Serial Number";
 
         end
 
         end
         if s then
+
         if s and  s ~= fullPageName() then
             s = string.format( "[[%s|ISSN]]", s );
+
             if s == "ISSN" then
 +
                s = "[[ISSN]]";
 +
            else
 +
                s = string.format( "[[wikipedia:%s|ISSN]]", s );
 +
            end
 
         else
 
         else
 
             s = "ISSN";
 
             s = "ISSN";
 
         end
 
         end
         r = string.format( "%s&#160;%s", s, r );
+
         r = string.format( "%s%s", s, r );
 
     else
 
     else
 
         r = "ISSN" .. r;
 
         r = "ISSN" .. r;
Zeile 1.388: Zeile 1.463:       −
function URIutil.linkURN( attempt, alter, any1, any2, alert )
+
function URIutil.linkPMID( attempt, any, abbr, adhere, alert )
     -- Retrieve bracketed titled external URN link
+
     -- Retrieve external PMID link with "PMID"
 
     -- Precondition:
 
     -- Precondition:
     --    attempt  -- string, with presumable URN, starting with "urn:"
+
     --    attempt  -- string or number with presumable PMID
     --    alter    -- alternative handler
+
     --    any      -- intentionally dummy parameter
     --    any1     -- intentionally dummy parameter
+
     --    abbr     -- true: link PMID abbreviation
     --    any2    -- intentionally dummy parameter
+
     --    adhere  -- true: use &nbsp;  else: use simple space;
     --    alert    -- string, with title of maintenance category, or nil
+
     --    alert    -- string with title of maintenance category, or nil
 
     -- Postcondition:
 
     -- Postcondition:
     --    Returns
+
     --    Returns link
     --        1.    linked ID, or plain string if bad URN
+
    local s = type( attempt );
    --         2.   true, if to be preceded by "urn:"
+
     local legal, r;
     local r2 = true;
+
    if s == "string" then
     local r;
+
         r = mw.text.trim( attempt );
     if not URIutil.mayURI( attempt, true ) then
+
        if r == "" then
         local s = attempt:match( "^%s*[uU][rR][nN]:(%S+)%s*$" );
+
            r = "PMID";
         if s then
+
            s = "empty";
             local space, sign = s:match( "^(%w+):(.+)$" );
+
        end
             if space then
+
     elseif s == "number" then
                 local defs = fetch( "urn" );
+
        r = tostring( attempt );
                 if type( defs ) == "table" then
+
        s = "string";
                    local resolver = defs.resolver;
+
     else
                    space    = space:lower();
+
        r = "PMID";
                     resolver = resolver[ space ];
+
    end
                    r2      = ( resolver ~= true );
+
     if s == "string" then
                     if type( resolver ) == "table" then
+
         legal = r:match( "^[1-9]%d*$" );
                        r, sign = URNresolve( resolver, sign, alter );
+
         if legal then
                         s = string.format( "%s:%s", space, sign );
+
             local cnf = fetch( "config" );
                         if r then
+
             if cnf then
                            r = r:gsub( "%$1",  "urn:" .. s );
+
                 s = cnf.pmid;
                            r = string.format( "[%s %s]", r, s );
+
                 if type( s ) == "string" and
                         end
+
                  s ~= "-"  and
                     elseif r2 then
+
                  s ~= "" then
                         if type( defs.sns ) == "string" then
+
                     local sep;
                            s = string.format( ":%s:", space );
+
                     if s:find( "$1", 5, true ) then
                             if not defs.sns:find( s, 1, true ) then
+
                         s = s:gsub( "%$1", r );
                                 s = false;
+
                    else
                             end
+
                         s = s .. r;
                        else
+
                    end
                            s = false;
+
                    r = string.format( "[%s %s]", s, r );
                        end
+
                    if adhere then
                        if s then
+
                        sep = "&#160;";
                            r = string.format( "%s:%s", space, sign );
+
                    else
 +
                         sep = " ";
 +
                    end
 +
                     if abbr then
 +
                        s = cnf.supportPMID;
 +
                         if type( s ) == "string" and
 +
                          s ~= "-"  and
 +
                          s ~= "" and
 +
                          s ~= fullPageName() then
 +
                             if s == "PMID" then
 +
                                 s = "[[PMID]]";
 +
                             else
 +
                                s = string.format( "[[%s|PMID]]", s );
 +
                            end
 
                         else
 
                         else
                             r = string.format( "%s&#58;%s",
+
                             s = "PMID";
                                              space, sign );
   
                         end
 
                         end
 
                     else
 
                     else
                         s = "link" .. space:upper();
+
                         s = "PMID";
                        r = URIutil[ s ]( sign, alter, nil, nil, alert );
   
                     end
 
                     end
 +
                    r = string.format( "%s%s%s", s, sep, r );
 
                 else
 
                 else
                     r = fault( "Bad structure in Module:URIutil/urn" );
+
                     cnf = false;
 
                 end
 
                 end
 
             end
 
             end
 +
            if not cnf then
 +
                r = string.format( "PMID %s", r );
 +
            end
 +
        else
 +
            r = string.format( "PMID %s", r );
 
         end
 
         end
 
     end
 
     end
     if not r then
+
     if not legal then
 +
        local e = mw.html.create( "span" )
 +
                        :addClass( "invalid-PMID" )
 +
                        :wikitext( r );
 +
        r = tostring( e ) .. fault( "(?!?!)" );
 
         if alert then
 
         if alert then
             r = flop( alert )  or  "";
+
             r = r .. flop( alert );
            if attempt then
  −
                r = attempt .. r;
  −
            end
  −
        else
  −
            r = mw.text.trim( attempt );
   
         end
 
         end
 
     end
 
     end
     return r, r2;
+
     return r;
end -- URIutil.linkURN()
+
end -- URIutil.linkPMID()
         −
function URIutil.mayDOI( attempt )
+
function URIutil.linkURN( attempt, alter, any1, any2, alert, at, alone )
     -- Is this a syntactically correct DOI, or empty?
+
     -- Retrieve bracketed titled external URN link
 
     -- Precondition:
 
     -- Precondition:
     --    attempt  -- string with presumable DOI
+
     --    attempt  -- string, with presumable URN, starting with "urn:"
 +
    --    alter    -- alternative handler
 +
    --    any1    -- intentionally dummy parameter
 +
    --    any2    -- intentionally dummy parameter
 +
    --    alert    -- string, with title of maintenance category, or nil
 +
    --    at      -- fragment, or nil
 +
    --    alone    -- true, if link text not preceded by "urn:"
 
     -- Postcondition:
 
     -- Postcondition:
     --    Returns number of organization
+
     --    Returns
     --             0  if empty
+
     --         1.    linked ID, or plain string if bad URN
     --             false if not empty and not a DOI
+
     --         2.    true, if to be preceded by "urn:"
 +
    local r2 = true;
 
     local r;
 
     local r;
     if type( attempt ) == "string" then
+
     if URIutil.mayURN( attempt ) then
         local s = mw.text.trim( attempt );
+
         local e = mw.html.create( "span" )
         if #s >= 10 then
+
                        :addClass( "invalid-URN" );
             r = URIutil.isDOI( attempt );
+
        local serial  = attempt;
         elseif #s == 0 then
+
        local suffix  = flop( alert );
            r = 0;
+
         if serial:sub( 1, 4 ):lower() == "urn:" then
         else
+
             serial = serial:sub( 5 );
             r = false;
+
         end
 +
        e:wikitext( serial );
 +
        r = tostring( e ) .. fault( "(?!?!)" );
 +
         if suffix then
 +
             r = r .. suffix;
 
         end
 
         end
 
     else
 
     else
         r = false;
+
         local s = attempt:match( "^%s*[uU][rR][nN]:(%S+)%s*$" );
    end
+
        if s then
    return r;
+
            local space, sign = s:match( "^(%w+):(.+)$" );
end -- URIutil.mayDOI()
+
            if space then
 
+
                local defs = fetch( "urn" );
 
+
                if type( defs ) == "table" then
 
+
                    local resolver = defs.resolver;
function URIutil.mayHandle( attempt )
+
                    space    = space:lower();
    -- Is this a meaningful handle, or empty?
+
                    resolver = resolver[ space ];
    -- Precondition:
+
                    r2      = ( resolver ~= true );
    --    attempt  -- string with presumable handle
+
                    if type( resolver ) == "table" then
    -- Postcondition:
+
                        r, sign = URNresolve( resolver, sign, alter );
    --    Returns number of organization
+
                        s = string.format( "%s:%s", space, sign );
    --              0  if empty
+
                        if r then
    --              false if not empty and not a DOI
+
                            r = r:gsub( "%$1", "urn:" .. s );
    local r;
+
                            if at then
    if type( attempt ) == "string" then
+
                                r = string.format( "%s#%s", r, at );
        local s = mw.text.trim( attempt );
+
                            end
        if #s > 5 then
+
                            if alone then
            r = URIutil.isHandle( attempt );
+
                                r2 = true;
        elseif #s == 0 then
+
                            else
            r = 0;
+
                                s = "urn:" .. s;
        else
+
                            end
            r = false;
+
                            r = string.format( "[%s %s]", r, s );
 +
                        end
 +
                    elseif r2 then
 +
                        if type( defs.sns ) == "string" then
 +
                            s = string.format( ":%s:", space );
 +
                            if not defs.sns:find( s, 1, true ) then
 +
                                s = false;
 +
                            end
 +
                        else
 +
                            s = false;
 +
                        end
 +
                        if s then
 +
                            r = string.format( "%s:%s", space, sign );
 +
                        else
 +
                            r = string.format( "%s&#58;%s",
 +
                                              space, sign );
 +
                        end
 +
                        r2 = not alone;
 +
                    else
 +
                        s = "link" .. space:upper();
 +
                        r = URIutil[ s ]( sign, alter, nil, nil, alert );
 +
                    end
 +
                else
 +
                    r = fault( "Bad structure in Module:URIutil/urn" );
 +
                end
 +
            end
 
         end
 
         end
    else
  −
        r = false;
   
     end
 
     end
     return r;
+
    if not r then
end -- URIutil.mayHandle()
+
        if alert then
 
+
            r = flop( alert )  or  "";
 
+
            if attempt then
 +
                r = attempt .. r;
 +
            end
 +
        else
 +
            r = mw.text.trim( attempt );
 +
        end
 +
        r2 = false;
 +
    end
 +
     return r, r2;
 +
end -- URIutil.linkURN()
   −
function URIutil.mayISBN( attempt )
+
 
     -- Is this a syntactically correct ISBN, or empty?
+
 
 +
function URIutil.mayDOI( attempt )
 +
     -- Is this a syntactically correct DOI, or empty?
 
     -- Precondition:
 
     -- Precondition:
     --    attempt  -- string with presumable ISBN
+
     --    attempt  -- string with presumable DOI
 
     -- Postcondition:
 
     -- Postcondition:
     --    Returns  10 if 10 digits and hyphens; also X at end of ISBN-10
+
     --    Returns  number of organization
    --              13 if 13 digits and hyphens; beginning with bookland
   
     --              0  if empty
 
     --              0  if empty
     --              false if not empty and not an ISBN
+
     --              false if not empty and not a DOI
 
     local r;
 
     local r;
 
     if type( attempt ) == "string" then
 
     if type( attempt ) == "string" then
 
         local s = mw.text.trim( attempt );
 
         local s = mw.text.trim( attempt );
 
         if #s >= 10 then
 
         if #s >= 10 then
             r = URIutil.isISBN( attempt );
+
             r = URIutil.isDOI( attempt );
 
         elseif #s == 0 then
 
         elseif #s == 0 then
 
             r = 0;
 
             r = 0;
Zeile 1.535: Zeile 1.670:  
     end
 
     end
 
     return r;
 
     return r;
end -- URIutil.mayISBN()
+
end -- URIutil.mayDOI()
         −
function URIutil.mayISSN( attempt )
+
function URIutil.mayHandle( attempt )
     -- Is this a correct ISSN, or empty?
+
     -- Is this a meaningful handle, or empty?
 
     -- Precondition:
 
     -- Precondition:
     --    attempt  -- string with presumable ISSN
+
     --    attempt  -- string with presumable handle
 
     -- Postcondition:
 
     -- Postcondition:
     --    Returns  8 if 8 digits and hyphens; also X at end
+
     --    Returns  number of organization
    --              13 if 13 digits and hyphens; beginning with issnland
   
     --              0  if empty
 
     --              0  if empty
     --              false if not empty and not an ISSN
+
     --              false if not empty and not a DOI
 
     local r;
 
     local r;
 
     if type( attempt ) == "string" then
 
     if type( attempt ) == "string" then
 
         local s = mw.text.trim( attempt );
 
         local s = mw.text.trim( attempt );
         if #s >= 8 then
+
         if #s > 5 then
             r = URIutil.isISSNvalid( attempt );
+
             r = URIutil.isHandle( attempt );
 
         elseif #s == 0 then
 
         elseif #s == 0 then
 
             r = 0;
 
             r = 0;
Zeile 1.562: Zeile 1.696:  
     end
 
     end
 
     return r;
 
     return r;
end -- URIutil.mayISSN()
+
end -- URIutil.mayHandle()
         −
function URIutil.mayLCCN( attempt )
+
function URIutil.mayISBN( attempt )
     -- Is this a syntactically correct LCCN?
+
     -- Is this a syntactically correct ISBN, or empty?
 
     -- Precondition:
 
     -- Precondition:
     --    attempt  -- string with presumable LCCN
+
     --    attempt  -- string with presumable ISBN
 
     -- Postcondition:
 
     -- Postcondition:
     --    Returns  string with LCCN formatted aa9999-99999999
+
     --    Returns  10 if 10 digits and hyphens; also X at end of ISBN-10
 +
    --              13 if 13 digits and hyphens; beginning with bookland
 
     --              0  if empty
 
     --              0  if empty
     --              false if not recognized
+
     --              false if not empty and not an ISBN
 +
    local r;
 
     if type( attempt ) == "string" then
 
     if type( attempt ) == "string" then
 
         local s = mw.text.trim( attempt );
 
         local s = mw.text.trim( attempt );
         if s == "" then
+
         if #s >= 10 then
 +
            r = URIutil.isISBN( attempt );
 +
        elseif #s == 0 then
 
             r = 0;
 
             r = 0;
 
         else
 
         else
             r = URIutil.isLCCN( s );
+
             r = false;
 
         end
 
         end
 
     else
 
     else
Zeile 1.585: Zeile 1.723:  
     end
 
     end
 
     return r;
 
     return r;
end -- URIutil.mayLCCN()
+
end -- URIutil.mayISBN()
         −
function URIutil.mayURI( attempt, ascii )
+
function URIutil.mayISSN( attempt )
     -- Is this a syntactically correct URI, or empty?
+
     -- Is this a correct ISSN, or empty?
 
     -- Precondition:
 
     -- Precondition:
     --    attempt  -- string with presumable URI
+
     --    attempt  -- string with presumable ISSN
    --    ascii    -- limit to ASCII (no IRI)
   
     -- Postcondition:
 
     -- Postcondition:
     --    Returns  false if no problem
+
     --    Returns  8 if 8 digits and hyphens; also X at end
     --              string with violation
+
     --              13 if 13 digits and hyphens; beginning with issnland
     local r = URIutil.isEscValid( attempt );
+
    --              0  if empty
     if not r then
+
    --              false if not empty and not an ISSN
 +
     local r;
 +
     if type( attempt ) == "string" then
 
         local s = mw.text.trim( attempt );
 
         local s = mw.text.trim( attempt );
         r = s:match( "%s(.+)$" );
+
         if #s >= 8 then
        if not r then
+
             r = URIutil.isISSNvalid( attempt );
             r = s:match( "#(.*)$" );
+
        elseif #s == 0 then
            if r then
+
            r = 0;
                r = "&#35;" .. r;
+
        else
             elseif ascii then
+
             r = false;
                local p = string.format( "[%s].+$",
  −
                                        mw.ustring.char( 128,45,255 ) );
  −
                r = mw.ustring.match( s, p );
  −
            end
   
         end
 
         end
 +
    else
 +
        r = false;
 
     end
 
     end
 
     return r;
 
     return r;
end -- URIutil.mayURI()
+
end -- URIutil.mayISSN()
         −
function URIutil.mayURN( attempt )
+
function URIutil.mayLCCN( attempt )
     -- Is this a syntactically correct URN, or empty?
+
     -- Is this a syntactically correct LCCN?
 
     -- Precondition:
 
     -- Precondition:
     --    attempt  -- string with presumable URN, starting with "urn:"
+
     --    attempt  -- string with presumable LCCN
 
     -- Postcondition:
 
     -- Postcondition:
     --    Returns  false if no problem
+
     --    Returns  string with LCCN formatted aa9999-99999999
     --              string with violation
+
    --              0  if empty
     local r = URIutil.mayURI( attempt, true );
+
     --              false if not recognized
    if not r then
+
     if type( attempt ) == "string" then
        local s = attempt:match( "^%s*[uU][rR][nN]:(.+)$" );
+
         local s = mw.text.trim( attempt );
         if s then
+
        if  s == "" then
            local space, id = s:match( "^(%w+):(.+)$" );
+
             r = 0;
            if space then
  −
                r = URNnamespace( space:lower(), id );
  −
            else
  −
                r = s;
  −
            end
  −
        elseif mw.text.trim( attempt ) == "" then
  −
             r = false;
   
         else
 
         else
             r = "urn:";
+
             r = URIutil.isLCCN( s );
 
         end
 
         end
 +
    else
 +
        r = false;
 
     end
 
     end
 
     return r;
 
     return r;
end -- URIutil.mayURN()
+
end -- URIutil.mayLCCN()
         −
function URIutil.plainISBN( attempt )
+
function URIutil.mayURI( attempt, ascii )
     -- Format ISBN as digits (and 'X') only string
+
     -- Is this a syntactically correct URI, or empty?
 
     -- Precondition:
 
     -- Precondition:
     --    attempt  -- string with presumable ISBN
+
     --    attempt  -- string with presumable URI
 +
    --    ascii    -- limit to ASCII (no IRI)
 
     -- Postcondition:
 
     -- Postcondition:
     --    Returns  string with 10 or 13 chars
+
     --    Returns  false if no problem
     --              false if not empty and not an ISBN
+
     --              string with violation
     local r;
+
     local r = URIutil.isEscValid( attempt );
     local isbn = ISBNfactory( attempt );
+
     if not r then
    if type( isbn ) == "table" then
+
        local s = mw.text.trim( attempt );
        r = ISBNflat( isbn );
+
        r = s:match( "%s(.+)$" );
    else
+
        if not r then
         r = false;
+
            r = s:match( "#(.*)$" );
 +
            if r then
 +
                r = "&#35;" .. r;
 +
            elseif ascii then
 +
                local p = string.format( "[%s].+$",
 +
                                        mw.ustring.char( 128,45,255 ) );
 +
                r = mw.ustring.match( s, p );
 +
            end
 +
         end
 
     end
 
     end
 
     return r;
 
     return r;
end -- URIutil.plainISBN()
+
end -- URIutil.mayURI()
         −
function URIutil.uriDOI( attempt, anything, abbr )
+
function URIutil.mayURN( attempt )
     -- Retrieve linked URI on DOI resolver
+
     -- Is this a syntactically correct URN, or empty?
 
     -- Precondition:
 
     -- Precondition:
     --    attempt   -- string with presumable DOI
+
     --    attempt -- string with presumable URN, starting with "urn:"
     --    anything  -- intentionally dummy parameter
+
     -- Postcondition:
     --     abbr      -- true or string: link doi: abbreviation
+
     --     Returns  false if no problem
     local r = URIutil.linkDOI( attempt );
+
     --             string with violation
     if r then
+
     local r = URIutil.mayURI( attempt, true );
         if abbr then
+
     if not r then
             local s;
+
        local s = attempt:match( "^%s*[uU][rR][nN]:(.+)$" );
             if type( abbr ) == "string" then
+
         if s then
                 s = abbr;
+
             local space, id = s:match( "^(%w+):(.+)$" );
 +
             if space then
 +
                 r = URNnamespace( space:lower(), id );
 
             else
 
             else
                 s = "Digital Object Identifier";
+
                 r = s;
 
             end
 
             end
            r = string.format( "[[%s|doi]]:%s", s, r );
   
         else
 
         else
             r = "doi:" .. r;
+
             s = mw.text.trim( attempt );
 +
            if s == "" then
 +
                r = false;
 +
            elseif s:match( "^https?://" ) then
 +
                r = "http:";
 +
            else
 +
                r = "urn:";
 +
            end
 
         end
 
         end
 
     end
 
     end
 
     return r;
 
     return r;
end -- URIutil.uriDOI()
+
end -- URIutil.mayURN()
         −
function URIutil.uriHandle( attempt, anything, abbr )
+
function URIutil.plainISBN( attempt )
     -- Retrieve linked URI on handle resolver
+
     -- Format ISBN as digits (and 'X') only string
 
     -- Precondition:
 
     -- Precondition:
     --    attempt   -- string with presumable handle
+
     --    attempt -- string with presumable ISBN
     --    anything  -- intentionally dummy parameter
+
     -- Postcondition:
     --    abbr      -- true or string: link hdl: abbreviation
+
     --     Returns  string with 10 or 13 chars
     local r = URIutil.linkHandle( attempt );
+
     --             false if not empty and not an ISBN
     if r then
+
     local r;
        local s;
+
     local isbn = ISBNfactory( attempt );
        if type( abbr ) == "string" then
+
     if type( isbn ) == "table" then
            s = abbr;
+
         r = ISBNflat( isbn );
         end
+
    else
        if s then
+
        r = false;
            r = string.format( "[[%s|hdl]]:%s", s, r );
  −
        else
  −
            r = "hdl:" .. r;
  −
        end
   
     end
 
     end
 
     return r;
 
     return r;
end -- URIutil.uriHandle()
+
end -- URIutil.plainISBN()
         −
function URIutil.uriURN( attempt, anything, alter, alert )
+
function URIutil.targetISSN( attempt, allow, any1, any2, alert )
     -- Retrieve linked URI on URN resolver
+
     -- Retrieve bracketed titled external link on ISSN DB without "ISSN"
 
     -- Precondition:
 
     -- Precondition:
     --    attempt  -- string with presumable URN, starting with "urn:"
+
    --    attempt  -- string with presumable ISSN
     --    anything  -- intentionally dummy parameter
+
    --    allow    -- true: permit invalid check digit
     --    alter    -- string with alternative handler, or nil
+
    --    any1    -- intentionally dummy parameter
     --    alert    -- string with title of maintenance category, or nil
+
    --    any2    -- intentionally dummy parameter
     -- Postcondition:
+
    --    alert    -- string with title of maintenance category, or nil
     --    Returns  link, or plain string if bad URN
+
    -- Postcondition:
     local r, l = URIutil.linkURN( attempt, alter, false, false, alert );
+
    --    Returns  link
     if l then
+
    local cnf  = fetch( "config" );
         local s = fetch( "config" ).supportURN;
+
    local issn = ISSNfactory( attempt );
         if s then
+
    local lapsus, r;
             if type( s ) ~= "string"
+
    if type( issn ) == "table" then
               or  s == "" then
+
        local lenient;
                 s = false;
+
        if type( allow ) == "string" then
             end
+
            lenient = ( allow ~= "0" );
         else
+
        else
             s = "Uniform Resource Name";
+
            lenient = allow;
         end
+
        end
         if s then
+
        if lenient then
             r = string.format( "[[%s|urn]]:%s", s, r );
+
            lapsus = false;
         else
+
        else
             r = "urn:" .. r;
+
            lapsus = ( not ISSNfaith( issn ) );
         end
+
        end
     else
+
        r = ISSNformat( issn, issn.type );
     end
+
        if type( cnf.issn ) == "string" then
     return r;
+
            local s = cnf.issn
end -- URIutil.uriURN()
+
            if s:find( "$1", 5, true ) then
 
+
                s = s:gsub( "%$1", r );
 
+
            else
 
+
                s = s .. r;
local Template = function ( frame, action )
+
            end
     -- Retrieve library result for template access
+
            r = string.format( "[%s %s]", s, r );
     -- Precondition:
+
        end
     --    frame  -- object
+
    else
     --    action  -- string; function name
+
        lapsus = true;
     -- Postcondition:
+
        r      = attempt;
     --    Returns  appropriate string, or error message (development)
+
    end
     local lucky, r = pcall( URIutil[ action ],
+
    if lapsus then
                             frame.args[ 1 ] or "",
+
        local e = mw.html.create( "span" )
                             frame.args[ 2 ],
+
                        :addClass( "invalid-ISSN" )
                             faculty( frame.args.link, true ),
+
                        :wikitext( r );
                             faculty( frame.args.nbsp, true ),
+
        r = tostring( e ) .. fault( "(?!?!)" );
                             frame.args.cat );
+
        if alert then
     if lucky then
+
            r = r .. flop( alert );
 +
        end
 +
    end
 +
    return r;
 +
end -- URIutil.targetISSN()
 +
 
 +
 
 +
 
 +
function URIutil.uriDOI( attempt, anything, abbr )
 +
    -- Retrieve linked URI on DOI resolver
 +
    -- Precondition:
 +
    --    attempt  -- string with presumable DOI
 +
    --    anything  -- intentionally dummy parameter
 +
    --    abbr      -- true or string: link doi: abbreviation
 +
    local r = URIutil.linkDOI( attempt );
 +
    if r then
 +
        if abbr then
 +
            local s;
 +
            if type( abbr ) == "string" then
 +
                s = abbr;
 +
            else
 +
                s = "Digital Object Identifier";
 +
            end
 +
            if s ~= fullPageName() then
 +
                r = string.format( "[[%s|doi]]:%s", s, r );
 +
            else
 +
                r = "doi:" .. r;
 +
            end
 +
        else
 +
            r = "doi:" .. r;
 +
        end
 +
    end
 +
    return r;
 +
end -- URIutil.uriDOI()
 +
 
 +
 
 +
 
 +
function URIutil.uriHandle( attempt, anything, abbr )
 +
    -- Retrieve linked URI on handle resolver
 +
    -- Precondition:
 +
    --    attempt  -- string with presumable handle
 +
    --    anything  -- intentionally dummy parameter
 +
    --    abbr      -- true or string: link hdl: abbreviation
 +
    -- Postcondition:
 +
    --    Returns  combined linked URI, or false
 +
    local r = URIutil.linkHandle( attempt );
 +
    if r then
 +
        local s;
 +
        if type( abbr ) == "string" then
 +
            s = abbr;
 +
        else
 +
            local cnf = fetch( "config" );
 +
            if cnf then
 +
                s = cnf.supportHandle;
 +
                if type( s ) ~= "string"  or
 +
                  s == "-"  or
 +
                  s == ""  or
 +
                  s == fullPageName() then
 +
                    s = false;
 +
                end
 +
            end
 +
        end
 +
        if s then
 +
            r = string.format( "[[%s|hdl]]:%s", s, r );
 +
        else
 +
            r = "hdl:" .. r;
 +
        end
 +
    end
 +
    return r;
 +
end -- URIutil.uriHandle()
 +
 
 +
 
 +
 
 +
function URIutil.uriURN( attempt, anything, alter, alert, at )
 +
    -- Retrieve linked URI on URN resolver
 +
    -- Precondition:
 +
     --    attempt  -- string with presumable URN, starting with "urn:"
 +
     --    anything  -- intentionally dummy parameter
 +
     --    alter    -- string with alternative handler, or nil
 +
     --    alert    -- string with title of maintenance category, or nil
 +
    --    at        -- fragment, or nil
 +
     -- Postcondition:
 +
     --    Returns  link, or plain string if bad URN
 +
     local r, l =
 +
        URIutil.linkURN( attempt, alter, false, false, alert, at, true );
 +
     if l then
 +
         local s = fetch( "config" ).supportURN;
 +
         if s then
 +
             if type( s ) ~= "string"
 +
              or  s == "-"
 +
               or  s == "" then
 +
                 s = false;
 +
             end
 +
         else
 +
             s = "Uniform Resource Name";
 +
         end
 +
         if s and  s ~= fullPageName() then
 +
             r = string.format( "[[%s|urn]]:%s", s, r );
 +
         else
 +
             r = "urn:" .. r;
 +
         end
 +
     end
 +
    return r;
 +
end -- URIutil.uriURN()
 +
 
 +
 
 +
 
 +
Failsafe.failsafe = function ( atleast )
 +
    -- Retrieve versioning and check for compliance
 +
    -- Precondition:
 +
    --    atleast  -- string, with required version or "wikidata" or "~"
 +
    --                or false
 +
    -- Postcondition:
 +
    --    Returns  string  -- with queried version, also if problem
 +
    --              false  -- if appropriate
 +
    local last  = ( atleast == "~" )
 +
    local since = atleast
 +
    local r
 +
    if last  or  since == "wikidata" then
 +
        local item = Failsafe.item
 +
        since = false
 +
        if type( item ) == "number"  and  item > 0 then
 +
            local entity = mw.wikibase.getEntity( string.format( "Q%d",
 +
                                                                item ) )
 +
            if type( entity ) == "table" then
 +
                local vsn = entity:formatPropertyValues( "P348" )
 +
                if type( vsn ) == "table"  and
 +
                  type( vsn.value ) == "string"  and
 +
                  vsn.value ~= "" then
 +
                    if last  and  vsn.value == Failsafe.serial then
 +
                        r = false
 +
                    else
 +
                        r = vsn.value
 +
                    end
 +
                end
 +
            end
 +
        end
 +
    end
 +
    if type( r ) == "nil" then
 +
        if not since  or  since <= Failsafe.serial then
 +
            r = Failsafe.serial
 +
        else
 +
            r = false
 +
        end
 +
     end
 +
     return r
 +
end -- Failsafe.failsafe()
 +
 
 +
 
 +
 
 +
local Template = function ( frame, action )
 +
     -- Retrieve library result for template access
 +
     -- Precondition:
 +
     --    frame  -- object
 +
     --    action  -- string; function name
 +
     -- Postcondition:
 +
     --    Returns  appropriate string, or error message (development)
 +
     local lucky, r = pcall( URIutil[ action ],
 +
                             frame.args[ 1 ] or "",
 +
                             frame.args[ 2 ],
 +
                             faculty( frame.args.link, true ),
 +
                             faculty( frame.args.nbsp, true ),
 +
                             frame.args.cat,
 +
                            frame.args.fragment );
 +
     if lucky then
 
         if r then
 
         if r then
 
             r = tostring( r );
 
             r = tostring( r );
Zeile 1.834: Zeile 2.143:  
function p.linkLCCN( frame )
 
function p.linkLCCN( frame )
 
     return Template( frame, "linkLCCN" );
 
     return Template( frame, "linkLCCN" );
 +
end
 +
function p.linkPMID( frame )
 +
    return Template( frame, "linkPMID" );
 
end
 
end
 
function p.linkURN( frame )
 
function p.linkURN( frame )
Zeile 1.861: Zeile 2.173:  
function p.plainISBN( frame )
 
function p.plainISBN( frame )
 
     return Template( frame, "plainISBN" );
 
     return Template( frame, "plainISBN" );
 +
end
 +
function p.targetISSN( frame )
 +
    return Template( frame, "targetISSN" );
 
end
 
end
 
function p.uriDOI( frame )
 
function p.uriDOI( frame )
Zeile 1.871: Zeile 2.186:  
     return Template( frame, "uriURN" );
 
     return Template( frame, "uriURN" );
 
end
 
end
function p.failsafe()
+
p.failsafe = function ( frame )
     return URIutil.serial;
+
    local s = type( frame );
end
+
    local since;
function p.URIutil()
+
    if s == "table" then
     return URIutil;
+
        since = frame.args[ 1 ];
 +
    elseif s == "string" then
 +
        since = frame;
 +
    end
 +
    if since then
 +
        since = mw.text.trim( since );
 +
        if since == "" then
 +
            since = false;
 +
        end
 +
    end
 +
     return Failsafe.failsafe( since )  or  "";
 +
end -- p.failsafe()
 +
function p.URIutil( arg )
 +
    local r;
 +
    if arg then
 +
        r = "";
 +
    else
 +
        r = URIutil;
 +
    end
 +
     return r;
 
end
 
end
    
return p;
 
return p;
Cookies helfen uns bei der Bereitstellung von imedwiki. Durch die Nutzung von imedwiki erklärst du dich damit einverstanden, dass wir Cookies speichern.

Navigationsmenü