Modul:WLink: Unterschied zwischen den Versionen

1.510 Bytes hinzugefügt ,  25. November 2014
update
wp>PerfektesChaos
(update)
wp>PerfektesChaos
(update)
Zeile 1: Zeile 1:
--[=[ 2014-11-01
--[=[ 2014-11-25
WLink
WLink
ansiPercent()
ansiPercent()
Zeile 17: Zeile 17:
isBracketedLink()
isBracketedLink()
isBracketedURL()
isBracketedURL()
isCategorization()
isExternalLink()
isExternalLink()
isInterlanguage()
isInterlanguage()
isInterwiki()
isInterwiki()
isMedia()
isTitledLink()
isTitledLink()
isValidLink()
isValidLink()
Zeile 280: Zeile 282:
     end
     end
     if lonely then
     if lonely then
         local i = r1:find( "#", 1, true )
         local i = r1:find( "#", 1, true );
         if i == 1 then
         if i == 1 then
             r1 = "";
             r1 = "";
Zeile 769: Zeile 771:
     return ( r == 1 );
     return ( r == 1 );
end -- WLink.isBracketedURL()
end -- WLink.isBracketedURL()
function WLink.isCategorization( attempt )
    -- Does attempt match a categorization?
    -- Precondition:
    --    attempt  -- string, with presumable link somewhere
    -- Postcondition:
    --    Returns  boolean
    local r = false;
    local s, m = WLink.getTarget( attempt );
    if m == 2 then
        local w = WLink.wikilink( s );
        if w  and  w.ns == 14
              and  not ( w.lead or w.lang or w.project )
              and  w.title ~= "" then
            r = true;
        end
    end
    return r;
end -- WLink.isCategorization()




Zeile 794: Zeile 817:
     --    Returns  boolean
     --    Returns  boolean
     local r = false;
     local r = false;
     --    if m == 2 and
     local s, m = WLink.getTarget( attempt );
    --      s:find( ":", 3, true ) and  s:byte( 1, 1 ) ~= 58 then
    if m == 2 then
    --        local s
        local w = WLink.wikilink( s );
     --    end
        if w and w.lang and not w.project and not w.lead
            and  w.title ~= "" then
            r = true;
        end
     end
     return r;
     return r;
end -- WLink.isInterlanguage()
end -- WLink.isInterlanguage()
Zeile 804: Zeile 831:


function WLink.isInterwiki( attempt )
function WLink.isInterwiki( attempt )
     -- Does attempt match an interwiki link?
     -- Does attempt match an interwiki link within wikifarm?
     -- Precondition:
     -- Precondition:
     --    attempt  -- string, with presumable link somewhere
     --    attempt  -- string, with presumable link somewhere
Zeile 811: Zeile 838:
     local r = false;
     local r = false;
     local s, m = WLink.getTarget( attempt );
     local s, m = WLink.getTarget( attempt );
     if m == 2 and
     if m == 2 then
      s:find( ":", 3, true )  and  s:byte( 1, 1 ) ~= 58 then
        local w = WLink.wikilink( s );
         local s
        if w and  ( w.lang or w.project ) and  w.title ~= "" then
            r = true;
         end
     end
     end
     return r;
     return r;
end -- WLink.isInterwiki()
end -- WLink.isInterwiki()
function WLink.isMedia( attempt )
    -- Does attempt match a media translusion?
    -- Precondition:
    --    attempt  -- string, with presumable link somewhere
    -- Postcondition:
    --    Returns  boolean
    local r = false;
    local s, m = WLink.getTarget( attempt );
    if m == 2 then
        local w = WLink.wikilink( s );
        if w  and  w.ns == 6
          and  not ( w.lead or w.lang or w.project )
          and  w.title ~= ""
          and  WLink.getExtension( w.title ) then
            r = true;
        end
    end
    return r;
end -- WLink.isMedia()




Zeile 885: Zeile 936:
     -- Postcondition:
     -- Postcondition:
     --    Returns  table or false
     --    Returns  table or false
     --              table of tables with { value, type }
     --              table of assignments with { type, value}
     --                      type is one of "lead",
     --                      type is one of "lead",
     --                          "project", "lang", "ns", "space", "title"
     --                          "project", "lang", "ns", "space", "title"
Zeile 946: Zeile 997:
     end
     end
     if r.lead and
     if r.lead and
       ( r.project or
       ( r.project or  not r.title  or
         ( not r.lang  and  r.ns ~= 6  and  r.ns ~= 14 ) ) then
         ( not r.lang  and  r.ns ~= 6  and  r.ns ~= 14 ) ) then
         r.lead = false;
         r.lead = false;
    end
    if r.title == "" then
        r = false;
     end
     end
     return r;
     return r;
end -- wikilink()
end -- WLink.wikilink()




Zeile 1.013: Zeile 1.061:


-- Export
-- Export
local p = { }
local p = { };


p.ansiPercent = function ( frame )
p.ansiPercent = function ( frame )
Zeile 1.065: Zeile 1.113:
p.isBracketedURL = function ( frame )
p.isBracketedURL = function ( frame )
     return Template( frame, "isBracketedURL" );
     return Template( frame, "isBracketedURL" );
end
p.isCategorization = function ( frame )
    return Template( frame, "isCategorization" );
end
end
p.isExternalLink = function ( frame )
p.isExternalLink = function ( frame )
Zeile 1.074: Zeile 1.125:
p.isInterwiki = function ( frame )
p.isInterwiki = function ( frame )
     return Template( frame, "isInterwiki" );
     return Template( frame, "isInterwiki" );
end
p.isMedia = function ( frame )
    return Template( frame, "isMedia" );
end
end
p.isTitledLink = function ( frame )
p.isTitledLink = function ( frame )
Zeile 1.091: Zeile 1.145:
end
end


return p
return p;
Anonymer Benutzer