Module:Article history/config: Difference between revisions

Content deleted Content added
fix
refactor the "spurious bullet" category code to use the "categories" config function - this lets us use the existing category suppression system
Line 1,847:
end,
makeData = function (articleHistoryObj)
returnlocal data = makeDateData(articleHistoryObj, 'dyk', {'entry'})
data.entryHasBullet = false
for i, t in ipairs(data) do
if t.entry then
local count
t.entry, count = t.entry:gsub('^%s*%*%s*', '')
if count > 0 then
data.entryHasBullet = true
end
end
end
return data
end,
text = function (articleHistoryObj, collapsibleNoticeObj)
Line 1,877 ⟶ 1,888:
ctext[#ctext + 1] = string.format(
"The text of the entry was: ''Did you know %s''",
data[1].entry
data[1].entry and mw.ustring.gsub(data[1].entry, '^%s*%*%s*', '[[Category:Pages using article history with a spurious bullet]]')
)
else
Line 1,883 ⟶ 1,894:
local lastEntryDate
for i, t in ipairs(data) do
entries[#entries + 1] = t.entry and mw.ustring.gsub(t.entry, '^%s*%*%s*', '[[Category:Pages using article history with a spurious bullet]]')
lastEntryDate = t.date
end
Line 1,913 ⟶ 1,924:
categories = function (articleHistoryObj, collapsibleNoticeObj)
local cats = {}
 
-- Standard DYK category
local status = articleHistoryObj:getStatusId()
local cat
Line 1,924 ⟶ 1,937:
cat = 'Wikipedia Did you know articles'
end
cats[#cats + 1] = Category.new(cat)
 
-- Category for spurious bullets
local data = collapsibleNoticeObj:getData(articleHistoryObj)
if data and data.entryHasBullet then
cats[#cats + 1] = Category.new(
data[1].entry and mw.ustring.gsub(data[1].entry, '^%s*%*%s*', '[[Category:Pages using article history with a spurious bullet]]')
)
end
 
return cats
end