Modulo:Webarchive/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
riformulo con booleano
in vista di altre funzioni per sito
Riga 10:
local track = {} -- array associativo per accumulare le categorie di tracciamento
local maxurls = 10 -- massimo numero di URL permessi
local no_archive_date = falseencoded_date
 
local servizi = {
{ 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', tailbracket = ' in %sArchive.is%s', tracking = 'Categoria:Template Webarchive - collegamenti a archive.is' },
{ signature = 'archive.fo', service = 'archiveis', tailbracket = ' in %sArchive.is%s', tracking = 'Categoria:Template Webarchive - collegamenti a archive.is' },
Riga 158:
function p.decodeWebciteDate(url)
local path = mw.uri.new(url).path
if not path then no_archive_dateencoded_date = truefalse return end
local path_elements = mw.text.split(path, '/')
 
Riga 173:
mw.ustring.find(path_elements[2], 'getfile') or
tonumber(path_elements[2]) then
encoded_date = false
no_archive_date = true
return false
end
local snapdate = os.date('%Y %m %d', string.sub(string.format('%d', base62(path_elements[2])),1,10))
Riga 188:
function p.decodeWaybackDate(url)
local path = mw.uri.new(url).path
if not path then no_archive_dateencoded_date = truefalse return end
local snapdate = string.gsub(path, '^/w?e?b?/?', '') -- rimuove la sequenza iniziale "/web/" o "/"
local path_elements = mw.text.split(snapdate, '/')
Riga 224:
end
tracking = servizio['tracking'] or tracking
encoded_date = servizio['encoded_date']
break
end
Line 350 ⟶ 351:
if udate and udate ~= date then
date = date .. inlineRed('<sup>[Data nell\'URL non combaciante: ' .. udate .. ']</sup>', 'warning')
elseif no_archive_datenot == falseudate and (url_main.service == 'wayback' or url_main.serviceencoded_date == 'webcite')true then
date = date .. ' ' .. inlineRed('Data nell\'URL indecifrabile', 'error')
end
Line 361 ⟶ 362:
end
if not date then
date = no_archive_dateencoded_date == truefalse and inlineRed('Data mancante', 'warning') or
inlineRed('Data nell\'URL indecifrabile', 'error')
end