Modulo:Webarchive/sandbox: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
riscrivo decodeWebciteDate |
m pulizia |
||
Riga 48:
--[[--------------------------< inlineError >-----------------------
Errore critico. Formatta l'output completamente in rosso. Aggiunge una categoria di tracciamento.
]]
local function inlineError(arg, msg)
track["Categoria:Errori di compilazione del template Webarchive"] = 1
return '<span style="font-size:100%" class="error citation-comment">Errore
end
--[[--------------------------< inlineRed >-----------------------
Formatta un frammento di testo in rosso, quale ad esempio un avvertimento da integrare nell'output finale.
Aggiunge una categoria di tracciamento.
]]
local function inlineRed(msg, trackmsg)
if trackmsg == "warning" then
track["Categoria:Errori di compilazione del template Webarchive - Avvisi"] = 1
Riga 74 ⟶ 65:
track["Categoria:Errori di compilazione del template Webarchive"] = 1
end
return '<span style="font-size:100%" class="error citation-comment">' .. msg .. '</span>'
end
--[[--------------------------< base62 >-----------------------
Converte base-62 in base-10
Crediti: https://de.wikipedia.org/wiki/Modul:Expr
]]
local function base62( value )
local r = 1
if value:match( "^%w+$" ) then
local n = #value
Riga 116 ⟶ 100:
--[[--------------------------< tableLength >-----------------------
Restituisce il numero di elementi in una tabella
]]
local function tableLength(t)
local count = 0
Riga 126 ⟶ 107:
return count
end
--[[--------------------------< dateFormat >-----------------------
Restituisce il formato di una data: dmy, mdy, iso, ymd
Se non riesce a determinarla, restituisce nil
]]
local function dateFormat(date)
local dt = {}
dt.split = {}
Riga 168 ⟶ 144:
end
return nil
end
--[[--------------------------< makeDate >-----------------------
Controlla la data prelevata automaticamente dall'url di un archivio
Se è valida la formatta, altrimenti restituisce nil
]]
local function makeDate(y, m, d)
local current_year = tonumber(os.date("%Y"))
Riga 191 ⟶ 163:
--[[--------------------------< decodeWebciteDate >-----------------------
Ricava la data da un URI-path a Webcite (es. /67xHmVFWP)
]]
function p.decodeWebciteDate(path)
local path_elements = mw.text.split(path, "/")
--
-- http://www.webcitation.org/query?id=1138911916587475
Riga 219 ⟶ 189:
--[[--------------------------< snapDateToString >-----------------------
Ricava la data da un URI-path a Wayback (es. /web/20160901010101/http://example.com )
Gestisce anche le non cifre come "re_", "-" e "*"
]]
function p.decodeWaybackDate(path)
Riga 246 ⟶ 214:
--[[--------------------------< serviceName >-----------------------
Given a ___domain extracted by mw.uri.new() (eg. web.archive.org) set tail string and service ID
]]
local function serviceName(url_main, nolink)
local tracking = "Categoria:Template Webarchive - altri archivi"
local bracketopen = "[["
Riga 282 ⟶ 246:
--[[--------------------------< parseExtraArgs >-----------------------
Parse numbered arguments from 2 to maxurls, such as url2..url10, date2..date10, title2..title10
e memorized them in a table
Riga 293 ⟶ 256:
Returns the parsed table
]]
local function parseExtraArgs(args, maxurls)
local i, indx, argurl, argurl2, argdate, argtitle
local ulx = {}
Riga 314 ⟶ 275:
return ulx
end
--[[--------------------------< comma >-----------------------
Given a date string, return "," if it's MDY
]]
local function comma(date)
local n = mw.text.split(date, " ")
Riga 334 ⟶ 291:
--[[--------------------------< createTracking >-----------------------
Return data in track[] ie. tracking categories
]]
local function createTracking()
-- Return tracking category only in namespace 0
local current_namespace = mw.title.getCurrentTitle().namespace
Riga 352 ⟶ 305:
end
return sand
end
--[[--------------------------< createRendering >-----------------------
Return a rendering of the data in ulx[][]
]]
local function createRendering(url_main, ulx)
local sand, displayheader, displayfield
local period1 = "" -- For backwards compat with {{wayback}}
local period2 = "."
--local url_main = ulx[1]
local indexstr = "archiviato"
Riga 374 ⟶ 320:
end
-- For {{wayback}}, {{webcite}}
if url_main.format == "none" then
if not url_main.title and not url_main.date then -- No title. No date
Riga 425 ⟶ 370:
--[[--------------------------< createRendering >-----------------------
▲ Funzione di interfaccia principale per implementazione di
▲ template:Webarchive
]]
function p.webarchive(frame)
-- carico in args i parametri, se sono nulli sono ignorati, eccetto che per il parametro nolink
Riga 444 ⟶ 386:
end
})
local tname = "Webarchive" -- name of calling template. Change if template rename.
Riga 452 ⟶ 393:
local url1 = args.url or args.url1
if not url1 then
return inlineError("url", "vuoto
end
if mw.ustring.find( url1, "https://web.http") then -- track bug
Riga 528 ⟶ 469:
return rend .. createTracking()
end
|