<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mywikibiz.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AVENAClassnomination</id>
	<title>Module:VENAClassnomination - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mywikibiz.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AVENAClassnomination"/>
	<link rel="alternate" type="text/html" href="https://mywikibiz.com/index.php?title=Module:VENAClassnomination&amp;action=history"/>
	<updated>2026-06-19T09:48:42Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.3</generator>
	<entry>
		<id>https://mywikibiz.com/index.php?title=Module:VENAClassnomination&amp;diff=479956&amp;oldid=prev</id>
		<title>Zoran: Pywikibot 6.4.0</title>
		<link rel="alternate" type="text/html" href="https://mywikibiz.com/index.php?title=Module:VENAClassnomination&amp;diff=479956&amp;oldid=prev"/>
		<updated>2021-07-16T07:50:31Z</updated>

		<summary type="html">&lt;p&gt;Pywikibot 6.4.0&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- This module implements {{VENAClassnomination}}.&lt;br /&gt;
&lt;br /&gt;
local lang = mw.language.getContentLanguage()&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Output template&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- This template contains the final output of the module. Parameters like&lt;br /&gt;
-- ${PARAMETER_NAME} are substituted with the results of the output template&lt;br /&gt;
-- parameter functions below.&lt;br /&gt;
&lt;br /&gt;
local OUTPUT_TEMPLATE = [=[&lt;br /&gt;
${MONTH_AND_YEAR}&lt;br /&gt;
* ${HEADING}&lt;br /&gt;
* ${COMMENT}&lt;br /&gt;
&amp;lt;small&amp;gt;${STATUS} by ${AUTHORS}. ${NOMINATED} at ~~~~~.&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:* &amp;lt;!-- REPLACE THIS LINE TO WRITE FIRST COMMENT, KEEPING   :*   --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--Please do not write below this line or remove this line. Place comments above this line.--&amp;gt;]=]&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Helper functions&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- Creates a formatted error message that can be used with substitution.&lt;br /&gt;
local function formatError(msg)&lt;br /&gt;
	return string.format('{{error|1=%s}}', msg)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Creates a boilerplate error message for invalid titles.&lt;br /&gt;
local function formatInvalidTitleError(page, pageType)&lt;br /&gt;
	local msg = string.format(&lt;br /&gt;
		'&amp;quot;%s&amp;quot; is not a valid %s; check for bad characters',&lt;br /&gt;
		page, pageType&lt;br /&gt;
	)&lt;br /&gt;
	return formatError(msg)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Same as {{ROOTPAGENAME}}. If the page is an invalid title, returns nil.&lt;br /&gt;
local function getRootPageText(page)&lt;br /&gt;
	local title = mw.title.new(page)&lt;br /&gt;
	if title then&lt;br /&gt;
		return title.rootPageTitle.text&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Normalize positional parameters for a template invocation. If any of the&lt;br /&gt;
-- parameters contain equals signs, the parameters are all prefixed with&lt;br /&gt;
-- numbers.&lt;br /&gt;
local function normalizeTemplateParameters(params)&lt;br /&gt;
	local ret = {}&lt;br /&gt;
	local hasEquals = false&lt;br /&gt;
	for i, param in ipairs(params) do&lt;br /&gt;
		if param:find('=') then&lt;br /&gt;
			hasEquals = true&lt;br /&gt;
			break&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if hasEquals then&lt;br /&gt;
		for i, param in ipairs(params) do&lt;br /&gt;
			ret[i] = string.format('%d=%s', i, param)&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		for i, param in ipairs(params) do&lt;br /&gt;
			ret[i] = param&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Makes a link to a user's user page and talk page, like found in a standard&lt;br /&gt;
