Modulo:Webarchive: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
si archivia "a" qualcosa? |
correzioni varie |
||
Riga 5:
]]
require('Module:No globals')
local getArgs = require('Module:Arguments').getArgs
local p = {}
local track = {} -- Associative array to hold tracking categories
local maxurls = 10 -- Max number of URLs allowed.
local servizi = {
Riga 76 ⟶ 81:
end
--[[--------------------------< base62 >-----------------------
Riga 139 ⟶ 123:
]]
local function tableLength(
local count = 0
for _ in pairs(
return count
end
Riga 243 ⟶ 227:
-- 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"
Riga 267 ⟶ 251:
end
local fulldate = makeDate(dt.year, dt.month, dt.day, df)
if not fulldate then
return inlineRed("[Date error] (4)", "error")
Riga 288 ⟶ 272:
local snapdate, snapdatelong, currdate, fulldate
local snapdate = string.gsub(
local safe = snapdate
local
snapdate =
if snapdate == "*" then -- eg. /web/*/http..
return "index"
Riga 329 ⟶ 313:
end
local fulldate = makeDate(year, month, day, df)
if not fulldate then
return inlineRed("[Date error] (7)", "error")
Riga 344 ⟶ 328:
]]
local function serviceName(
local tracking = "Categoria:Template Webarchive - altri archivi"
Riga 354 ⟶ 338:
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
Riga 385 ⟶ 371:
]]
local function parseExtraArgs(args, maxurls)
local i,
local ulx = {}
for i = 2, maxurls do
argurl = "url" .. i
if
ulx[
ulx[
if not ulx[
end
indx = indx + 1
end
end
return ulx
end
--[[--------------------------< comma >-----------------------
Riga 425 ⟶ 400:
local function comma(date)
local
local
if
if not tonumber(
return ","
else
Riga 463 ⟶ 438:
]]
local function createRendering(url_main, ulx)
local sand, displayheader, displayfield
Riga 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+1] = mw.ustring.format("[%s %s]", urlx["url"], urlx["title"] or urlx["date"] )
end
sand = sand .. table.concat(archives_output, ", ") .. "."
end
return sand
Riga 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 =
if
if not displayfield then displayfield = urlx["date"] end
else
if not displayfield then displayfield = "Pagina " .. indx+1 end
end
archive_ouptut[#archives_output+1] = mw.ustring.format("[%s %s]", urlx["url"], displayfield )
end
sand = sand .. table.concat(archive_output, ", ") .. "."
return sand
end
Riga 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()
Riga 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
Riga 595 ⟶ 553:
end
end
elseif date and
local ldf = dateFormat(date)
if ldf then
Riga 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
Riga 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
Riga 636 ⟶ 594:
end
end
-- Title argument
local ulx = parseExtraArgs(args, maxurls)
--if true then return mw.text.jsonEncode(ulx, mw.text.JSON_PRETTY) end
local rend = createRendering(url_main, ulx)
if not rend then
rend = '<span style="font-size:100%" class="error citation-comment">Errori in [[:Template:' .. tname .. ']]: Problema sconosciuto. Si prega di segnalarlo nella [[Discussioni_template:' .. tname .. '|pagina di discussione]] del template.</span>'
|