Modul:Webarchiv

Aus Wikipedia
Vorlagenprogrammierung Diskussionen Lua Unterseiten
Modul Deutsch

Modul: Dokumentation

Diese Seite enthält Code in der Programmiersprache Lua. Einbindungszahl Cirrus


local p = { }

p.getdomain = function ( frame )
    local url = frame.args[1]
    local domain
    if url:match( "^https?://[%w%-%.]*/" ) then
        domain = url:match( "^https?://[%w%-%.]*" ):gsub("http://", ""):gsub("https://", ""):gsub("www.", "")
    else
        domain = "Fehler"
    end
    return domain or ""
end -- p.getdomain

p.archiveis = function ( frame )
    local timestamp = frame.args[1]
    local date
    if timestamp:match( "^20[0-9][0-9]%.[0-1][0-9]%.[0-3][0-9]%-[0-2][0-9][0-5][0-9][0-5][0-9]" ) then
        date = timestamp:match( "^20[0-9][0-9]%.[0-1][0-9]%.[0-3][0-9]%-[0-2][0-9][0-5][0-9][0-5][0-9]" ):gsub("%-", ""):gsub("%.", "")
    else
        date = timestamp
    end
    return date or ""
end

return p