<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://pharmacopedia.wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ATopCategories</id>
	<title>Module:TopCategories - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://pharmacopedia.wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ATopCategories"/>
	<link rel="alternate" type="text/html" href="https://pharmacopedia.wiki/index.php?title=Module:TopCategories&amp;action=history"/>
	<updated>2026-06-10T10:47:19Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0-beta</generator>
	<entry>
		<id>https://pharmacopedia.wiki/index.php?title=Module:TopCategories&amp;diff=3361&amp;oldid=prev</id>
		<title>MediaWiki default: Create TopCategories Lua module for dynamic top-10 list</title>
		<link rel="alternate" type="text/html" href="https://pharmacopedia.wiki/index.php?title=Module:TopCategories&amp;diff=3361&amp;oldid=prev"/>
		<updated>2026-05-14T19:47:02Z</updated>

		<summary type="html">&lt;p&gt;Create TopCategories Lua module for dynamic top-10 list&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
local categories = {&lt;br /&gt;
	&amp;#039;Addiction Medicine&amp;#039;, &amp;#039;Amphetamines&amp;#039;, &amp;#039;Anesthetics&amp;#039;, &amp;#039;Anti-Dementia Medicines&amp;#039;,&lt;br /&gt;
	&amp;#039;Anticonvulsants / Antiepileptics&amp;#039;, &amp;#039;Antidepressants&amp;#039;, &amp;#039;Antihistamines&amp;#039;,&lt;br /&gt;
	&amp;#039;Antiparkinsonian Medicines&amp;#039;, &amp;#039;Antipsychotics / Neuroleptics&amp;#039;,&lt;br /&gt;
	&amp;#039;Anxiolytics &amp;amp; Sedative-Hypnotics&amp;#039;, &amp;#039;Arylcyclohexylamines&amp;#039;, &amp;#039;Barbiturates&amp;#039;,&lt;br /&gt;
	&amp;#039;Benzodiazepines&amp;#039;, &amp;#039;Cannabinoids&amp;#039;, &amp;#039;Cathinones&amp;#039;,&lt;br /&gt;
	&amp;#039;Classical Psychedelics (Serotonergic)&amp;#039;, &amp;#039;Deliriants&amp;#039;, &amp;#039;Dissociatives&amp;#039;,&lt;br /&gt;
	&amp;#039;Empathogens / Entactogens&amp;#039;, &amp;#039;Ergotamines&amp;#039;,&lt;br /&gt;
	&amp;#039;Eugeroics (Wakefulness-Promoting Agents)&amp;#039;, &amp;#039;GABAergics&amp;#039;, &amp;#039;Local Anesthetics&amp;#039;,&lt;br /&gt;
	&amp;#039;Lysergamides&amp;#039;, &amp;#039;Methylphenidates (Phenidates)&amp;#039;, &amp;#039;Migraine Medicines&amp;#039;,&lt;br /&gt;
	&amp;#039;Monoamine Oxidase Inhibitors (MAOIs)&amp;#039;, &amp;#039;Mood Stabilizers&amp;#039;,&lt;br /&gt;
	&amp;#039;Muscle Relaxants (CNS-acting)&amp;#039;, &amp;#039;NBOMe / NBOH series&amp;#039;, &amp;#039;Natural opioids&amp;#039;,&lt;br /&gt;
	&amp;#039;Nootropics&amp;#039;, &amp;#039;Opioid Antagonists&amp;#039;, &amp;#039;Opioids&amp;#039;, &amp;#039;Orexin Receptor Antagonists&amp;#039;,&lt;br /&gt;
	&amp;#039;Phenethylamines&amp;#039;, &amp;#039;Psychedelics&amp;#039;, &amp;#039;Pyrrolidinophenones&amp;#039;,&lt;br /&gt;
	&amp;#039;Research Materials&amp;#039;, &amp;#039;Second-Generation Antipsychotics (SGAs / Atypicals)&amp;#039;,&lt;br /&gt;
	&amp;#039;Selective Serotonin Reuptake Inhibitors (SSRIs)&amp;#039;, &amp;#039;Semisynthetic opioids&amp;#039;,&lt;br /&gt;
	&amp;#039;Serotonin–Norepinephrine Reuptake Inhibitors (SNRIs)&amp;#039;,&lt;br /&gt;
	&amp;#039;Stimulants &amp;amp; Wake-Promoting Agents&amp;#039;, &amp;#039;Synthetic opioids&amp;#039;,&lt;br /&gt;
	&amp;#039;Tricyclic Antidepressants (TCAs)&amp;#039;, &amp;#039;Triptans (5-HT1B/1D Agonists)&amp;#039;,&lt;br /&gt;
	&amp;#039;Tryptamines&amp;#039;, &amp;#039;Xanthines&amp;#039;, &amp;#039;Z-Drugs (Non-Benzodiazepine Hypnotics)&amp;#039;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function p.list(frame)&lt;br /&gt;
	local counts = {}&lt;br /&gt;
	for _, cat in ipairs(categories) do&lt;br /&gt;
		local n = mw.site.stats.pagesInCategory(cat, &amp;#039;pages&amp;#039;)&lt;br /&gt;
		if n &amp;gt; 0 then&lt;br /&gt;
			table.insert(counts, {name = cat, count = n})&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	-- Sort descending by count to pick top 10&lt;br /&gt;
	table.sort(counts, function(a, b) return a.count &amp;gt; b.count end)&lt;br /&gt;
	local top10 = {}&lt;br /&gt;
	for i = 1, math.min(10, #counts) do&lt;br /&gt;
		table.insert(top10, counts[i])&lt;br /&gt;
	end&lt;br /&gt;
	-- Re-sort top 10 alphabetically&lt;br /&gt;
	table.sort(top10, function(a, b) return a.name &amp;lt; b.name end)&lt;br /&gt;
	local lines = {}&lt;br /&gt;
	for _, item in ipairs(top10) do&lt;br /&gt;
		table.insert(lines, &amp;#039;* [[:Category:&amp;#039; .. item.name .. &amp;#039;|&amp;#039; .. item.name .. &amp;#039;]]&amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
	return table.concat(lines, &amp;#039;\n&amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>MediaWiki default</name></author>
	</entry>
</feed>