<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/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://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ARequest_redirect"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Request_redirect&amp;action=history"/>
	<updated>2026-04-20T05:11:46Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:Request_redirect&amp;diff=144647&amp;oldid=prev</id>
		<title>imported&gt;Mr. Stradivarius: tweak heading spacing</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Request_redirect&amp;diff=144647&amp;oldid=prev"/>
		<updated>2015-07-23T07:12:07Z</updated>

		<summary type="html">&lt;p&gt;tweak heading spacing&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&amp;#039;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 = &amp;#039;== Redirect request: [[:${title}]] ==&amp;#039;&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 &amp;#039;%s&amp;#039; does not exist&amp;quot;,&lt;br /&gt;
			tostring(template)&lt;br /&gt;
		))&lt;br /&gt;
	end&lt;br /&gt;
	content = content:gsub(&amp;#039;${(@?)([a-zA-Z_]+)}&amp;#039;, function (at, param)&lt;br /&gt;
		if at == &amp;#039;@&amp;#039; then&lt;br /&gt;
			return substituteParameters(param, data)&lt;br /&gt;
		else&lt;br /&gt;
			return data[param] or &amp;#039;&amp;#039;&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&amp;#039;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&amp;#039;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 &amp;#039;noinput&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	local title = mw.title.new(page)&lt;br /&gt;
	if not title then&lt;br /&gt;
		return &amp;#039;invalid&amp;#039;&lt;br /&gt;
	elseif title.exists then&lt;br /&gt;
		return &amp;#039;exists&amp;#039;&lt;br /&gt;
	else&lt;br /&gt;
		return &amp;#039;missing&amp;#039;&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 == &amp;#039;invalid&amp;#039; then&lt;br /&gt;
		closeReason = &amp;#039;notitle&amp;#039;&lt;br /&gt;
		data.errormsg = string.format(&lt;br /&gt;
			&amp;#039;&amp;quot;%s&amp;quot; is an invalid title.&amp;#039;,&lt;br /&gt;
			data.title&lt;br /&gt;
		)&lt;br /&gt;
	elseif targetStatus == &amp;#039;invalid&amp;#039; then&lt;br /&gt;
		closeReason = &amp;#039;notarget&amp;#039;&lt;br /&gt;
		data.errormsg = string.format(&lt;br /&gt;
			&amp;#039;&amp;quot;%s&amp;quot; is an invalid title.&amp;#039;,&lt;br /&gt;
			data.target&lt;br /&gt;
		)&lt;br /&gt;
	elseif titleStatus == &amp;#039;exists&amp;#039; then&lt;br /&gt;
		if targetStatus == &amp;#039;exists&amp;#039; then&lt;br /&gt;
			closeReason = &amp;#039;exist&amp;#039;&lt;br /&gt;
			data.errormsg = string.format(&lt;br /&gt;
				&amp;#039;[[:%s]] already exists on Wikipedia.&amp;#039;,&lt;br /&gt;
				data.title&lt;br /&gt;
			)&lt;br /&gt;
		elseif targetStatus == &amp;#039;missing&amp;#039; 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 == &amp;#039;noinput&amp;#039;&lt;br /&gt;
			closeReason = &amp;#039;notitle&amp;#039;&lt;br /&gt;
			data.errormsg = &amp;#039;You have not specified the title of the redirect that you want created.&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
	elseif titleStatus == &amp;#039;missing&amp;#039; then&lt;br /&gt;
		-- If targetStatus == &amp;#039;exists&amp;#039; the submission is good and we don&amp;#039;t need&lt;br /&gt;
		-- to do anything.&lt;br /&gt;
		if targetStatus == &amp;#039;missing&amp;#039; then&lt;br /&gt;
			closeReason = &amp;#039;notarget&amp;#039;&lt;br /&gt;
			data.errormsg = string.format(&lt;br /&gt;
				&amp;quot;Redirect target [[:%s]] doesn&amp;#039;t exist.&amp;quot;,&lt;br /&gt;
				data.target&lt;br /&gt;
			)&lt;br /&gt;
		elseif targetStatus == &amp;#039;noinput&amp;#039; then&lt;br /&gt;
			closeReason = &amp;#039;notarget&amp;#039;&lt;br /&gt;
			data.errormsg = &amp;#039;Redirect target was not specified.&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		-- titleStatus == &amp;#039;noinput&amp;#039;&lt;br /&gt;
		if targetStatus == &amp;#039;exists&amp;#039; then&lt;br /&gt;
			closeReason = &amp;#039;notitle&amp;#039;&lt;br /&gt;
			data.errormsg = &amp;#039;You have not specified the title of the redirect that you want created.&amp;#039;&lt;br /&gt;
		elseif targetStatus == &amp;#039;missing&amp;#039; then&lt;br /&gt;
			closeReason = &amp;#039;notarget&amp;#039;&lt;br /&gt;
			data.errormsg = string.format(&lt;br /&gt;
				&amp;quot;Redirect target [[:%s]] doesn&amp;#039;t exist.&amp;quot;,&lt;br /&gt;
				data.target&lt;br /&gt;
			)&lt;br /&gt;
		else&lt;br /&gt;
			-- targetStatus == &amp;#039;noinput&amp;#039;&lt;br /&gt;
			closeReason = &amp;#039;blank&amp;#039;&lt;br /&gt;
			data.errormsg = &amp;#039;We cannot accept empty submissions.&amp;#039;&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 = &amp;#039;CLOSED_REQUEST&amp;#039;&lt;br /&gt;
		data.afcredirect = frame:expandTemplate{&lt;br /&gt;
			title = &amp;#039;afc redirect&amp;#039;,&lt;br /&gt;
			args = {closeReason}&lt;br /&gt;
		}&lt;br /&gt;
	elseif closeReason then&lt;br /&gt;
		template = &amp;#039;REQUEST_WITH_ERROR&amp;#039;&lt;br /&gt;
	else&lt;br /&gt;
		template = &amp;#039;OPEN_REQUEST&amp;#039;&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(&amp;#039;Module:Arguments&amp;#039;).getArgs(frame, {&lt;br /&gt;
		wrappers = &amp;#039;Template:Request redirect&amp;#039;&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>imported&gt;Mr. Stradivarius</name></author>
	</entry>
</feed>