<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mindpowe.red/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://mindpowe.red/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ARedirect_hatnote"/>
	<link rel="alternate" type="text/html" href="https://mindpowe.red/wiki/index.php?title=Module:Redirect_hatnote&amp;action=history"/>
	<updated>2026-04-06T13:12:56Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>https://mindpowe.red/wiki/index.php?title=Module:Redirect_hatnote&amp;diff=494&amp;oldid=prev</id>
		<title>WikiSysop: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://mindpowe.red/wiki/index.php?title=Module:Redirect_hatnote&amp;diff=494&amp;oldid=prev"/>
		<updated>2020-08-07T21:29:09Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&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: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 21:29, 7 August 2020&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>WikiSysop</name></author>
		
	</entry>
	<entry>
		<id>https://mindpowe.red/wiki/index.php?title=Module:Redirect_hatnote&amp;diff=493&amp;oldid=prev</id>
		<title>en&gt;Galobtter: text= option</title>
		<link rel="alternate" type="text/html" href="https://mindpowe.red/wiki/index.php?title=Module:Redirect_hatnote&amp;diff=493&amp;oldid=prev"/>
		<updated>2018-03-31T10:45:06Z</updated>

		<summary type="html">&lt;p&gt;text= option&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;quot;X&amp;quot; redirects here. For other uses, see Y.'&lt;br /&gt;
-- It implements the {{redirect}} template.&lt;br /&gt;
--]]&lt;br /&gt;
&lt;br /&gt;
local mHatnote = require('Module:Hatnote')&lt;br /&gt;
local mHatList = require('Module:Hatnote list')&lt;br /&gt;
local mArguments --lazily initialize&lt;br /&gt;
local libraryUtil = require('libraryUtil')&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;
local function getTitle(...)&lt;br /&gt;
	local success, titleObj = pcall(mw.title.new, ...)&lt;br /&gt;
	if success then&lt;br /&gt;
		return titleObj&lt;br /&gt;
	else&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.redirect(frame)&lt;br /&gt;
	mArguments = require('Module:Arguments')&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't bother checking currentTitle, redirectTitle or&lt;br /&gt;
	-- targetTitle, as they are only used in testing.&lt;br /&gt;
	checkType('_redirect', 1, args, 'table')&lt;br /&gt;
	checkType('_redirect', 2, numRedirects, 'number', true)&lt;br /&gt;
	numRedirects = numRedirects or 1&lt;br /&gt;
	checkType('_redirect', 3, options, 'table', 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;
				'missing redirect parameter',&lt;br /&gt;
				'Template:Redirect#Errors',&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] = '&amp;quot;' .. v .. '&amp;quot;'&lt;br /&gt;
	end&lt;br /&gt;
	local text = {&lt;br /&gt;
		mHatList.andList(formattedRedirect) .. ' ' .. (#redirect == 1 and 'redirects' or 'redirect') .. ' here.',&lt;br /&gt;
		mHatList._forSee(args, #redirect + 1, {title = redirect[1], extratext = args.text})&lt;br /&gt;
	}&lt;br /&gt;
	text = table.concat(text, ' ')&lt;br /&gt;
	-- Functionality for adding categories	&lt;br /&gt;
	local categoryTable = {}&lt;br /&gt;
	function addCategory(cat)&lt;br /&gt;
		if cat and cat ~= '' then&lt;br /&gt;
			-- Add by index to avoid duplicates&lt;br /&gt;
			categoryTable[string.format('[[Category:%s]]', cat)] = true&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	--Generate tracking categories&lt;br /&gt;
	local mhOptions = {}&lt;br /&gt;
	for k,v in pairs(redirect) do&lt;br /&gt;
		-- We don't need a tracking category if the template invocation has been&lt;br /&gt;
		-- copied directly from the docs, or if we aren't in main- or category-space.&lt;br /&gt;
		if not v:find('^REDIRECT%d*$') and v ~= 'TERM' -- &lt;br /&gt;
			and currentTitle.namespace == 0 or currentTitle.namespace == 14&lt;br /&gt;
		then&lt;br /&gt;
			redirectTitle = redirectTitle or getTitle(v)&lt;br /&gt;
			if not redirectTitle or not redirectTitle.exists then&lt;br /&gt;
				addCategory('Missing redirects')&lt;br /&gt;
			elseif not redirectTitle.isRedirect then&lt;br /&gt;
				addCategory('Articles with redirect hatnotes needing review')&lt;br /&gt;
			else&lt;br /&gt;
				local mRedirect = require('Module:Redirect')&lt;br /&gt;
				local target = mRedirect.getTarget(redirectTitle)&lt;br /&gt;
				targetTitle = targetTitle or target and getTitle(target)&lt;br /&gt;
				if targetTitle and targetTitle ~= currentTitle then&lt;br /&gt;
					addCategory('Articles with redirect hatnotes needing review')&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 redirectTitle and redirectTitle.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 = ''&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>en&gt;Galobtter</name></author>
		
	</entry>
</feed>