<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://oxeyewiki.o7.si/w/index.php?action=history&amp;feed=atom&amp;title=Module%3APagetype</id>
	<title>Module:Pagetype - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://oxeyewiki.o7.si/w/index.php?action=history&amp;feed=atom&amp;title=Module%3APagetype"/>
	<link rel="alternate" type="text/html" href="https://oxeyewiki.o7.si/w/index.php?title=Module:Pagetype&amp;action=history"/>
	<updated>2026-06-03T19:56:30Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.0</generator>
	<entry>
		<id>https://oxeyewiki.o7.si/w/index.php?title=Module:Pagetype&amp;diff=16593&amp;oldid=prev</id>
		<title>Koza1brada: 2 revisions imported</title>
		<link rel="alternate" type="text/html" href="https://oxeyewiki.o7.si/w/index.php?title=Module:Pagetype&amp;diff=16593&amp;oldid=prev"/>
		<updated>2024-10-24T13:30:58Z</updated>

		<summary type="html">&lt;p&gt;2 revisions imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 14:30, 24 October 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&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;!-- diff cache key mediawiki:diff:1.41:old-16592:rev-16593 --&gt;
&lt;/table&gt;</summary>
		<author><name>Koza1brada</name></author>
	</entry>
	<entry>
		<id>https://oxeyewiki.o7.si/w/index.php?title=Module:Pagetype&amp;diff=16592&amp;oldid=prev</id>
		<title>OxeyeWiki&gt;Catdotjs: 1 revision imported: Adding modules for infoboxes </title>
		<link rel="alternate" type="text/html" href="https://oxeyewiki.o7.si/w/index.php?title=Module:Pagetype&amp;diff=16592&amp;oldid=prev"/>
		<updated>2024-03-03T04:48:34Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported: Adding modules for infoboxes &lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 05:48, 3 March 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&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;!-- diff cache key mediawiki:diff:1.41:old-16591:rev-16592 --&gt;
&lt;/table&gt;</summary>
		<author><name>OxeyeWiki&gt;Catdotjs</name></author>
	</entry>
	<entry>
		<id>https://oxeyewiki.o7.si/w/index.php?title=Module:Pagetype&amp;diff=16591&amp;oldid=prev</id>
		<title>commons&gt;Plastikspork: Add exist check per discussion</title>
		<link rel="alternate" type="text/html" href="https://oxeyewiki.o7.si/w/index.php?title=Module:Pagetype&amp;diff=16591&amp;oldid=prev"/>
		<updated>2024-02-03T14:03:49Z</updated>

		<summary type="html">&lt;p&gt;Add exist check per discussion&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--------------------------------------------------------------------------------&lt;br /&gt;
