Module:Webarchive: திருத்தங்களுக்கு இடையிலான வேறுபாடு
உள்ளடக்கம் நீக்கப்பட்டது உள்ளடக்கம் சேர்க்கப்பட்டது
copied from sandbox |
tracking category support |
||
வரிசை 17:
local function inline_error(arg, msg)
track["Category:Webarchive template errors"] = 1
return '<span style="font-size:100%" class="error citation-comment">Error in webarchive template: Check <code style="color:inherit; border:inherit; padding:inherit;">|' .. arg .. '=</code> value. ' .. msg .. '</span>'
end
வரி 23 ⟶ 26:
Render a text fragment in red, such as a warning as part of the final output.
Add tracking category.
]]
local function inlineRed(msg, trackmsg)
if trackmsg == "warning" then
track["Category:Webarchive template warnings"] = 1
elseif trackmsg == "error" then
track["Category:Webarchive template errors"] = 1
end
return '<span style="font-size:100%" class="error citation-comment">' .. msg .. '</span>'
end
வரி 213 ⟶ 225:
if not tonumber(dt.year) or not tonumber(dt.month) or not tonumber(dt.day) then
return inlineRed("[Date error] (1)", "error")
end
if tonumber(dt.month) > 12 or tonumber(dt.day) > 31 or tonumber(dt.month) < 1 then
return inlineRed("[Date error] (2)", "error")
end
if tonumber(dt.year) > tonumber(os.date("%Y")) or tonumber(dt.year) < 1900 then
return inlineRed("[Date error] (3)", "error")
end
fulldate = makeDate(dt.year, dt.month, dt.day, df)
if not fulldate then
return inlineRed("[Date error] (4)", "error")
else
return fulldate
வரி 260 ⟶ 272:
if not tonumber(snapdate) then
return inlineRed("[Date error] (2)", "error")
end
local dlen = string.len(snapdate)
if dlen < 4 then
return inlineRed("[Date error] (3)", "error")
end
if dlen < 14 then
வரி 275 ⟶ 287:
local day = string.sub(snapdatelong, 7, 8)
if not tonumber(year) or not tonumber(month) or not tonumber(day) then
return inlineRed("[Date error] (4)", "error")
end
if tonumber(month) > 12 or tonumber(day) > 31 or tonumber(month) < 1 then
return inlineRed("[Date error] (5)", "error")
end
currdate = os.date("%Y")
if tonumber(year) > tonumber(currdate) or tonumber(year) < 1900 then
return inlineRed("[Date error] (6)", "error")
end
fulldate = makeDate(year, month, day, df)
if not fulldate then
return inlineRed("[Date error] (7)", "error")
else
return fulldate
வரி 309 ⟶ 321:
bracketclose = ""
end
if mw.ustring.find( host, "archive.org", 1, plain ) then
வரி 319 ⟶ 334:
ulx.url1.service = "archiveis"
ulx.url1.tail = " at " .. bracketopen .. "Archive.is" .. bracketclose
elseif mw.ustring.find( host, "archive.today", 1, plain ) then
ulx.url1.service = "archiveis"
ulx.url1.tail = " at " .. bracketopen .. "Archive.is" .. bracketclose
elseif mw.ustring.find( host, "archive-it", 1, plain ) then
ulx.url1.service = "archiveit"
ulx.url1.tail = " at " .. bracketopen .. "Archive-It" .. bracketclose
elseif mw.ustring.find( host, "arquivo.pt", 1, plain) then
ulx.url1.tail = " at the " .. "Portugese Web Archive"
elseif mw.ustring.find( host, "loc.gov", 1, plain ) then
ulx.url1.tail = " at the " .. bracketopen .. "Library of Congress" .. bracketclose
elseif mw.ustring.find( host, "webharvest.gov", 1, plain ) then
ulx.url1.tail = " at the " .. bracketopen .. "National Archives and Records Administration" .. bracketclose
elseif mw.ustring.find( host, "bibalex.org", 1, plain ) then
ulx.url1.tail = " at " .. "[[Bibliotheca_Alexandrina#Internet_Archive_partnership|Bibliotheca Alexandrina]]"
elseif mw.ustring.find( host, "collectionscanada", 1, plain ) then
ulx.url1.tail = " at the " .. "Canadian Government Web Archive"
elseif mw.ustring.find( host, "haw.nsk", 1, plain ) then
ulx.url1.tail = " at the " .. "Croatian Web Archive (HAW)"
elseif mw.ustring.find( host, "nlib.ee", 1, plain ) then
ulx.url1.tail = " at the " .. "Estonian Web Archive"
elseif mw.ustring.find( host, "vefsafn.is", 1, plain ) then
ulx.url1.tail = " at the " .. "Icelandic Web Archive"
elseif mw.ustring.find( host, "proni.gov", 1, plain ) then
ulx.url1.tail = " at the " .. bracketopen .. "Public Record Office of Northern Ireland" .. bracketclose
elseif mw.ustring.find( host, "uni-lj.si", 1, plain ) then
ulx.url1.tail = " at the " .. "Slovenian Web Archive"
elseif mw.ustring.find( host, "stanford.edu", 1, plain ) then
ulx.url1.tail = " at the " .. "[[Stanford University Libraries|Stanford Web Archive]]"
elseif mw.ustring.find( host, "nationalarchives.gov.uk", 1, plain ) then
ulx.url1.tail = " at the " .. bracketopen .. "UK Government Web Archive" .. bracketclose
elseif mw.ustring.find( host, "parliament.uk", 1, plain ) then
ulx.url1.tail = " at the " .. bracketopen .. "UK Parliament's Web Archive" .. bracketclose
elseif mw.ustring.find( host, "webarchive.org.uk", 1, plain ) then
ulx.url1.tail = " at the " .. bracketopen .. "UK Web Archive" .. bracketclose
elseif mw.ustring.find( host, "nlb.gov.sg", 1, plain ) then
ulx.url1.tail = " at " .. "Web Archive Singapore"
elseif mw.ustring.find( host, "nlb.gov.sg", 1, plain ) then
ulx.url1.tail = " at " .. "Web Archive Singapore"
else
track["Category:Webarchive template other archives"] = 1
▲ ulx.url1.service = "unknown"
▲ ulx.url1.tail = " at " .. ulx.url1.host
end
வரி 354 ⟶ 406:
ulx[argurl2]["date"] = args[argdate]
else
ulx[argurl2]["date"] = inlineRed("[Date missing]", "warning")
end
argtitle = "title" .. j
வரி 389 ⟶ 441:
return ""
end
end
--[[--------------------------< createRenderingTracking >-----------------------
Create a rendering of the data in track[] for tracking categories
]]
local function createRenderingTracking()
local sand = ""
if tableLength(track) > 0 then
for key,_ in pairs(track) do
sand = sand .. "[[" .. key .. "]]"
end
end
end
வரி 486 ⟶ 556:
local tname = "Webarchive" -- name of calling template. Change if template rename.
ulx = {} -- Associative array to hold template data
track = {} -- Associative array to hold tracking categories
maxurls = 10 -- Max number of URLs allowed.
local verifydates = "yes" -- See documentation. Set "no" to disable.
வரி 494 ⟶ 565:
local url1 = trimArg(args.url) or trimArg(args.url1)
if not url1 then
return inline_error("url", "Empty.") .. createRenderingTracking()
end
ulx.url1 = {}
வரி 518 ⟶ 589:
local udate = decodeWaybackDate( uri1.path, ldf )
if udate ~= date then
date = udate .. inlineRed("<sup>[Date mismatch]</sup>", "warning")
end
end
வரி 526 ⟶ 597:
local udate = decodeWebciteDate( uri1.path, ldf )
if udate ~= date then
date = udate .. inlineRed("<sup>[Date mismatch]</sup>", "warning")
end
end
elseif not date and ulx.url1.service == "wayback" then
date = decodeWaybackDate( uri1.path, "iso" )
if not date then
date = inlineRed("[Date error] (1)", "error")
end
elseif not date and ulx.url1.service == "webcite" then
date = decodeWebciteDate( uri1.path, "iso" )
if not date then
date = inlineRed("[Date error] (1)", "error")
end
elseif not date then
date = inlineRed("[Date missing]", "warning")
end
ulx.url1.date = date
வரி 565 ⟶ 640:
local rend = createRendering()
if not rend then
▲ return rend
▲ error("Error in [[:Template:"..tname.."]]: Unknown problem. Please report on template talk page.")
end
return rend .. createRenderingTracking()
end
| |||