Module:Webarchive: Difference between revisions

use require('strict') instead of require('Module:No globals')
m (1 revision imported: Wikipedia article on Nicotine templates needed)
imported>WOSlinker
(use require('strict') instead of require('Module:No globals'))
 
Line 11: Line 11:
]]
]]


require('Module:No globals');
require('strict');
local getArgs = require ('Module:Arguments').getArgs;
local getArgs = require ('Module:Arguments').getArgs;


Line 268: Line 268:
local date = table.concat ({year, month, day}, '-'); -- assemble year-initial numeric-format date (zero padding not required here)
local date = table.concat ({year, month, day}, '-'); -- assemble year-initial numeric-format date (zero padding not required here)


if non_western_digits then --this wiki uses non-western digits?
if non_western_digits then -- this wiki uses non-western digits?
date = mw.ustring.gsub (date, '%d', digits); -- convert this wiki's non-western digits to western digits
date = mw.ustring.gsub (date, '%d', digits); -- convert this wiki's non-western digits to western digits
end
end
Line 359: Line 359:


decode = makeDate (dt.year, dt.month, dt.day, 'iso'); -- date comparisons are all done in iso format with western digits
decode = makeDate (dt.year, dt.month, dt.day, 'iso'); -- date comparisons are all done in iso format with western digits
if non_western_digits then --this wiki uses non-western digits?
if non_western_digits then -- this wiki uses non-western digits?
decode = mw.ustring.gsub (decode, '%d', digits); -- convert this wiki's non-western digits to western digits
decode = mw.ustring.gsub (decode, '%d', digits); -- convert this wiki's non-western digits to western digits
end
end
Line 370: Line 370:


Given a URI-path to Wayback (eg. /web/20160901010101/http://example.com )
Given a URI-path to Wayback (eg. /web/20160901010101/http://example.com )
or Library of Congress Web Archives (/all/20160901010101/http://example.com)
or Library of Congress Web Archives (eg. /all/20160901010101/http://example.com)
or UK Government Web Archive (eg. /ukgwa/20160901010101/http://example.com or /tna/20160901010101/http://example.com)
 
return the formatted date eg. "September 1, 2016" in df format  
return the formatted date eg. "September 1, 2016" in df format  
Handle non-digits in snapshot ID such as "re_" and "-" and "*"
Handle non-digits in snapshot ID such as "re_" and "-" and "*"
Line 388: Line 390:
local msg, snapdate;
local msg, snapdate;


snapdate = path:gsub ('^/all/', ''):gsub ('^/web/', ''):gsub ('^/', ''); -- remove leading '/all/', leading '/web/' or leading '/'
snapdate = path:gsub ('^/web/', ''):gsub ('^/all/', ''):gsub ('^/ukgwa/', ''):gsub ('^/tna/', ''):gsub ('^/', ''); -- remove leading /web/, /all/, /ukgwa/, /tna/, or /
snapdate = snapdate:match ('^[^/]+'); -- get timestamp
snapdate = snapdate:match ('^[^/]+'); -- get timestamp
if snapdate == "*" then -- eg. /web/*/http.. or /all/*/http..
if snapdate == "*" then -- eg. /web/*/http.., etc.
return 'index'; -- return indicator that this url has an index date
return 'index'; -- return indicator that this url has an index date
end
end
Line 548: Line 550:
ulx[argurl2] = {}
ulx[argurl2] = {}
ulx[argurl2]["url"] = args[argurl]
ulx[argurl2]["url"] = args[argurl]
argdate = "date" .. j
argdate = "date" .. i
if args[argdate] then
if args[argdate] then
ulx[argurl2]["date"] = args[argdate]
ulx[argurl2]["date"] = args[argdate]
Line 555: Line 557:
end
end
argtitle = "title" .. j
argtitle = "title" .. i
if args[argtitle] then
if args[argtitle] then
ulx[argurl2]["title"] = args[argtitle]
ulx[argurl2]["title"] = args[argtitle]
Line 847: Line 849:
date = 'index';
date = 'index';
ldf = 'iso'; -- set to default format
ldf = 'iso'; -- set to default format
elseif 'mdy' == date then
date = nil; -- if date extracted from URL,
ldf = 'mdy'; -- then |date=mdy overrides iso
elseif 'dmy' == date then
date = nil; -- if date extracted from URL,
ldf = 'dmy'; -- then |date=dmy overrides iso
elseif 'ymd' == date then
date = nil; -- if date extracted from URL,
ldf = 'ymd'; -- then |date=ymd overrides iso
else
else
date, ldf = decode_date (date); -- get an iso format date from date and get date's original format
date, ldf = decode_date (date); -- get an iso format date from date and get date's original format
Line 852: Line 863:
end
end


if 'wayback' == ulx.url1.service or 'locwebarchives' == ulx.url1.service then
if 'wayback' == ulx.url1.service or 'locwebarchives' == ulx.url1.service or 'ukgwa' == ulx.url1.service then
if date then
if date then
if config.verifydates then
if config.verifydates then
Anonymous user