<?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%3APortal_bar</id>
	<title>Module:Portal bar - 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%3APortal_bar"/>
	<link rel="alternate" type="text/html" href="https://mindpowe.red/wiki/index.php?title=Module:Portal_bar&amp;action=history"/>
	<updated>2026-04-05T21:13:48Z</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:Portal_bar&amp;diff=1658&amp;oldid=prev</id>
		<title>imported&gt;BrownHairedGirl: add Book talk to list of banned namespaces</title>
		<link rel="alternate" type="text/html" href="https://mindpowe.red/wiki/index.php?title=Module:Portal_bar&amp;diff=1658&amp;oldid=prev"/>
		<updated>2019-09-18T22:21:28Z</updated>

		<summary type="html">&lt;p&gt;add Book talk to list of banned namespaces&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- This module implements {{portal bar}}.&lt;br /&gt;
&lt;br /&gt;
require('Module:No globals')&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
local function checkPortalExists(portal)&lt;br /&gt;
	return not (mw.title.makeTitle(100, portal).id == 0)&lt;br /&gt;
end&lt;br /&gt;
local getImageName = require( 'Module:Portal' ).image&lt;br /&gt;
local yesno = require( 'Module:Yesno' )&lt;br /&gt;
&lt;br /&gt;
local trackingEnabled = true&lt;br /&gt;
&lt;br /&gt;
-- Check whether to do tracking in this namespace&lt;br /&gt;
-- Returns true unless the page is one of the banned namespaces&lt;br /&gt;
local function checkTrackingNamespace()&lt;br /&gt;
	local thisPage = mw.title.getCurrentTitle()&lt;br /&gt;
	if (thisPage.namespace == 1) -- Talk&lt;br /&gt;
		or (thisPage.namespace == 2) -- User&lt;br /&gt;
		or (thisPage.namespace == 3) -- User talk&lt;br /&gt;
		or (thisPage.namespace == 5) -- Wikipedia talk&lt;br /&gt;
		or (thisPage.namespace == 7) -- File talk&lt;br /&gt;
		or (thisPage.namespace == 11) -- Template talk&lt;br /&gt;
		or (thisPage.namespace == 15) -- Category talk&lt;br /&gt;
		or (thisPage.namespace == 101) -- Portal talk&lt;br /&gt;
		or (thisPage.namespace == 109) -- Book talk&lt;br /&gt;
		or (thisPage.namespace == 118) -- Draft&lt;br /&gt;
		or (thisPage.namespace == 119) -- Draft talk&lt;br /&gt;
		or (thisPage.namespace == 829) -- Module talk&lt;br /&gt;
		then&lt;br /&gt;
		return false&lt;br /&gt;
	end&lt;br /&gt;
	return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Check whether to do tracking on this pagename&lt;br /&gt;
-- Returns false if the page title matches one of the banned strings&lt;br /&gt;
-- Otherwise returns true&lt;br /&gt;
local function checkTrackingPagename()&lt;br /&gt;
	local thisPage = mw.title.getCurrentTitle()&lt;br /&gt;
	local thisPageLC = mw.ustring.lower(thisPage.text)&lt;br /&gt;
	if (string.match(thisPageLC, &amp;quot;/archive&amp;quot;) ~= nil) then&lt;br /&gt;
		return false&lt;br /&gt;
	end&lt;br /&gt;
	if (string.match(thisPageLC, &amp;quot;/doc&amp;quot;) ~= nil) then&lt;br /&gt;
		return false&lt;br /&gt;
	end&lt;br /&gt;
	if (string.match(thisPageLC, &amp;quot;/test&amp;quot;) ~= nil) then&lt;br /&gt;
		return false&lt;br /&gt;
	end&lt;br /&gt;
	return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Builds the portal bar used by {{portal bar}}.&lt;br /&gt;
