<?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%3ARequest_redirect</id>
	<title>Module:Request redirect - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mywikibiz.com/index.php?action=history&amp;feed=atom&amp;title=Module%3ARequest_redirect"/>
	<link rel="alternate" type="text/html" href="https://mywikibiz.com/index.php?title=Module:Request_redirect&amp;action=history"/>
	<updated>2026-06-21T03:11:30Z</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:Request_redirect&amp;diff=479124&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:Request_redirect&amp;diff=479124&amp;oldid=prev"/>
		<updated>2021-07-16T05:38:41Z</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 [[Template:Request redirect]].&lt;br /&gt;
&lt;br /&gt;
local p, templates = {}, {}&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Templates&lt;br /&gt;
--&lt;br /&gt;
-- These are templates used in the module's output. The templates use two&lt;br /&gt;
-- different kinds of parameter. Parameters that look like ${parameter} will be&lt;br /&gt;
-- replaced with the corresponding value from a data table. Parameters that &lt;br /&gt;
-- look like ${@TEMPLATE_NAME} will be replaced recursively by other templates&lt;br /&gt;
-- in the templates table. This helps to reduce duplication of template code&lt;br /&gt;
-- while also avoiding tricky conditional logic inside templates.&lt;br /&gt;
-- &lt;br /&gt;
-- Templates can contain arbitrary wikitext; wikitext will be expanded on&lt;br /&gt;
-- transclusion, and left as-is on substitution.&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
templates.HEADING = '== Redirect request: [[:${title}]] =='&lt;br /&gt;
&lt;br /&gt;
templates.BODY = [=[&lt;br /&gt;
* Target of redirect: [[:${target}]]&lt;br /&gt;
* Reason: ${reason}&lt;br /&gt;
* Source (if applicable): ${source}&lt;br /&gt;
~~~~]=]&lt;br /&gt;
&lt;br /&gt;
templates.OPEN_REQUEST = [=[&lt;br /&gt;
${@HEADING}&lt;br /&gt;
${@BODY}]=]&lt;br /&gt;
&lt;br /&gt;
templates.CLOSED_REQUEST = [=[&lt;br /&gt;
${@HEADING}&lt;br /&gt;
{{afc-c|d}}&lt;br /&gt;
${@BODY}&lt;br /&gt;
&lt;br /&gt;
${afcredirect} &amp;lt;small&amp;gt;(Automatically declined)&amp;lt;/small&amp;gt;&lt;br /&gt;
{{afc-c|b}}]=]&lt;br /&gt;
&lt;br /&gt;
templates.REQUEST_WITH_ERROR = [=[&lt;br /&gt;
${@HEADING}&lt;br /&gt;
${@BODY}&lt;br /&gt;
&lt;br /&gt;
{{error|Error: ${errormsg}}}&amp;lt;!--subst:afc redirect|${closereason}--&amp;gt;]=]&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Helper functions&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- Substitutes parameters like ${parameter} and ${@TEMPLATE_NAME}. Templates&lt;br /&gt;
-- are transcluded recursively.&lt;br /&gt;
local function substituteParameters(template, data)&lt;br /&gt;
	local content = templates[template]&lt;br /&gt;
	if not content then&lt;br /&gt;
		error(string.format(&lt;br /&gt;
			&amp;quot;the template '%s' does not exist&amp;quot;,&lt;br /&gt;
			tostring(template)&lt;br /&gt;
		))&lt;br /&gt;
	end&lt;br /&gt;
	content = content:gsub('${(@?)([a-zA-Z_]+)}', function (at, param)&lt;br /&gt;
		if at == '@' then&lt;br /&gt;
			return substituteParameters(param, data)&lt;br /&gt;
		else&lt;br /&gt;
			return data[param] or ''&lt;br /&gt;
		end&lt;br /&gt;
	end)&lt;br /&gt;
	return content&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Expand a template, substituting parameters and expanding wikitext as&lt;br /&gt;
-- appropriate.&lt;br /&gt;
local function expand(template, data, frame)&lt;br /&gt;
	frame = frame or mw.getCurrentFrame()&lt;br /&gt;
	local content = substituteParameters(template, data)&lt;br /&gt;
	if mw.isSubsting() then&lt;br /&gt;
		return content&lt;br /&gt;
	else&lt;br /&gt;
		return frame:preprocess(content)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Finds a page's status. This can be either:&lt;br /&gt;
-- * &amp;quot;noinput&amp;quot; - for missing user input&lt;br /&gt;
-- * &amp;quot;invalid&amp;quot; - for invalid titles (e.g. page names containing the &amp;quot;|&amp;quot; symbol)&lt;br /&gt;
-- * &amp;quot;missing&amp;quot; - valid titles that don't exist&lt;br /&gt;
-- * &amp;quot;exists&amp;quot;  - valid titles that exist&lt;br /&gt;
local function getPageStatus(page)&lt;br /&gt;
	if not page then&lt;br /&gt;
		return 'noinput'&lt;br /&gt;
	end&lt;br /&gt;
	local title = mw.title.new(page)&lt;br /&gt;
	if not title then&lt;br /&gt;
		return 'invalid'&lt;br /&gt;
	elseif title.exists then&lt;br /&gt;
		return 'exists'&lt;br /&gt;
	else&lt;br /&gt;
		return 'missing'&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;
