Module:Article history/config: Difference between revisions

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'] or args[prefix .. 'date2'] or prefixArgs[prefix]
end
 
Line 125:
 
-- Organise the input
local function addData(sep)
if args[prefix .. 'date'] then
local t = {}
local argPrefix = prefix .. sep
do
local key = prefixargPrefix .. 'date'
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 = prefixargPrefix .. suffix
t[suffix] = args[key]
end
t.argPrefix = argPrefix
data[#data + 1] = t
end
if args[prefix .. 'date'] then
addData('')
end
if prefixArgs[prefix] then
for _, prefixData in ipairs(prefixArgs[prefix]) do
local key = prefix .. addData(tostring(prefixData[1]) .. 'date')
local t = {}
do
local key = prefix .. tostring(prefixData[1]) .. 'date'
t.date = validateDate(key, args[key], articleHistoryObj)
end
for i, suffix in ipairs(suffixes) do
local key = prefix .. tostring(prefixData[1]) .. suffix
t[suffix] = args[key]
end
data[#data + 1] = t
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('on [[%s|%s]]', t.link, t.date)
doneLinks[t.link] = true
else
dates[i] = string.format('on %s', t.date)
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
doend
for i, suffixt in ipairs(suffixesdata) do
if not t.link then
if t.ymdDate >= 20090101 then
t.link = string.format(
'Wikipedia:ITN archives/%d/%s',
) t.year,
break t.month
end )
elseif t.ymdDate >= 20050101 then
t.link = string.format(
'Portal:Current events/%d %s %d',
t.year,
t.month,
t.day
end )
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')
local data = collapsibleNoticeObj:getData(articleHistoryObj)
if data then
for i, t in ipairs(data) do
if t.link then
cats[#cats + 1] = Category.new(
'Article history templates with linked itn dates'
)
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
for i, t in ipairs(data) do
if datat.oldid then
-- 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,