function p._main( portals, args )&lt;br /&gt;
	&lt;br /&gt;
	if #portals &amp;lt; 1 then return '' end -- Don't display a blank navbox if no portals were specified.&lt;br /&gt;
	&lt;br /&gt;
	local nav = mw.html.create( 'div' )&lt;br /&gt;
		:addClass( 'noprint metadata' )&lt;br /&gt;
		:attr( 'role', 'navigation' )&lt;br /&gt;
		:attr( 'aria-label' , 'Portals' )&lt;br /&gt;
		:css( 'font-weight', 'bold' )&lt;br /&gt;
	if yesno( args.border ) == false then&lt;br /&gt;
		nav&lt;br /&gt;
			:css( 'padding', '0.3em 1.7em 0.1em' )&lt;br /&gt;
			:css( 'font-size', '88%' )&lt;br /&gt;
			:css( 'text-align', 'center' )&lt;br /&gt;
	else&lt;br /&gt;
		nav&lt;br /&gt;
			:addClass( 'navbox' )&lt;br /&gt;
			:css( 'padding', '0.4em 2em' )&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if (args.tracking == 'no') or (args.tracking == 'n') or (args.tracking == 'false') then&lt;br /&gt;
		trackingEnabled = false&lt;br /&gt;
	end&lt;br /&gt;
	if (checkTrackingNamespace() == false) then&lt;br /&gt;
		trackingEnabled = false&lt;br /&gt;
	end&lt;br /&gt;
	if (checkTrackingPagename() == false) then&lt;br /&gt;
		trackingEnabled = false&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- If no portals have been specified, display an error and add the page to a tracking category.&lt;br /&gt;
	if not portals[1] then&lt;br /&gt;
		if (args.nominimum == 'yes') or (args.nominimum == 'y') or (args.nominimum == 'true') then&lt;br /&gt;
		-- if nominimum as been set to yes (or similar), omit the warning&lt;br /&gt;
			&lt;br /&gt;
		else&lt;br /&gt;
			root:wikitext('&amp;lt;strong class=&amp;quot;error&amp;quot;&amp;gt;No portals specified: please specify at least one portal&amp;lt;/strong&amp;gt;')&lt;br /&gt;
		end&lt;br /&gt;
		if (trackingEnabled) then&lt;br /&gt;
			root:wikitext('[[Category:Portal templates without a parameter]]')&lt;br /&gt;
		end&lt;br /&gt;
		return tostring(root)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- scan for nonexistent portals, if they exist remove them from the portals table. If redlinks=yes, then don't remove&lt;br /&gt;
	local portallen = #portals&lt;br /&gt;
	-- traverse the list backwards to ensure that no portals are missed (table.remove also moves down the portals in the list, so that the next portal isn't checked if going fowards.&lt;br /&gt;
	-- going backwards allows us to circumvent this issue&lt;br /&gt;
	for i=portallen,1,-1 do&lt;br /&gt;
		-- the use of pcall here catches any errors that may occour when attempting to locate pages when the page name is invalid&lt;br /&gt;
		-- if pcall returns true, then rerun the function to find if the page exists&lt;br /&gt;
		if not pcall(checkPortalExists, portals[i]) or not checkPortalExists(portals[i]) then&lt;br /&gt;
			-- Getting here means a redlinked portal has been found&lt;br /&gt;
			if (args.redlinks == 'yes') or (args.redlinks == 'y') or (args.redlinks == 'true') or (args.redlinks == 'include') then&lt;br /&gt;
				-- if redlinks as been set to yes (or similar), add the cleanup category and then break the loop before the portal is removed from the list&lt;br /&gt;
				if trackingEnabled then&lt;br /&gt;
					nav:wikitext('[[Category:Portal templates with redlinked portals]]')&lt;br /&gt;
				end&lt;br /&gt;
				break&lt;br /&gt;
			end&lt;br /&gt;
			-- remove the portal (this does not happen if redlinks=yes)&lt;br /&gt;
			table.remove(portals,i)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- if the length of the table is different, then rows were removed from the table, so portals were removed. If this is the case add the cleanup category&lt;br /&gt;
	if not (portallen == #portals) then&lt;br /&gt;
		if #portals == 0 then&lt;br /&gt;
        	if trackingEnabled then&lt;br /&gt;
				return '[[Category:Portal templates with all redlinked portals]]'&lt;br /&gt;
			else&lt;br /&gt;
				return &amp;quot;&amp;quot;&lt;br /&gt;
			end&lt;br /&gt;
        end&lt;br /&gt;
		if trackingEnabled then&lt;br /&gt;
			nav:wikitext('[[Category:Portal templates with redlinked portals]]')&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local list = mw.html.create( 'ul' )&lt;br /&gt;
		:css( 'margin', '0.1em 0 0' )&lt;br /&gt;
	for _, portal in ipairs( portals ) do&lt;br /&gt;
		list&lt;br /&gt;
			:tag( 'li' )&lt;br /&gt;
				:css( 'display', 'inline' )&lt;br /&gt;
				:tag( 'span' ) -- Inline-block on inner span for IE6-7 compatibility.&lt;br /&gt;
					:css( 'display', 'inline-block' )&lt;br /&gt;
					:css( 'white-space', 'nowrap' )&lt;br /&gt;
					:tag( 'span' )&lt;br /&gt;
						:css( 'margin', '0 0.5em' )&lt;br /&gt;
						:wikitext( string.format( '[[File:%s|24x21px]]', getImageName{ portal } ) )&lt;br /&gt;
						:done()&lt;br /&gt;
					:wikitext( string.format( '[[Portal:%s|%s portal]]', portal, portal ) )&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	nav&lt;br /&gt;
		:node( list )&lt;br /&gt;
	&lt;br /&gt;
	return tostring( nav )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Processes external arguments and sends them to the other functions.&lt;br /&gt;
function p.main( frame )&lt;br /&gt;
	-- If called via #invoke, use the args passed into the invoking&lt;br /&gt;
	-- template, or the args passed to #invoke if any exist. Otherwise&lt;br /&gt;
	-- assume args are being passed directly in from the debug console&lt;br /&gt;
	-- or from another Lua module.&lt;br /&gt;
	local origArgs&lt;br /&gt;
	if type( frame.getParent ) == 'function' then&lt;br /&gt;
		origArgs = frame:getParent().args&lt;br /&gt;
		for k, v in pairs( frame.args ) do&lt;br /&gt;
			origArgs = frame.args&lt;br /&gt;
			break&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		origArgs = frame&lt;br /&gt;
	end&lt;br /&gt;
	-- Process the args to make an array of portal names that can be used with ipairs. We need to use ipairs because we want to list&lt;br /&gt;
	-- all the portals in the order they were passed to the template, but we also want to be able to deal with positional arguments&lt;br /&gt;
	-- passed explicitly, for example {{portal|2=Politics}}. The behaviour of ipairs is undefined if nil values are present, so we&lt;br /&gt;
	-- need to make sure they are all removed.&lt;br /&gt;
	local portals, args = {}, {}&lt;br /&gt;
	for k, v in pairs( origArgs ) do&lt;br /&gt;
		if type( k ) == 'number' and type( v ) == 'string' then -- Make sure we have no non-string portal names.&lt;br /&gt;
			if mw.ustring.find( v, '%S' ) then -- Remove blank values.&lt;br /&gt;
				table.insert( portals, k )&lt;br /&gt;
				end&lt;br /&gt;
			elseif type( k ) ~= 'number' then -- Separate named arguments from portals.&lt;br /&gt;
			if type( v ) == 'string' then&lt;br /&gt;
				v = mw.text.trim( v )&lt;br /&gt;
			end&lt;br /&gt;
			args[ k ] = v&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	table.sort( portals )&lt;br /&gt;
	for i, v in ipairs( portals ) do&lt;br /&gt;
		portals[ i ] = mw.text.trim( origArgs[ v ] ) -- Swap keys with values, trimming whitespace.&lt;br /&gt;
	end&lt;br /&gt;
	return p._main( portals, args )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;BrownHairedGirl</name></author>
		
	</entry>
</feed>