-- signature.&lt;br /&gt;
local function makeUserLinks(user)&lt;br /&gt;
	return string.format(&lt;br /&gt;
		'[[User:%s|%s]] ([[User talk:%s|talk]])',&lt;br /&gt;
		user, user, user&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Returns an array of authors. If the user didn't specify any authors, the&lt;br /&gt;
-- first one is the result of {{REVISIONUSER}}.&lt;br /&gt;
local function getNormalisedAuthors(data)&lt;br /&gt;
	local authors = {}&lt;br /&gt;
	for i, author in ipairs(data.authors) do&lt;br /&gt;
		authors[i] = author&lt;br /&gt;
	end&lt;br /&gt;
	authors[1] = authors[1] or data.revisionUser&lt;br /&gt;
	return authors&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Removes gaps from sparse arrays. This is used to process numbered arguments&lt;br /&gt;
-- like author2 and ALT4.&lt;br /&gt;
local compressSparseArray = require(&amp;quot;Module:TableTools&amp;quot;).compressSparseArray&lt;br /&gt;
&lt;br /&gt;
-- Splits numbered arguments by their prefixes. A table of arguments like this:&lt;br /&gt;
--    {foo1 = &amp;quot;foo1&amp;quot;, foo2 = &amp;quot;foo2&amp;quot;, bar3 = &amp;quot;bar3&amp;quot;}&lt;br /&gt;
-- Would be turned into this:&lt;br /&gt;
--    {foo = {[1] = &amp;quot;foo1&amp;quot;, [2] = &amp;quot;foo2&amp;quot;}, bar = {[3] = &amp;quot;bar3&amp;quot;}}&lt;br /&gt;
-- Note that the subtables of the returned tables are not normal arrays, but&lt;br /&gt;
-- sparse arrays (there can be gaps between values).&lt;br /&gt;
local function splitByPrefix(args)&lt;br /&gt;
	local ret = {}&lt;br /&gt;
	for key, val in pairs(args) do&lt;br /&gt;
		if type(key) == 'string' then&lt;br /&gt;
			local prefix, num = key:match('^(.-)([1-9][0-9]*)$')&lt;br /&gt;
			if prefix then&lt;br /&gt;
				num = tonumber(num)&lt;br /&gt;
				ret[prefix] = ret[prefix] or {}&lt;br /&gt;
				ret[prefix][num] = val&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Returns an array of numbered arguments with the given prefixes. Earlier&lt;br /&gt;
-- prefixes have precedence, and args[prefix] will overwrite args[prefix .. 1].&lt;br /&gt;
-- For example, for this arguments table:&lt;br /&gt;
--   {&lt;br /&gt;
--      author = &amp;quot;author&amp;quot;,&lt;br /&gt;
--      author1 = &amp;quot;author1&amp;quot;,&lt;br /&gt;
--      author2 = &amp;quot;author2,&lt;br /&gt;
--      creator2 = &amp;quot;creator2&amp;quot;&lt;br /&gt;
--   }&lt;br /&gt;
-- The function call getPrefixedArgs(args, splitArgs, {'creator', 'author'})&lt;br /&gt;
-- will produce:&lt;br /&gt;
--   {&amp;quot;author&amp;quot;, &amp;quot;creator2&amp;quot;}&lt;br /&gt;
--&lt;br /&gt;
-- Parameters:&lt;br /&gt;
-- args - the table of arguments specified by the user&lt;br /&gt;
-- splitArgs - the table of arguments as processed by splitByPrefix&lt;br /&gt;
-- prefixes - an array of prefixes&lt;br /&gt;
local function getPrefixedArgs(args, splitArgs, prefixes)&lt;br /&gt;
	local ret = {}&lt;br /&gt;
	for i, prefix in ipairs(prefixes) do&lt;br /&gt;
		if splitArgs[prefix] then&lt;br /&gt;
			for num, val in pairs(splitArgs[prefix]) do&lt;br /&gt;
				if not ret[num] then&lt;br /&gt;
					ret[num] = val&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	-- Allow prefix to overwrite prefix1.&lt;br /&gt;
	for _, prefix in ipairs(prefixes) do&lt;br /&gt;
		local val = args[prefix]&lt;br /&gt;
		if val then&lt;br /&gt;
			ret[1] = val&lt;br /&gt;
			break&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return compressSparseArray(ret)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Output template parameter functions&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- The results of these functions are substituted into parameters in the&lt;br /&gt;
-- output template. The parameters look like ${PARAMETER_NAME}. Trying to use&lt;br /&gt;
-- a parameter that doesn't have a function defined here will result in an&lt;br /&gt;
-- error.&lt;br /&gt;
--&lt;br /&gt;
-- The functions take a data table as a single argument. This table contains&lt;br /&gt;
-- the following fields:&lt;br /&gt;
-- * errors - a table of formatted error messages that were found when&lt;br /&gt;
--     processing the input.&lt;br /&gt;
-- * args - the table of arguments supplied by the user.&lt;br /&gt;
-- * articles - an array of the article names found in the arguments.&lt;br /&gt;
-- * authors - an array of the expanders/creators/writers/authors found in the&lt;br /&gt;
--     arguments.&lt;br /&gt;
-- * revisionUser - the user that last edited the page. As this module is only&lt;br /&gt;
--     substitited, this is always the current user.&lt;br /&gt;
-- * alts - an array of the ALT hooks found in the arguments.&lt;br /&gt;
-- * title - the mw.title object for the current page.&lt;br /&gt;
--&lt;br /&gt;
-- Template parameter functions should return a string, false, or nil.&lt;br /&gt;
-- Functions returning false or nil will be treated as outputting the empty&lt;br /&gt;
-- string &amp;quot;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
local params = {}&lt;br /&gt;
&lt;br /&gt;
-- Renders any errors that were found when processing the input.&lt;br /&gt;
function params.INPUT_ERRORS(data)&lt;br /&gt;
	local nErrors = #data.errors&lt;br /&gt;
	if nErrors &amp;gt; 1 then&lt;br /&gt;
		return '\n* ' .. table.concat(data.errors, '\n* ')&lt;br /&gt;
	elseif nErrors == 1 then&lt;br /&gt;
		return '\n' .. data.errors[1]&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- The current month and year, e.g. &amp;quot;March 2015&amp;quot;.&lt;br /&gt;
function params.MONTH_AND_YEAR()&lt;br /&gt;
	return lang:formatDate('F Y')&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- The contents of the heading.&lt;br /&gt;
function params.HEADING(data)&lt;br /&gt;
	return table.concat(data.articles, ', ')&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- The current subpage name.&lt;br /&gt;
function params.NOM_SUBPAGE(data)&lt;br /&gt;
	return data.title.subpageText&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Other arguments for the nompage link template, separated by pipes.&lt;br /&gt;
function params.NOMPAGE_LINK_ARGS(data)&lt;br /&gt;
	local vals = normalizeTemplateParameters(data.articles)&lt;br /&gt;
	return table.concat(vals, '|')&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- A comment.&lt;br /&gt;
function params.COMMENT(data)&lt;br /&gt;
	if data.args.comment then&lt;br /&gt;
		return &amp;quot;\n:* ''Comment'': &amp;quot; .. data.args.comment&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- The status of the article when it was nominated.&lt;br /&gt;
function params.STATUS(data)&lt;br /&gt;
	local status = data.args.status&lt;br /&gt;
	status = status and status:lower()&lt;br /&gt;
&lt;br /&gt;
	-- C&lt;br /&gt;
	if status == 'C' then&lt;br /&gt;
		return 'C-class'&lt;br /&gt;
	-- B&lt;br /&gt;
	elseif status == 'B' then&lt;br /&gt;
		return 'B-class'&lt;br /&gt;
&lt;br /&gt;
	-- Improved to GA&lt;br /&gt;
	elseif status == 'ga' then&lt;br /&gt;
		return 'Good Article'&lt;br /&gt;
&lt;br /&gt;
	-- Default&lt;br /&gt;
	else&lt;br /&gt;
		return 'unknown'&lt;br /&gt;
	end&lt;br /&gt;
end	&lt;br /&gt;
&lt;br /&gt;
-- A list of the authors, with user and user talk links.&lt;br /&gt;
function params.AUTHORS(data)&lt;br /&gt;
	local authors = getNormalisedAuthors(data)&lt;br /&gt;
	for i, author in ipairs(authors) do&lt;br /&gt;
		authors[i] = makeUserLinks(author)&lt;br /&gt;
	end&lt;br /&gt;
	local separator = ', '&lt;br /&gt;
	local conjunction&lt;br /&gt;
	if #authors &amp;gt; 2 then&lt;br /&gt;
		conjunction = ', and '&lt;br /&gt;
	else&lt;br /&gt;
		conjunction = ' and '&lt;br /&gt;
	end&lt;br /&gt;
	return mw.text.listToText(authors, separator, conjunction)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Blurb for who the article was nominated by.&lt;br /&gt;
function params.NOMINATED(data)&lt;br /&gt;
	local authors = data.authors&lt;br /&gt;
	if #authors &amp;gt; 1 or authors[1] and authors[1] ~= data.revisionUser then&lt;br /&gt;
		return 'Nominated by ' .. makeUserLinks(data.revisionUser)&lt;br /&gt;
	else&lt;br /&gt;
		return 'Self-nominated'&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Exports&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
function p._main(args, frame, title)&lt;br /&gt;
	-- Subst check.&lt;br /&gt;
	-- Check for the frame object as well to make debugging easier from the&lt;br /&gt;
	-- debug console.&lt;br /&gt;
	if frame and not mw.isSubsting() then&lt;br /&gt;
		return '&amp;lt;strong class=&amp;quot;error&amp;quot;&amp;gt;' ..&lt;br /&gt;
			'This template must be [[Wikipedia:Substitution|substituted]]. ' ..&lt;br /&gt;
			'Replace &amp;lt;code&amp;gt;{{VENAClassnomination}}&amp;lt;/code&amp;gt; with ' ..&lt;br /&gt;
			'&amp;lt;code&amp;gt;{{subst:VENAClassnomination}}&amp;lt;/code&amp;gt;.&amp;lt;/strong&amp;gt;'&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Set default arguments.&lt;br /&gt;
	frame = frame or mw.getCurrentFrame()&lt;br /&gt;
	title = title or mw.title.getCurrentTitle()&lt;br /&gt;
&lt;br /&gt;
	-- Process data from the arguments.&lt;br /&gt;
	local splitArgs = splitByPrefix(args)&lt;br /&gt;
	local articles = getPrefixedArgs(args, splitArgs, {'article'})&lt;br /&gt;
	local authors = getPrefixedArgs(&lt;br /&gt;
		args,&lt;br /&gt;
		splitArgs,&lt;br /&gt;
		{'expander', 'creator', 'writer', 'author'}&lt;br /&gt;
	)&lt;br /&gt;
	local alts = getPrefixedArgs(args, splitArgs, {'ALT'})&lt;br /&gt;
&lt;br /&gt;
	-- Input sanity checks.&lt;br /&gt;
	local errors = {}&lt;br /&gt;
	for i, article in ipairs(articles) do&lt;br /&gt;
		local articleTitle = mw.title.new(article)&lt;br /&gt;
		if not articleTitle then&lt;br /&gt;
			table.insert(errors, formatInvalidTitleError(&lt;br /&gt;
				article,&lt;br /&gt;
				'article name'&lt;br /&gt;
			))&lt;br /&gt;
			articles[i] = ''&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if #articles &amp;lt; 1 then&lt;br /&gt;
		articles[1] = title.subpageText&lt;br /&gt;
	end&lt;br /&gt;
	for i, author in ipairs(authors) do&lt;br /&gt;
		authors[i] = getRootPageText(author)&lt;br /&gt;
		if not authors[i] then&lt;br /&gt;
			table.insert(errors, formatInvalidTitleError(author, 'user name'))&lt;br /&gt;
			authors[i] = ''&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Substitute the parameters in the output template.&lt;br /&gt;
	local data = {&lt;br /&gt;
		errors = errors,&lt;br /&gt;
		args = args,&lt;br /&gt;
		articles = articles,&lt;br /&gt;
		authors = authors,&lt;br /&gt;
		revisionUser = frame:preprocess('{{safesubst:REVISIONUSER}}'),&lt;br /&gt;
		alts = alts,&lt;br /&gt;
		title = title,&lt;br /&gt;
	}&lt;br /&gt;
	local ret = OUTPUT_TEMPLATE:gsub('${([%u_]+)}', function (funcName)&lt;br /&gt;
		local func = params[funcName]&lt;br /&gt;
		if not func then&lt;br /&gt;
			error(string.format(&lt;br /&gt;
				&amp;quot;invalid parameter '${%s}' &amp;quot; ..&lt;br /&gt;
				&amp;quot;(no corresponding parameter function found)&amp;quot;,&lt;br /&gt;
				funcName&lt;br /&gt;
			))&lt;br /&gt;
		end&lt;br /&gt;
		return func(data) or ''&lt;br /&gt;
	end)&lt;br /&gt;
	return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	local args = require('Module:Arguments').getArgs(frame, {&lt;br /&gt;
		wrappers = 'Template:VENAClassnomination'&lt;br /&gt;
	})&lt;br /&gt;
	return p._main(args, frame)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Zoran</name></author>
	</entry>
</feed>