Module:Article history/config: Difference between revisions

Content deleted Content added
new format for the DYK object
convert featured topics code to use separate functions for each list field to return
Line 400:
 
notices = {
{
-- Featured topics
id = 'FT',
function (articleHistoryObj)
local argsisActive = function (articleHistoryObj.args)
local prefixArgsargs = articleHistoryObj.prefixArgsargs
local articleprefixArgs = articleHistoryObj.currentTitle.subjectPageTitle.prefixedTextprefixArgs
if not return (args.ftname and notor prefixArgs.ft) and true or thenfalse
 
end,
-- Exit if no featured topic parameters were given.
makeData = function (articleHistoryObj)
if not args.ftname and not prefixArgs.ft then
returnlocal nildata = {}
end
 
-- Assemble data about all of the featured topics.
local topics = {}
do
local getTopicStatus = require('Module:FeaturedTopicSum').status
local yesno = require('Module:Yesno')
 
local function makeTopicData(name, isMain, paramNum)
if name then
Line 438 ⟶ 434:
end
end
topicsdata[#topicsdata + 1] = makeTopicData(args.ftname, args.ftmain)
if prefixArgs.ft then
for i, t in ipairs(prefixArgs.ft) do
if t[1] > 1 then -- we use args.ftname instead of args.ft1name
topicsdata[#topicsdata + 1] = makeTopicData(t.name, t.main, t[1])
end
end
end
end
 
-- Check for rogue ft.. parameters
if #topicsdata < 1 then
articleHistoryObj:raiseError(
"a parameter starting with 'ft' was detected, but no " ..
"featured topic names were specified; " ..
"please check the parameter names",
'Template:Article history#Errors'
)
end
 
local ret = {}
 
-- GetFind if one of the icontopics is featured.
local isFeaturedisInFeaturedTopic = false
do
for _, topic in ipairs(topicsdata) do
local isFeatured = false
for _, topic in ipairs(topics) do
if topic.status == 'FT' then
isFeaturedisInFeaturedTopic = true
break
end
end
data.isInFeaturedTopic = isInFeaturedTopic
if isFeatured then
 
ret.icon = 'Cscr-featuredtopic.svg'
return retdata
ret.iconCaption = 'Featured topic star'
end,
icon = function (articleHistoryObj, noticeObj)
local data = noticeObj:getData()
if data.isInFeaturedTopic then
ret.icon =return 'Cscr-featuredtopic.svg'
else
ret.icon =return 'Support cluster.svg'
ret.iconCaption = 'Good topic star'
end
end,
ret.iconSize = '48px'
iconCaption = function (articleHistoryObj, noticeObj)
ret.iconSmallSize = '30px'
local data = noticeObj:getData()
end
if data.isInFeaturedTopic then
ret.iconCaption =return 'Featured topic star'
else
ret.iconCaption =return 'Good topic star'
end,
end,
ret.iconSize = '48px',
ret.iconSmallSize = '30px',
text = function (articleHistoryObj, noticeObj)
local data = noticeObj:getData()
local article = articleHistoryObj.currentTitle.subjectPageTitle.prefixedText
 
-- Make the text
do
local firstBlurb = "'''%s''' is %s the '''[[Wikipedia:Featured topics/%s|%s]] series''', %s."
local otherBlurb = "It is also %s the '''[[Wikipedia:Featured topics/%s|%s]] series''', %s."
Line 504 ⟶ 509:
-- First topic
do
local topic = topicsdata[1]
local link
if topic.status == 'FT' then
Line 524 ⟶ 529:
 
-- Other topics
for i = 2, #topicsdata do
local topic = topicsdata[i]
local link
if topic.status == 'FT' then
Line 553 ⟶ 558:
-- Final blurb
do
local isPlural = #topicsdata > 1
text[#text + 1] = string.format(
finalBlurb,
Line 561 ⟶ 566:
end
 
ret.text =return table.concat(text, ' ')
end,
categories = function (articleHistoryObj, noticeObj)
 
local data = noticeObj:getData()
-- Categories
local status = articleHistoryObj:getStatusId()
do
local cats = {}
local status = articleHistoryObj:getStatusId()
 
local function addCat(cat, sort)
Line 586 ⟶ 590:
-- Topic-specific status categories
local function addTopicCats(catFormat)
for i, topic in ipairs(topicsdata) do
addCat(string.format(catFormat, topic.name))
end
Line 600 ⟶ 604:
-- Importance categories
local hasTop, hasHigh, hasMid, hasLow -- These check for dupes
for i, topic in ipairs(topicsdata) do
local cat, sort
if topic.status == 'FT' then
Line 626 ⟶ 630:
end
 
ret.categories =return cats
end
},
 
return ret
end,
-- Main page date
function (articleHistoryObj)