Module:Article history/config: Difference between revisions

Content deleted Content added
convert featured topics code to use separate functions for each list field to return
convert the main page date to the new scheme
Line 635:
 
-- Main page date
{
function (articleHistoryObj)
id = 'MAINDATE',
local args = articleHistoryObj.args
isActive = function (articleHistoryObj)
local ret = {}
local statusargs = articleHistoryObj:getStatusId().args
local status = articleHistoryObj:getStatusId()
return not args.maindate and status ~= 'FA' and status ~= 'FL'
end,
makeData = function (articleHistoryObj)
local args = articleHistoryObj.args
local retdata = {}
data.mainDate = args.maindate
 
if not argsdata.maindatemainDate then
if local status == 'FA' thenarticleHistoryObj:getStatusId()
elseif if status == 'FLFA' then
return {categories = {Category.new(
data.categoryOnly = 'Featured articles that have not appeared on the main page'
elseif status == 'FL' then
)}}
data.categoryOnly = 'Featured lists that have not appeared on the main page'
elseif status == 'FL' then
end
return {categories = {Category.new(
return retdata
'Featured lists that have not appeared on the main page'
)}} end
 
else
data.mainDateTimestamp = getYmdDate(data.mainDate)
local data.currentTimestamp = getYmdDate()
if not data.mainDateTimestamp then
articleHistoryObj:raiseError(
string.format(
"invalid date '%s' detected in parameter 'maindate'",
data.mainDate
),
'Template:Article history#Errors'
)}}
)end
-- The first Today's Featured List was on 13 June 2011.
local data.isList = (status == 'FL' or status == 'FFL') and data.mainDateTimestamp >= 20110613
 
return data
end,
ret.icon = 'Wikipedia-logo-v2.svg',
ret.iconCaption = 'Main Page trophy',
text = function (articleHistoryObj, noticeObj)
local data = noticeObj:getData()
if data.categoryOnly then
return nil
end
end
 
local mainDateTimestamp = getYmdDate(args.maindate)
local currentTimestamp = getYmdDate()
if not mainDateTimestamp then
articleHistoryObj:raiseError(
string.format(
"invalid date '%s' detected in parameter 'maindate'",
args.maindate
),
'Template:Article history#Errors'
)
end
local isList = (status == 'FL' or status == 'FFL') and mainDateTimestamp >= 20110613
-- Icon
ret.icon = 'Wikipedia-logo-v2.svg'
ret.iconCaption = 'Main Page trophy'
-- Text
do
local blurb = "This article %s on Wikipedia's [[Main Page]] as " ..
"[[Wikipedia:Today's featured %s/%s|Today's featured %s]]%s."
local longDate = getLongDate(argsdata.maindatemainDate)
local pagetype = data.isList and 'list' or 'article'
local tenseBlurb, dateBlurb
if data.mainDateTimestamp < data.currentTimestamp then
tenseBlurb = 'appeared'
dateBlurb = ' on ' .. longDate
elseif data.mainDateTimestamp == data.currentTimestamp then
tenseBlurb = 'is currently on'
dateBlurb = ''
Line 688 ⟶ 696:
dateBlurb = ' on ' .. longDate
end
ret.text =return string.format(
blurb, tenseBlurb, pagetype, longDate, pagetype, dateBlurb
)
end,
categories = function (articleHistoryObj, noticeObj)
 
local data = noticeObj:getData()
-- Categories
do
local cats = {}
if data.categoryOnly then
cats[#cats + 1] = string.format(
cats[1] = Category.new(data.categoryOnly)
'Featured %s that have appeared on the main page',
else
isList and 'lists' or 'articles'
cats[#cats + 1] = Category.new(string.format(
)
'Featured %s that have appeared on the main page',
ret.categories = cats
data.isList and 'lists' or 'articles'
))
)end
return cats
end
}
return ret
end
},