Module:Webarchive: திருத்தங்களுக்கு இடையிலான வேறுபாடு
உள்ளடக்கம் நீக்கப்பட்டது உள்ளடக்கம் சேர்க்கப்பட்டது
Self-reverting per request from two different admin. |
Extract date from an Archive.is URL, as already done with Wayback and WebCite URLs. Tested first with /sandbox, Module:Webarchive/testcases, and Template:Webarchive/testcases/Production. |
||
வரிசை 259:
end
--[[--------------------------<
Given a URI-path to Wayback (eg. /web/20160901010101/http://example.com )
வரிசை 320:
end
--[[--------------------------< decodeArchiveisDate >-----------------------
Given an Archive.is "long link" URI-path (e.g. /2016.08.28-144552/http://example.com)
return the date in df format (e.g. if df = dmy, return 28 August 2016)
Handles "." and "-" in snapshot date, so 2016.08.28-144552 is same as 20160828144552
]]
local function decodeArchiveisDate(path, df)
local snapdate, snapdatelong, currdate, fulldate
local safe = path
local N = mw.text.split(safe, "/")
safe = N[2] -- get snapshot date, e.g. 2016.08.28-144552
snapdate = string.gsub(safe, "[%.%-]", "") -- remove periods and hyphens
if not tonumber(snapdate) then -- if not numeric, it is "short link", not date
return "short link" -- e.g. http://archive.is/hD1qz
end
local dlen = string.len(snapdate)
if dlen < 4 then
return inlineRed("[Date error] (3)", "error")
end
if dlen < 14 then
snapdatelong = snapdate .. string.rep("0", 14 - dlen)
else
snapdatelong = snapdate
end
local year = string.sub(snapdatelong, 1, 4)
local month = string.sub(snapdatelong, 5, 6)
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
end
end
வரி 658 ⟶ 711:
end
end
elseif date and ulx.url1.service == "archiveis" and verifydates == "yes" then
local ldf = dateFormat(date)
if ldf then
local udate = decodeArchiveisDate( uri1.path, ldf )
if udate == "short link" then -- skip
elseif 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" )
வரி 670 ⟶ 732:
date = inlineRed("[Date error] (1)", "error")
end
elseif not date and ulx.url1.service == "archiveis" then
date = decodeArchiveisDate( uri1.path, "iso" )
if date == "short link" then
date = inlineRed("[Date missing]", "warning")
elseif not date then
date = inlineRed("[Date error] (1)", "error")
end
elseif not date then
date = inlineRed("[Date missing]", "warning")
| |||