<?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%3AAsbox</id>
	<title>Module:Asbox - 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%3AAsbox"/>
	<link rel="alternate" type="text/html" href="https://mindpowe.red/wiki/index.php?title=Module:Asbox&amp;action=history"/>
	<updated>2026-04-06T06:55:34Z</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:Asbox&amp;diff=1535&amp;oldid=prev</id>
		<title>imported&gt;Od Mishehu: Namespace isn't included in default sort key, update comment appropriately</title>
		<link rel="alternate" type="text/html" href="https://mindpowe.red/wiki/index.php?title=Module:Asbox&amp;diff=1535&amp;oldid=prev"/>
		<updated>2019-05-28T14:27:54Z</updated>

		<summary type="html">&lt;p&gt;Namespace isn&amp;#039;t included in default sort key, update comment appropriately&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 was created by User:CodeHydro (Alexander Zhikun He).&lt;br /&gt;
User:Jackmcbarn and User:Mr._Stradivarius provided a great deal of assistance in writting p.main()&lt;br /&gt;
&lt;br /&gt;
p.main() draw heavily from the following version of Template:Asbox of the English Wikipedia, authored primarily by User:Rich_Farmbrough&lt;br /&gt;
https://en.wikipedia.org/w/index.php?title=Template:Asbox&amp;amp;oldid=619510287&lt;br /&gt;
&lt;br /&gt;
p.templatepage() is derived from the following revision of Template:Asbox/templatepage, authored primarily by User:MSGJ&lt;br /&gt;
https://en.wikipedia.org/w/index.php?title=Template:Asbox/templatepage&amp;amp;oldid=632914791&lt;br /&gt;
&lt;br /&gt;
Both templates had significant contributions from numerous others listed in the revision history tab of their respective pages.&lt;br /&gt;
--]]&lt;br /&gt;
local WRAPPER_TEMPLATE, args = 'Template:Asbox'&lt;br /&gt;
local p, Buffer, stubCats = {&lt;br /&gt;
	--Prevents dupli-cats... get it? Maybe not?&lt;br /&gt;
	cats = setmetatable({}, {__newindex = function(t, i, v)&lt;br /&gt;
		if not rawget(t, i) then&lt;br /&gt;
			rawset(t, i, v)&lt;br /&gt;
			table.insert(t, i)&lt;br /&gt;
		end&lt;br /&gt;
	end}),&lt;br /&gt;
	--initializes variables required by both p.main and p.templatepage&lt;br /&gt;
	init = function(self, frame, page)&lt;br /&gt;
		args, page = args or require('Module:Arguments').getArgs(frame, {&lt;br /&gt;
			wrappers = WRAPPER_TEMPLATE&lt;br /&gt;
		}), page or mw.title.getCurrentTitle()&lt;br /&gt;
		--Ensures demo parameter will never affect category() output for articles&lt;br /&gt;
		self.demo = self.demo or page.namespace ~= 0 and args.demo&lt;br /&gt;
		return args, page&lt;br /&gt;
	end&lt;br /&gt;
}, require('Module:Buffer')&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Formats category links. Stores them until called with cat.done=true&lt;br /&gt;
Takes multiple or single categories in the form of 'cat'&lt;br /&gt;
or a table of strings and/or tables containing parts. (See below)&lt;br /&gt;
]]&lt;br /&gt;
local attention, catTag, catKey = Buffer'Stub message templates needing attention', '[[Category:%s]]', '%s|%s%s'&lt;br /&gt;
local function category(cat)&lt;br /&gt;
	for _, v in ipairs((tostring(cat) == cat or cat.t) and {cat} or cat) do&lt;br /&gt;
		--[[&lt;br /&gt;
		If v is a table:&lt;br /&gt;
			[1] = full category name; defaults to local attention if blank&lt;br /&gt;
			k = Category sort key. Prefix before v.t&lt;br /&gt;
			t = page.text or args.tempsort#; appended after k (or in its place if omitted). Required if v is not a string&lt;br /&gt;
		Basically the same as v = (v[1] or attention) .. ' | ' .. (v.k or '') .. v.t&lt;br /&gt;
		]]&lt;br /&gt;
		if v and v ~= true then--reject v = nil, false, or true&lt;br /&gt;
			p.cats[catTag:format(tostring(v) == v and&lt;br /&gt;
				v&lt;br /&gt;
				or (v[1] and Buffer(v[1]) or attention):_in(v.k):_(v.t):_str(2, nil, nil, '|')&lt;br /&gt;
			)] = true&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return cat.done and table.concat(p.cats, p.demo and ' | ' or nil) or ''&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Makes an ombox warning;&lt;br /&gt;