function p._main(args, frame)&lt;br /&gt;
	frame = frame or mw.getCurrentFrame()&lt;br /&gt;
&lt;br /&gt;
	local data = {}&lt;br /&gt;
	data.title = args.title or args[1]&lt;br /&gt;
	data.target = args.target or args[2]&lt;br /&gt;
	data.reason = args.reason or args[3]&lt;br /&gt;
	data.source = args.source or args[4]&lt;br /&gt;
&lt;br /&gt;
	-- Check parameters for errors.&lt;br /&gt;
	local titleStatus = getPageStatus(data.title)&lt;br /&gt;
	local targetStatus = getPageStatus(data.target)&lt;br /&gt;
	local closeReason&lt;br /&gt;
	if titleStatus == 'invalid' then&lt;br /&gt;
		closeReason = 'notitle'&lt;br /&gt;
		data.errormsg = string.format(&lt;br /&gt;
			'&amp;quot;%s&amp;quot; is an invalid title.',&lt;br /&gt;
			data.title&lt;br /&gt;
		)&lt;br /&gt;
	elseif targetStatus == 'invalid' then&lt;br /&gt;
		closeReason = 'notarget'&lt;br /&gt;
		data.errormsg = string.format(&lt;br /&gt;
			'&amp;quot;%s&amp;quot; is an invalid title.',&lt;br /&gt;
			data.target&lt;br /&gt;
		)&lt;br /&gt;
	elseif titleStatus == 'exists' then&lt;br /&gt;
		if targetStatus == 'exists' then&lt;br /&gt;
			closeReason = 'exist'&lt;br /&gt;
			data.errormsg = string.format(&lt;br /&gt;
				'[[:%s]] already exists on Wikipedia.',&lt;br /&gt;
				data.title&lt;br /&gt;
			)&lt;br /&gt;
		elseif targetStatus == 'missing' then&lt;br /&gt;
			-- Assume the user got the pages the wrong way round.&lt;br /&gt;
			data.title, data.target = data.target, data.title&lt;br /&gt;
		else&lt;br /&gt;
			-- targetStatus == 'noinput'&lt;br /&gt;
			closeReason = 'notitle'&lt;br /&gt;
			data.errormsg = 'You have not specified the title of the redirect that you want created.'&lt;br /&gt;
		end&lt;br /&gt;
	elseif titleStatus == 'missing' then&lt;br /&gt;
		-- If targetStatus == 'exists' the submission is good and we don't need&lt;br /&gt;
		-- to do anything.&lt;br /&gt;
		if targetStatus == 'missing' then&lt;br /&gt;
			closeReason = 'notarget'&lt;br /&gt;
			data.errormsg = string.format(&lt;br /&gt;
				&amp;quot;Redirect target [[:%s]] doesn't exist.&amp;quot;,&lt;br /&gt;
				data.target&lt;br /&gt;
			)&lt;br /&gt;
		elseif targetStatus == 'noinput' then&lt;br /&gt;
			closeReason = 'notarget'&lt;br /&gt;
			data.errormsg = 'Redirect target was not specified.'&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		-- titleStatus == 'noinput'&lt;br /&gt;
		if targetStatus == 'exists' then&lt;br /&gt;
			closeReason = 'notitle'&lt;br /&gt;
			data.errormsg = 'You have not specified the title of the redirect that you want created.'&lt;br /&gt;
		elseif targetStatus == 'missing' then&lt;br /&gt;
			closeReason = 'notarget'&lt;br /&gt;
			data.errormsg = string.format(&lt;br /&gt;
				&amp;quot;Redirect target [[:%s]] doesn't exist.&amp;quot;,&lt;br /&gt;
				data.target&lt;br /&gt;
			)&lt;br /&gt;
		else&lt;br /&gt;
			-- targetStatus == 'noinput'&lt;br /&gt;
			closeReason = 'blank'&lt;br /&gt;
			data.errormsg = 'We cannot accept empty submissions.'&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Find the template we need, and expand {{Afc redirect}} if it is needed.&lt;br /&gt;
	local template&lt;br /&gt;
	if closeReason and args.close then&lt;br /&gt;
		template = 'CLOSED_REQUEST'&lt;br /&gt;
		data.afcredirect = frame:expandTemplate{&lt;br /&gt;
			title = 'afc redirect',&lt;br /&gt;
			args = {closeReason}&lt;br /&gt;
		}&lt;br /&gt;
	elseif closeReason then&lt;br /&gt;
		template = 'REQUEST_WITH_ERROR'&lt;br /&gt;
	else&lt;br /&gt;
		template = 'OPEN_REQUEST'&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Return the template with parameters substituted.&lt;br /&gt;
	return expand(template, data, frame)&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:Request redirect'&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>