<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://themidnight.wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ARedirect_hatnote</id>
	<title>Module:Redirect hatnote - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://themidnight.wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ARedirect_hatnote"/>
	<link rel="alternate" type="text/html" href="https://themidnight.wiki/index.php?title=Module:Redirect_hatnote&amp;action=history"/>
	<updated>2026-04-03T22:23:48Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://themidnight.wiki/index.php?title=Module:Redirect_hatnote&amp;diff=13072&amp;oldid=prev</id>
		<title>Timothy: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://themidnight.wiki/index.php?title=Module:Redirect_hatnote&amp;diff=13072&amp;oldid=prev"/>
		<updated>2024-04-03T04:22:19Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 00:22, 3 April 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Timothy</name></author>
	</entry>
	<entry>
		<id>https://themidnight.wiki/index.php?title=Module:Redirect_hatnote&amp;diff=13071&amp;oldid=prev</id>
		<title>wikipedia&gt;Nihiltres: Updated from sandbox: Migrated p._quote to Module:Hatnote</title>
		<link rel="alternate" type="text/html" href="https://themidnight.wiki/index.php?title=Module:Redirect_hatnote&amp;diff=13071&amp;oldid=prev"/>
		<updated>2022-09-05T18:21:32Z</updated>

		<summary type="html">&lt;p&gt;Updated from sandbox: Migrated p._quote to Module:Hatnote&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--[[&lt;br /&gt;
-- This module produces a &amp;quot;redirect&amp;quot; hatnote. It looks like this:&lt;br /&gt;
-- &amp;#039;&amp;quot;X&amp;quot; redirects here. For other uses, see Y.&amp;#039;&lt;br /&gt;
-- It implements the {{redirect}} template.&lt;br /&gt;
--]]&lt;br /&gt;
&lt;br /&gt;
local mHatnote = require(&amp;#039;Module:Hatnote&amp;#039;)&lt;br /&gt;
local mHatList = require(&amp;#039;Module:Hatnote list&amp;#039;)&lt;br /&gt;
local mArguments --lazily initialize&lt;br /&gt;
local libraryUtil = require(&amp;#039;libraryUtil&amp;#039;)&lt;br /&gt;
local checkType = libraryUtil.checkType&lt;br /&gt;
local checkTypeMulti = libraryUtil.checkTypeMulti&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Helper functions&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local function getTitle(...)&lt;br /&gt;
	--Calls mw.title.new and returns either a title object, or nil on error&lt;br /&gt;
	local success, titleObj = pcall(mw.title.new, ...)&lt;br /&gt;
	return success and titleObj or nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Main functions&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
function p.redirect(frame)&lt;br /&gt;
	mArguments = require(&amp;#039;Module:Arguments&amp;#039;)&lt;br /&gt;
	local args = mArguments.getArgs(frame, {parentOnly=true})&lt;br /&gt;
	--Get number of redirects&lt;br /&gt;
	local numRedirects = tonumber(frame.args[1]) or 1&lt;br /&gt;
	-- Create the options table.&lt;br /&gt;
	local options = {}&lt;br /&gt;
	options.selfref = args.selfref&lt;br /&gt;
	return p._redirect(args, numRedirects, options)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._redirect(args, numRedirects, options, currentTitle, redirectTitle, targetTitle)&lt;br /&gt;
	-- Validate the input. Don&amp;#039;t bother checking currentTitle, redirectTitle or&lt;br /&gt;
	-- targetTitle, as they are only used in testing.&lt;br /&gt;
	checkType(&amp;#039;_redirect&amp;#039;, 1, args, &amp;#039;table&amp;#039;)&lt;br /&gt;
	checkType(&amp;#039;_redirect&amp;#039;, 2, numRedirects, &amp;#039;number&amp;#039;, true)&lt;br /&gt;
	numRedirects = numRedirects or 1&lt;br /&gt;
	checkType(&amp;#039;_redirect&amp;#039;, 3, options, &amp;#039;table&amp;#039;, true)&lt;br /&gt;
	options = options or {}&lt;br /&gt;
	currentTitle = currentTitle or mw.title.getCurrentTitle()&lt;br /&gt;
	-- Get the table of redirects&lt;br /&gt;
	local redirect = {}&lt;br /&gt;
	for i = 1, numRedirects do&lt;br /&gt;
		-- Return an error if a redirect parameter is missing.&lt;br /&gt;
		if not args[i] then&lt;br /&gt;
			return mHatnote.makeWikitextError(&lt;br /&gt;
				&amp;#039;missing redirect parameter&amp;#039;,&lt;br /&gt;
				&amp;#039;Template:Redirect#Errors&amp;#039;,&lt;br /&gt;
				args.category&lt;br /&gt;
			)&lt;br /&gt;
		end&lt;br /&gt;
		redirect[i] = args[i]&lt;br /&gt;
	end&lt;br /&gt;
	-- Generate the text.&lt;br /&gt;
	local formattedRedirect = {}&lt;br /&gt;
	for k,v in pairs(redirect) do&lt;br /&gt;
		formattedRedirect[k] = mHatnote.quote(v)&lt;br /&gt;
	end&lt;br /&gt;
	local text = {&lt;br /&gt;
		mHatList.andList(formattedRedirect) .. &amp;#039; &amp;#039; .. (#redirect == 1 and &amp;#039;redirects&amp;#039; or &amp;#039;redirect&amp;#039;) .. &amp;#039; here.&amp;#039;,&lt;br /&gt;
		mHatList._forSee(args, #redirect + 1, {title = redirect[1], extratext = args.text})&lt;br /&gt;
	}&lt;br /&gt;
	text = table.concat(text, &amp;#039; &amp;#039;)&lt;br /&gt;
	-- Functionality for adding categories	&lt;br /&gt;
	local categoryTable = {}&lt;br /&gt;
	local function addCategory(cat)&lt;br /&gt;
		if cat and cat ~= &amp;#039;&amp;#039; then&lt;br /&gt;
			-- Add by index to avoid duplicates&lt;br /&gt;
			categoryTable[string.format(&amp;#039;[[Category:%s]]&amp;#039;, cat)] = true&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	--Generate tracking categories&lt;br /&gt;
	local mhOptions = {}&lt;br /&gt;
	local redirTitle&lt;br /&gt;
	for k,v in pairs(redirect) do&lt;br /&gt;
		-- We don&amp;#039;t need a tracking category if the template invocation has been&lt;br /&gt;
		-- copied directly from the docs, or if we aren&amp;#039;t in main- or category-space.&lt;br /&gt;
		if not v:find(&amp;#039;^REDIRECT%d*$&amp;#039;) and v ~= &amp;#039;TERM&amp;#039; -- &lt;br /&gt;
			and currentTitle.namespace == 0 or currentTitle.namespace == 14&lt;br /&gt;
		then&lt;br /&gt;
			redirTitle = redirectTitle or getTitle(v)&lt;br /&gt;
			if not redirTitle or not redirTitle.exists then&lt;br /&gt;
				addCategory(&amp;#039;Missing redirects&amp;#039;)&lt;br /&gt;
			elseif not redirTitle.isRedirect then&lt;br /&gt;
				if string.find(redirTitle:getContent(), &amp;#039;#invoke:RfD&amp;#039;) then&lt;br /&gt;
					addCategory(&amp;#039;Articles with redirect hatnotes impacted by RfD&amp;#039;)&lt;br /&gt;
				else&lt;br /&gt;
					addCategory(&amp;#039;Articles with redirect hatnotes needing review&amp;#039;)&lt;br /&gt;
				end&lt;br /&gt;
			else&lt;br /&gt;
				local target = targetTitle or redirTitle.redirectTarget&lt;br /&gt;
				if target and target ~= currentTitle then&lt;br /&gt;
					addCategory(&amp;#039;Articles with redirect hatnotes needing review&amp;#039;)&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		-- Generate the options to pass to [[Module:Hatnote]].&lt;br /&gt;
		if currentTitle.namespace == 0 and not mhOptions.selfref&lt;br /&gt;
			and redirTitle and redirTitle.namespace ~= 0&lt;br /&gt;
		then&lt;br /&gt;
			-- We are on a mainspace page, and the hatnote starts with something&lt;br /&gt;
			-- like &amp;quot;Wikipedia:Foo redirects here&amp;quot;, so automatically label it as&lt;br /&gt;
			-- a self-reference.&lt;br /&gt;
			mhOptions.selfref = true&lt;br /&gt;
		else&lt;br /&gt;
			mhOptions.selfref = options.selfref&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	--concatenate all the categories&lt;br /&gt;
	local category = &amp;#039;&amp;#039;&lt;br /&gt;
	for k,v in pairs(categoryTable) do&lt;br /&gt;
		category = category .. k&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return mHatnote._hatnote(text, mhOptions) .. category&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>wikipedia&gt;Nihiltres</name></author>
	</entry>
</feed>