<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.tachyony.co.uk/w/index.php?action=history&amp;feed=atom&amp;title=Module%3ASubject_bar</id>
	<title>Module:Subject bar - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.tachyony.co.uk/w/index.php?action=history&amp;feed=atom&amp;title=Module%3ASubject_bar"/>
	<link rel="alternate" type="text/html" href="https://wiki.tachyony.co.uk/w/index.php?title=Module:Subject_bar&amp;action=history"/>
	<updated>2026-05-15T13:53:40Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.5</generator>
	<entry>
		<id>https://wiki.tachyony.co.uk/w/index.php?title=Module:Subject_bar&amp;diff=4454&amp;oldid=prev</id>
		<title>Tachyony: Created page with &quot;require(&#039;Module:No globals&#039;)  local sisterBar = require(&#039;Module:Sister project links&#039;)._main local portalBar = require(&#039;Module:Portal bar&#039;)._main local compressSparseArray = require(&#039;Module:TableTools&#039;).compressSparseArray  local p = {}  local trackingEnabled = true  -- Check whether to do tracking in this namespace -- Returns true unless the page is one of the banned namespaces local function checkTrackingNamespace() 	local thisPageNS = mw.title.getCurrentTitle().namesp...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.tachyony.co.uk/w/index.php?title=Module:Subject_bar&amp;diff=4454&amp;oldid=prev"/>
		<updated>2021-12-19T04:55:20Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;require(&amp;#039;Module:No globals&amp;#039;)  local sisterBar = require(&amp;#039;Module:Sister project links&amp;#039;)._main local portalBar = require(&amp;#039;Module:Portal bar&amp;#039;)._main local compressSparseArray = require(&amp;#039;Module:TableTools&amp;#039;).compressSparseArray  local p = {}  local trackingEnabled = true  -- Check whether to do tracking in this namespace -- Returns true unless the page is one of the banned namespaces local function checkTrackingNamespace() 	local thisPageNS = mw.title.getCurrentTitle().namesp...&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 sisterBar = require(&amp;#039;Module:Sister project links&amp;#039;)._main&lt;br /&gt;
local portalBar = require(&amp;#039;Module:Portal bar&amp;#039;)._main&lt;br /&gt;
local compressSparseArray = require(&amp;#039;Module:TableTools&amp;#039;).compressSparseArray&lt;br /&gt;
&lt;br /&gt;
local p = {}&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 thisPageNS = mw.title.getCurrentTitle().namespace&lt;br /&gt;
	if (thisPageNS == 1) -- Talk&lt;br /&gt;
		or (thisPageNS == 2) -- User&lt;br /&gt;
		or (thisPageNS == 3) -- User talk&lt;br /&gt;
		or (thisPageNS == 5) -- Wikipedia talk&lt;br /&gt;
		or (thisPageNS == 7) -- File talk&lt;br /&gt;
		or (thisPageNS == 11) -- Template talk&lt;br /&gt;
		or (thisPageNS == 15) -- Category talk&lt;br /&gt;
		or (thisPageNS == 101) -- Portal talk&lt;br /&gt;
		or (thisPageNS == 118) -- Draft&lt;br /&gt;
		or (thisPageNS == 119) -- Draft talk&lt;br /&gt;
		or (thisPageNS == 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)&lt;br /&gt;
		or (string.match(thisPageLC, &amp;quot;/doc&amp;quot;) ~= nil)&lt;br /&gt;
		or (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;
local sisters = {&amp;#039;commons&amp;#039;,&amp;#039;species&amp;#039;,&amp;#039;voy&amp;#039;,&amp;#039;n&amp;#039;,&amp;#039;wikt&amp;#039;,&amp;#039;b&amp;#039;,&amp;#039;q&amp;#039;,&amp;#039;s&amp;#039;,&amp;#039;v&amp;#039;,&amp;#039;d&amp;#039;}&lt;br /&gt;
&lt;br /&gt;
local function findNumericArgs(key, args)&lt;br /&gt;
	local pattern = &amp;quot;^&amp;quot;..key..&amp;quot;_?(%d+)$&amp;quot;  -- pattern to match&lt;br /&gt;
	local values = {}&lt;br /&gt;
	for k, v in pairs(args) do  --- loop through all arguments&lt;br /&gt;
		local ord = tonumber(mw.ustring.match(k,pattern)) --- if &amp;quot;foo_?%d+&amp;quot;, extract number&lt;br /&gt;
		if ord then&lt;br /&gt;
			values[ord] = v&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if args[key] ~= nil then&lt;br /&gt;
		values[1] = args[key]&lt;br /&gt;
	end&lt;br /&gt;
	values = compressSparseArray(values)  --- squeeze out gaps/nils in values, keep ordering&lt;br /&gt;
	return values&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._main(args)&lt;br /&gt;
	-- Tracking is on by default.&lt;br /&gt;
	-- It is disabled if any of the following is true&lt;br /&gt;
	-- 1/ the parameter &amp;quot;tracking&amp;quot; is set to &amp;#039;no, &amp;#039;n&amp;#039;, or &amp;#039;false&amp;#039;&lt;br /&gt;
	-- 2/ the current page fails the namespace tests in checkTrackingNamespace()&lt;br /&gt;
	-- 3/ the current page fails the pagename tests in checkTrackingPagename()&lt;br /&gt;
	if (args.tracking == &amp;#039;no&amp;#039;) or (args.tracking == &amp;#039;n&amp;#039;) or (args.tracking == &amp;#039;false&amp;#039;)&lt;br /&gt;
		or (checkTrackingNamespace() == false) or (checkTrackingPagename() == false) then&lt;br /&gt;
		trackingEnabled = false&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
	local result = &amp;quot;&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
	local hasPortal = false&lt;br /&gt;
	for key, _ in pairs(args) do&lt;br /&gt;
		if mw.ustring.sub(key,1,6) == &amp;#039;portal&amp;#039; then&lt;br /&gt;
			hasPortal = true&lt;br /&gt;
			break&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if hasPortal then&lt;br /&gt;
		local portalList = findNumericArgs(&amp;quot;portal&amp;quot;,args)&lt;br /&gt;
		result = portalBar(portalList, {tracking=trackingEnabled, qid=args.qid})&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local hasSister = args.auto&lt;br /&gt;
	for _, sister in ipairs(sisters) do&lt;br /&gt;
		if hasSister then&lt;br /&gt;
			break&lt;br /&gt;
		end&lt;br /&gt;
		if args[sister] ~= nil then&lt;br /&gt;
			hasSister = true&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if hasSister then&lt;br /&gt;
		local sisterArgs = {auto=1, bar=1, tracking=trackingEnabled, qid=args.qid}&lt;br /&gt;
    	for _, t in ipairs(sisters) do&lt;br /&gt;
    		sisterArgs[t] = args[t..&amp;#039;-search&amp;#039;] or args[t]&lt;br /&gt;
    	end&lt;br /&gt;
		result = result..sisterBar(sisterArgs)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
    -- If called via #invoke, use the args passed into the invoking template,&lt;br /&gt;
    -- or the args passed to #invoke if any exist. Otherwise assume args are&lt;br /&gt;
    -- being passed directly in from the debug console or from another Lua module.&lt;br /&gt;
    local origArgs&lt;br /&gt;
    if frame == mw.getCurrentFrame() 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;
    -- Remove blank arguments.&lt;br /&gt;
    local args = {}&lt;br /&gt;
    for k, v in pairs(origArgs) do&lt;br /&gt;
        if v ~= &amp;#039;&amp;#039; then&lt;br /&gt;
            args[k] = v&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return p._main(args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Tachyony</name></author>
	</entry>
</feed>