Content deleted Content added
track linked itn dates |
add oldid parameters for OTD, automatically link ITN dates, don't separate each date with "on" in date lists, and remove the tracking category for ITN link parameters |
||
Line 76:
local args = articleHistoryObj.args
local prefixArgs = articleHistoryObj.prefixArgs
return args[prefix .. 'date
end
Line 125:
-- Organise the input
local function addData(sep)
if args[prefix .. 'date'] then▼
local t = {}
local argPrefix = prefix .. sep
do
local key =
t.date = validateDate(key, args[key], articleHistoryObj)
t.month, t.day, t.year = t.date:match('(%a+) (%d+), (%d+)')
t.day = tonumber(t.day)
t.year = tonumber(t.year)
t.ymdDate = getYmdDate(t.date)
end
for _, suffix in ipairs(suffixes) do
local key =
t[suffix] = args[key]
end
t.argPrefix = argPrefix
data[#data + 1] = t
▲ if args[prefix .. 'date'] then
addData('')
end
if prefixArgs[prefix] then
for _, prefixData in ipairs(prefixArgs[prefix]) do
do▼
▲ local key = prefix .. tostring(prefixData[1]) .. 'date'
▲ end
for i, suffix in ipairs(suffixes) do▼
end▼
end
end
Line 165:
-- The parameter $1 in the blurb will be replaced with the list of dates.
local function makeDateText(dateData, blurb)
local dates, doneLinks = {}, {}
for i, t in ipairs(dateData) do
if t.link and not doneLinks[t.link] then
dates[i] = string.format('
doneLinks[t.link] = true
else
dates[i] = string.format('
end
end
Line 1,751 ⟶ 1,752:
"Wikipedia's [[Main Page]] in the " ..
"''\"[[:Template:Did you know|Did you know?]]\"'' " ..
"column on $1.",
raPage
)
Line 1,834 ⟶ 1,835:
if not data then
return nil
if t.ymdDate >= 20090101 then
t.link = string.format(
'Wikipedia:ITN archives/%d/%s',
elseif t.ymdDate >= 20050101 then
t.link = string.format(
'Portal:Current events/%d %s %d',
t.year,
t.month,
t.day
end
end
end
local intro
Line 1,843 ⟶ 1,862:
local blurb = intro ..
" featured on Wikipedia's [[Main Page]] in the " ..
"''\"[[Template:In the news|In the news]]\"'' column on $1."
return makeDateText(data, blurb)
end,
Line 1,849 ⟶ 1,868:
local cats = {}
cats[1] = Category.new('Wikipedia In the news articles')
if data then▼
for i, t in ipairs(data) do▼
▲ if t.link then
▲ )
▲ break
▲ end
▲ end
▲ end
return cats
end
Line 1,871 ⟶ 1,879:
end,
makeData = function (articleHistoryObj)
return makeDateData(articleHistoryObj, 'otd', {'link', 'oldid'})
-- TODO: remove 'link' after it is no longer needed for tracking
end,
icon = 'Nuvola apps date.svg',
Line 1,881 ⟶ 1,890:
if not data then
return nil
▲ end
-- TODO: Move this inside the main module
local oldid = tonumber(t.oldid)
if oldid and
math.floor(oldid) == oldid and
oldid > 0 and
oldid < math.huge
then
-- If the oldid is valid, it takes precedence over
-- explicit links.
t.link = 'Special:PermaLink/' .. t.oldid
else
collapsibleNoticeObj:addWarning(
string.format(
"invalid oldid '%s' detected in parameter '%s'; " ..
"if an oldid is specified it must be a positive integer",
t.oldid,
t.argPrefix .. 'oldid'
),
'Template:Article history#Invalid oldid'
)
end
end
end
local intro
Line 1,891 ⟶ 1,925:
" featured on Wikipedia's [[Main Page]] in the " ..
"''\"[[Wikipedia:Selected anniversaries|On this day...]]\"'' " ..
"column on $1."
return makeDateText(data, blurb)
end,
|