Modulo:Webarchive/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
fix
riscrivo decodeWebciteDate
Riga 56:
 
track["Categoria:Errori di compilazione del template Webarchive"] = 1
return '<span style="font-size:100%" class="error citation-comment">Errore nella compilazione del template webarchiveWebarchive: controllare il valore di <code style="color:inherit; border:inherit; padding:inherit;">&#124;' .. arg .. '=</code> value. (' .. msg .. ').</span>'
 
end
Riga 192:
--[[--------------------------< decodeWebciteDate >-----------------------
 
GivenRicava ala data da un URI-path toa Webcite (eges. /67xHmVFWP) return the encoded date in df format
 
]]
local function p.decodeWebciteDate(path, df)
dt.split local path_elements = mw.text.split(path, "/")
 
-- valid URL formats that are not base62
local dt = {}
dt.split = {}
 
-- http://www.webcitation.org/query?id=1138911916587475
dt.split = mw.text.split(path, "/")
-- http://www.webcitation.org/query?url=http..&date=2012-06-01+21:40:03
 
-- http://www.webcitation.org/1138911916587475
-- valid URL formats that are not base62
-- http://www.webcitation.org/cache/73e53dd1f16cf8c5da298418d2a6e452870cf50e
 
-- http://www.webcitation.org/querygetfile.php?idfileid=11389119165874751c46e791d68e89e12d0c2532cc3cf629b8bc8c8e
-- http://www.webcitation.org/query?url=http..&date=2012-06-01+21:40:03
-- http://www.webcitation.org/1138911916587475
-- http://www.webcitation.org/cache/73e53dd1f16cf8c5da298418d2a6e452870cf50e
-- http://www.webcitation.org/getfile.php?fileid=1c46e791d68e89e12d0c2532cc3cf629b8bc8c8e
 
if mw.ustring.find( dt.split[2], "query") or
mw.ustring.find( dt.split[2], "cache") or
mw.ustring.find( dt.split[2], "getfile") or
tonumber(dt.split[2]) then
return "query"
end
 
dt.full = os.date("%Y %m %d", string.sub(string.format("%d", base62(dt.split[2])),1,10) )
dt.split = mw.text.split(dt.full, " ")
dt.year = dt.split[1]
dt.month = dt.split[2]
dt.day = dt.split[3]
 
if not tonumber(dt.year) or not tonumber(dt.month) or not tonumber(dt.day) then
return inlineRed("[Errore nella data] (1)", "error")
end
 
if tonumber(dt.month) > 12 or tonumber(dt.day) > 31 or tonumber(dt.month) < 1 then
return inlineRed("[Errore nella data] (2)", "error")
end
if tonumber(dt.year) > tonumber(os.date("%Y")) or tonumber(dt.year) < 1900 then
return inlineRed("[Errore nella data] (3)", "error")
end
 
local fulldate = makeDate(dt.year, dt.month, dt.day, df)
if not fulldate then
return inlineRed("[Errore nella data] (4)", "error")
else
return fulldate
end
 
if mw.ustring.find( dt.splitpath_elements[2], "query") or
mw.ustring.find( dt.splitpath_elements[2], "cache") or
mw.ustring.find( dt.splitpath_elements[2], "getfile") or
tonumber(dt.splitpath_elements[2]) then
return "query"nil
end
dt.full local snapdate = os.date("%Y %m %d", string.sub(string.format("%d", base62(dt.splitpath_elements[2])),1,10) )
local dt.split = mw.text.split(dt.fullsnapdate, " ")
local fulldate = makeDate(dt.year[1], dt.month[2], dt.day, df[3])
return fulldate or inlineRed("[ErroreCollegamento nellanon data] (1)valido", "error")
end
 
Line 485 ⟶ 460:
if url1 == "https://web.archive.org/http:/" then -- track bug
track["Categoria:Errori di compilazione del template Webarchive"] = 1
return inlineError("url", "Invalid URL non valido") .. createTracking()
end
 
Line 509 ⟶ 484:
local ldf = dateFormat(date)
if ldf then
local udate = p.decodeWebciteDate( uri1.path, ldf )
if udate == "query" then -- skip
elseif udate ~= date then
Line 517 ⟶ 492:
elseif not date and url_main.service == "wayback" then
date = p.decodeWaybackDate( uri1.path, "iso" )
if not date then
date = inlineRed("[Errore nella data] (1)", "error")
end
elseif not date and url_main.service == "webcite" then
date = p.decodeWebciteDate( uri1.path, "iso" )
if date == "query" then
date = inlineRed("[Data mancante]", "warning")