Content deleted Content added
remove unnecessary mw.language.getContentLanguage call |
new format for the DYK object |
||
Line 1,461:
collapsibleNotices = {
-- DYK
{
id = 'DYK',
icon = 'DYK questionmark icon.svg',
iconCaption = 'Did You Know',
isActive = function (articleHistoryObj)
local args = articleHistoryObj.args
local prefixArgs = articleHistoryObj.prefixArgs
return not args.dykdate and not args.dykdate2 and not prefixArgs.dyk
end,
makeData = function (articleHistoryObj)
local args = articleHistoryObj.args
local prefixArgs = articleHistoryObj.prefixArgs
-- Sanity checks
if
for _, t in ipairs(prefixArgs.dyk) do
if not t.date then
articleHistoryObj:raiseError(
string.format(
"an argument starting with 'dyk%d' was detected, " ..
"but no 'dyk%ddate' parameter was specified",
t[1], t[1]
),
'Template:Article history#Errors'
)
end
end
end
local function validateDate(key, date)
local longDate = getLongDate(date)
if longDate then
return longDate
else
articleHistoryObj:raiseError(
string.format(
"
tostring(date),
),
'Template:Article history#Errors'
Line 1,482 ⟶ 1,505:
end
end
local
if args.dykdate then
data[#data + 1] = {
date = validateDate('dykdate', args.dykdate),
}
end
if args.dykdate2 then
data[#data + 1] = {
date = validateDate('dykdate2', args.dykdate2),
entry = args.dykentry2
}
articleHistoryObj:addWarning(
"the 'dykdate2' and 'dykentry2' parameters are " ..
"deprecated; use 'dyk2date' and 'dyk2entry' instead",
'Template:Article history#Errors'
)
end
if prefixArgs.dyk then
for _, t in ipairs(prefixArgs.dyk) do
date = validateDate('dyk' .. t[1] .. 'date', t.date),
entry = t.entry
}
end
end
if #data < 1 then
error('no DYKs found and parameter checks failed')
end
text = function (articleHistoryObj, collapsibleNoticeObj)
local data = collapsibleNoticeObj:getData()
local text = {}
local raPage
do
raPage = 'Wikipedia:Recent additions/'
.. getDate('Y/F#j F Y',
local raTitle = makeTitle(raPage)
if not raTitle or not raTitle.exists then
Line 1,550 ⟶ 1,554:
end
text[#text + 1] =
"A [[%s|'''fact from this article''']] appeared on Wikipedia's " ..
"[[Main Page]] in the ''\"[[:Template:Did you know|Did you know?]]\"'' column ",
raPage
)
local dates = {}
for i, t in ipairs(
dates[i] = 'on ' .. t.date
end
Line 1,563 ⟶ 1,567:
text[#text + 1] = '.'
end,
collapsibleText = function (articleHistoryObj, collapsibleNoticeObj)
local data = collapsibleNoticeObj:getData()
local ctext = {}
if #
ctext[#ctext + 1] = string.format(
"The text of the entry was: ''Did you know %s''",
)
else
local entries = {}
local lastEntryDate
for i, t in ipairs(
entries[#entries + 1] = t.entry
lastEntryDate = t.date
Line 1,589 ⟶ 1,592:
ctext[#ctext + 1] = 'The text of the entries was:\n'
local list = mw.html.create('ul')
for i, t in ipairs(
if t.entry then
list:tag('li'):wikitext(string.format(
Line 1,601 ⟶ 1,604:
end
if #ctext > 0 then
else
return nil
end
end,
categories = function (articleHistoryObj, collapsibleNoticeObj)
local cats = {}
local status = articleHistoryObj:getStatusId()
Line 1,620 ⟶ 1,623:
end
cats[1] = Category.new(cat)
end
}
},
|