--                                                                            --&lt;br /&gt;
--      This meta-module which automatically detects namespaces, and allows   --&lt;br /&gt;
--      for a great deal of customisation. It can easily be ported to other   --&lt;br /&gt;
--      wikis by changing the values in the [[Module:Pagetype/config]].       --&lt;br /&gt;
--                                                                            --&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- Load config.&lt;br /&gt;
local cfg = mw.loadData(&amp;#039;Module:Pagetype/config&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
-- Load required modules.&lt;br /&gt;
local getArgs = require(&amp;#039;Module:Arguments&amp;#039;).getArgs&lt;br /&gt;
local yesno = require(&amp;#039;Module:Yesno&amp;#039;)&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
-- Look up a namespace argument in the args table.&lt;br /&gt;
local function lookUpNamespaceArg(args, key)&lt;br /&gt;
	local arg = args[key]&lt;br /&gt;
	-- Convert &amp;quot;yes&amp;quot;, &amp;quot;1&amp;quot; etc. to true, &amp;quot;no&amp;quot;, &amp;quot;0&amp;quot; etc. to false, and leave&lt;br /&gt;
	-- other values the same.&lt;br /&gt;
	return yesno(arg, arg)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Append multiple values to an array&lt;br /&gt;
local function appendMultiple(target, source)&lt;br /&gt;
	for _, value in ipairs(source) do&lt;br /&gt;
		table.insert(target, value)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Get argument keys for a title&amp;#039;s namespace&lt;br /&gt;
local function getNamespaceArgKeys(title, cfg)&lt;br /&gt;
	local nsInfo = mw.site.namespaces[title.namespace]&lt;br /&gt;
	local customAliases = cfg.customNamespaceAliases[title.namespace] or {}&lt;br /&gt;
	local keys = {}&lt;br /&gt;
	if nsInfo.name ~= &amp;#039;&amp;#039; then&lt;br /&gt;
		table.insert(keys, nsInfo.name)&lt;br /&gt;
	end&lt;br /&gt;
	if nsInfo.canonicalName ~= nsInfo.name and nsInfo.canonicalName ~= &amp;#039;&amp;#039; then&lt;br /&gt;
		table.insert(keys, nsInfo.canonicalName)&lt;br /&gt;
	end&lt;br /&gt;
	appendMultiple(keys, nsInfo.aliases)&lt;br /&gt;
	appendMultiple(keys, customAliases)&lt;br /&gt;
	return keys&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Get the argument for a title&amp;#039;s namespace, if it was specified in the args table.&lt;br /&gt;
local function getNamespaceArg(title, args, cfg)&lt;br /&gt;
	if title.isTalkPage then&lt;br /&gt;
		return lookUpNamespaceArg(args, cfg.talk)&lt;br /&gt;
	end&lt;br /&gt;
	for _, key in ipairs(getNamespaceArgKeys(title, cfg)) do&lt;br /&gt;
		local arg = lookUpNamespaceArg(args, mw.ustring.lower(key))&lt;br /&gt;
		if arg ~= nil then&lt;br /&gt;
			return arg&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Look up a page type specific to the title&amp;#039;s namespace&lt;br /&gt;
local function getExplicitPageType(title, cfg)&lt;br /&gt;
	if title.isTalkPage then&lt;br /&gt;
		return cfg.talkDefault&lt;br /&gt;
	else&lt;br /&gt;
		return cfg.pagetypes[title.namespace]&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Get a default page type that is not specific to the title&amp;#039;s namespace&lt;br /&gt;
local function getDefaultPageType(args, cfg)&lt;br /&gt;
	local other = lookUpNamespaceArg(args, cfg.other)&lt;br /&gt;
	if type(other) == &amp;#039;string&amp;#039; then&lt;br /&gt;
		return other&lt;br /&gt;
	else&lt;br /&gt;
		return cfg.otherDefault&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function detectRedirects(title, args)&lt;br /&gt;
	local redirect = lookUpNamespaceArg(args, cfg.redirect)&lt;br /&gt;
	if redirect == false then&lt;br /&gt;
		-- Don&amp;#039;t detect redirects if they have been specifically disallowed.&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Allow custom values for redirects.&lt;br /&gt;
	if not title.isRedirect then&lt;br /&gt;
		return nil&lt;br /&gt;
	elseif type(redirect) == &amp;#039;string&amp;#039; then&lt;br /&gt;
		return redirect&lt;br /&gt;
	else&lt;br /&gt;
		return cfg.redirectDefault&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function capitalize(pageType)&lt;br /&gt;
	local first = mw.ustring.sub(pageType, 1, 1)&lt;br /&gt;
	local rest = mw.ustring.sub(pageType, 2)&lt;br /&gt;
	return mw.ustring.upper(first) .. rest&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function pluralize(pageType, cfg)&lt;br /&gt;
	if cfg.irregularPlurals[pageType] then&lt;br /&gt;
		return cfg.irregularPlurals[pageType]&lt;br /&gt;
	else&lt;br /&gt;
		return pageType .. cfg.plural -- often &amp;#039;s&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function parseContent(title, args, list, parameter, default, articleOnly)&lt;br /&gt;
	if articleOnly and title.namespace~=0 -- only detect in mainspace&lt;br /&gt;
		or title.namespace==828 and title.subpageText~=&amp;#039;doc&amp;#039; -- don&amp;#039;t detect modules&lt;br /&gt;
		or not title.exists -- can&amp;#039;t check unless page exists&lt;br /&gt;
	then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	local templates = mw.loadData(&amp;#039;Module:Pagetype/&amp;#039; .. list)&lt;br /&gt;
	local content = title:getContent()&lt;br /&gt;
	if content == nil then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	content = require(&amp;#039;Module:Wikitext Parsing&amp;#039;).PrepareText(content) -- disregard templates which do not have any affect &lt;br /&gt;
	local templateNames = {}&lt;br /&gt;
	local templateFound = false&lt;br /&gt;
	for template in string.gmatch(content, &amp;quot;{{%s*([^|}]-)%s*[|}]&amp;quot;) do&lt;br /&gt;
		if templates[capitalize(template)] then&lt;br /&gt;
			templateFound = true&lt;br /&gt;
			break&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local out = lookUpNamespaceArg(args, parameter)&lt;br /&gt;
	if not templateFound then&lt;br /&gt;
		return nil&lt;br /&gt;
	elseif type(out)==&amp;#039;string&amp;#039; then&lt;br /&gt;
		return out&lt;br /&gt;
	else&lt;br /&gt;
		return default&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Gets the pagetype from a class specified from the first positional parameter.&lt;br /&gt;
local function getPageTypeFromClass(args, class, key, aliasTable, default)&lt;br /&gt;
	local arg = lookUpNamespaceArg(args, key)&lt;br /&gt;
	if arg == false then&lt;br /&gt;
		-- Don&amp;#039;t check for this class if it is specifically disallowed.&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	if aliasTable[class] then&lt;br /&gt;
		if type(arg) == &amp;#039;string&amp;#039; then&lt;br /&gt;
			return arg&lt;br /&gt;
		else&lt;br /&gt;
			return default&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Get page types for mainspaces pages with an explicit class specified&lt;br /&gt;
local function getMainNamespaceClassPageType(title, args, cfg)&lt;br /&gt;
	if title.namespace ~= 0 then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	local class = args[1]&lt;br /&gt;
	if type(class) == &amp;#039;string&amp;#039; then&lt;br /&gt;
		-- Put in lower case so e.g. &amp;quot;na&amp;quot; and &amp;quot;NA&amp;quot; will both match.&lt;br /&gt;
		class = mw.ustring.lower(class)&lt;br /&gt;
	end&lt;br /&gt;
	return getPageTypeFromClass(&lt;br /&gt;
		args,&lt;br /&gt;
		class,&lt;br /&gt;
		cfg.na,&lt;br /&gt;
		cfg.naAliases,&lt;br /&gt;
		cfg.naDefault&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Get page type specified by an explicit namespace argument.&lt;br /&gt;
local function getNamespaceArgPageType(title, args, cfg)&lt;br /&gt;
	local namespaceArg = getNamespaceArg(title, args, cfg)&lt;br /&gt;
	if namespaceArg == true then&lt;br /&gt;
		-- Namespace has been explicitly enabled, so return the default for&lt;br /&gt;
		-- this namespace&lt;br /&gt;
		return getExplicitPageType(title, cfg)&lt;br /&gt;
	elseif namespaceArg == false then&lt;br /&gt;
		-- Namespace has been explicitly disabled&lt;br /&gt;
		return getDefaultPageType(args, cfg)&lt;br /&gt;
	elseif namespaceArg then&lt;br /&gt;
		-- This namespaces uses custom text&lt;br /&gt;
		return namespaceArg&lt;br /&gt;
	else&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Whether the title is in the set of default active namespaces which are looked up in cfg.pagetypes.&lt;br /&gt;
local function isInDefaultActiveNamespace(title, args, cfg)&lt;br /&gt;
	local defaultNamespacesKey = args[cfg.defaultns]&lt;br /&gt;
	if defaultNamespacesKey == cfg.defaultnsAll then&lt;br /&gt;
		return true&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local defaultNamespaces&lt;br /&gt;
	if defaultNamespacesKey == cfg.defaultnsExtended then&lt;br /&gt;
		defaultNamespaces = cfg.extendedNamespaces&lt;br /&gt;
	elseif defaultNamespacesKey == cfg.defaultnsNone then&lt;br /&gt;
		defaultNamespaces = {}&lt;br /&gt;
	else&lt;br /&gt;
		defaultNamespaces = cfg.defaultNamespaces&lt;br /&gt;
	end&lt;br /&gt;
	return defaultNamespaces[title.namespace] or false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Get page type not specified or detected by other means&lt;br /&gt;
local function getOtherPageType(title, args, cfg)&lt;br /&gt;
	if isInDefaultActiveNamespace(title, args, cfg) then&lt;br /&gt;
		return getExplicitPageType(title, cfg)&lt;br /&gt;
	else&lt;br /&gt;
		return getDefaultPageType(args, cfg)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getPageType(title, args, cfg)&lt;br /&gt;
	return (&lt;br /&gt;
		detectRedirects(title, args, cfg)&lt;br /&gt;
		or parseContent(title, args, &amp;#039;softredirect&amp;#039;, cfg.softRedirect, cfg.softRedirectDefault)&lt;br /&gt;
		or parseContent(title, args, &amp;#039;setindex&amp;#039;, cfg.sia, cfg.siaDefault, true)&lt;br /&gt;
		or parseContent(title, args, &amp;#039;disambiguation&amp;#039;, cfg.dab, cfg.dabDefault, true)&lt;br /&gt;
		or getMainNamespaceClassPageType(title, args, cfg)&lt;br /&gt;
		or getNamespaceArgPageType(title, args, cfg)&lt;br /&gt;
		or getOtherPageType(title, args, cfg)&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function shouldUseSubjectTitle(args, cfg)&lt;br /&gt;
	return not yesno(args.talk, true) and args[cfg.defaultns] ~= cfg.defaultnsAll&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Get the Scribunto title object to fetch the page type of&lt;br /&gt;
local function getTitle(args, cfg)&lt;br /&gt;
	local title&lt;br /&gt;
	if args.page then&lt;br /&gt;
		title = mw.title.new(args.page)&lt;br /&gt;
		if not title then&lt;br /&gt;
			return nil&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		title = mw.title.getCurrentTitle()&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if shouldUseSubjectTitle(args, cfg) then&lt;br /&gt;
		return title.subjectPageTitle&lt;br /&gt;
	else&lt;br /&gt;
		return title&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._main(args)&lt;br /&gt;
	local title = getTitle(args, cfg)&lt;br /&gt;
	local pageType = getPageType(title, args, cfg)&lt;br /&gt;
	if yesno(args.plural, false) then&lt;br /&gt;
		pageType = pluralize(pageType, cfg)&lt;br /&gt;
	end&lt;br /&gt;
	if yesno(args.caps, false) then&lt;br /&gt;
		pageType = capitalize(pageType)&lt;br /&gt;
	end&lt;br /&gt;
	return pageType&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	local args = getArgs(frame)&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>commons&gt;Plastikspork</name></author>
	</entry>
</feed>