Modulo:Webarchive/sandbox: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
altro controllo |
riformulo con booleano |
||
Riga 10:
local track = {} -- array associativo per accumulare le categorie di tracciamento
local maxurls = 10 -- massimo numero di URL permessi
local no_archive_date = false
local servizi = {
Line 153 ⟶ 154:
--[[--------------------------< decodeWebciteDate >-----------------------
Ricava la data da un URL a Webcite (es. www.webcitation.org/67xHmVFWP)
]]
function p.decodeWebciteDate(url)
local path = mw.uri.new(url).path
if not path then
local path_elements = mw.text.split(path, '/')
Riga 169:
-- http://www.webcitation.org/getfile.php?fileid=1c46e791d68e89e12d0c2532cc3cf629b8bc8c8e
if not path_elements[2] or mw.ustring.find(path_elements[2], 'query') or
mw.ustring.find(path_elements[2], 'cache') or
mw.ustring.find(path_elements[2], 'getfile') or
tonumber(path_elements[2]) then
no_archive_date = true
return false
end
Line 187 ⟶ 188:
function p.decodeWaybackDate(url)
local path = mw.uri.new(url).path
if not path then
local snapdate = string.gsub(path, '^/w?e?b?/?', '') -- rimuove la sequenza iniziale "/web/" o "/"
local path_elements = mw.text.split(snapdate, '/')
Line 345 ⟶ 346:
if date then
date = formatDate(date)
local udate = url_main.service == 'wayback' and p.decodeWaybackDate(url_main.url) or
url_main.service == 'webcite' and p.decodeWebciteDate(url_main.url)
if udate and udate ~= date then
date = date .. inlineRed('<sup>[Data nell\'URL non combaciante: ' .. udate .. ']</sup>', 'warning')
elseif
date = date .. ' ' .. inlineRed('Data nell\'URL indecifrabile', 'error')
end
elseif url_main.service == 'wayback' then
date = p.decodeWaybackDate(url_main.url
elseif url_main.service == 'webcite' then
date = p.decodeWebciteDate(url_main.url)
if date == false then▼
date = inlineRed('Data mancante', 'warning')▼
date = inlineRed('Data nell\'URL indecifrabile', 'error')▼
end▼
else
date = inlineRed('Data mancante', 'warning')
end
url_main.date = date
|