有兽档案馆
搜索
切换搜索
切换菜单
切换个人菜单
查看“Module:Article history/config”的源代码
来自有兽档案馆
阅读
查看源代码
查看历史
模块
讨论
更多操作
←
Module: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 = 'LIB:优良条目/' .. topic display = ' 优良条目' .. topic else link = 'LIB:优良条目' display = '优良条目' 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'''是一条[[LIB:典范条目|典范条目]],即此条目可" .. "作为[[LIB:社群首页|有兽档案馆社群]]的典范之作。 如有需要,请" .. "[[LIB:勇于更新页面|勇于更新页面]]" return string.format(text, articlePage) end, categories = {'典范条目讨论'} }, FFA = { id = 'FFA', name = '已撤销的典范条目', icon = 'Featured article star - cross.svg', iconSize = '48px', text = "'''$1'''曾属'''[[LIB:典范条目|典范条目]]''',但已[[LIB:已撤销的典范条目|撤销资格]]。" .. "下方条目里程碑的连结中可了解撤销资格的详细原因及改善建议。 条目照建议改善而重新" .. "符合[[LIB:典范条目标准|标准]]后可再次提名[[LIB:典范条目评选|评选]]。" }, FFAC = { id = 'FFAC', name = '典范条目落选', icon = 'Cscr-former.svg', text = "'''$1'''曾获提名'''[[LIB:典范条目评选|典范条目评选]]'''," .. "惟因其尚未符合[[LIB:典范条目标准|标准]]而落选。下方条目里程碑的链接中可" .. "了解落选的详细原因及改善建议。 列表照建议改善之后可再次提名评选。", categories = {'典范条目落选'} }, FL = { id = 'FL', name = '特色列表', icon = 'Featured article star.svg', iconSize = '48px', text = function (articleHistoryObj) local articlePage = articleHistoryObj.currentTitle.subjectPageTitle.prefixedText local text = "'''%s'''是一条[[LIB:特色列表|特色列表]],即此列表可" .. "作为[[LIB:社群首页|有兽档案馆社群]]的典范之作。 如有需要,请" .. "[[LIB:勇于更新页面|勇于更新页面]]。" return string.format(text, articlePage) end, categories = {'特色列表讨论'} }, FFL = { id = 'FFL', name = '已撤销的特色列表', icon = 'Cscr-featured-strike.svg', text = "'''$1'''曾属'''[[LIB:特色列表|特色列表]]''',但已[[LIB:已撤销的特色列表|撤销资格]]。" .. "下方条目里程碑的连结中可了解撤销资格的详细原因及改善建议。 列表照建议改善而重新" .. "符合[[LIB:特色列表标准|标准]]后可再次提名[[LIB:特色列表评选|评选]]。" }, FFLC = { id = 'FFLC', name = '特色列表落选', icon = 'Cscr-former.svg', iconCaption = 'Former FLC', text = "'''$1'''曾获提名'''[[LIB:特色列表评选|特色列表评选]]'''," .. "惟因其尚未符合[[LIB:特色列表标准|标准]]而落选。 下方条目里程碑的链接中可" .. "了解落选的详细原因及改善建议。 列表照建议改善之后可再次提名评选。", 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'''因符合[[LIB:优良条目标准|标准]]而获列入" .. "'''[[LIB:优良条目|优良条目]]'''。如有需要,请" .. "[[LIB:勇于更新页面|勇于更新页面]]。<small>如条目不再" .. "达标可提出[[LIB:优良条目评选|重新评选]]。</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'''曾获提名'''[[LIB:优良条目评选|优良条目评选]]'''," .. "惟因其尚未符合[[LIB:优良条目标准|标准]]而落选。 下方条目里程碑的链接中可" .. "了解落选的详细原因及改善建议。 条目照建议改善之后可再次提名评选。" 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'''曾属'''[[LIB:优良条目|优良条目]]''',但已[[LIB:已撤销的优良条目|撤销资格]]。" .. "下方条目里程碑的连结中可了解撤销资格的详细原因及改善建议。 条目照建议改善而重新" .. "符合[[LIB:优良条目标准|标准]]後可再次提名[[LIB:优良条目评选|评选]]。" 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 " .. "''[[LIB:Former featured topics|former featured topic]]'' series. " .. "If it has improved again to " .. "[[LIB:Featured topic criteria|featured topic standard]], " .. "you may [[LIB:Featured topic candidates|renominate]] " .. "the topic to become a [[LIB:Featured topic|featured topic]]." }, FFTC = { id = 'FFTC', name = 'Former featured topic candidate', icon = 'Cscr-former.svg', text = "This article is part of a ''former'' " .. "[[LIB: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 [[LIB:Featured portals|featured portal]], " .. "which means it has been " .. "'''''[[LIB: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 [[LIB: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''''' " .. "[[LIB: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( "请前往[[LIB:典范条目评选|典范条目评选]]提名评选。", 'Template:Article history#典范条目评选' ) end }, FAR = { id = 'FAR', text = function (articleHistoryObj) articleHistoryObj:raiseError( "请前往[[LIB:典范条目评选|典范条目评选]]提名重选。", '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 while current%v == 0 do current = current/v end end return math.floor(current) end local function addNewStatus(current, new) if current%new ~= 0 then current = current*new end return 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 not actionObj.ignore then if actionObj.id == 'FAC' then raiseInvalidStatus(statusCode, {2,3}, i) if actionObj.resultId == "promoted" then statusCode = 2 else statusCode = addNewStatus(statusCode, 17) end elseif actionObj.id == 'FLC' then raiseInvalidStatus(statusCode, {2,3}, i) if actionObj.resultId == "promoted" then statusCode = 3 else statusCode = addNewStatus(statusCode, 19) end elseif actionObj.id == 'GAN' then raiseInvalidStatus(statusCode, {2,3,5}, i) if actionObj.resultId == "listed" then statusCode = addNewStatus(statusCode, 5) statusCode = removeOldStatus(statusCode, {13,23}) else statusCode = addNewStatus(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 = addNewStatus(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 = addNewStatus(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 = addNewStatus(statusCode, 13) statusCode = removeOldStatus(statusCode, {5}) end 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 nil 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 '''[[LIB:Featured topics/%s|%s]] series''', %s." local otherBlurb = "It is also %s the '''[[LIB:Featured topics/%s|%s]] series''', %s." local finalBlurb = "%s identified as among the best series of " .. "articles produced by the [[LIB:Wikipedians|Wikipedia community]]. " .. "If you can update or improve %s, [[LIB:Be bold|please do so]]." local main = 'the main article in' local notMain = 'part of' local featuredLink = 'a [[LIB:Featured topics|featured topic]]' local featuredNoLink = 'a featured topic' local goodLink = 'a [[LIB: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( "[[LIB:典范条目/%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在有兽档案馆[[LIB:首页|首页]]的%s上展示。", mainDateLong, makeFeaturedLink(mainDateLong, todaysFA) ) elseif isCurrent(data.mainDateFATimestamp) then return string.format( "此条目现正于有兽档案馆[[LIB:首页|首页]]的%s上展示。", mainDateLong, makeFeaturedLink(mainDateLong, todaysFA) ) else return string.format( "此条目将于%s在有兽档案馆[[LIB:首页|首页]]的%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( "[[LIB:优良条目/%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在有兽档案馆[[LIB:首页|首页]]的%s上展示。", mainDateLong, makeFeaturedLink(mainDateLong, todaysGA) ) elseif isCurrent(data.mainDateGATimestamp) then return string.format( "此条目现正于有兽档案馆[[LIB:首页|首页]]的%s上展示。", mainDateLong, makeFeaturedLink(mainDateLong, todaysGA) ) else return string.format( "此条目将于%s在有兽档案馆[[LIB:首页|首页]]的%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 = '典范条目评选', aliases = {'FAN'}, 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 = '特色列表評選', aliases = {'FLN'}, results = { promoted = { id = 'promoted', text = '入选', aliases = {'pass', 'passed', '入选', '入選'} }, ['not promoted'] = { id = 'not promoted', text = '落选', aliases = {'fail', 'failed', '落选', '落選'} } } }, FLR = { id = 'FLR', name = '特色列表重审', aliases = {'FLRC'}, 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 return ret 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登上有兽档案馆[[LIB:首页|首页]]的「'''[[: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登上有兽档案馆[[LIB:首页|首页]]的「'''[[: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登上有兽档案馆[[LIB:首页|首页]]的「'''[[: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 or articleHistoryObj.prefixArgs['DC'] end, makeData = function (articleHistoryObj) local args = articleHistoryObj.args local prefixArgs = articleHistoryObj.prefixArgs local data = {} local prefix = 'DC' local suffixes = {'id','topic','type','other'} -- Organise the input local function addData(sep) local t = {} local argPrefix = prefix .. sep for _, suffix in ipairs(suffixes) do local key = argPrefix .. ((suffix=='id')and '' or suffix) t[suffix] = args[key] end t.argPrefix = argPrefix if mw.text.trim(t.id or '') ~= '' then data[#data + 1] = t else articleHistoryObj:raiseError( articleHistoryObj:message('action-error-no-code', t.argPrefix), articleHistoryObj:message('action-error-no-code-help') ) end end if args.DC 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, icon = 'Wikipedia_zh_dc_logo.svg', iconCaption = '动员令', iconSize = '25px', noticeBarIcon = true, text = function (articleHistoryObj, collapsibleNoticeObj) local prefix = 'DC' local args = articleHistoryObj.args local prefixArgs = articleHistoryObj.prefixArgs local data = collapsibleNoticeObj:getData(articleHistoryObj) local DCs = {} local ren_text = '' if #data == 1 then local dcItem = data[1] local mtopic = "" if dcItem.topic then mtopic = dcItem.topic end local mtype = "" if dcItem.type then mtype = ",属" .. dcItem.type .. "条目" end ren_text = string.format("此条目为[[LIB:动员令/第%s次动员令|第%s次动员令]]%s的作品之一%s。", dcItem.id, dcItem.id, mtopic, mtype) else -- Sanity checks if prefixArgs[prefix] then for _, t in ipairs(data) do local mtopic = mw.text.trim(t.topic or '')~='' and t.topic or '' DCs[#DCs+1] = string.format('[[LIB:动员令/第%s次动员令|第%s次动员令]]%s', t.id, t.id, mtopic) end end local DCList = mw.text.listToText(DCs, '、', '及') ren_text = mw.message.newRawMessage("此条目为$1的作品之一。", DCList):plain() end return ren_text end, collapsibleText = function (articleHistoryObj, collapsibleNoticeObj) local data = collapsibleNoticeObj:getData(articleHistoryObj) if not data then return nil end if #data == 1 then return nil end local ctext = {} local entries = {} for i, t in ipairs(data) do entries[#entries + 1] = t.type end ctext[#ctext + 1] = "本条目参加多次动员令:" local list = mw.html.create('ul') for i, t in ipairs(data) do if t.id then local mtopic = "" if t.topic then mtopic = t.topic end local mtype = "" if t.type then mtype = mtype .. ",属" .. t.type .. "条目" end local other_data = mw.text.split(t.other or '', ',') for _, other_key in ipairs(other_data) do local other = mw.ustring.lower(mw.text.trim(other_key)) if other == 'improve' then mtype = mtype .. ";此条目亦有完成改善工程,提升了条目的质量" end if other == 'pic' then mtype = mtype .. ";此条目亦有提报原创图片贡献,使条目更为丰富" end end list:tag('li'):wikitext(string.format( "[[LIB:动员令/第%s次动员令|第%s次动员令]]%s作品之一%s。", t.id, t.id, mtopic, mtype)) end end ctext[#ctext + 1] = tostring(list) if #ctext > 0 then return table.concat(ctext) else return nil end 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 = "本条目已经由[[LIB:同行评审|有兽档案馆社群]]同行评审并已存档,当中或有可以改善此条目的信息。" }, }, ------------------------------------------------------------------------------- -- 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', ignore = 'ignore' }, -- 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 ------------------------------------------------------------------------------- }
该页面使用的模板:
Module:Arguments
(
查看源代码
)
Module:Article history/Category
(
查看源代码
)
Module:Article history/config
(
查看源代码
)
Module:Article history/config/doc
(
查看源代码
)
Module:Documentation
(
查看源代码
)
Module:Fullurl
(
查看源代码
)
Module:No globals
(
查看源代码
)
Module:Page name
(
查看源代码
)
Module:Yesno
(
查看源代码
)
返回
Module:Article history/config
。