<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.cultopedia.org/index.php?action=history&amp;feed=atom&amp;title=Module%3ARedirect_template</id>
	<title>Module:Redirect template - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.cultopedia.org/index.php?action=history&amp;feed=atom&amp;title=Module%3ARedirect_template"/>
	<link rel="alternate" type="text/html" href="https://www.cultopedia.org/index.php?title=Module:Redirect_template&amp;action=history"/>
	<updated>2026-04-06T01:34:32Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.5</generator>
	<entry>
		<id>https://www.cultopedia.org/index.php?title=Module:Redirect_template&amp;diff=719&amp;oldid=prev</id>
		<title>imported&gt;Pppery: Changed protection settings for &quot;Module:Redirect template&quot; ([Edit=Require administrator access] (indefinite) [Move=Require administrator access] (indefinite))</title>
		<link rel="alternate" type="text/html" href="https://www.cultopedia.org/index.php?title=Module:Redirect_template&amp;diff=719&amp;oldid=prev"/>
		<updated>2025-08-11T23:33:36Z</updated>

		<summary type="html">&lt;p&gt;Changed protection settings for &amp;quot;&lt;a href=&quot;/index.php/Module:Redirect_template&quot; title=&quot;Module:Redirect template&quot;&gt;Module:Redirect template&lt;/a&gt;&amp;quot; ([Edit=Require administrator access] (indefinite) [Move=Require administrator access] (indefinite))&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;require(&amp;#039;strict&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
-- key is beginning of arg name. value is table with namespace number and link&lt;br /&gt;
-- alternatively, a function taking the namespace number and returning a validity&lt;br /&gt;
-- can be used&lt;br /&gt;
local namespaceCategories = {&lt;br /&gt;
	all = { function() return true end },&lt;br /&gt;
	main = { 0, &amp;#039;[[WP:Mainspace|main]]&amp;#039; },&lt;br /&gt;
	help = { 12, &amp;#039;[[WP:Help namespace|help]]&amp;#039; },&lt;br /&gt;
	portal = { 100, &amp;#039;[[WP:Portal|portal]]&amp;#039; },&lt;br /&gt;
	mos = { 126, &amp;#039;[[WP:MOS namespace|MOS]]&amp;#039; },&lt;br /&gt;
	talk = { function(n) return n &amp;gt; 0 and n%2 == 1 end, &amp;#039;[[Help:Talk pages|talk]]&amp;#039; },&lt;br /&gt;
	template = { 10, &amp;#039;[[WP:Template namespace|template]]&amp;#039; },&lt;br /&gt;
	wikipedia = { 4, &amp;#039;[[WP:Project namespace|Wikipedia project]]&amp;#039; },&lt;br /&gt;
	category = { 14, &amp;#039;[[WP:Categorization|category]]&amp;#039; },&lt;br /&gt;
	user = { 2, &amp;#039;[[WP:User pages|user]]&amp;#039; },&lt;br /&gt;
	draft = { 118, &amp;#039;[[WP:Drafts|draft]]&amp;#039; },&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
-- remove whitespaces from beginning and end of args&lt;br /&gt;
local function valueFunc(key, val)&lt;br /&gt;
	if type(val) == &amp;#039;string&amp;#039; then&lt;br /&gt;
		val = val:match(&amp;#039;^%s*(.-)%s*$&amp;#039;)&lt;br /&gt;
		if val == &amp;#039;&amp;#039; then&lt;br /&gt;
			return nil&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return val&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getPrettyName(args)&lt;br /&gt;
	for k in pairs(namespaceCategories) do&lt;br /&gt;
		if args[k .. &amp;#039; category&amp;#039;] then&lt;br /&gt;
			return string.format(&amp;quot;&amp;#039;&amp;#039;&amp;#039;[[:Category:%s|%s]]&amp;#039;&amp;#039;&amp;#039;: &amp;quot;, args[k .. &amp;#039; category&amp;#039;], args.name)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return string.format(&amp;quot;&amp;#039;&amp;#039;&amp;#039;%s&amp;#039;&amp;#039;&amp;#039;: &amp;quot;, args.name)&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, {wrappers = &amp;#039;Template:Redirect template&amp;#039;, valueFunc = valueFunc})&lt;br /&gt;
	local namespace = mw.title.getCurrentTitle().namespace&lt;br /&gt;
&lt;br /&gt;
	--- XXX: this is a HORRIBLE HACK. kill it with fire as soon as https://phabricator.wikimedia.org/T14974 is fixed&lt;br /&gt;
	--- [[phab:T14974]] was previously known as [[bugzilla:12974]] https://bugzilla.wikimedia.org/show_bug.cgi?id=12974&lt;br /&gt;
	local beCompatibleWithBug14974 = args.info and (args.info:find(&amp;#039;^[:;#*]&amp;#039;, 1) == 1 or args.info:find(&amp;#039;{|&amp;#039;, 1, true) == 1) and &amp;#039;\n&amp;#039; or &amp;#039; &amp;#039;&lt;br /&gt;
	&lt;br /&gt;
	local content = string.format(&amp;#039;\n&amp;lt;div class=&amp;quot;rcat %s&amp;quot;&amp;gt;\n*%sThis is a redirect%s%s.%s%s\n&amp;lt;/div&amp;gt;&amp;#039;,&lt;br /&gt;
		args.id and (&amp;#039;rcat-&amp;#039; .. string.gsub(args.id, &amp;#039; &amp;#039;, &amp;#039;_&amp;#039;)) or &amp;#039;&amp;#039;,&lt;br /&gt;
		args.name and getPrettyName(args) or &amp;#039;&amp;#039;,&lt;br /&gt;
		args.from and (&amp;#039; from &amp;#039; .. args.from) or &amp;#039;&amp;#039;,&lt;br /&gt;
		args.to and (&amp;#039; to &amp;#039; .. args.to) or &amp;#039;&amp;#039;,&lt;br /&gt;
		args.info and beCompatibleWithBug14974 or &amp;#039;&amp;#039;,&lt;br /&gt;
		args.info or &amp;#039;&amp;#039;&lt;br /&gt;
	)&lt;br /&gt;
	&lt;br /&gt;
	for k,v in pairs(namespaceCategories) do&lt;br /&gt;
		if args[k .. &amp;#039; category&amp;#039;] then&lt;br /&gt;
			if type(v[1]) == &amp;#039;function&amp;#039; and v[1](namespace) or v[1] == namespace then&lt;br /&gt;
				if args.sortkey then&lt;br /&gt;
					content = content .. string.format(&amp;#039;[[Category:%s|%s]]&amp;#039;, args[k .. &amp;#039; category&amp;#039;], args.sortkey)&lt;br /&gt;
					else&lt;br /&gt;
						content = content .. string.format(&amp;#039;[[Category:%s]]&amp;#039;, args[k .. &amp;#039; category&amp;#039;])&lt;br /&gt;
				end&lt;br /&gt;
			elseif args[&amp;#039;other category&amp;#039;] then&lt;br /&gt;
				if args.sortkey then&lt;br /&gt;
					content = content .. string.format(&amp;#039;[[Category:%s|%s]]&amp;#039;, args[&amp;#039;other category&amp;#039;], args.sortkey)&lt;br /&gt;
					else&lt;br /&gt;
						content = content .. string.format(&amp;#039;[[Category:%s]]&amp;#039;, args[&amp;#039;other category&amp;#039;])&lt;br /&gt;
				end&lt;br /&gt;
			else&lt;br /&gt;
				content = content .. frame:expandTemplate{title = &amp;#039;Incorrect redirect template&amp;#039;, args = {v[2]}}&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if namespace == 0 then&lt;br /&gt;
		local yesno = require(&amp;#039;Module:Yesno&amp;#039;)&lt;br /&gt;
		if yesno(args.printworthy) == true then&lt;br /&gt;
			return content .. &amp;#039;[[Category:Printworthy redirects]]&amp;#039;&lt;br /&gt;
		elseif yesno(args.printworthy) == false then&lt;br /&gt;
			return content .. &amp;#039;[[Category:Unprintworthy redirects]]&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;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Pppery</name></author>
	</entry>
</feed>