Modul:Vorlage:Internetquelle

Aus AnthroWiki

Die Dokumentation für dieses Modul kann unter Modul:Vorlage:Internetquelle/Doku erstellt werden

local Serial = "LEGACY 2019-01-22"
--[=[
Unterstützung für {{Internetquelle}} *** Vorabversion: LEGACY/Vorlagenprogrammierung Altbestand
]=]
local p = { }


p.archivBot = function ( frame )
    -- Parmeter archiv-bot analysieren
    local s = frame.args.stamp
    local r
    if s  and  s ~= ""  and  s ~= "0" then
        if s == "1"  or
           s:match( "^20[12]%d%-[0-1]%d%-[0-3]%d" ) then
            r = frame.args.text
        else
            local e = mw.html.create( "span" )
                             :attr( "class", "error" )
            s = "Internetquelle: archiv-bot ungültig"
            r = tostring( e:wikitext( s ) )
        end
    end
    return r or ""
end -- p.archivBot



p.archivURL = function ( frame )
    -- Parmeter archiv-url verwerten
    local s     = frame.args[ 1 ]
    local start = s:match( "^https?://(%S+)$" )
    local r
    if start then
        if start:sub( 1, 11 ) == "archive.is/" then
            r = string.format( "https://archive.today/%s",
                               start:sub( 12 ) )
        else    
            r = s
        end    
    else
        local e = mw.html.create( "span" )
                         :attr( "class", "error" )
        s = "Internetquelle: archiv-url ungültig"
        r = tostring( e:wikitext( s ) )
    end
    return r
end -- p.archivURL



p.Endpunkt = function ( frame )
    -- LEGACY für Vorlage:Internetquelle
    local r = ""
    local s = frame.args.titel
    if s then
        local Text = require( "Module:Text" )
        Text = Text.Text()
        if Text.sentenceTerminated( s ) then
            r = ""
        else
            r = "."
        end
    end
    return r
end -- p.Endpunkt



p.TitelFormat = function ( frame )
    -- LEGACY für Vorlage:Internetquelle
    local r = ""
    local s = frame.args.titel
    if s then
        local Text = require( "Module:Text" )
        Text = Text.Text()
        if Text.sentenceTerminated( s ) then
            r = s
        else
            r = s .. "."
        end
        r = string.format( "<i>%s</i>", r )
    end
    return r
end -- p.TitelFormat

function p.failsafe()
    return Serial
end

return p