<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.moltenaether.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AClass</id>
	<title>Module:Class - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.moltenaether.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AClass"/>
	<link rel="alternate" type="text/html" href="https://wiki.moltenaether.com/w/index.php?title=Module:Class&amp;action=history"/>
	<updated>2026-04-30T17:51:40Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.40.1</generator>
	<entry>
		<id>https://wiki.moltenaether.com/w/index.php?title=Module:Class&amp;diff=17268&amp;oldid=prev</id>
		<title>Cyclops: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://wiki.moltenaether.com/w/index.php?title=Module:Class&amp;diff=17268&amp;oldid=prev"/>
		<updated>2022-07-26T20:50:39Z</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;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 20:50, 26 July 2022&lt;/td&gt;
				&lt;/tr&gt;
&lt;!-- diff cache key buwiki:diff::1.12:old-17267:rev-17268 --&gt;
&lt;/table&gt;</summary>
		<author><name>Cyclops</name></author>
	</entry>
	<entry>
		<id>https://wiki.moltenaether.com/w/index.php?title=Module:Class&amp;diff=17267&amp;oldid=prev</id>
		<title>wikipedia&gt;Nihiltres: Changed protection settings for &quot;Module:Class&quot;: To match cascading protection on parent Template:Class ([Edit=Require administrator access] (indefinite) [Move=Require administrator access] (indefinite))</title>
		<link rel="alternate" type="text/html" href="https://wiki.moltenaether.com/w/index.php?title=Module:Class&amp;diff=17267&amp;oldid=prev"/>
		<updated>2022-06-16T15:37:58Z</updated>

		<summary type="html">&lt;p&gt;Changed protection settings for &amp;quot;&lt;a href=&quot;/db/Module:Class&quot; title=&quot;Module:Class&quot;&gt;Module:Class&lt;/a&gt;&amp;quot;: To match cascading protection on parent &lt;a href=&quot;/db/Template:Class&quot; title=&quot;Template:Class&quot;&gt;Template:Class&lt;/a&gt; ([Edit=Require administrator access] (indefinite) [Move=Require administrator access] (indefinite))&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- This module implements [[Template:Class]], [[Template:Class/icon]] and&lt;br /&gt;
-- [[Template:Class/colour]].&lt;br /&gt;
&lt;br /&gt;
local mArguments -- lazily loaded&lt;br /&gt;
local configuration = mw.loadData('Module:Class/configuration')&lt;br /&gt;
local definitions = configuration.definitions&lt;br /&gt;
local msg = configuration.messages&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Argument helper functions&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local function getRawArgs(frame, wrapper)&lt;br /&gt;
	--Retrieves the arguments from the frame&lt;br /&gt;
	mArguments = mArguments or require('Module:Arguments')&lt;br /&gt;
	return mArguments.getArgs(frame, {&lt;br /&gt;
		wrappers = wrapper,&lt;br /&gt;
		trim = false,&lt;br /&gt;
		removeBlanks = false&lt;br /&gt;
	})&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function makeInvokeFunction(func, wrapper)&lt;br /&gt;
	--Wraps a general function into an invokable version&lt;br /&gt;
	return function (frame)&lt;br /&gt;
		local args = getRawArgs(frame, wrapper)&lt;br /&gt;
		return func(args)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- String helper functions&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local function trim(str)&lt;br /&gt;
	--Trims strings, passes through non-strings without modification&lt;br /&gt;
	return (type(str) == 'string') and mw.text.trim(str) or str&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function normalizeValue(val)&lt;br /&gt;
	--Normalizes strings, particularly class codes&lt;br /&gt;
	if type(val) == 'string' then val = trim(val):lower() end&lt;br /&gt;
	if val == '' then val = nil end&lt;br /&gt;
	return val&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function ucfirst(str)&lt;br /&gt;
	--Capitalizes the first character of a string&lt;br /&gt;
	return mw.ustring.upper(mw.ustring.sub(str, 1, 1)) .. mw.ustring.sub(str, 2)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Definition helper functions&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local function getDefinition(code)&lt;br /&gt;
	--Retrieves the definition and canonical class code for a given code.&lt;br /&gt;
	--Returns two values: the definition object and the canonical class code&lt;br /&gt;
	--string.&lt;br /&gt;
	local canonicalCode = normalizeValue(code)&lt;br /&gt;
	if code == msg.defaultCode then canonicalCode = code end&lt;br /&gt;
	local class = definitions[canonicalCode]&lt;br /&gt;
	while class and class.alias do&lt;br /&gt;
		canonicalCode = class.alias&lt;br /&gt;
		class = definitions[class.alias]&lt;br /&gt;
	end&lt;br /&gt;
	if not class then&lt;br /&gt;
		return nil, nil&lt;br /&gt;
	end&lt;br /&gt;
	return class, canonicalCode&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getDefault()&lt;br /&gt;
	--Shortcut function for retrieving the default definition&lt;br /&gt;
	return getDefinition(msg.defaultCode) end&lt;br /&gt;
&lt;br /&gt;
local function getProperty(class, default, map)&lt;br /&gt;
	--Retrieves a given property from a string given a class definition, a&lt;br /&gt;
	--default class definition, and a map for the path to traverse through the&lt;br /&gt;
	--class object. The map should be a sequential table of string property&lt;br /&gt;
	--names, e.g. {&amp;quot;colour&amp;quot;, &amp;quot;base&amp;quot;} would retrieve someClass.colour.base&lt;br /&gt;
	local prop, dProp = class, default&lt;br /&gt;
	for k, v in ipairs(map) do&lt;br /&gt;
		prop = ((type(prop) == 'table') or nil) and prop[v]&lt;br /&gt;
		dProp = ((type(dProp) == 'table') or nil) and dProp[v]&lt;br /&gt;
	end&lt;br /&gt;
	if prop == nil then prop = dProp end&lt;br /&gt;
	return prop&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Color functions&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
