<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://linguifex.com/w/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://linguifex.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3ARedirect_template"/>
	<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:Redirect_template&amp;action=history"/>
	<updated>2026-04-06T10:39:53Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://linguifex.com/w/index.php?title=Module:Redirect_template&amp;diff=186802&amp;oldid=prev</id>
		<title>Gaffney.flancer: Created page with &quot;require(&#039;Module:No globals&#039;)  local p = {}  -- key is beginning of arg name. value is table with namespace number and link -- alternatively, a function taking the namespace nu...&quot;</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:Redirect_template&amp;diff=186802&amp;oldid=prev"/>
		<updated>2020-03-07T20:56:19Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;require(&amp;#039;Module:No globals&amp;#039;)  local p = {}  -- key is beginning of arg name. value is table with namespace number and link -- alternatively, a function taking the namespace nu...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;require(&amp;#039;Module:No globals&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;
	talk = { function(n) return n &amp;gt; 0 and n%2 == 1 end, &amp;#039;[[Help:Using 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;
}&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://bugzilla.wikimedia.org/show_bug.cgi?id=12974 is fixed&lt;br /&gt;
	local beCompatibleWithBug12974 = 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&amp;lt;/div&amp;gt;&amp;#039;,&lt;br /&gt;
		args.class 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 beCompatibleWithBug12974 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;
				content = content .. string.format(&amp;#039;[[Category:%s]]&amp;#039;, args[k .. &amp;#039; category&amp;#039;])&lt;br /&gt;
			elseif args[&amp;#039;other category&amp;#039;] then&lt;br /&gt;
				content = content .. string.format(&amp;#039;[[Category:%s]]&amp;#039;, args[&amp;#039;other category&amp;#039;])&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>Gaffney.flancer</name></author>
	</entry>
</feed>