Modulo:Webarchive/sandbox: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
Prova per errore di lint |
refactoring in corso d'opera |
||
Riga 5:
]]
require('Module:No globals')
local getArgs = require('Module:Arguments').getArgs
local p = {}
local ulx = {} -- Associative array to hold template data
local track = {} -- Associative array to hold tracking categories
local maxurls = 10 -- Max number of URLs allowed.
local servizi = {
Line 72 ⟶ 78:
end
return '<
end
--[[--------------------------< base62 >-----------------------
Line 139 ⟶ 124:
]]
local function tableLength(
local count = 0
for _ in pairs(
return count
end
Line 243 ⟶ 228:
-- http://www.webcitation.org/getfile.php?fileid=1c46e791d68e89e12d0c2532cc3cf629b8bc8c8e
if mw.ustring.find( dt.split[2], "query"
mw.ustring.find( dt.split[2], "cache"
mw.ustring.find( dt.split[2], "getfile"
tonumber(dt.split[2]) then
return "query"
Line 267 ⟶ 252:
end
local fulldate = makeDate(dt.year, dt.month, dt.day, df)
if not fulldate then
return inlineRed("[Date error] (4)", "error")
Line 288 ⟶ 273:
local snapdate, snapdatelong, currdate, fulldate
local snapdate = string.gsub(
local safe = snapdate
local
snapdate =
if snapdate == "*" then -- eg. /web/*/http..
return "index"
Line 329 ⟶ 314:
end
local fulldate = makeDate(year, month, day, df)
if not fulldate then
return inlineRed("[Date error] (7)", "error")
Line 344 ⟶ 329:
]]
local function serviceName(
local tracking = "Categoria:Template Webarchive - altri archivi"
Line 354 ⟶ 339:
end
for _,servizio in ipairs(servizi) do
if mw.ustring.find(url_main.host, servizio.signature
if servizio['tailbracket'] then
else
end
tracking = servizio['tracking'] or tracking
break
end
end
if url_main.tail == nil then
url_main.tail = " a " .. url_main.host .. " " .. inlineRed("Errore: URL di servizio di archiviazione sconosciuto")
end
track[tracking] = 1
Line 385 ⟶ 372:
]]
local function parseExtraArgs(args, maxurls, ulx)
local i,
for i = 2, maxurls do
argurl = "url" .. i
if
ulx[
ulx[
if not ulx[
end
indx = indx + 1
end
end
end
--[[--------------------------< comma >-----------------------
Line 425 ⟶ 400:
local function comma(date)
local
local
if
if not tonumber(
return ","
else
Line 470 ⟶ 445:
local period2 = "."
local url_main = ulx[1]
local indexstr = "archiviato"
if
indexstr = "archivio"
end
-- For {{wayback}}, {{webcite}}
if
if not
sand = "[" ..
elseif not
if
period1 = "."
period2 = ""
end
sand = "[" ..
elseif
sand = "[" ..
elseif
sand = "[" ..
else
return nil
end
if #ulx
sand = sand .. period2 .. " Archivi aggiuntivi: "
local archives_output = {}
archives_output[#archives_output] = mw.ustring.format("[%s %s]", ulx[indx]["url"], ulx[indx]["title"] or ulx[indx]["date"] )
end
sand = sand .. mw.text.listToText(archives_output, ",", ".")
end
return sand
Line 516 ⟶ 480:
-- For {{cite archives}}
else
if
displayheader = "Archivi aggiuntivi: "
else -- Multiple pages from the same archive
displayheader = "Pagine di archivio
end
local sand = displayheader
local archives_output = {}
displayfield = ulx[indx]["title"]
if
if not displayfield then displayfield = ulx[indx]["date"] end
else
if not displayfield then displayfield = "Pagina " .. indx end
end
archive_ouptut[#archives_output] = mw.ustring.format("[%s %s]", ulx[indx]["url"], displayfield )
end
sand = sand .. mw.text.listToText(archive_otuput, ",", ".")
return sand
end
Line 547 ⟶ 502:
function p.webarchive(frame)
local args = getArgs(frame
valueFunc = function (key, value)
if key == 'nolink' then
return true
elseif value then
value = mw.text.trim(value)
if value ~= '' then return value end
end
return nil
end
})
-- if (args[1]==nil) and (args["url"]==nil) then -- if no argument provided than check parent template/module args
-- args = frame:getParent().args
-- end
local tname = "Webarchive" -- name of calling template. Change if template rename.
local verifydates = "yes" -- See documentation. Set "no" to disable.
-- URL argument (first)
local url1 =
if not url1 then
return inlineError("url", "Empty.") .. createTracking()
end
if mw.ustring.find( url1, "https://web.http"
track["Categoria:Errori di compilazione del template Webarchive"] = 1
return inlineError("url", "https://web.http") .. createTracking()
Line 572 ⟶ 535:
end
local uri1 = mw.uri.new(
serviceName(url_main, args.nolink)
-- Date argument
local date =
if date == "*" and
date = "index"
elseif date and
local ldf = dateFormat(date)
if ldf then
Line 595 ⟶ 553:
end
end
elseif date and
local ldf = dateFormat(date)
if ldf then
Line 604 ⟶ 562:
end
end
elseif not date and
date = decodeWaybackDate( uri1.path, "iso" )
if not date then
date = inlineRed("[Date error] (1)", "error")
end
elseif not date and
date = decodeWebciteDate( uri1.path, "iso" )
if date == "query" then
Line 619 ⟶ 577:
date = inlineRed("[Data mancante]", "warning")
end
-- Format argument
local format =
if not format then
format = "none"
else
if format == "addlpages" then
if not
format = "none"
end
Line 636 ⟶ 594:
end
end
-- Title argument
ulx
parseExtraArgs(args, maxurls, ulx)
--if true then return mw.text.jsonEncode(ulx, mw.text.JSON_PRETTY) end
local rend = createRendering()
if not rend then
|