function p._colour(code)&lt;br /&gt;
	--Retrieves the base colour for a given code&lt;br /&gt;
	return getProperty(getDefinition(code), getDefault(), msg.baseColourPath)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.colour(frame)&lt;br /&gt;
	--Retrieves the base colour for a given code; is invokable&lt;br /&gt;
	local args = getRawArgs(frame, msg.colourTemplateLocation)&lt;br /&gt;
	-- Nowiki tags prevent output beginning with &amp;quot;#&amp;quot; from triggering bug 14974.&lt;br /&gt;
	return frame:extensionTag('nowiki', p._colour(args[1]))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Icon functions&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
function p._icon(args)&lt;br /&gt;
	--Retrieves an icon image and formats it as wikitext&lt;br /&gt;
	local class = getDefinition(args[msg.argumentNames.class] or args[1])&lt;br /&gt;
	local default = getDefault()&lt;br /&gt;
	local file = getProperty(class, default, msg.iconPath)&lt;br /&gt;
	local label = &lt;br /&gt;
		getProperty(class, default, msg.tooltipPath) or&lt;br /&gt;
		ucfirst(getProperty(class, default, msg.fullLabelPath))&lt;br /&gt;
	local attrib = getProperty(class, default, msg.iconAttribPath)&lt;br /&gt;
	local span = mw.html.create('span')&lt;br /&gt;
&lt;br /&gt;
	span&lt;br /&gt;
		:cssText(args[msg.argumentNames.style])&lt;br /&gt;
		:attr('title', label)&lt;br /&gt;
		:wikitext(&lt;br /&gt;
			string.format(&lt;br /&gt;
				'[[File:%s|%s|16px%s|class=noviewer|alt=]]',&lt;br /&gt;
				file,&lt;br /&gt;
				label,&lt;br /&gt;
				attrib and '' or '|link='&lt;br /&gt;
			)&lt;br /&gt;
		)&lt;br /&gt;
	return tostring(span)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.icon = makeInvokeFunction(p._icon, msg.iconTemplateLocation)&lt;br /&gt;
--Invokable version of p._icon&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Class functions&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
function p._class(args)&lt;br /&gt;
	--Parses its arguments into a table cell with an optional icon, a name&lt;br /&gt;
	--linked to an appropriate category, and appropriate colour styling&lt;br /&gt;
	local classDef, classCode =&lt;br /&gt;
		getDefinition(args[msg.argumentNames.class] or args[1])&lt;br /&gt;
	local default = getDefault()&lt;br /&gt;
	local iconDefault = getProperty(classDef, default, msg.iconDefaultPath)&lt;br /&gt;
	local shortLabel = getProperty(classDef, default, msg.shortLabelPath)&lt;br /&gt;
	local categoryRoot = getProperty(classDef, default, msg.categoryRootPath)&lt;br /&gt;
	--o is short for &amp;quot;options&amp;quot;, go for &amp;quot;get options&amp;quot;. Bool true → case-sensitive&lt;br /&gt;
	local o, go = {}, msg.getOptions&lt;br /&gt;
	for k, v in pairs(go) do&lt;br /&gt;
		o[k] = v[2] and trim(args[v[1]]) or normalizeValue(args[v[1]])&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local cell = mw.html.create(o.header and 'th' or 'td')&lt;br /&gt;
	--image=yes forces icon, image=no disables it, otherwise checks default&lt;br /&gt;
	local icon = iconDefault and (o.image ~= msg.no) or (o.image == msg.yes)&lt;br /&gt;
	icon = icon and p.icon(args) .. '&amp;amp;nbsp;' or ''&lt;br /&gt;
&lt;br /&gt;
	local category&lt;br /&gt;
	if o.fullcategory then&lt;br /&gt;
		category = o.fullcategory&lt;br /&gt;
	elseif o.category then&lt;br /&gt;
		category = string.format(msg.catRootFormat, categoryRoot, o.category)&lt;br /&gt;
	elseif o.topic then&lt;br /&gt;
		category = string.format(msg.catTopicFormat, categoryRoot, o.topic)&lt;br /&gt;
	else&lt;br /&gt;
		category = string.format(msg.catBasicFormat, categoryRoot)&lt;br /&gt;
	end&lt;br /&gt;
	local text = string.format(msg.categoryFormat, category, shortLabel)&lt;br /&gt;
	cell&lt;br /&gt;
		:addClass(msg.globalClass)&lt;br /&gt;
		:addClass(&lt;br /&gt;
			o.bold == msg.no and msg.classPrefix .. msg.unboldClassSuffix or nil&lt;br /&gt;
		)&lt;br /&gt;
		:addClass(msg.classPrefix .. (classCode or msg.defaultClassSuffix))&lt;br /&gt;
		:attr('rowspan', tonumber(o.rowspan))&lt;br /&gt;
		:wikitext(icon, text)&lt;br /&gt;
&lt;br /&gt;
		return mw.getCurrentFrame():extensionTag{&lt;br /&gt;
			name = 'templatestyles', args = {src = msg.stylesLocation}&lt;br /&gt;
		} .. tostring(cell)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.class = makeInvokeFunction(p._class, msg.templateLocation)&lt;br /&gt;
--Invokable version of p._class&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>wikipedia&gt;Nihiltres</name></author>
	</entry>
</feed>