Modulo:Webarchive/sandbox: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
m pulizia |
riscrivo funzione dateFormat |
||
Riga 108:
end
--[[--------------------------<
]]
local function
local
▲ dt.split = mw.text.split(date, "-")
▲ if tableLength(dt.split) == 3 then
if
y, m, d = split[1], split[2], split[3]
else▼
end
▲ dt.split = mw.text.split(date, " ")
try_year = tonumber(split[3])
▲ if tableLength(dt.split) == 3 then
if try_year and try_year > 1900 and try_year < 2200 then
▲ if tonumber(dt.split[3]) then
if
m, d, y = split[1], split[2], split[3]
end
else
y, m, d = split[1], split[2], split[3]
end
end
end
end
if tonumber(d) == 1 then d = '1º' end
return y and mw.ustring.format('%s %s %s', d, m, y) or date
end
--[[--------------------------<
Controlla la data prelevata automaticamente dall'url di un archivio.
Se è valida la formatta in dmy, altrimenti restituisce nil.
]]
local function
local current_year = tonumber(os.date("%Y"))
y, m, d = tonumber(y), tonumber(m), tonumber(d)
Riga 159 ⟶ 156:
m = month_localized[m]
if d == 1 then d = '1º' end
return mw.ustring.format(
end
Riga 184 ⟶ 181:
local snapdate = os.date("%Y %m %d", string.sub(string.format("%d", base62(path_elements[2])),1,10))
local dt = mw.text.split(snapdate, " ")
local fulldate =
return fulldate or inlineRed("Collegamento non valido", "error")
end
Riga 208 ⟶ 205:
local month = string.sub(snapdate, 5, 6)
local day = string.sub(snapdate, 7, 8)
fulldate =
end
return fulldate or inlineRed("Collegamento non valido", "error")
Riga 214 ⟶ 211:
--[[--------------------------< serviceName >-----------------------
Imposta la stringa di coda e l'ID del servizio in base al dominio
estratto da mw.uri.new() (es. web.archive.org)
]]
local function serviceName(url_main, nolink)
local tracking =
local bracketopen, bracketclose =
▲ url_main.service = "altri"
for _,servizio in ipairs(servizi) do
if mw.ustring.find(url_main.host, servizio.signature) then
Riga 291 ⟶ 282:
--[[--------------------------< createTracking >-----------------------
]]
local function createTracking()
--
local current_namespace = mw.title.getCurrentTitle().namespace
if current_namespace ~= 0 then return '' end
local sand = ''
▲ local sand = ""
if tableLength(track) > 0 then
for key,_ in pairs(track) do
sand = sand ..
end
end
Riga 376 ⟶ 366:
-- carico in args i parametri, se sono nulli sono ignorati, eccetto che per il parametro nolink
local args = getArgs(frame, {
valueFunc = function
if key == 'nolink' then
return true
Riga 387 ⟶ 377:
})
-- Verifica eventuali errori nel parametro url
local url1 = args.url or args.url1
if not url1 then
return inlineError("url", "vuoto") .. createTracking()
▲ if mw.ustring.find( url1, "https://web.http") then -- track bug
track["Categoria:Errori di compilazione del template Webarchive"] = 1
return inlineError("url", "https://web.http") .. createTracking()
▲ if url1 == "https://web.archive.org/http:/" then -- track bug
track["Categoria:Errori di compilazione del template Webarchive"] = 1
return inlineError("url", "URL non valido") .. createTracking()
Riga 412 ⟶ 397:
-- Date argument
local date = args.date or args.date1 or args.data or args.data1
if date and (url_main.service ==
date =
if
▲ date = udate .. inlineRed("<sup>[Date non combacianti]</sup>", "warning")
▲ local udate = p.decodeWebciteDate( uri1.path, ldf )
end
elseif not date and url_main.service == "wayback" then
Riga 464 ⟶ 437:
local rend = createRendering(url_main, ulx)
if not rend then
rend =
track["Category:Webarchive template errors"] = 1
end
|