Takes table {ifNot = Boolean, text, {cat. sort key, cat. sort name}}&lt;br /&gt;
Will return an empty string instead when ifNot evaluates to true &lt;br /&gt;
]]&lt;br /&gt;
local function ombox(v)&lt;br /&gt;
	if v.ifNot then return end&lt;br /&gt;
	p.ombox = p.ombox or require('Module:Message box').ombox&lt;br /&gt;
	category{v[2]}&lt;br /&gt;
	return p.ombox{&lt;br /&gt;
		type = 'content',&lt;br /&gt;
		text = v[1]&lt;br /&gt;
	}&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Unlike original template, module now takes unlimited cats! This function also performs&lt;br /&gt;
most stub category error checks except for the ombox for when main |category= is omitted (See p.template())&lt;br /&gt;
]]&lt;br /&gt;
local function catStub(page, pageDoc)&lt;br /&gt;
	stubCats = {missing = {}, v = {}}&lt;br /&gt;
	local code&lt;br /&gt;
	for k, _ in pairs(args) do&lt;br /&gt;
		--Find category parameters and store the number (main cat = '')&lt;br /&gt;
		table.insert(stubCats, string.match(k, '^category(%d*)$'))&lt;br /&gt;
	end&lt;br /&gt;
	table.sort(stubCats)&lt;br /&gt;
	for k, v in ipairs(stubCats) do&lt;br /&gt;
		--Get category names and, if called by p.templatepage, the optional sort key&lt;br /&gt;
		local tsort, cat = args['tempsort' .. v], mw.ustring.gsub(args['category' .. v], '[^%w%p%s]', '')--remove all hidden unicode chars &lt;br /&gt;
		--Do not place template in main category if |tempsort = 'no'. However, DO place articles of that template in the main category.&lt;br /&gt;
		table.insert(stubCats.v,&lt;br /&gt;
			 page and (--p.templatepage passes page; p.main does not, i.e. articles are categorized without sort keys.&lt;br /&gt;
				v=='' and tsort == 'no'--if true, inserts 'true' in table, which category() will reject&lt;br /&gt;
				or tsort and {cat, k = ' ', t = tsort}&lt;br /&gt;
				or {cat, k = ' *', t = page.text}--note space in front of sort key&lt;br /&gt;
			)&lt;br /&gt;
			or cat&lt;br /&gt;
		)&lt;br /&gt;
		--Check category existance only if on the template page (i.e. stub documentation)&lt;br /&gt;
		if page then&lt;br /&gt;
			if not mw.title.new('Category:' .. cat).exists then&lt;br /&gt;
				code = code or mw.html.create'code':wikitext'|category'&lt;br /&gt;
				table.insert(stubCats.missing, tostring(mw.clone(code):wikitext(v)))&lt;br /&gt;
			end&lt;br /&gt;
			--[[&lt;br /&gt;
			Checks non-demo stub template for documentation and flags if doc is present.&lt;br /&gt;
			All stub cats names are checked and flagged if it does not match 'Category: [] stub'.&lt;br /&gt;
			The main stub cat is exempt from the name check if the stub template has its own doc&lt;br /&gt;
			(presumably, this doc would have an explanation as to why the main stub cat is non-conforming).&lt;br /&gt;
			]]&lt;br /&gt;
			table.insert(stubCats.v, v == '' and not p.demo and pageDoc.exists and&lt;br /&gt;
				'Stub message templates with documentation subpages'&lt;br /&gt;
				or not cat:match' stubs$' and {k = 'S', t = page.text}&lt;br /&gt;
			)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	--Add category names after loop is completed&lt;br /&gt;
	category(stubCats.v)&lt;br /&gt;
	return #stubCats.missing &amp;gt; 0 and ombox{&lt;br /&gt;
		--Changed, original msg:&lt;br /&gt;
		--One or more of the stub categories defined in this template do not seem to exist!&lt;br /&gt;
		--Please double-check the parameters {{para|category}}, {{para|category1}} and {{para|category2}}.&lt;br /&gt;
		'The following parameter'&lt;br /&gt;
			.. (#stubCats.missing == 1 and ' defines a stub category that does' or 's define stub categories that do')&lt;br /&gt;
			.. ' not exist: ' .. mw.text.listToText(stubCats.missing),&lt;br /&gt;
		{k = 'N', t = page.text}&lt;br /&gt;
	}&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--Shows population of categories found by catStub(). Outputs demo values if none&lt;br /&gt;
