Modulo:Webarchive/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
altro controllo per prevenire il valore restituito dalla funzione base62 quando la stringa è vuota
aggiungo funzione decodeArchiveisDate, adattata dalla versione 844168596 su en.wiki
Riga 15:
{ signature = 'archive.org', service = 'wayback', encoded_date = true, tailbracket = ' in %sInternet Archive%s', tracking = 'Categoria:Template Webarchive - collegamenti all\'Internet Archive' },
{ signature = 'webcitation.org', service = 'webcite', encoded_date = true, tailbracket = ' in %sWebCite%s', tracking = 'Categoria:Template Webarchive - collegamenti a WebCite' },
{ signature = 'archive.is', service = 'archiveis', encoded_date = true, tailbracket = ' in %sArchive.is%s', tracking = 'Categoria:Template Webarchive - collegamenti a archive.is' },
{ signature = 'archive.fo', service = 'archiveis', encoded_date = true, tailbracket = ' in %sArchive.is%s', tracking = 'Categoria:Template Webarchive - collegamenti a archive.is' },
{ signature = 'archive.today', service = 'archiveis', encoded_date = true, tailbracket = ' in %sArchive.is%s', tracking = 'Categoria:Template Webarchive - collegamenti a archive.is' },
{ signature = 'archive.il', service = 'archiveis', encoded_date = true, tailbracket = ' in %sArchive.is%s', tracking = 'Categoria:Template Webarchive - collegamenti a archive.is' },
{ signature = 'archive.ec', service = 'archiveis', encoded_date = true, tailbracket = ' in %sArchive.is%s', tracking = 'Categoria:Template Webarchive - collegamenti a archive.is' },
{ signature = 'archive[-]it.org', service = 'archiveit', tailbracket = ' in %sArchive-It%s' },
{ signature = 'arquivo.pt', tail = ' nel Portuguese Web Archive' },
Riga 160:
local path_elements = mw.text.split(path, '/')
 
-- Formatiformati URL validi che non sono base62:
 
-- http://www.webcitation.org/query?id=1138911916587475
Riga 198:
snapdate = string.gsub(snapdate, '[*]$', '')
local fulldate
localif dlentonumber(snapdate) =and string.len(snapdate) >= 8 then
if tonumber(snapdate) and dlen >= 8 then
local year = string.sub(snapdate, 1, 4)
local month = string.sub(snapdate, 5, 6)
Line 207 ⟶ 206:
return fulldate
end
 
--[[--------------------------< decodeArchiveisDate >-----------------------
Ricava la data da un URL esteso ad Archive.is (es. https://archive.is/2016.08.28-144552/http://example.com).
Gestisce "." e "-" nella data, rendendo 2016.08.28-144552 uguale a 20160828144552.
]]
function p.decodeArchiveisDate(url)
local path = mw.uri.new(url).path
local path_elements = mw.text.split(path, '/')
local snapdate = path_elements[2]
if path == '' or not path_elements[2] or path_elements[2] == '' then return end
snapdate = string.gsub(snapdate, '[%.%-]', '')
if not tonumber(snapdate) then encoded_date = false return end -- formato link breve
local fulldate
if tonumberstring.len(snapdate) and dlen >= 8 then
local year = string.sub(snapdate, 1, 4)
local month = string.sub(snapdate, 5, 6)
local day = string.sub(snapdate, 7, 8)
fulldate = formatUrlDate(year, month, day)
end
return fulldate
end
 
--[[--------------------------< serviceName >-----------------------