模組:沙盒/Justincheng12345/Article history/config
外观
-------------------------------------------------------------------------------
-- Configuration data for [[Module:Article history]]
-------------------------------------------------------------------------------
local lang = mw.language.getContentLanguage()
local Category = require('Module:Article history/Category')
-------------------------------------------------------------------------------
-- Helper functions
-------------------------------------------------------------------------------
-- lua cannot interpret xxxx年yy月zz日
local function convertDate(dateString)
for y,m,d in string.gmatch(dateString, "(%d+)年(%d+)月(%d+)日") do
return y .. "-" .. m .. "-" .. d
end
end
-- Makes a link to a template page surrounded by double curly braces. A
-- workalike for the {{tl}} template.
local function makeTemplateLink(s)
local openb = mw.text.nowiki('{{')
local closeb = mw.text.nowiki('}}')
return string.format('%s[[Template:%s|%s]]%s', openb, s, s, closeb)
end
-- No Good Article topic in zhwiki
-- Gets the Good Article topic for the given key. Uses
-- [[Module:Good article topics]].
local function getGoodArticleTopic(key)
if not key then
return nil
end
return require('Module:Good article topics')._main(key)
end
-- Returns the Good Article page link and display value for a given Good Article
-- key. If the key wasn't valid, the default Good Article page and display value
-- is returned instead.
local function getGoodArticleTopicLink(key)
local topic = getGoodArticleTopic(key)
local link, display
if topic then
link = 'Wikipedia:Good articles/' .. topic
display = topic .. ' good articles'
else
link = 'Wikipedia:Good articles'
display = 'good articles'
end
return link, display
end
-- Wrapper function for mw.language:formatDate, going through pcall to catch
-- invalid input errors.
local function getDate(format, date)
local chineseDate, newDate = pcall(convertDate, date)
if chineseDate and newDate then
date = newDate
end
local success, result = pcall(lang.formatDate, lang, format, date)
if success then
return result
end
end
-- Gets the date in the format YYYYMMDD, as a number. Months and dates are
-- zero-padded. Results from this function are intended to be used in date
-- calculations.
local function getYmdDate(date)
date = getDate('Ymd', date)
if date then
return tonumber(date)
else
return nil
end
end
-- Gets the date in the format Month d, YYYY.
local function getLongDate(date)
return getDate('Y年Fj日', date)
end
-- Returns true if the given page is an existing title, and false or nil
-- otherwise
local function titleExists(page)
local success, title = pcall(mw.title.new, page)
return success and title.exists
end
-- Returns a truthy value if a date parameter for the given prefix has been
-- provided by the user.
local function isActiveDatedObject(articleHistoryObj, prefix)
local args = articleHistoryObj.args
local prefixArgs = articleHistoryObj.prefixArgs
return args[prefix .. 'date'] or prefixArgs[prefix]
end
-- Returns a date as formatted by getLongDate. If the date is invalid, it raises
-- an error using param as the parameter name containing the invalid date.
local function validateDate(param, date, articleHistoryObj)
local longDate = getLongDate(date)
if longDate then
return longDate
else
articleHistoryObj:raiseError(
string.format(
"參數「'%s'」中發現錯誤日期「%s」",
param, tostring(date)
),
'Template:Article history#錯誤日期'
)
end
end
-- Generates a data table for a date-related notice such as DYK and ITN. prefix
-- is the parameter prefix for that notice type (e.g. "dyk"), and suffixes is
-- an array of parameter suffixes in addition to "date" that is used by that
-- notice type (e.g. "entry" for the "dykentry" and "dyk2entry" parameters).
local function makeDateData(articleHistoryObj, prefix, suffixes)
local args = articleHistoryObj.args
local prefixArgs = articleHistoryObj.prefixArgs
-- Sanity checks
if prefixArgs[prefix] then
for _, t in ipairs(prefixArgs[prefix]) do
if not t.date then
articleHistoryObj:raiseError(
string.format(
"發現以「%s%d」起始的參數,但尚未指定參數「%s%ddate」",
prefix, t[1],
prefix, t[1]
),
'Template:Article history#沒有日期'
)
end
end
end
local data = {}
-- Organise the input
local function addData(sep)
local t = {}
local argPrefix = prefix .. sep
do
local key = argPrefix .. '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 = argPrefix .. 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
addData(tostring(prefixData[1]))
end
end
if #data < 1 then
error(string.format(
"no data items found for prefix '%s' and parameter checks failed'",
tostring(prefix)
))
end
return data
end
-- This makes the text for Main Page features such as DYKs and ITNs for the
-- dates contained in dateData (made with the makeDateData function).
-- 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('[[%s|%s]]', t.link, t.date)
doneLinks[t.link] = true
else
dates[i] = string.format('%s', t.date)
end
end
local dateList = mw.text.listToText(dates, '、', '及')
return mw.message.newRawMessage(blurb, dateList):plain()
end
return {
-------------------------------------------------------------------------------
-- CONFIG TABLE START
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Statuses
-- Configuration for possible current statuses of the article.
-------------------------------------------------------------------------------
-- The statuses table contain configuration tables for possible current statuses
-- of the article.
-- Each table can have the following fields:
--
-- id: the main ID for the status. This should be the same as the configuration
-- table key.
-- aliases: a table of ID aliases that can be used to access the config table.
-- icon: The status icon.
-- iconSize: The icon size, including "px" suffix. The default is defined in
-- defaultStatusIconSize.
-- iconSmallSize: The icon size if we are outputting a small template. The
-- default is defined in defaultSmallStatusIconSize.
-- iconMultiSize: The icon size if we are outputting multiple status rows. The
-- default is defaultSmallStatusIconSize.
-- text: The status text. This may be a string or a function. If it is a
-- function, it takes an article history object as input, and should return
-- the text string. If it is a string, it can have the following parameters:
-- $1 - The full page name of the article or subject page
-- $2 - The page name without the namespace name
-- categories: The categories set by the status. This may be an array of
-- category names, or a function. If it is a function, it takes an article
-- history object as the first parameter, and the current status object as
-- the second parameter, and should return an array of category objects.
-- noticeBarIcon: the icon to use for the notice bar. This can be a string, or
-- a function, or true. If it is a function it takes an article history
-- object as the first parameter, and should output the icon filename. If it
-- is true, it uses the value of icon. If it is nil then no notice bar icon
-- will be displayed.
-- noticeBarIconCaption: the caption to use for the notice bar icon. The status
-- name is used by default. This can be a string or a function. If it is a
-- function, it takes an article history object as its first parameter, and
-- should return the caption text. If this is absent, the icon caption is
-- used instead.
-- noticeBarIconSize: the size of the notice bar icon, including "px" suffix.
-- The default is set by defaultNoticeBarIconSize.
statuses = {
FA = {
id = 'FA',
name = '典範條目',
icon = 'Featured article star.svg',
text = function (articleHistoryObj)
local articlePage = articleHistoryObj.currentTitle.subjectPageTitle.prefixedText
local text = "'''%s'''是一條[[Wikipedia:典範條目|典範條目]],即此條目可" ..
"作為[[Wikipedia:社群首頁|維基百科社群]]的典範之作。如有需要,請" ..
"[[Wikipedia:勇於更新頁面|勇於更新頁面]]。"
return string.format(text, articlePage)
end,
categories = {'典範條目討論'}
},
FFA = {
id = 'FFA',
name = '已撤銷的典範條目',
icon = 'Featured article star - cross.svg',
iconSize = '48px',
text = "'''$1'''曾屬'''[[Wikipedia:典範條目|典範條目]]''',但已[[Wikipedia:已撤銷的典範條目|撤銷資格]]。" ..
"下方條目里程碑的連結中可了解撤銷資格的詳細原因及改善建議。條目照建議改善而重新" ..
"符合[[Wikipedia:典範條目標準|標準]]後可再次提名[[Wikipedia:典範條目評選|評選]]。"
},
FFAC = {
id = 'FFAC',
name = '典範條目落選',
icon = 'Cscr-former.svg',
text = "'''$1'''曾獲提名'''[[Wikipedia:典範條目評選|典範條目評選]]'''," ..
"惟因其尚未符合[[Wikipedia:典範條目標準|標準]]而落選。下方條目里程碑的連結中可" ..
"了解落選的詳細原因及改善建議。列表照建議改善之後可再次提名評選。",
categories = {'典範條目落選'}
},
FL = {
id = 'FL',
name = '特色列表',
icon = 'Featured article star.svg',
iconSize = '48px',
text = function (articleHistoryObj)
local articlePage = articleHistoryObj.currentTitle.subjectPageTitle.prefixedText
local text = "'''%s'''是一條[[Wikipedia:特色列表|特色列表]],即此列表可" ..
"作為[[Wikipedia:社群首頁|維基百科社群]]的典範之作。如有需要,請" ..
"[[Wikipedia:勇於更新頁面|勇於更新頁面]]。"
return string.format(text, articlePage)
end,
categories = {'特色列表討論'}
},
FFL = {
id = 'FFL',
name = '已撤銷的特色列表',
icon = 'Cscr-featured-strike.svg',
text = "'''$1'''曾屬'''[[Wikipedia:特色列表|特色列表]]''',但已[[Wikipedia:已撤銷的特色列表|撤銷資格]]。" ..
"下方條目里程碑的連結中可了解撤銷資格的詳細原因及改善建議。列表照建議改善而重新" ..
"符合[[Wikipedia:特色列表標準|標準]]後可再次提名[[Wikipedia:特色列表評選|評選]]。"
},
FFLC = {
id = 'FFLC',
name = '特色列表落選',
icon = 'Cscr-former.svg',
iconCaption = 'Former FLC',
text = "'''$1'''曾獲提名'''[[Wikipedia:特色列表評選|特色列表評選]]'''," ..
"惟因其尚未符合[[Wikipedia:特色列表標準|標準]]而落選。下方條目里程碑的連結中可" ..
"了解落選的詳細原因及改善建議。列表照建議改善之後可再次提名評選。",
categories = {'特色列表落選'}
},
GA = {
id = 'GA',
name = '優良條目',
icon = 'Symbol support vote.svg',
iconSize = '40px',
iconMultiSize = '25px',
text = function (articleHistoryObj)
local articlePage = articleHistoryObj.currentTitle.subjectPageTitle.prefixedText
local text = "'''%s'''因符Autodetect-dev合[[Wikipedia:優良條目標準|標準]]而獲列入" ..
"'''[[Wikipedia:優良條目|優良條目]]'''。如有需要,請" ..
"[[Wikipedia:勇於更新頁面|勇於更新頁面]]。<small>如條目不再" ..
"達標可提出[[Wikipedia:優良條目評選|重新評選]]。</small>"
return string.format(text, articlePage)
end,
categories = {'優良條目討論'}
},
FGAN = {
id = 'FGAN',
name = '優良條目落選',
icon = 'Symbol unsupport vote.svg',
text = function (articleHistoryObj)
local articlePage = articleHistoryObj.currentTitle.subjectPageTitle.prefixedText
local text = "'''%s'''曾獲提名'''[[Wikipedia:優良條目評選|優良條目評選]]'''," ..
"惟因其尚未符合[[Wikipedia:優良條目標準|標準]]而落選。下方條目里程碑的連結中可" ..
"了解落選的詳細原因及改善建議。條目照建議改善之後可再次提名評選。"
return string.format(text, articlePage)
end,
categories = {'優良條目落選'}
},
DGA = {
id = 'DGA',
name = '已撤銷的優良條目',
icon = 'Symbol unsupport vote.svg',
iconCaption = 'Former good article',
text = function (articleHistoryObj)
local articlePage = articleHistoryObj.currentTitle.subjectPageTitle.prefixedText
local text = "'''%s'''曾屬'''[[Wikipedia:優良條目|優良條目]]''',但已[[Wikipedia:已撤銷的優良條目|撤銷資格]]。" ..
"下方條目里程碑的連結中可了解撤銷資格的詳細原因及改善建議。條目照建議改善而重新" ..
"符合[[Wikipedia:優良條目標準|標準]]後可再次提名[[Wikipedia:優良條目評選|評選]]。"
return string.format(text, articlePage)
end
},
FFT = {
id = 'FFT',
name = 'Part of former featured topic',
icon = 'Cscr-featured-strike.svg',
iconCaption = 'Former featured topic',
text = "This article is part of a " ..
"''[[Wikipedia:Former featured topics|former featured topic]]'' series. " ..
"If it has improved again to " ..
"[[Wikipedia:Featured topic criteria|featured topic standard]], " ..
"you may [[Wikipedia:Featured topic candidates|renominate]] " ..
"the topic to become a [[Wikipedia:Featured topic|featured topic]]."
},
FFTC = {
id = 'FFTC',
name = 'Former featured topic candidate',
icon = 'Cscr-former.svg',
text = "This article is part of a ''former'' " ..
"[[Wikipedia:Featured topic candidates|featured topic candidate]]. " ..
"Please view the links under Article milestones below to see why " ..
"the nomination failed."
},
FPO = {
id = 'FPO',
name = 'featured topic',
icon = 'Cscr-featured.svg',
text = "The '''$2 Portal''' is a [[Wikipedia:Featured portals|featured portal]], " ..
"which means it has been " ..
"'''''[[Wikipedia:Featured portal candidates/Portal:$2|identified]]''''' " ..
"as one of the best portals on [[Wikipedia]]. " ..
"If you see a way this portal can be updated or improved without " ..
"compromising previous work, please feel free to contribute.",
categories = function (articleHistoryObj)
return {Category.new(
'Wikipedia featured portals',
articleHistoryObj.currentTitle.text
)}
end
},
FFPO = {
id = 'FFPO',
name = 'Former featured portal',
icon = 'Featured article star - cross.svg',
text = "This portal is a [[Wikipedia:Former featured portals|former featured portal]]. " ..
"Please see the links under Portal milestones below for its " ..
"original nomination page and why it was removed.",
categories = function (articleHistoryObj)
return {Category.new(
'Wikipedia former featured portals',
articleHistoryObj.currentTitle.text
)}
end
},
FFPOC = {
id = 'FFPOC',
name = 'Former featured portal candidate',
icon = 'Cscr-former.svg',
text = "This portal is a '''''former''''' " ..
"[[Wikipedia:Featured portal candidates|featured portal candidate]]. " ..
"Please see the links under Portal milestones below for its " ..
"original nomination page and why the nomination failed.",
categories = function (articleHistoryObj)
return {Category.new(
'Wikipedia featured portal candidates (contested)',
articleHistoryObj.currentTitle.text
)}
end
},
PR = {
-- Peer review is a valid current status, but it doesn't trigger a
-- header row.
id = 'PR',
name = '同行評審',
noticeBarIcon = 'Nuvola apps kedit.svg'
},
NA = {
-- A valid current status, but doesn't trigger a header row.
id = 'NA',
noticeBarIcon = 'Nuvola apps kedit.svg'
},
-- The following are invalid statuses.
FAC = {
id = 'FAC',
text = function (articleHistoryObj)
articleHistoryObj:raiseError(
"請前往[[Wikipedia:典範條目評選|典範條目評選]]提名評選。",
'Template:Article history#典範條目評選'
)
end
},
FAR = {
id = 'FAR',
text = function (articleHistoryObj)
articleHistoryObj:raiseError(
"請前往[[Wikipedia:典範條目評選|典範條目評選]]提名重選。",
'Template:Article history#典範條目評選'
)
end
},
STUB = {
id = 'STUB',
aliases = {'START', 'B', 'A'},
text = function (articleHistoryObj)
local currentStatusParam = articleHistoryObj.cfg.currentStatusParam
articleHistoryObj:raiseError(
string.format(
"切勿為參數「%s」填上「%s」,條目評級應於各專題模板處填寫",
currentStatusParam,articleHistoryObj.args[currentStatusParam],
currentStatusParam
),
'Template:Article history#專題評核'
)
end
},
-- The followings are Multi-statuses
-- It can be modified to get statues recursively, but it would take some time to develop
-- Also the performence for recursive or split-string method comparing to this is not known.
['FFA/DGA/FFAC/FGAN'] = {
id = 'FFA/DGA/FFAC/FGAN',
name = '典範條目及優良條目資格皆已撤銷;其後重新評選典範條目及優良條目亦落選',
isMulti = true,
statuses = {'FFA', 'DGA', 'FFAC', 'FGAN'}
},
['FFA/DGA/FFAC'] = {
id = 'FFA/DGA/FFAC',
name = '典範條目及優良條目資格皆已撤銷;其後重新評選典範條目亦落選',
isMulti = true,
statuses = {'FFA', 'DGA', 'FFAC'}
},
['FFA/DGA/FGAN'] = {
id = 'FFA/DGA/FGAN',
name = '典範條目及優良條目資格皆已撤銷;其後重新評選優良條目亦落選',
isMulti = true,
statuses = {'FFA', 'DGA', 'FGAN'}
},
['FFA/FFAC/FGAN'] = {
id = 'FFA/FFAC/FGAN',
name = '已撤銷的典範條目;其後重新評選典範條目及優良條目亦落選',
isMulti = true,
statuses = {'FFA', 'FFAC', 'FGAN'}
},
['DGA/FFAC/FGAN'] = {
id = 'FFA/FFAC/FGAN',
name = '已撤銷的優良條目;其後重新評選典範條目及優良條目亦落選',
isMulti = true,
statuses = {'DGA', 'FFAC', 'FGAN'}
},
['GA/FFA/FFAC'] = {
id = 'FFA/FFAC/FGAN',
name = '典範條目資格撤銷後評選為優良條目;其後重新評選典範條目亦落選',
isMulti = true,
statuses = {'GA', 'FFA', 'FFAC'}
},
['FFA/DGA'] = {
id = 'FFA/DGA',
name = '典範條目及優良條目資格皆已撤銷',
isMulti = true,
statuses = {'FFA', 'DGA'}
},
['FFA/FFAC'] = {
id = 'FFA/FFAC',
name = '已撤銷的典範條目;其後重新評選亦落選',
isMulti = true,
statuses = {'FFA', 'FFAC'}
},
['FFA/FGAN'] = {
id = 'FFA/FGAN',
name = '已撤銷的典範條目;其後評選優良條目亦落選',
isMulti = true,
statuses = {'FFA', 'FGAN'}
},
['DGA/FFAC'] = {
id = 'DGA/FFAC',
name = '已撤銷的優良條目;其後評選典範條目亦落選',
isMulti = true,
statuses = {'DGA', 'FFAC'}
},
['DGA/FGAN'] = {
id = 'DGA/FGAN',
name = '已撤銷的優良條目;其後重新評選亦落選',
isMulti = true,
statuses = {'DGA', 'FGAN'}
},
['FFAC/FGAN'] = {
id = 'FFAC/FGAN',
name = '評選典範條目及優良條目皆已落選',
isMulti = true,
statuses = {'FFAC', 'FGAN'}
},
['GA/FFAC'] = {
id = 'GA/FFAC',
name = '優良條目;其後評選典範條目落選',
isMulti = true,
statuses = {'GA', 'FFAC'}
},
['GA/FFA'] = {
id = 'GA/FFA',
name = '典範條目資格撤銷後評選為優良條目',
isMulti = true,
statuses = {'GA', 'FFA'}
},
['FFL/FFLC'] = {
id = 'FFL/FFLC',
name = '已撤銷的特色列表;其後重新評選亦落選',
isMulti = true,
statuses = {'FFL', 'FFLC'}
}
},
-- This function allows the generation of custom status ID. It takes an
-- articleHistory object as the first parameter, and should output the status
-- ID.
getStatusIdFunction = function (articleHistoryObj)
-- Cauclate the right status by each action
-- Can't think of a good way using table, so why not back to uni-tier
-- Using a single int with each status assigned a prime number
local actions = articleHistoryObj:getActionObjects()
local statusTable = {[2]="FA",[3]="FL",[5]="GA",[7]="FFA",[11]="FFL",
[13]="DGA",[17]="FFAC",[19]="FFLC",[23]="FGAN"}
local statusCode = 1
local function removeOldStatus(current, old)
for k,v in pairs(old) do
if current%v == 0 then
current = current/v
end
end
return math.floor(current)
end
local function raiseInvalidStatus(current, invalid, i)
for k,v in pairs(invalid) do
if current%v == 0 then
articleHistoryObj:raiseError(
"參數「action" .. i .. "」發現錯誤事項,故系統無法計算正確的當前狀態",
'Template:Article history'
)
end
end
end
for i = 1, #actions, 1 do
local actionObj = actions[i]
if actionObj.id == 'FAC' then
raiseInvalidStatus(statusCode, {2,3}, i)
if actionObj.resultId == "promoted" then
statusCode = 2
else
statusCode = statusCode * 17
end
elseif actionObj.id == 'FLC' then
raiseInvalidStatus(statusCode, {2,3}, i)
if actionObj.resultId == "promoted" then
statusCode = 3
else
statusCode = statusCode * 19
end
elseif actionObj.id == 'GAN' then
raiseInvalidStatus(statusCode, {2,3,5}, i)
if actionObj.resultId == "listed" then
statusCode = statusCode * 5
statusCode = removeOldStatus(statusCode, {13,23})
else
statusCode = statusCode * 23
end
elseif actionObj.id == 'FAR' then
raiseInvalidStatus(statusCode, {3,5,7,11,13,17,19,23}, i)
if actionObj.resultId == "demoted" or actionObj.resultId == "merged" then
statusCode = statusCode * 7
statusCode = removeOldStatus(statusCode, {2})
end
elseif actionObj.id == 'FLR' then
raiseInvalidStatus(statusCode, {2,5,7,11,13,17,19,23}, i)
if actionObj.resultId == "demoted" or actionObj.resultId == "merged" then
statusCode = statusCode * 11
statusCode = removeOldStatus(statusCode, {3})
end
elseif actionObj.id == 'GAR' then
raiseInvalidStatus(statusCode, {2,3,11,13,23}, i)
if actionObj.resultId == "delisted" then
statusCode = statusCode * 13
statusCode = removeOldStatus(statusCode, {5})
end
end
end
-- get and return ID from the number
local statusID = ""
local ordered_keys = {}
for k in pairs(statusTable) do
table.insert(ordered_keys, k)
end
table.sort(ordered_keys)
for i = 1, #ordered_keys do
local k, v = ordered_keys[i], statusTable[ordered_keys[i] ]
if statusCode%k==0 then
statusID = statusID .. v .. "/"
statusCode = statusCode/k
end
end
return statusID and statusID:sub(1, -2) or ""
end,
-------------------------------------------------------------------------------
-- Notices
-------------------------------------------------------------------------------
-- The notices table contains configuration tables for notices about the article
-- that are unrelated to its current status.
-- Each configuration table can have the following fields:
--
-- id: the main ID for the notice. This should be the same as the configuration
-- table key.
-- isActive: a function that should return a truthy value if the notice should
-- be displayed, and a falsy value if not. (Falsy values are false and nil,
-- and truthy values are everything else.) The function takes an article
-- history object as its first parameter.
-- makeData: a function that should return a table of data to be used by other
-- functions in this notice configuration table. It can be accessed using
-- noticeObj:getData().
-- icon: the filename of the notice icon, minus the "File:" prefix.
-- iconCaption: the icon caption.
-- iconSize: The icon size, including "px" suffix. The default is defined in
-- defaultIconSize.
-- iconSmallSize: The icon size if we are outputting a small template. The
-- default is defined in defaultSmallIconSize.
-- text: The notice text. This may be a string or a function. If it is a
-- function, it takes an article history object as the first parameter, and
-- the current notice object as the second parameter, and should return the
-- text string.
-- categories: The categories set by the notice. This may be an array of
-- category names, or a function. If it is a function, it takes an article
-- history object as the first parameter, and the current notice object as
-- the second parameter, and should return an array of category objects.
-- noticeBarIcon: the icon to use for the notice bar. This can be a string, or
-- a function, or true. If it is a function it takes an article history
-- object as the first parameter, and should output the icon filename. If it
-- is true, it uses the value of icon. If it is nil then no notice bar icon
-- will be displayed.
-- noticeBarIconCaption: the caption to use for the notice bar icon. This can be
-- a string or a function. If it is a function, it takes an article history
-- object as its first parameter, and should return the caption text. If this
-- is absent, the icon caption is used instead.
-- noticeBarIconSize: the size of the notice bar icon, including "px" suffix.
-- The default is set by defaultNoticeBarIconSize.
notices = {
{
id = 'FT',
isActive = function (articleHistoryObj)
local args = articleHistoryObj.args
local prefixArgs = articleHistoryObj.prefixArgs
-- ftmain is included here because it leads to better error
-- messages than leaving it out, even though ftmain by itself is
-- invalid.
return args.ftname or args.ftmain or prefixArgs.ft
end,
makeData = function (articleHistoryObj)
local args = articleHistoryObj.args
local prefixArgs = articleHistoryObj.prefixArgs
local data = {}
local getTopicStatus = require('Module:FeaturedTopicSum').status
local yesno = require('Module:Yesno')
local function makeTopicData(name, isMain, paramNum)
if name then
return {
name = name,
isMain = yesno(isMain) or false,
status = getTopicStatus(name),
paramNum = paramNum
}
elseif isMain then
local num = paramNum and tostring(paramNum) or ''
articleHistoryObj:raiseError(
string.format(
"parameter 'ft%smain' is set, but no featured " ..
"topic name is set in parameter 'ft%sname'",
num, num
),
'Template:Article history#Featured topic names'
)
else
return nil
end
end
data[#data + 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
data[#data + 1] = makeTopicData(t.name, t.main, t[1])
end
end
end
-- Check for rogue ft.. parameters
if #data < 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#Featured topic names'
)
end
-- Find if one of the topics is featured.
local isInFeaturedTopic = false
for _, topic in ipairs(data) do
if topic.status == 'FT' then
isInFeaturedTopic = true
break
end
end
data.isInFeaturedTopic = isInFeaturedTopic
return data
end,
icon = function (articleHistoryObj, noticeObj)
local data = noticeObj:getData(articleHistoryObj)
if not data then
return nil
end
if data.isInFeaturedTopic then
return 'Cscr-featuredtopic.svg'
else
return 'Support cluster.svg'
end
end,
iconCaption = function (articleHistoryObj, noticeObj)
local data = noticeObj:getData(articleHistoryObj)
if not data then
return nil
end
if data.isInFeaturedTopic then
return 'Featured topic star'
else
return 'Good topic star'
end
end,
iconSize = '48px',
iconSmallSize = '30px',
text = function (articleHistoryObj, noticeObj)
local data = noticeObj:getData(articleHistoryObj)
if not data then
return nil
end
local article = articleHistoryObj.currentTitle.subjectPageTitle.prefixedText
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."
local finalBlurb = "%s identified as among the best series of " ..
"articles produced by the [[Wikipedia:Wikipedians|Wikipedia community]]. " ..
"If you can update or improve %s, [[Wikipedia:Be bold|please do so]]."
local main = 'the main article in'
local notMain = 'part of'
local featuredLink = 'a [[Wikipedia:Featured topics|featured topic]]'
local featuredNoLink = 'a featured topic'
local goodLink = 'a [[Wikipedia:Good topics|good topic]]'
local goodNoLink = 'a good topic'
local thisSingular = 'This is'
local thisPlural = 'These are'
local itSingular = 'it'
local itPlural = 'them'
local hasFeaturedLink = false
local hasGoodLink = false
local text = {}
-- First topic
do
local topic = data[1]
local link
if topic.status == 'FT' then
link = featuredLink
hasFeaturedLink = true
else
link = goodLink
hasGoodLink = true
end
text[#text + 1] = string.format(
firstBlurb,
article,
topic.isMain and main or notMain,
topic.name,
topic.name,
link
)
end
-- Other topics
for i = 2, #data do
local topic = data[i]
local link
if topic.status == 'FT' then
if hasFeaturedLink then
link = featuredNoLink
else
link = featuredLink
hasFeaturedLink = true
end
else
if hasGoodLink then
link = goodNoLink
else
link = goodLink
hasGoodLink = true
end
end
text[#text + 1] = string.format(
otherBlurb,
topic.isMain and main or notMain,
topic.name,
topic.name,
link
)
end
-- Final blurb
do
local isPlural = #data > 1
text[#text + 1] = string.format(
finalBlurb,
isPlural and thisPlural or thisSingular,
isPlural and itPlural or itSingular
)
end
return table.concat(text, ' ')
end,
categories = function (articleHistoryObj, noticeObj)
local data = noticeObj:getData(articleHistoryObj)
if not data then
return nil
end
local status = articleHistoryObj:getStatusId()
local article = articleHistoryObj.currentTitle.subjectPageTitle.prefixedText
local cats = {}
local function addCat(cat, sort)
cats[#cats + 1] = Category.new(cat, sort)
end
-- Page-wide status categories
if status == 'FA' then
addCat('FA-Class Featured topics articles')
elseif status == 'FL' then
addCat('FL-Class Featured topics articles')
elseif status == 'FFA/GA' or status == 'GA' then
addCat('GA-Class Featured topics articles')
else
addCat('Unassessed Featured topics articles')
end
-- Topic-specific status categories
local function addTopicCats(catFormat)
for i, topic in ipairs(data) do
addCat(string.format(catFormat, topic.name))
end
end
if status == 'FA' or status == 'FL' then
addTopicCats('Wikipedia featured topics %s featured content')
elseif status == 'FFA/GA' or 'GA' then
addTopicCats('Wikipedia featured topics %s good content')
else
addTopicCats('Wikipedia featured topics %s')
end
-- Importance categories
local hasTop, hasHigh, hasMid, hasLow -- These check for dupes
for i, topic in ipairs(data) do
local cat, sort
if topic.status == 'FT' then
if topic.isMain and not hasTop then
cat = 'Top-importance Featured topics articles'
sort = topic.name .. ' ' .. article
hasTop = true
elseif not topic.isMain and not hasHigh then
cat = 'High-importance Featured topics articles'
hasHigh = true
end
else
if topic.isMain and not hasMid then
cat = 'Mid-importance Featured topics articles'
sort = topic.name .. ' ' .. article
hasMid = true
elseif not topic.isMain and not hasLow then
cat = 'Low-importance Featured topics articles'
hasLow = true
end
end
if cat then
addCat(cat, sort)
end
end
return cats
end
},
-- Main page FA date
{
id = 'MAINDATEFA',
isActive = function (articleHistoryObj)
local args = articleHistoryObj.args
local status = articleHistoryObj:getStatusId()
return args.maindateFA or status == 'FA' or status == 'FL'
end,
makeData = function (articleHistoryObj)
local args = articleHistoryObj.args
local status = articleHistoryObj:getStatusId()
local data = {}
local function validateMainDate(argName, dataName, dataTimestampName)
data[dataName] = args[argName]
if data[dataName] then
data[dataTimestampName] = getYmdDate(data[dataName])
if not data[dataTimestampName] then
articleHistoryObj:raiseError(
string.format(
"參數「'%s'」中發現錯誤日期「%s」",
argName, data[dataName]
),
'Template:Article history#錯誤日期'
)
end
end
end
validateMainDate('maindateFA', 'mainDateFA', 'mainDateFATimestamp')
data.currentTimestamp = getYmdDate()
return data
end,
icon = 'Wikipedia-logo-v2.svg',
iconCaption = 'Main Page trophy',
text = function (articleHistoryObj, noticeObj)
local data = noticeObj:getData(articleHistoryObj)
if not data or not data.mainDateFA then
return nil
end
-- Build the blurb for all the possible combinations of past,
-- present and future appearances of maindate and maindate2.
local todaysFA = ""
local mainDateLong = getLongDate(data.mainDateFA)
if data.isList then
todaysFA = "特色列表"
else
todaysFA = "典範條目"
end
local function makeFeaturedLink(date, display)
return string.format(
"[[Wikipedia:典範條目/%s|%s]]",
date,
display or date
)
end
local function isPast(timestamp)
return timestamp < data.currentTimestamp
end
local function isCurrent(timestamp)
return timestamp == data.currentTimestamp
end
if isPast(data.mainDateFATimestamp) then
return string.format(
"此條目曾於%s在維基百科[[Wikipedia:首頁|首頁]]的%s上展示。",
mainDateLong, makeFeaturedLink(mainDateLong, todaysFA)
)
elseif isCurrent(data.mainDateFATimestamp) then
return string.format(
"此條目現正於維基百科[[Wikipedia:首頁|首頁]]的%s上展示。",
mainDateLong, makeFeaturedLink(mainDateLong, todaysFA)
)
else
return string.format(
"此條目將於%s在維基百科[[Wikipedia:首頁|首頁]]的%s上展示。",
mainDateLong, makeFeaturedLink(mainDateLong, todaysFA)
)
end
end
},
-- Main page GA date
{
id = 'MAINDATEGA',
isActive = function (articleHistoryObj)
local args = articleHistoryObj.args
local status = articleHistoryObj:getStatusId()
return (args.maindateGA or status == 'GA') and not args.maindateFA
end,
makeData = function (articleHistoryObj)
local args = articleHistoryObj.args
local status = articleHistoryObj:getStatusId()
local data = {}
local function validateMainDate(argName, dataName, dataTimestampName)
data[dataName] = args[argName]
if data[dataName] then
data[dataTimestampName] = getYmdDate(data[dataName])
if not data[dataTimestampName] then
articleHistoryObj:raiseError(
string.format(
"參數「'%s'」中發現錯誤日期「%s」",
argName, data[dataName]
),
'Template:Article history#錯誤日期'
)
end
end
end
validateMainDate('maindateGA', 'mainDateGA', 'mainDateGATimestamp')
data.currentTimestamp = getYmdDate()
return data
end,
icon = 'Wikipedia-logo-v2.svg',
iconCaption = 'Main Page trophy',
text = function (articleHistoryObj, noticeObj)
local data = noticeObj:getData(articleHistoryObj)
if not data or not data.mainDateGA then
return nil
end
-- Build the blurb for all the possible combinations of past,
-- present and future appearances of maindate and maindate2.
local todaysGA = "優良條目"
local mainDateLong = getLongDate(data.mainDateGA)
local function makeFeaturedLink(date, display)
return string.format(
"[[Wikipedia:優良條目/%s|%s]]",
date,
display or date
)
end
local function isPast(timestamp)
return timestamp < data.currentTimestamp
end
local function isCurrent(timestamp)
return timestamp == data.currentTimestamp
end
if isPast(data.mainDateGATimestamp) then
return string.format(
"此條目曾於%s在維基百科[[Wikipedia:首頁|首頁]]的%s上展示。",
mainDateLong, makeFeaturedLink(mainDateLong, todaysGA)
)
elseif isCurrent(data.mainDateGATimestamp) then
return string.format(
"此條目現正於維基百科[[Wikipedia:首頁|首頁]]的%s上展示。",
mainDateLong, makeFeaturedLink(mainDateLong, todaysGA)
)
else
return string.format(
"此條目將於%s在維基百科[[Wikipedia:首頁|首頁]]的%s上展示。",
mainDateLong, makeFeaturedLink(mainDateLong, todaysGA)
)
end
end
}
},
-------------------------------------------------------------------------------
-- Actions
-------------------------------------------------------------------------------
-- The actions table contains configuration tables for actions such as featured
-- article candidacies and peer review, etc.
-- Each configuration table can have the following fields:
--
-- id: the main ID for the action. This should be the same as the configuration
-- table key.
-- name: the name of the action. This can be a string or a function. If it is
-- a function, it takes an article history object as its first parameter and
-- the action object as its second parameter, and should return the name.
-- results: a table of possible results for the action. Keys in the table should
-- be a result ID, e.g. "promoted" or "kept", and values should be a subtable
-- with the following fields:
-- id: the result ID. This should be the same as the table key. It will
-- also define a possible input value for the action's result parameter.
-- text: the displayed result text. This may be a string or a function. If it
-- is a function, it takes an article history object as the first
-- parameter and the current action object as the second parameter, and
-- should return the result string.
-- aliases: an array of result ID aliases. Each of these will define a valid
-- value for the action's result parameter.
-- text: The action text. This may be a string or a function. If it is a
-- function, it takes an article history object as the first parameter and
-- the current action object as the second parameter, and should return the
-- text string.
-- categories: The categories set by the notice. This may be an array of
-- category names, or a function. If it is a function, it takes an article
-- history object as the first parameter and the current action object as the
-- second parameter, and should return an array of category objects.
-- noticeBarIcon: the icon to use for the notice bar. This can be a string, or
-- a function, or true. If it is a function it takes an article history
-- object as the first parameter, and should output the icon filename. If it
-- is true, it uses the value of icon. If it is nil then no notice bar icon
-- will be displayed.
-- noticeBarIconCaption: the caption to use for the notice bar icon. This can be
-- a string or a function. If it is a function, it takes an article history
-- object as its first parameter, and should return the caption text. If this
-- is absent, the icon caption is used instead.
-- noticeBarIconSize: the size of the notice bar icon, including "px" suffix.
-- The default is set by defaultNoticeBarIconSize.
actions = {
FAC = {
id = 'FAC',
name = '典範條目候選',
results = {
promoted = {
id = 'promoted',
text = '入選',
aliases = {'pass', 'passed', '入選', '入选'}
},
['not promoted'] = {
id = 'not promoted',
text = '落選',
aliases = {'fail', 'failed', '落選', '落选'}
}
}
},
FAR = {
id = 'FAR',
name = '典範條目重審',
aliases = {'FARC'},
results = {
kept = {
id = 'kept',
text = '維持',
aliases = {'pass', 'passed', 'keep', '維持', '维持'}
},
demoted = {
id = 'demoted',
text = '撤銷',
aliases = {'fail', 'failed', 'remove', 'removed', '撤銷', '撤销'}
},
merged = {
id = 'merged',
text = '合併',
aliases = {'merge'}
}
},
categories = function (articleHistoryObj, actionObj)
local ret = {}
local result = actionObj.resultId
if result == 'demoted' or result == 'merged' then
local status = articleHistoryObj:getStatusId()
local sortKey = articleHistoryObj.currentTitle.subjectPageTitle.prefixedText
if status == 'FA' or status == 'FL' then
sortKey = '#' .. sortKey
end
ret[#ret + 1] = Category.new(
'已撤銷的典範條目',
sortKey
)
end
return ret
end
},
FLC = {
id = 'FLC',
name = '特色列表候選',
results = {
promoted = {
id = 'promoted',
text = '入選',
aliases = {'pass', 'passed', '入選', '入选'}
},
['not promoted'] = {
id = 'not promoted',
text = '落選',
aliases = {'fail', 'failed', '落選', '落选'}
}
}
},
FLR = {
id = 'FLR',
name = '特色列表重審',
results = {
kept = {
id = 'kept',
text = '維持',
aliases = {'pass', 'passed', 'keep', '維持', '维持'}
},
demoted = {
id = 'demoted',
text = '撤銷',
aliases = {'fail', 'failed', 'remove', 'removed', '撤銷', '撤销'}
},
merged = {
id = 'merged',
text = '合併',
aliases = {'merge', '合併'}
}
},
categories = function (articleHistoryObj, actionObj)
local ret = {}
local result = actionObj.resultId
if result == 'demoted' or result == 'merged' then
local sortKey = articleHistoryObj.currentTitle.text
if articleHistoryObj:getStatusId() == 'FL' then
sortKey = '#' .. sortKey
end
ret[#ret + 1] = Category.new(
'已撤銷的特色列表',
sortKey
)
end
return ret
end
},
GAN = {
id = 'GAN',
name = '優良條目候選',
aliases = {'GAC'},
results = {
listed = {
id = 'listed',
text = '入選',
aliases = {'pass', 'passed', 'promoted', '入選', '入选'}
},
['not listed'] = {
id = 'not listed',
text = '落選',
aliases = {'fail', 'failed', 'not promoted', '落選', '落选'}
}
}
},
GAR = {
id = 'GAR',
name = '優良條目重審',
results = {
kept = {
id = 'kept',
text = '維持',
aliases = {'pass', 'passed', 'keep', '維持', '维持'}
},
delisted = {
id = 'delisted',
text = '撤銷',
aliases = {'fail', 'failed', 'remove', 'removed', '撤銷', '撤销'}
}
},
categories = function (articleHistoryObj, actionObj)
local ret = {}
if actionObj.resultId == 'delisted' then
local status = articleHistoryObj:getStatusId()
local sortkey = articleHistoryObj.currentTitle.text
if status == 'FA' then
sortkey = "#" .. sortkey
elseif status == 'GA/FFA/FFAC' or status == 'GA/FFAC' or
status == 'GA/FFA' or status == 'GA' then
sortkey = "*" .. sortkey
end
ret[#ret + 1] = Category.new(
'已撤銷的優良條目',
sortkey
)
end
end
},
PR = {
id = 'PR',
name = '同行評審',
results = {
reviewed = {
id = 'reviewed',
text = '已評審',
aliases = {'_BLANK'}
},
['not reviewed'] = {
id = 'not reviewed',
text = '現正評審',
}
},
categories = {'已同行評審的條目'}
},
WAR = {
id = 'WAR',
name = '維基專題甲級條目評審',
results = {
approved = {
id = 'approved',
text = '通過評審',
aliases = {'pass', 'passed'}
},
['not approved'] = {
id = 'not approved',
text = '未通過評審',
aliases = {'fail', 'failed', 'not reviewed'}
},
reviewed = {
id = 'reviewed',
text = '評審中',
aliases = {'_BLANK'}
},
kept = {
id = 'kept',
text = '維持',
aliases = {'keep'}
},
demoted = {
id = 'demoted',
text = '撤銷',
aliases = {'demote'}
}
}
},
AFD = {
id = 'AFD',
name = '頁面存廢討論',
aliases = {'PAGEDEL','VFD','DEL'},
results = {
kept = {
id = 'kept',
text = '保留',
aliases = {'withdrawn', 'keep','保留'}
},
deleted = {
id = 'deleted',
text = '刪除',
aliases = {'delete','刪除','删除'}
},
merged = {
id = 'merged',
text = '合併',
aliases = {'merge'}
},
['no consensus'] = {
id = 'no consensus',
text = '沒有共識',
aliases = {'nc'}
},
['speedily kept'] = {
id = 'speedily kept',
text = '快速保留',
aliases = {'speedy keep'}
},
['speedily deleted'] ={
id = 'speedily deleted',
text = '快速刪除',
aliases = {'speedy delete'}
},
redirected = {
id = 'redirected',
text = '重定向',
aliases = {'redirect'}
},
renamed = {
id = 'renamed',
text = '更名',
aliases = {'rename', 'move', 'moved'}
},
}
},
CSD = {
id = 'CSD',
name = '快速刪除候選',
results = {
kept = {
id = 'kept',
text = '保留',
aliases = {'withdrawn', 'keep', 'speedy keep'}
},
deleted = {
id = 'deleted',
text = '刪除',
aliases = {'delete', 'speedily deleted', 'speedy delete'}
},
redirected = {
id = 'redirected',
text = '重定向',
aliases = {'redirect'}
},
afd = {
id = 'afd',
text = '轉交[[頁面存廢討論]]',
aliases = {'afded'}
},
renamed = {
id = 'renamed',
text = '更名',
aliases = {'rename', 'move', 'moved'}
},
}
},
DRV = {
id = 'DRV',
name = '存廢覆核請求',
results = {
endorsed = {
id = 'endorsed',
text = '覆核',
aliases = {'endorse'}
},
restored = {
id = 'restored',
text = '回復頁面',
aliases = {'restore'}
},
overturned = {
id = 'overturned',
text = '駁回',
aliases = {'overturn'}
},
['no consensus'] = {
id = 'no consensus',
text = '沒有共識'
}
}
}
},
-------------------------------------------------------------------------------
-- Collapsible notices
-------------------------------------------------------------------------------
-- The collapsibleNotices table contains configuration tables for notices that
-- go in the collapsible part of the template, underneath the actions.
-- Each configuration table can have the following fields:
--
-- id: the main ID for the notice. This should be the same as the configuration
-- table key.
-- isActive: a function that should return a truthy value if the notice should
-- be displayed, and a falsy value if not. (Falsy values are false and nil,
-- and truthy values are everything else.) The function takes an article
-- history object as its first parameter.
-- makeData: a function that should return a table of data to be used by other
-- functions in this notice configuration table. It can be accessed using
-- noticeObj:getData().
-- icon: the filename of the notice icon, minus the "File:" prefix.
-- iconCaption: the icon caption.
-- iconSize: The icon size, including "px" suffix. The default is defined in
-- defaultIconSize.
-- iconSmallSize: The icon size if we are outputting a small template. The
-- default is defined in defaultSmallIconSize.
-- text: The notice text. This may be a string or a function. If it is a
-- function, it takes an article history object as the first parameter, and
-- the current collapsible notice object as the second parameter, and should
-- return the text string.
-- categories: The categories set by the notice. This may be an array of
-- category names, or a function. If it is a function, it takes an article
-- history object as the first parameter, and the current collapsible notice
-- object as the second parameter, and should return an array of category
-- objects.
-- noticeBarIcon: the icon to use for the notice bar. This can be a string, or
-- a function, or true. If it is a function it takes an article history
-- object as the first parameter, and should output the icon filename. If it
-- is true, it uses the value of icon. If it is nil then no notice bar icon
-- will be displayed.
-- noticeBarIconCaption: the caption to use for the notice bar icon. This can be
-- a string or a function. If it is a function, it takes an article history
-- object as its first parameter, and should return the caption text. If this
-- is absent, the icon caption is used instead.
-- noticeBarIconSize: the size of the notice bar icon, including "px" suffix.
-- The default is set by defaultNoticeBarIconSize.
collapsibleNotices = {
-- DYK
{
id = 'DYK',
icon = 'DYK questionmark icon.svg',
iconCaption = '新條目推薦',
iconSmallSize = '15px',
noticeBarIcon = true,
isActive = function (articleHistoryObj)
return isActiveDatedObject(articleHistoryObj, 'dyk')
end,
makeData = function (articleHistoryObj)
return makeDateData(articleHistoryObj, 'dyk', {'entry'})
end,
text = function (articleHistoryObj, collapsibleNoticeObj)
local data = collapsibleNoticeObj:getData(articleHistoryObj)
if not data then
return nil
end
return makeDateText(data, "本條目曾於$1登上維基百科[[Wikipedia:首頁|首頁]]的「'''[[:Template:Dyk|你知道嗎?]]'''」欄位。")
end,
collapsibleText = function (articleHistoryObj, collapsibleNoticeObj)
local data = collapsibleNoticeObj:getData(articleHistoryObj)
if not data then
return nil
end
local ctext = {}
local entries = {}
local lastEntryDate
for i, t in ipairs(data) do
entries[#entries + 1] = t.entry
lastEntryDate = t.date
end
ctext[#ctext + 1] = "新條目推薦的題目為:"
local list = mw.html.create('ul')
for i, t in ipairs(data) do
if t.entry then
list:tag('li'):wikitext(string.format(
"%s:%s",
t.date, t.entry
))
end
end
ctext[#ctext + 1] = tostring(list)
if #ctext > 0 then
return table.concat(ctext)
else
return nil
end
end,
categories = {'推薦的新條目'}
},
-- ITN
{
id = 'ITN',
isActive = function (articleHistoryObj)
return isActiveDatedObject(articleHistoryObj, 'itn')
end,
makeData = function (articleHistoryObj)
return makeDateData(articleHistoryObj, 'itn', {'link'})
end,
icon = 'Globe current.svg',
iconCaption = '新聞動態',
noticeBarIcon = true,
noticeBarIconSize = '20px',
text = function (articleHistoryObj, collapsibleNoticeObj)
local data = collapsibleNoticeObj:getData(articleHistoryObj)
if not data then
return nil
end
return makeDateText(data, "本條目曾於$1登上維基百科[[Wikipedia:首頁|首頁]]的「'''[[:Template:Itn|新聞動態]]'''」欄位。")
end,
categories = function (articleHistoryObj, collapsibleNoticeObj)
local cats = {}
cats[1] = Category.new('新聞動態條目')
return cats
end
},
-- On This Day
{
id = 'OTD',
isActive = function (articleHistoryObj)
return isActiveDatedObject(articleHistoryObj, 'otd')
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',
iconCaption = '歷史上的今天',
noticeBarIcon = true,
noticeBarIconSize = '20px',
text = function (articleHistoryObj, collapsibleNoticeObj)
local data = collapsibleNoticeObj:getData(articleHistoryObj)
if not data then
return nil
end
return makeDateText(data, "本條目曾$1登上維基百科[[Wikipedia:首頁|首頁]]的「'''[[:Template:Itn|歷史上的今天]]'''」欄位。")
end,
categories = function (articleHistoryObj, collapsibleNoticeObj)
local cats = {}
cats[1] = Category.new('Selected anniversaries 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(
'歷史上的今天條目'
)
break
end
end
end
return cats
end
},
-- 動員令
{
id = 'DC',
isActive = function (articleHistoryObj)
return articleHistoryObj.args.DC
end,
icon = 'Wikipedia-logo-v2-wordmark.svg',
iconCaption = '動員令',
iconSize = '25px',
noticeBarIcon = true,
text = function (articleHistoryObj)
local mtopic = ""
if articleHistoryObj.args.DCtopic then
mtopic = articleHistoryObj.args.DCtopic
end
local mtype = ""
if articleHistoryObj.args.DCtype then
mtype = ",屬" .. articleHistoryObj.args.DCtype .. "條目"
end
return string.format("此條目為[[Wikipedia:動員令/第%s次動員令|第%s次動員令]]%s的作品之一%s。", articleHistoryObj.args.DC, articleHistoryObj.args.DC, mtopic, mtype)
end,
categories = function (articleHistoryObj)
local cats = {}
if articleHistoryObj.args.DCtopic then
local mtopic = ""
mtopic = string.format("第%s次動員令%s作品",articleHistoryObj.args.DC,articleHistoryObj.args.DCtopic)
table.insert(cats, Category.new(mtopic))
end
if articleHistoryObj.args.DCtype then
local mtype = ""
mtype = string.format("第%s次動員令%s條目",articleHistoryObj.args.DC,articleHistoryObj.args.DCtype)
table.insert(cats, Category.new(mtype))
end
table.insert(cats, Category.new(string.format("第%s次動員令貢獻一覽",articleHistoryObj.args.DC)))
return cats
end
},
-- Peer review
{
id = 'PR',
isActive = function (articleHistoryObj)
local prObj
local actions = articleHistoryObj:getActionObjects()
for i = #actions, 1, -1 do
local actionObj = actions[i]
if actionObj.id == 'PR' and actionObj.resultId == 'reviewed' then
return true
end
end
return false
end,
icon = 'Nuvola apps kedit.svg',
iconCaption = '同行評審',
iconSize = '25px',
noticeBarIcon = true,
text = "本條目已經由[[Wikipedia:社群首頁|維基百科社群]]同行評審並已存檔,當中或有可以改善此條目的資訊。"
},
},
-------------------------------------------------------------------------------
-- Notice bar icons
-------------------------------------------------------------------------------
-- This table holds configuration tables for notice bar icons that don't appear
-- as part of a row. Other notice bar icons are handled in the statuses,
-- notices, actions, and collapsibleNotices tables.
-- It accepts the following fields:
-- isActive: a function that should return a truthy value if the notice should
-- be displayed, and a falsy value if not. (Falsy values are false and nil,
-- and truthy values are everything else.) The function takes an article
-- history object as its first parameter.
-- icon: the filename of the notice bar icon, minus the "File:" prefix.
noticeBarIcons = {
-- peer reviews shown in collapsibleNotices in zhwiki
-- Wikipedia 1.0
{
isActive = function (articleHistoryObj)
return articleHistoryObj.args['v1.0NotAnActiveOption']
end,
icon = 'WP1 0 Icon.svg'
}
},
-------------------------------------------------------------------------------
-- Extra categories
-------------------------------------------------------------------------------
-- This table contains categories that don't appear as part of a row. It is an
-- array of functions; each function takes an article history object as input
-- and must return an array of category objects as output.
extraCategories = {
-- Four award
function (articleHistoryObj)
local yesno = require('Module:Yesno')
local ret = {}
local isFour = yesno(articleHistoryObj.args.four)
if isFour then
ret[#ret + 1] = Category.new('Wikipedia four award articles')
elseif isFour == false then
ret[#ret + 1] = Category.new('Wikipedia articles rejected for Four awards')
elseif articleHistoryObj:getStatusId() == 'FA' then
local isDYK = false
for i, obj in ipairs(articleHistoryObj:getCollapsibleNoticeObjects()) do
if obj.id == 'DYK' then
isDYK = true
break
end
end
if isDYK then
for i, obj in ipairs(articleHistoryObj:getActionObjects()) do
if obj.id == 'GAN' and obj.resultId == 'listed' then
ret[#ret + 1] = Category.new('Possible Wikipedia four award articles')
break
end
end
end
end
return ret
end,
-- Deletion to Quality award
function (articleHistoryObj)
local ret = {}
local status = articleHistoryObj:getStatusId()
if status == 'FA' or status == 'FL' or status == 'GA' then
local iAfd = 0
local hasAfd = false
local actionObjects = articleHistoryObj:getActionObjects()
for i, obj in ipairs(actionObjects) do
if obj.id == 'AFD' then
iAfd = i
hasAfd = true
break
end
end
if hasAfd then
local function hasNomination(id, result)
for i = iAfd + 1, #actionObjects do
local obj = actionObjects[i]
if obj.id == id and obj.resultId == result then
return true
end
end
return false
end
if status == 'GA' and hasNomination('GAN', 'listed') or
status == 'FL' and hasNomination('FLC', 'promoted') or
status == 'FA' and hasNomination('FAC', 'promoted')
then
ret[#ret + 1] = Category.new('Deletion to Quality Award candidates')
end
end
end
return ret
end,
-- Track small banners
function (articleHistoryObj)
local ret = {}
if articleHistoryObj.isSmall then
table.insert(ret, Category.new('Small article history templates'))
end
return ret
end,
},
-------------------------------------------------------------------------------
-- Parameters
-------------------------------------------------------------------------------
-- The parameter values used to generate the page actions. These are used as
-- Lua patterns, so any of the magic characters *+-.^$%[] should be escaped
-- with a preceding % symbol.
actionParamPrefix = 'action',
actionParamSuffixes = {
[''] = 'code',
date = 'date',
link = 'link',
result = 'resultCode',
oldid = 'oldid'
},
-- The parameter used to set the current status.
currentStatusParam = 'currentstatus',
-------------------------------------------------------------------------------
-- Other settings
-------------------------------------------------------------------------------
-- If this number or fewer of collapsible rows are present (including actions
-- and collapsible notices) they will not be collapsed. If this is set to the
-- string "all", all rows will always be visible. Otherwise, the input must be
-- a number. The default is three rows.
uncollapsedRows = 3,
-- The default size for icons. The default is 30px.
defaultIconSize = '30px',
-- The default size for icons for small templates. The default is 15px.
defaultSmallIconSize = '15px',
-- The default size for status icons. The default is 50px.
defaultStatusIconSize = '50px',
-- The default size for status icons for small templates. The default is 30px.
defaultSmallStatusIconSize = '30px',
-- The default size for notice bar icons. The default is 15px.
defaultNoticeBarIconSize = '15px',
-- The default size for collapsible status icons. The default is 50px.
defaultCollapsibleNoticeIconSize = '20px',
-- The default size for collapsible status icons for small templates. The
-- default is 30px.
defaultSmallCollapsibleNoticeIconSize = '20px',
-------------------------------------------------------------------------------
-- Messages
-------------------------------------------------------------------------------
msg = {
-- The heading for the collapsible table of actions if we are in the main
-- namespace or the talk namespace.
['milestones-header'] = '條目里程碑',
-- The heading for the collapsible table of actions if we are in a different
-- namespace.
-- $1 - the subject namespace name.
['milestones-header-other-ns'] = '里程碑',
-- The milestones date header.
['milestones-date-header'] = '日期',
-- The milestones process header.
['milestones-process-header'] = '事項',
-- The milestones result header.
['milestones-result-header'] = '結果',
-- The format to display the action dates in. The syntax is the same as the
-- #time parser function.
['action-date-format'] = 'Y年Fj日',
-- The category to use if any errors are detected.
['error-category'] = '條目里程碑出錯',
-- Define boilerplate text for error messages and warnings, both with and
-- without help links.
-- $1 - the error message
-- $2 - a link to a help page and section for the error
['error-message-help'] = '錯誤:$1([[$2|幫助]])。',
['error-message-nohelp'] = '錯誤:$1。',
['warning-help'] = '警告:$1([[$2|幫助]])。',
['warning-nohelp'] = '警告:$1。',
-- Error for row objects that should output notice bar icons but for which no
-- icon values could be found.
['row-error-missing-icon'] = "資訊欄未能找到相應圖示",
-- A help link for row-error-missing-icon
['row-error-missing-icon-help'] = 'Template:Article history#沒有圖示',
-- Error for action objects that aren't passed a code.
-- $1 - the parameter name for the code
['action-error-no-code'] = "「$1」未能找到事項代碼,請為其加入一正確代碼或刪除其他以「$1」起始的參數",
-- A help link for action-error-no-code
['action-error-no-code-help'] = 'Template:Article history#事項代碼',
-- Error for action objects that are passed an invalid code.
-- $1 - the code that the user input
-- $2 - the parameter name for the code
['action-error-invalid-code'] = "參數「$2」帶有錯誤事項代碼「$1」",
-- A help link for action-error-invalid-code
['action-error-invalid-code-help'] = 'Template:Article history#事項代碼',
-- Error for action objects with blank result parameters, where result
-- parameters are required for the action's ID.
-- $1 - the action ID
-- $2 - the result parameter name
['action-error-blank-result'] = "事項「$1」尚未填寫結果。請於「$2」填上結果代碼",
-- A help link for action-error-blank-result
['action-error-blank-result-help'] = 'Template:Article history#事項結果',
-- Error for action objects with invalid result parameters.
-- $1 - the result code that the user input
-- $2 - the action ID
-- $3 - the result parameter name
['action-error-invalid-result'] = "參數「$3」中的事項「$2」發現錯誤結果「$1」",
-- A help link for action-error-invalid-result
['action-error-invalid-result-help'] = 'Template:Article history#事項結果',
-- Warning for action objects with invalid dates.
-- $1 - the date input by the user
-- $2 - the date parameter name
['action-warning-invalid-date'] = "參數「$2」中發現錯誤日期「$1」",
-- A help link for action-warning-invalid-date
['action-warning-invalid-date-help'] = 'Template:Article history#錯誤日期',
-- Error for action objects with no dates.
-- $1 - the parameter number
-- $2 - the date parameter name
-- $3 - the action parameter name
['action-warning-no-date'] = "事項「$1」尚未指定日期,請於參數「$2」填上日期或刪除其他以「$3」起始的參數",
-- A help link for action-warning-no-date
['action-warning-no-date-help'] = 'Template:Article history#沒有日期',
-- The text to display in place of the action date if it is missing.
['action-date-missing'] = '?',
-- Error for action objects with invalid oldids.
-- $1 - the oldid input by the user
-- $2 - the oldid parameter name
['action-warning-invalid-oldid'] = "參數「$2」發現錯誤oldid「$1」,oldid必須為正整數",
-- A help link for action-warning-invalid-oldid
['action-warning-invalid-oldid-help'] = 'Template:Article history#錯誤oldid',
-- Error for invalid current status codes.
-- $1 - the code input by the user
['articlehistory-warning-invalid-status'] = "模板中指定了錯誤的事項,故系統無法計算正確的當前狀態",
-- A help link for articlehistory-warning-invalid-status
['articlehistory-warning-invalid-status-help'] = 'Template:Article history#錯誤當前狀態',
-- Warning for invocations that specify a current status without specifying any
-- actions.
['articlehistory-warning-status-no-actions'] = "發現當前狀態但未有指定任何事項",
-- A help link for articlehistory-warning-status-no-actions
['articlehistory-warning-status-no-actions-help'] = 'Template:Article history#沒有事項',
-- The text to display the current status at the bottom of the collapsible
-- table.
-- $1 - the current status name
['status-blurb'] = "當前狀態:'''$1'''",
-- The text to display at the bottom of the collapsible table if the current
-- status is unknown.
['status-unknown'] = '?',
}
-------------------------------------------------------------------------------
-- CONFIG TABLE END
-------------------------------------------------------------------------------
}