local function population()&lt;br /&gt;
	local wikitext, base = {}, '* [[:Category:%s]] (population: %s)\n'&lt;br /&gt;
	if not args.category and stubCats[1] ~= false then&lt;br /&gt;
		table.insert(stubCats, 1, false)&lt;br /&gt;
	end&lt;br /&gt;
	for _, v in ipairs(stubCats) do&lt;br /&gt;
		table.insert(wikitext, base:format(&lt;br /&gt;
			v and args['category' .. v] or '{{{category}}}',&lt;br /&gt;
			v and mw.site.stats.pagesInCategory(args['category' .. v], 'all') or 0&lt;br /&gt;
		))&lt;br /&gt;
	end&lt;br /&gt;
	return table.concat(wikitext)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--Includes standard stub documention and flags stub templates with bad parameter values.&lt;br /&gt;
function p.templatepage(frame, page)&lt;br /&gt;
	args, page = p:init(frame, page)&lt;br /&gt;
	local tStubDoc = mw.title.new'Template:Stub documentation'&lt;br /&gt;
	local pageDoc = page:subPageTitle('doc')&lt;br /&gt;
	--Reorganization note: Original Asbox alternates between outputting categories and checking on params |category#=.&lt;br /&gt;
	--Rather than checking multiple times and switching tasks, all stub category param operations have been rolled into catStub()&lt;br /&gt;
	return Buffer(&lt;br /&gt;
		ombox{--Show ombox warnings for missing args.&lt;br /&gt;
			ifNot = args.category,&lt;br /&gt;
			'The &amp;lt;code&amp;gt;|category&amp;lt;/code&amp;gt; parameter is not set. Please add an appropriate stub category.',&lt;br /&gt;
			{k = 'C', t = page.text}&lt;br /&gt;
		})&lt;br /&gt;
		:_(ombox{&lt;br /&gt;
			ifNot = args.subject or args.article or args.qualifier,&lt;br /&gt;
			'This stub template contains no description! At least one of the parameters &amp;lt;code&amp;gt;|subject&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;|article&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;|qualifier&amp;lt;/code&amp;gt; must be defined.',&lt;br /&gt;
			{k = 'D', t = page.text}&lt;br /&gt;
		})&lt;br /&gt;
		:_(catStub(page, pageDoc))--catStub() may also return an ombox if there are non-existing categories&lt;br /&gt;
		:_(category{&lt;br /&gt;
			done = p.demo ~= 'doc',--Outputs categories if not doc demo&lt;br /&gt;
			'Stub message templates',&lt;br /&gt;
			'Exclude in print',&lt;br /&gt;
			args.icon and&lt;br /&gt;
				'Stub message templates using icon parameter'&lt;br /&gt;
				or args.image and (&lt;br /&gt;
					mw.title.new('Media:' .. mw.text.split(args.image, '|')[1]).exists--do nothing if exists. category() will reject true&lt;br /&gt;
					or {k = 'B', t = page.text}&lt;br /&gt;
				)&lt;br /&gt;
				or 'Stub message templates without images',&lt;br /&gt;
			args.imagealt and {k = 'I', t = page.text},&lt;br /&gt;
		})&lt;br /&gt;
		:_((not p.demo or p.demo == 'doc') and--Add standard stub template documentation&lt;br /&gt;
			require('Module:Documentation').main{&lt;br /&gt;
				content = Buffer(page.text ~= 'Stub' and--This comparison performed in {{Asbox/stubtree}} before it invokes Module:Asbox stubtree&lt;br /&gt;
						require('Module:Asbox stubtree').subtree{args = {pagename = page.text}}&lt;br /&gt;
					)&lt;br /&gt;
					:_in'\n== About this template ==\nThis template is used to identify a':_(args.subject):_'stub':_(args.qualifier):_out' '--space&lt;br /&gt;
					:_'. It uses {{[[Template:Asbox|asbox]]}}, which is a meta-template designed to ease the process of creating and maintaining stub templates.\n=== Usage ===\nTyping '&lt;br /&gt;
					:_(mw.html.create'code'&lt;br /&gt;
						:wikitext('{{', page.text == 'Stub' and 'stub' or page.text, '}}')&lt;br /&gt;
					)&lt;br /&gt;
					:_' produces the message shown at the beginning, and adds the article to the following categor'&lt;br /&gt;
					:_(#stubCats &amp;gt; 1 and 'ies' or 'y')&lt;br /&gt;
					:_':\n'&lt;br /&gt;
					:_(population())&lt;br /&gt;
					:_(pageDoc.exists and--transclusion of /doc if it exists&lt;br /&gt;
						frame:expandTemplate{title = pageDoc.text}&lt;br /&gt;
					)&lt;br /&gt;
					:_'\n== General information ==\n'&lt;br /&gt;
					:_(frame:expandTemplate{title = tStubDoc.text})&lt;br /&gt;
					:_'\n\n'(),&lt;br /&gt;
				['link box'] = Buffer'This documentation is automatically generated by [[Module:Asbox]].'&lt;br /&gt;
					:_in'The general information is transcluded from [[Template:Stub documentation]]. '&lt;br /&gt;
						:_(mw.html.create'span'&lt;br /&gt;
							:cssText'font-size:smaller;font-style:normal;line-height:130%'&lt;br /&gt;
							:node(('([%s edit] | [%s history])'):format(&lt;br /&gt;
								tStubDoc:fullUrl('action=edit', 'relative'),&lt;br /&gt;
								tStubDoc:fullUrl('action=history', 'relative')&lt;br /&gt;
							))&lt;br /&gt;
						)&lt;br /&gt;
						:_out()&lt;br /&gt;
					:_(page.protectionLevels.edit and page.protectionLevels.edit[1] == 'sysop' and&lt;br /&gt;
						&amp;quot;This template is [[WP:PROTECT|fully protected]] and any [[WP:CAT|categories]] should be added to the template's [&amp;quot;&lt;br /&gt;
						.. pageDoc:fullUrl('action=edit&amp;amp;preload=Template:Category_interwiki/preload', 'relative')&lt;br /&gt;
						.. '| /doc] subpage, which is not protected.'&lt;br /&gt;
					)' &amp;lt;br/&amp;gt;'&lt;br /&gt;
			}&lt;br /&gt;
		)()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame, page)&lt;br /&gt;
	args, page = p:init(frame, page)&lt;br /&gt;
	local output = mw.html.create'table'&lt;br /&gt;
		:addClass'metadata plainlinks stub'&lt;br /&gt;
		:css{background = 'transparent'}&lt;br /&gt;
		:attr{role = 'presentation'}&lt;br /&gt;
		:tag'tr'&lt;br /&gt;
			:node((args.icon or args.image) and&lt;br /&gt;
				mw.html.create'td'&lt;br /&gt;
					:wikitext(args.icon or ('[[File:%s|%spx|alt=%s]]'):format(&lt;br /&gt;
						args.image or '',&lt;br /&gt;
						args.pix or '40x30',&lt;br /&gt;
						args.imagealt or 'Stub icon'&lt;br /&gt;
					))&lt;br /&gt;
			)&lt;br /&gt;
			:tag'td'&lt;br /&gt;
				:tag'i'&lt;br /&gt;
					:wikitext(&lt;br /&gt;
						Buffer'This':_(args.subject):_(args.article or 'article'):_(args.qualifier)' ',--space&lt;br /&gt;
						' is a [[Wikipedia:stub|stub]]. You can help Wikipedia by [',&lt;br /&gt;
						page:fullUrl('action=edit', 'relative'),&lt;br /&gt;
						' expanding it].'&lt;br /&gt;
					)&lt;br /&gt;
				:done()&lt;br /&gt;
				:node(args.name and&lt;br /&gt;
					require'Module:Navbar'._navbar{&lt;br /&gt;
						args.name,&lt;br /&gt;
						mini = 'yes',&lt;br /&gt;
						style = 'position: absolute; right: 15px; display: none;'&lt;br /&gt;
					}&lt;br /&gt;
				)&lt;br /&gt;
				:node(args.note and&lt;br /&gt;
					mw.html.create()&lt;br /&gt;
						:tag'br':done()&lt;br /&gt;
						:tag'span'&lt;br /&gt;
							:css{['font-style'] = 'normal', ['font-size'] = 'smaller'}&lt;br /&gt;
							:wikitext(args.note)&lt;br /&gt;
						:done()&lt;br /&gt;
				)&lt;br /&gt;
		:allDone()&lt;br /&gt;
	--[[&lt;br /&gt;
	Stub categories for templates include a sort key; this ensures that all stub tags appear at the beginning of their respective categories.&lt;br /&gt;
	Articles using the template do not need a sort key since they have unique names.&lt;br /&gt;
	When p.demo equals 'doc', the demo stub categories will appear as those for a stub template.&lt;br /&gt;
	Otherwise, any non-nil p.demo will emulate article space categories (plus any error cats unless set to 'art')&lt;br /&gt;
	]]&lt;br /&gt;
	if page.namespace == 0 then -- Main namespace&lt;br /&gt;
		category'All stub articles'&lt;br /&gt;
		catStub()&lt;br /&gt;
	elseif p.demo then&lt;br /&gt;
		if p.demo ~= 'doc' then catStub() end&lt;br /&gt;
		--Unless p.demo is set to 'art', it will also include error categories normally only shown on&lt;br /&gt;
		--the template but not in the article. The elseif after namespace == 0 means demo cats will never show in article space.&lt;br /&gt;
		p.demodoc = p.demo ~= 'art' and p.templatepage(frame, page)&lt;br /&gt;
		output = mw.html.create()&lt;br /&gt;
			:node(output)&lt;br /&gt;
			:tag'small':wikitext(&lt;br /&gt;
				'Demo categories: ',&lt;br /&gt;
				(category{done = true}:gsub('(%[%[)(Category:)([^|%]]-)(%|)', '%1%2%3|%2%3%4'):gsub('(%[%[)(Category:)', '%1:%2'))&lt;br /&gt;
			):done()&lt;br /&gt;
			:wikitext(p.demo == 'doc' and p.demodoc or nil)&lt;br /&gt;
	else&lt;br /&gt;
		--Checks for valid name; emulates original template's check using {{FULLPAGENAME:{{{name|}}}}}&lt;br /&gt;
		local normalizedName = mw.title.new(args.name or '')&lt;br /&gt;
		if normalizedName and normalizedName.fullText == page.fullText then&lt;br /&gt;
			output = mw.html.create():node(output):wikitext(p.templatepage(frame, page))&lt;br /&gt;
		elseif not page.isSubpage and page.namespace == 10 then-- Template namespace and not a subpage&lt;br /&gt;
			category{{k = args.name and 'E' or 'W', t = page.text}}&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return output:wikitext(not p.demo and category{done = true} or nil)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Od Mishehu</name></author>
		
	</entry>
</feed>