Module:Article history/config

This is an old revision of this page, as edited by Mr. Stradivarius (talk | contribs) at 09:39, 18 October 2014 (move FFA detection from the main module, and put double statuses in the statuses table with an "isDouble" field, for simplicity of looking up codes). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

-------------------------------------------------------------------------------
--              Configuration data for [[Module:Article history]]
-------------------------------------------------------------------------------

return {

-------------------------------------------------------------------------------
-- Actions
-------------------------------------------------------------------------------

actions = {
	FAC = {
		id = 'FAC',
		name = 'Featured article candidate',
		results = {
			promoted = {
				text = 'Promoted',
				aliases = {'pass', 'passed'}
			},
			['not promoted'] = {
				text = 'Not promoted',
				aliases = {'fail', 'failed'}
			}
		},
		validStatuses = {
			FFAC = true,
			FA = true,
			FFA = true
		}
	},
	FAR = {
		id = 'FAR',
		name = 'Featured article review',
		aliases = {'FARC'},
		results = {
			kept = {
				id = 'kept',
				text = 'Kept',
				aliases = {'pass', 'passed', 'keep'}
			},
			demoted = {
				id = 'demoted',
				text = 'Demoted',
				aliases = {'fail', 'failed', 'remove', 'removed'}
			},
			merged = {
				id = 'merged',
				text = 'Merged',
				aliases = {'merge'}
			}
		},
		validStatuses = {
			FA = true,
			FFA = true
		},
		categories = {
			function (actionObj, articleHistoryObj)
				local result = actionObj:getResult()
				if result == 'demoted' or result == 'merged' then
					local currentStatus = articleHistoryObj:getCurrentStatus()
					local sortKey = articleHistoryObj.currentTitle.subjectPageTitle.prefixedText
					if currentStatus == 'FA' or currentStatus == 'FL' then
						sortKey = '#' .. sortKey
					end
					return 'Wikipedia former featured articles', sortKey
				end
			end
		}
	},
	BP = {
		id = 'BP',
		name = 'Brilliant prose',
		results = {
			nominated = {
				id = 'nominated',
				text = 'Nominated',
				aliases = {'pass', 'promoted', 'nom'}
			}
		},
		validStatuses = {
		}
	},
	RBP = {
		id = 'RBP',
		name = 'Refreshing brilliant prose',
		results = {
			kept = {
				id = 'kept',
				text = 'Kept',
				aliases = {'pass', 'passed', 'keep'}
			},
			['not kept'] = {
				id = 'not kept',
				text = 'Not kept',
				aliases = {'fail', 'failed', 'remove', 'removed', 'demoted'}
			}
		},
		validStatuses = {
			FA = true,
			FFAC = true
		},
		categories = {
			function (actionObj, articleHistoryObj)
				if actionObj:getResult() == 'not kept' then
					return 'Wikipedia former brilliant prose', articleHistoryObj.currentTitle.text
				end
			end
		}
	},
	FLC = {
		id = 'FLC',
		name = 'Featured list candidate',
		results = {
			promoted = {
				text = 'Promoted',
				aliases = {'pass', 'passed'}
			},
			['not promoted'] = {
				text = 'Not promoted',
				aliases = {'fail', 'failed'}
			}
		},
		validStatuses = {
			FFLC = true,
			FL = true,
			FFL = true
		}
	},
	FLR = {
		id = 'FLR',
		name = 'Featured list removal candidate',
		results = {
			kept = {
				id = 'kept',
				text = 'Kept',
				aliases = {'pass', 'passed', 'keep'}
			},
			demoted = {
				id = 'demoted',
				text = 'Demoted',
				aliases = {'fail', 'failed', 'remove', 'removed'}
			},
			merged = {
				id = 'merged',
				text = 'Merged',
				aliases = {'merge'}
			}
		},
		validStatuses = {
			FL = true,
			FFL = true
		},
		categories = {
			function (actionObj, articleHistoryObj)
				local result = actionObj:getResult()
				if result == 'demoted' or result == 'merged' then
					local sortKey
					if articleHistoryObj:getCurrentStatus() == 'FL' then
						sortKey = '#' .. articleHistoryObj.currentTitle.subjectPageTitle.prefixedText
					else
						sortKey = articleHistoryObj.currentTitle.text
					end
					return 'Wikipedia former featured lists', sortKey
				end
			end
		}
	},
	FTC = {
		id = 'FTC',
		name = 'Featured topic candidate',
		results = {
			promoted = {
				id = 'promoted',
				text = 'Promoted',
				aliases = {'pass', 'passed'}
			},
			['not promoted'] = {
				id = 'not promoted',
				text = 'Not promoted',
				aliases = {'fail', 'failed'}
			}
		},
		validStatuses = false, -- Any status
	},
	FTR = {
		id = 'FTR',
		name = 'Featured topic removal candidate',
		results = {
			kept = {
				id = 'kept',
				text = 'Kept',
				aliases = {'pass', 'passed', 'keep'}
			},
			demoted = {
				id = 'demoted',
				text = 'Demoted',
				aliases = {'fail', 'failed', 'remove', 'removed'}
			},
			merged = {
				id = 'merged',
				text = 'Merged',
				aliases = {'merge'}
			}
		},
		validStatuses = false, -- Any status
	},
	FPOC = {
		id = 'FPOC',
		name = 'Featured portal candidate',
		results = {
			promoted = {
				id = 'promoted',
				text = 'Promoted',
				aliases = {'pass', 'passed'}
			},
			['not promoted'] = {
				id = 'not promoted',
				text = 'Not promoted',
				aliases = {'fail', 'failed'}
			}
		},
		validStatuses = {
			FFPOC = true,
			FPO = true,
			FFPO = true
		}
	},
	FPOR = {
		id = 'FPOR',
		name = 'Featured portal review',
		results = {
			kept = {
				id = 'kept',
				text = 'Kept',
				aliases = {'pass', 'passed', 'keep'}
			},
			demoted = {
				id = 'demoted',
				text = 'Demoted',
				aliases = {'fail', 'failed', 'remove', 'removed'}
			},
			merged = {
				id = 'merged',
				text = 'Merged',
				aliases = {'merge'}
			}
		},
		validStatuses = {
			FPO = true,
			FFPO = true
		}
	},
	GAN = {
		id = 'GAN',
		name = 'Good article nominee',
		aliases = {'GAC'},
		results = {
			listed = {
				id = 'listed',
				text = 'Listed',
				aliases = {'pass', 'passed', 'promoted'}
			},
			['not listed'] = {
				id = 'not listed',
				text = 'Not listed',
				aliases = {'fail', 'failed', 'not promoted'}
			}
		},
		validStatuses = {
			FGAN = true,
			GA = true,
			DGA = true,
			FFAC = true,
			FA = true,
			FFA = true
		},
		categories = {
			function (actionObj, articleHistoryObj)
				if actionObj:getResult() == 'not listed' then
					local currentStatus = articleHistoryObj:getCurrentStatus()
					if currentStatus ~= 'FA'
						and currentStatus ~= 'GA'
						and currentStatus ~= 'FFA'
					then
						return 'Former good article nominees', articleHistoryObj.currentTitle.text
					end
				end
			end
		}
	},
	GAR = {
		id = 'GAR',
		name = 'Good article reassessment',
		results = {
			kept = {
				id = 'kept',
				text = 'Kept',
				aliases = {'pass', 'passed', 'keep'}
			},
			delisted = {
				id = 'delisted',
				text = 'Delisted',
				aliases = {'fail', 'failed'}
			},
			listed = {
				id = 'listed',
				text = 'Listed'
			},
			['not listed'] = {
				id = 'not listed',
				text = 'Not listed'
			}
		},
		validStatuses = {
			GA = true,
			DGA = true,
			FFAC = true,
			FA = true,
			FFA = true
		},
		categories = {
			function (actionObj, articleHistoryObj)
				if actionObj:getResult() == 'delisted' then
					local currentStatus = articleHistoryObj:getCurrentStatus()
					if currentStatus ~= 'FA'
						and currentStatus ~= 'GA'
					then
						return 'Delisted good articles', articleHistoryObj.currentTitle.text
					end
				end
			end
		}
	},
	GTC = {
		id = 'GTC',
		name = 'Good topic candidate',
		results = {
			promoted = {
				id = 'promoted',
				text = 'Promoted',
				aliases = {'pass', 'passed'}
			},
			['not promoted'] = {
				id = 'not promoted',
				text = 'Not promoted',
				aliases = {'fail', 'failed'}
			}
		},
		validStatuses = false
	},
	GTR = {
		id = 'GTR',
		name = 'Good topic removal candidate',
		results = {
			kept = {
				id = 'kept',
				text = 'Kept',
				aliases = {'pass', 'passed', 'keep'}
			},
			demoted = {
				id = 'demoted',
				text = 'Demoted',
				aliases = {'fail', 'failed', 'remove', 'removed'}
			},
			merged = {
				id = 'merged',
				text = 'Merged',
				aliases = {'merge'}
			}
		},
		validStatuses = false
	},
	PR = {
		id = 'PR',
		name = 'Peer review',
		results = {
			reviewed = {
				id = 'reviewed',
				text = 'Reviewed',
			},
			['not reviewed'] = {
				id = 'not reviewed',
				text = 'Not reviewed',
			}
		},
		validStatuses = false,
		categories = {'Old requests for peer review'}
	},
	WPR = {
		id = 'WPR',
		name = function (actionObj, articleHistoryObj)
			local names = {
				approved = 'WikiProject approved revision',
				copyedited = 'Guild of Copy Editors',
				collaboration = 'WikiProject collaboration',
				maindate = "Today's featured article"
			}
			local result = actionObj:getResult()
			return result and names[result] or 'WikiProject peer review'
		end,
		results = {
			approved = {
				id = 'approved',
				text = function(actionObj, articleHistoryObj)
					if actionObj.oldid then
						local url = mw.uri.fullUrl(
							articleHistoryObj.currentTitle.prefixedText,
							{diff = 'cur', oldid = actionObj.oldid}
						)
						return string.format(
							'[%s %s]',
							tostring(url),
							'Diff to current version'
						)
					else
						error(string.format(
							"No oldid detected for the approved version; " ..
								"please set the 'action%doldid' parameter " ..
								"or give the 'action%dresult' parameter a " ..
								"different value.",
							actionObj.paramNum,
							actionObj.paramNum
						))
					end
				end,
				aliases = {'approved version'}
			},
			copyedited = {
				id = 'copyedited',
				text = 'Copyedited',
				aliases = {'copyedit', 'proofread'}
			},
			maindate = {
				id = 'maindate',
				text = 'Main Page'
			},
			collaborated = {
				id = 'collaborated',
				text = 'Collaborated',
				aliases = {'cotw', 'collaboration'}
			},
			reviewed = {
				id = 'reviewed',
				text = 'Reviewed',
				aliases = {''} -- This is "Reviewed" if the reason is blank, but not absent.
			}
		},
		validStatuses = false
	},
	WAR = {
		id = 'WAR',
		name = 'WikiProject A-class review',
		results = {
			approved = {
				id = 'approved',
				text = 'Approved',
				aliases = {'pass', 'passed'}
			},
			['not approved'] = {
				id = 'not approved',
				text = 'Not approved',
				aliases = {'fail', 'failed', 'not reviewed'}
			},
			reviewed = {
				id = 'reviewed',
				text = 'Reviewed',
				aliases = {''}
			},
			kept = {
				id = 'kept',
				text = 'Kept',
				aliases = {'keep'}
			},
			demoted = {
				id = 'demoted',
				text = 'Demoted',
				aliases = {'demote'}
			},
		},
		validStatuses = false
	},
	AFD = {
		id = 'AFD',
		name = 'Articles for deletion',
		results = {
			kept = {
				id = 'kept',
				text = 'Kept',
				aliases = {'withdrawn', 'keep'}
			},
			deleted = {
				id = 'deleted',
				text = 'Deleted',
				aliases = {'delete'}
			},
			merged = {
				id = 'merged',
				text = 'Merged',
				aliases = {'merge'}
			},
			['no consensus'] = {
				id = 'no consensus',
				text = 'No consensus'
			},
			['speedily kept'] = {
				id = 'speedily kept',
				text = 'Speedily kept',
				aliases = {'speedy keep'}
			},
			['speedily deleted'] ={
				id = 'speedily deleted',
				text = 'Speedily deleted',
				aliases = {'speedy delete'}
			},
			redirected = {
				id = 'redirected',
				text = 'Redirected',
				aliases = {'redirect'}
			},
			renamed = {
				id = 'renamed',
				text = 'Renamed',
				aliases = {'rename', 'move', 'moved'}
			}
		},
		validStatuses = false
	},
	MFD = {
		id = 'MFD',
		name = 'Miscellanea for deletion',
		results = {
			kept = {
				id = 'kept',
				text = 'Kept',
				aliases = {'withdrawn', 'keep'}
			},
			deleted = {
				id = 'deleted',
				text = 'Deleted',
				aliases = {'delete'}
			},
			merged = {
				id = 'merged',
				text = 'Merged',
				aliases = {'merge'}
			},
			['no consensus'] = {
				id = 'no consensus',
				text = 'No consensus'
			},
			['speedily kept'] = {
				id = 'speedily kept',
				text = 'Speedily kept',
				aliases = {'speedy keep'}
			},
			['speedily deleted'] = {
				id = 'speedily deleted',
				text = 'Speedily deleted',
				aliases = {'speedy delete'}
			},
			redirected = {
				id = 'redirected',
				text = 'Redirected',
				aliases = {'redirect'}
			},
			renamed = {
				id = 'renamed',
				text = 'Renamed',
				aliases = {'rename', 'move', 'moved'}
			}
		},
		validStatuses = false
	},
	TFD = {
		id = 'TFD',
		name = 'Templates for discussion',
		results = {
			kept = {
				id = 'kept',
				text = 'Kept',
				aliases = {'withdrawn', 'keep'}
			},
			deleted = {
				id = 'deleted',
				text = 'Deleted',
				aliases = {'delete'}
			},
			merged = {
				id = 'merged',
				text = 'Merged',
				aliases = {'merge'}
			},
			['no consensus'] = {
				id = 'no consensus',
				text = 'No consensus'
			},
			['speedily kept'] = {
				id = 'speedily kept',
				text = 'Speedily kept',
				aliases = {'speedy keep'}
			},
			['speedily deleted'] = {
				id = 'speedily deleted',
				text = 'Speedily deleted',
				aliases = {'speedy delete'}
			},
			redirected = {
				text = 'Redirected',
				aliases = {'redirect'}
			},
			renamed = {
				text = 'Renamed',
				aliases = {'rename', 'move', 'moved'}
			}
		},
		validStatuses = false
	},
	CSD = {
		id = 'CSD',
		name = 'Candidate for speedy deletion',
		results = {
			kept = {
				id = 'kept',
				text = 'Kept',
				aliases = {'withdrawn', 'keep'}
			},
			deleted = {
				id = 'deleted',
				text = 'Deleted',
				aliases = {'delete'}
			},
			merged = {
				id = 'merged',
				text = 'Merged',
				aliases = {'merge'}
			},
			['no consensus'] = {
				id = 'no consensus',
				text = 'No consensus'
			},
			['speedily kept'] = {
				id = 'speedily kept',
				text = 'Speedily kept',
				aliases = {'speedy keep'}
			},
			['speedily deleted'] = {
				id = 'speedily deleted',
				text = 'Speedily deleted',
				aliases = {'speedy delete'}
			},
			redirected = {
				id = 'redirected',
				text = 'Redirected',
				aliases = {'redirect'}
			},
			renamed = {
				id = 'renamed',
				text = 'Renamed',
				aliases = {'rename', 'move', 'moved'}
			}
		},
		validStatuses = false
	},
	PROD = {
		id = 'PROD',
		name = 'Proposed deletion',
		results = {
			kept = {
				id = 'kept',
				text = 'Kept',
				aliases = {'withdrawn', 'keep'}
			},
			deleted = {
				id = 'deleted',
				text = 'Deleted',
				aliases = {'delete'}
			},
			merged = {
				id = 'merged',
				text = 'Merged',
				aliases = {'merge'}
			},
			['no consensus'] = {
				id = 'no consensus',
				text = 'No consensus'
			},
			['speedily kept'] = {
				id = 'no consensus',
				text = 'Speedily kept',
				aliases = {'speedy keep'}
			},
			['speedily deleted'] = {
				id = 'speedily deleted',
				text = 'Speedily deleted',
				aliases = {'speedy delete'}
			},
			redirected = {
				id = 'redirected',
				text = 'Redirected',
				aliases = {'redirect'}
			},
			renamed = {
				id = 'renamed',
				text = 'Renamed',
				aliases = {'rename', 'move', 'moved'}
			}
		},
		validStatuses = false
	},
	DRV = {
		id = 'DRV',
		name = 'Deletion review',
		results = {
			endorsed = {
				id = 'endorsed',
				text = 'Endorsed',
				aliases = {'endorse'}
			},
			relisted = {
				id = 'relisted',
				text = 'Relisted',
				aliases = {'relist'}
			},
			overturned = {
				id = 'overturned',
				text = 'Overturned',
				aliases = {'overturn'}
			},
			['no consensus'] = {
				id = 'no consensus',
				text = 'No consensus'
			}
		},
		validStatuses = false
	}
},

-------------------------------------------------------------------------------
-- Statuses
-------------------------------------------------------------------------------

statuses = {
	FA = {
		id = 'FA',
		image = 'Featured article star.svg'
	},
	FFA = {
		id = 'FFA',
		image = 'Featured article star - cross.svg'
	},
	FFAC = {
		id = 'FFAC',
		aliases = {'FACFAILED'},
		image = 'Cscr-former.svg'
	},
	FL = {
		id = 'FL',
		image = 'Featured article star.svg'
	},
	FFL = {
		id = 'FFL',
		image = 'Cscr-featured-strike.svg'
	},
	FFLC = {
		id = 'FFLC',
		image = 'Cscr-former.svg'
	},
	['FFA/GA'] = {
		id = 'FFA/GA',
		isDouble = true,
		statuses = {'FFA', 'GA'}
	},
	GA = {
		id = 'GA',
		image = 'Symbol support vote.svg'
	},
	FGAN = {
		id = 'FGAN',
		aliases = {'FAILEDGA'},
		image = 'Symbol unsupport vote.svg'
	},
	DGA = {
		id = 'DGA',
		aliases = {'DELISTEDGA'},
		image = 'Symbol unsupport vote.svg'
	},
	FFT = {
		id = 'FFT',
		image = 'Cscr-featured-strike.svg'
	},
	FFTC = {
		id = 'FFTC',
		image = 'Cscr-former.svg'
	},
	FPO = {
		id = 'FPO',
		image = 'Cscr-former.svg'
	},
	FFPO = {
		id = 'FFPO',
		image = 'Featured article star - cross.svg'
	},
	FFPOC = {
		id = 'FFPOC',
		image = 'Cscr-former.svg'
	},
},

invalidStatuses = {
	FAC = {
		id = 'FAC'
	},
	FAR = {
		id = 'FAR'
	},
	STUB = {
		id = 'STUB',
		aliases = {'START', 'B', 'A'}
	},
	NA = {
		id = 'NA',
		aliases = {'PR', ''}
	},
},

getStatusIdFunction = function (articleHistoryObj)
	-- Get the status ID. The status code is the code passed in from the
	-- arguments, and the ID is the value contained in the config.
	local statuses = articleHistoryObj.cfg.statuses
	local statusCode = articleHistoryObj.args.currentstatus
	local statusId = articleHistoryObj:getStatusId(statusCode)

	-- Check for former featured articles.
	if statusId ~= 'FA'
		and statusId ~= 'FL'
		and statusId ~= 'FFA'
		and statusId ~= 'FFL'
		and statusId ~= 'FFA/GA'
	then
		local ffaObj
		for i = #articleHistoryObj.actions, 1, -1 do
			local actionObj = articleHistoryObj.actions[i]
			if actionObj.id == 'FAR' and actionObj:getResult() == 'demoted' then
				ffaObj = actionObj
				break
			end
		end
		if ffaObj then
			if not statusId then
				-- @TODO: Error
			elseif statusId == 'GA' then
				statusId = 'FFA/GA'
			elseif statusId ~= 'FFA' then
				-- @TODO: Error - 
			end
		end
	end

	return statusId
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 = 'result',
	oldid = 'oldid'
},

-------------------------------------------------------------------------------
-- Messages
-------------------------------------------------------------------------------

msg = {
}

-------------------------------------------------------------------------------
-- End config
-------------------------------------------------------------------------------

}