require('Module:No globals')
local conf = require( 'Module:Category described in year/conf' ) --configuration module
--[[==========================================================================]]
--[[ Case sensitive conf/map table ]]
--[[==========================================================================]]
local conf = {
--[[============================================================================
Any category group (e.g. Bacteria/Plants/etc.) NOT explicitly outlined here
in conf{} will follow the 'Default' tree for that group when the template is
used on that cateogry.
The default-style category tree is:
year -> century -> formal
year -> Animals:year -> Animals:century
Decadal categories are discouraged.
To create a new tree, only if necessarily different from the default, copy
an existing tree and paste it in an appropriate spot in the conf{} table,
following the same general table format, and updating any group-specific
variables.
============================================================================]]--
['tocmin'] = 401, --integer; minimum category size to add {{Category TOC}}
['Default'] = { --"group" (e.g. Amphibians/Birds/Crustaceans/Fish/Mammals/Molluscs/Reptiles/Sponges)
['yearmin'] = 1758, --integer; lowest possible year displayed in nav bars; 0/nil defaults to 1758 per ICZN Art. 5
['year'] = { --[[Category:Birds described in 1901]]
['parent1'] = 'century', --[[Category:Birds described in the 20th century]] --decade, century, or formal
['parent2'] = 'Animals', --[[Category:Animals described in 1901]]
['description'] = 'This category should only contain articles on [[species]] and notable [[subspecies]].', --adapted from [[Category:Species described in the 18th century]] & [[Category:Species described in the 21st century]]
},
['century'] = { --[[Category:Birds described in the 20th century]]
['parent1'] = 'formal', --[[Category:Birds by year of formal description]]
['parent2'] = 'Animals', --[[Category:Animals described in the 20th century]]
['description'] = '', --Century description tbd; container category, etc...
},
},
['Animals'] = { --"group"
['yearmin'] = 1757, --integer; lowest possible year displayed in nav bars; 0/nil defaults to 1758 per ICZN Art. 5
['year'] = { --[[Category:Animals described in 1901]]
['parent1'] = 'century', --[[Category:Animals described in the 20th century]]
['parent2'] = 'Species', --[[Category:Species described in 1901]]
['description'] = '', --Year description tbd; *not* a container cat
},
['century'] = { --[[Category:Animals described in the 20th century]]
['parent1'] = 'formal', --[[Category:Animals by year of formal description]]
['parent2'] = 'Species', --[[Category:Species described in the 20th century]]
['description'] = '', --Century description tbd; container category, etc...
},
},
['Spiders'] = { --"group"; ICZN allows names in Clerck's Aranei Svecici of 1757, earliest date used in World Spider Catalog
['yearmin'] = 1757, --integer; lowest possible year displayed in nav bars; 0/nil defaults to 1758 per ICZN Art. 5
['year'] = { --[[Category:Spiders described in 1901]]
['parent1'] = 'century', --[[Category:Spiders described in the 20th century]]
['parent2'] = 'Animals', --[[Category:Animals described in 1901]]
['description'] = '', --Year description tbd; Default-group's description doesn't apply
},
['century'] = { --[[Category:Spiders described in the 20th century]]
['parent1'] = 'formal', --[[Category:Spiders by year of formal description]]
['parent2'] = 'Animals', --[[Category:Animals described in the 20th century]]
['description'] = '', --Century description tbd; container category, etc...
},
},
--[[============================ Insects tree ============================]]
['Insects'] = { --"group"
['yearmin'] = 1757, --integer; lowest possible year displayed in nav bars; 0/nil defaults to 1758 per ICZN Art. 5
['year'] = { --[[Category:Insects described in 1901]]
['parent1'] = 'century', --[[Category:Insects described in the 20th century]]
['parent2'] = 'Animals', --[[Category:Animals described in 1901]]
['description'] = '', --Year description tbd; Default-group's description doesn't apply
},
['century'] = { --[[Category:Insects described in the 20th century]]
['parent1'] = 'formal', --[[Category:Insects by year of formal description]]
['parent2'] = 'Animals', --[[Category:Animals described in the 20th century]]
['description'] = '', --Century description tbd; container category, etc...
},
},
['Beetles'] = { --"subgroup" to Insects
['yearmin'] = 1757, --integer; lowest possible year displayed in nav bars; 0/nil defaults to 1758 per ICZN Art. 5
['year'] = { --[[Category:Beetles described in 1901]]
['parent1'] = 'century', --[[Category:Beetles described in the 20th century]]
['parent2'] = 'Insects', --[[Category:Insects described in 1901]]
['description'] = '', --Year description tbd; 'This category should only contain species articles', etc...
},
['century'] = { --[[Category:Beetles described in the 20th century]]
['parent1'] = 'formal', --[[Category:Beetles by year of formal description]]
['parent2'] = 'Insects', --[[Category:Insects described in the 20th century]]
['sortkey2'] = '*',
['description'] = '', --Century description tbd; container category, etc...
},
},
['Butterflies'] = { --"subgroup" to Insects
['yearmin'] = 1757, --integer; lowest possible year displayed in nav bars; 0/nil defaults to 1758 per ICZN Art. 5
['year'] = { --[[Category:Butterflies described in 1901]]
['parent1'] = 'century', --[[Category:Butterflies described in the 20th century]]
['parent2'] = 'Insects', --[[Category:Insects described in 1901]]
['description'] = '', --Year description tbd; 'This category should only contain species articles', etc...
},
['century'] = { --[[Category:Butterflies described in the 20th century]]
['parent1'] = 'formal', --[[Category:Butterflies by year of formal description]]
['parent2'] = 'Insects', --[[Category:Insects described in the 20th century]]
['sortkey2'] = '*',
['description'] = '', --Century description tbd; container category, etc...
},
},
['Moths'] = { --"subgroup" to Insects
['year'] = { --[[Category:Moths described in 1901]]
['parent1'] = 'century', --[[Category:Moths described in the 20th century]]
['parent2'] = 'Insects', --[[Category:Insects described in 1901]]
['description'] = '', --Year description tbd; 'This category should only contain species articles', etc...
},
['century'] = { --[[Category:Moths described in the 20th century]]
['parent1'] = 'formal', --[[Category:Moths by year of formal description]]
['parent2'] = 'Insects', --[[Category:Insects described in the 20th century]]
['sortkey2'] = '*',
['description'] = '', --Century description tbd; container category, etc...
},
},
--[[=========================== Molluscs tree ============================]]
['Bivalves'] = { --"subgroup" to Molluscs
['year'] = { --[[Category:Bivalves described in 1901]]
['parent1'] = 'century', --[[Category:Bivalves described in the 20th century]]
['parent2'] = 'Molluscs', --[[Category:Molluscs described in 1901]]
['description'] = '', --Year description tbd; 'This category should only contain species articles', etc...
},
['century'] = { --[[Category:Bivalves described in the 20th century]]
['parent1'] = 'formal', --[[Category:Bivalves by year of formal description]]
['parent2'] = 'Molluscs', --[[Category:Molluscs described in the 20th century]]
['sortkey2'] = '*',
['description'] = '', --Century description tbd; container category, etc...
},
},
['Cephalopods'] = { --"subgroup" to Molluscs
['year'] = { --[[Category:Cephalopods described in 1901]]
['parent1'] = 'century', --[[Category:Cephalopods described in the 20th century]]
['parent2'] = 'Molluscs', --[[Category:Molluscs described in 1901]]
['description'] = '', --Year description tbd; 'This category should only contain species articles', etc...
},
['century'] = { --[[Category:Cephalopods described in the 20th century]]
['parent1'] = 'formal', --[[Category:Cephalopods by year of formal description]]
['parent2'] = 'Molluscs', --[[Category:Molluscs described in the 20th century]]
['sortkey2'] = '*',
['description'] = '', --Century description tbd; container category, etc...
},
},
['Chitons'] = { --"subgroup" to Molluscs
['year'] = { --[[Category:Chitons described in 1901]]
['parent1'] = 'century', --[[Category:Chitons described in the 20th century]]
['parent2'] = 'Molluscs', --[[Category:Molluscs described in 1901]]
['description'] = '', --Year description tbd; 'This category should only contain species articles', etc...
},
['century'] = { --[[Category:Chitons described in the 20th century]]
['parent1'] = 'formal', --[[Category:Chitons by year of formal description]]
['parent2'] = 'Molluscs', --[[Category:Molluscs described in the 20th century]]
['sortkey2'] = '*',
['description'] = '', --Century description tbd; container category, etc...
},
},
['Gastropods'] = { --"subgroup" to Molluscs
['year'] = { --[[Category:Gastropods described in 1901]]
['parent1'] = 'century', --[[Category:Gastropods described in the 20th century]]
['parent2'] = 'Molluscs', --[[Category:Molluscs described in 1901]]
['description'] = '', --Year description tbd; 'This category should only contain species articles', etc...
},
['century'] = { --[[Category:Gastropods described in the 20th century]]
['parent1'] = 'formal', --[[Category:Gastropods by year of formal description]]
['parent2'] = 'Molluscs', --[[Category:Molluscs described in the 20th century]]
['sortkey2'] = '*',
['description'] = '', --Century description tbd; container category, etc...
},
},
--[[============================= Non-animals ============================]]
['Archaea'] = { --"group"
['year'] = { --[[Category:Archaea described in 1901]]
['parent1'] = 'century', --[[Category:Archaea described in the 20th century]]
['parent2'] = 'Species', --[[Category:Species described in 1901]]
['description'] = '', --Year description tbd; 'This category should only contain species articles', etc...
},
['century'] = { --[[Category:Archaea described in the 20th century]]
['parent1'] = 'formal', --[[Category:Archaea by year of formal description]]
['parent2'] = 'Species', --[[Category:Species described in the 20th century]]
['description'] = '', --Century description tbd; container category, etc...
},
},
['Bacteria'] = { --"group"
['yearmin'] = 1753, --integer; lowest possible year displayed in nav bars; 0/nil defaults to 1758 per ICZN Art. 5
['year'] = { --[[Category:Bacteria described in 1901]]
['parent1'] = 'century', --[[Category:Bacteria described in the 20th century]]
['parent2'] = 'Species', --[[Category:Species described in 1901]]
['description'] = '', --Year description tbd; 'This category should only contain species articles', etc...
},
['century'] = { --[[Category:Bacteria described in the 20th century]]
['parent1'] = 'formal', --[[Category:Bacteria by year of formal description]]
['parent2'] = 'Species', --[[Category:Species described in the 20th century]]
['description'] = '', --Century description tbd; container category, etc...
},
},
['Fungi'] = { --"group"
['yearmin'] = 1753, --integer; lowest possible year displayed in nav bars; 0/nil defaults to 1758 per ICZN Art. 5
['year'] = { --[[Category:Fungi described in 1901]]
['parent1'] = 'century', --[[Category:Fungi described in the 20th century]]
['parent2'] = 'Species', --[[Category:Species described in 1901]]
['description'] = '', --Year description tbd; 'This category should only contain species articles', etc...
},
['century'] = { --[[Category:Fungi described in the 20th century]]
['parent1'] = 'formal', --[[Category:Fungi by year of formal description]]
['parent2'] = 'Species', --[[Category:Species described in the 20th century]]
['description'] = '', --Century description tbd; container category, etc...
},
},
['Plants'] = { --"group"
['yearmin'] = 1753, --integer; lowest possible year displayed in nav bars; 0/nil defaults to 1758 per ICZN Art. 5
['year'] = { --[[Category:Plants described in 1901]]
['parent1'] = 'century', --[[Category:Plants described in the 20th century]]
['parent2'] = 'Species', --[[Category:Species described in 1901]]
['description'] = "This category includes plants that were ''first formally and validly described'' in %year% according to the rules of the [[International Code of Botanical Nomenclature]]. Use [[WP:RS|reliable sources]] like the [[International Plant Names Index]] to figure out the proper category. For examples see the [[Wikipedia:WikiProject Plants/Description in year categories|WikiProject Plants essay]] on this topic.", --taken from [[Category:Plants described in 1928]]
},
['century'] = { --[[Category:Plants described in the 20th century]]
['parent1'] = 'formal', --[[Category:Plants by year of formal description]]
['parent2'] = 'Species', --[[Category:Species described in the 20th century]]
['description'] = 'For advice on using the subcategories of this category, see [[Wikipedia:WikiProject Plants/Description in year categories]].', --taken from [[Category:Plants described in the 21st century]]
},
},
--[[==================== "Species described in"-level ====================]]
['Species'] = {
['yearmin'] = 1753, --integer; lowest possible year displayed in nav bars; 0/nil defaults to 1758 per ICZN Art. 5
['year'] = { --[[Category:Species described in 1901]]
['parent1'] = 'century', --[[Category:Species described in the 20th century]]
['sortkey1'] = ' ',
['parent2'] = 'Taxa', --[[Category:Taxa described in 1901]]
['parent3'] = 'environment', --[[Category:1901 in the environment]]
['description'] = '', --Year description tbd
},
['century'] = { --[[Category:Species described in the 20th century]]
['parent1'] = 'formal', --[[Category:Species by year of formal description]]
['parent2'] = 'Taxa', --[[Category:Taxa described in the 20th century]]
['parent3'] = 'environment', --[[Category:20th century in the environment]]
['description'] = "This category should only contain '''[[species]]''' and notable [[subspecies]] of [[Biota (taxonomy)|biota]] described in the '''[[%century% century]]'''.", --adapted from all 4 Species-century cats (18th-21st)
},
},
--[[===================== "Taxa described in"-level ======================]]
['Taxa'] = {
['yearmin'] = 1753, --integer; lowest possible year displayed in nav bars; 0/nil defaults to 1758 per ICZN Art. 5
['year'] = { --[[Category:Taxa described in 1901]]
['parent1'] = 'century', --[[Category:Taxa described in the 20th century]]
['parent2'] = 'biology', --[[Category:1901 in biology]]
['description'] = '', --Year description tbd
},
['century'] = { --[[Category:Taxa described in the 20th century]]
['parent1'] = 'formal', --[[Category:Taxa by year of formal description]]
['parent2'] = 'biology', --[[Category:20th century in biology]]
['description'] = '', --Century description tbd
},
},
--[[==================== "Fossil taxa described in"-level ====================]]
['Fossil taxa'] = {
['yearmin'] = 1753, --integer; lowest possible year displayed in nav bars; 0/nil defaults to 1758 per ICZN Art. 5
['year'] = { --[[Category:Fossil taxa described in 1901]]
['parent1'] = 'century', --[[Category:Fossil taxa described in the 20th century]]
['sortkey1'] = ' ',
['parent2'] = 'Taxa', --[[Category:Taxa described in 1901]]
['parent3'] = 'paleontology', --[[Category:1901 in paleontology]]
['description'] = 'This category should only contain articles on fossil [[genus|genera]] or lower.',
},
['century'] = { --[[Category:Fossil taxa described in the 20th century]]
['parent1'] = 'formal', --[[Category:Fossil taxa by year of formal description]]
['parent2'] = 'Taxa', --[[Category:Taxa described in the 20th century]]
['parent3'] = 'paleontology', --[[Category:20th century in paleontology]]
['description'] = '', --Century description tbd
},
},
}
--[[==========================================================================]]
--determine current/related/adjacent cats' properties/vars/etc.
local currGroup = mw.ustring.match(currCat, '^([%w ]+) described in') --Bacteria/Plants/etc.
if isNilOrEmpty(currGroup) then currGroup = mw.ustring.match(currCat, '^([%w ]+) by year of formal description') end
if conf[currGroup] == nil then conf[currGroup] = conf['Default'] end --default to Default
local currYDCcurrYDCF = nil --possible future values: year/decade/century/formal
local currYear = mw.ustring.match(currCat, 'described in (%d%d%d%d)$')
local currDeca = mw.ustring.match(currCat, 'described in the (%d%d%d%d)s$')
local currCent = mw.ustring.match(currCat, 'described in the (%d+)[snrt][tdh] century$')
local currFrml = mw.ustring.match(currCat, 'by year of (formal) description$')
local lastCent, nextCent = nil, nil --used with currYear & currCent
local parentDeca, parentCent = nil, nil --used with currYear & currDeca
local minYear = tonumber(conf[currGroup].yearminminyear)
if (minYear == nil or (minYear and minYear <= 1700)) then
minYear = 1758 --default to 1758 per ICZN Art. 5
end
if currYear then
currYDCcurrYDCF = 'year'
parentDeca = mw.ustring.match(currYear, '^(%d%d%d)%d$') .. '0'
if mw.ustring.match(currYear, '^%d%d00') then --1900 in 19th century
nextCent = parentCent + 1
elseif currDeca then
currYDCcurrYDCF = 'decade'
parentDeca = mw.ustring.match(currDeca, '^(%d%d%d)%d$') .. '0'
parentCent = mw.ustring.match(parentDeca, '^%d%d') + 1
elseif currCent then
currYDCcurrYDCF = 'century'
lastCent = currCent - 1
nextCent = currCent + 1
elseif currFrml then
currYDCF = 'formal'
else
bConfError = true
bConfError = true
trackingCategories[2] = '[[Category:Described in year error|1]]' --group (Bacteria/Plants/etc.) key missing from conf
elseif conf[currGroup][currYDCcurrYDCF] == nil then
bConfError = true
trackingCategories[2] = '[[Category:Described in year error|2]]' --year/decade/century/formal key missing
else
if conf[currGroup][currYDCcurrYDCF].description == nil then
bConfError = true
trackingCategories[2] = '[[Category:Described in year error|3]]' --description key missing
end
if conf[currGroup][currYDCcurrYDCF].parent1 == nil then
bConfError = true
trackingCategories[2] = '[[Category:Described in year error|4]]' --parent key missing
--produce description
description = conf[currGroup][currYDCcurrYDCF].description
if mw.ustring.match(description, '%%year%%') then
if currYear then description = mw.ustring.gsub(description, '%%year%%', currYear) --"2011"
local parenti = 'parent' .. iparent
local sortkeyi = 'sortkey' .. iparent
while conf[currGroup][currYDCcurrYDCF][parenti] do
local parent = conf[currGroup][currYDCcurrYDCF][parenti]
local sortkey = conf[currGroup][currYDCcurrYDCF][sortkeyi]
--[[========================== Year ==========================]]
if currYDCcurrYDCF == 'year' then
if nav == nil then
local args = { min = minYear }
--[[================== Decade (deprecated) ===================]]
elseif currYDCcurrYDCF == 'decade' then
if nav == nil then
nav = frame:expandTemplate{ title = 'Container category' }
--[[======================== Century =========================]]
elseif currYDCcurrYDCF == 'century' then
if nav == nil then
nav = frame:expandTemplate{ title = 'Container category' }
local args = { currGroup .. ' described in the ' .. addOrd(lastCent) .. ' century',
currGroup .. ' described in the ' .. addOrd(nextCent) .. ' century' }
nav = nav .. frame:expandTemplate{ title = 'Category pair', args = args }
end
categories[iparent] = '[[Category:'..addOrd(currCent)..' century in biology'..sortkey..']]' --if/when all biology cats exists, merge this elseif with 'paleontology'
end
elseif parent == 'paleontology' then
if isNilOrEmpty(sortkey) then sortkey = '' --default to none
else sortkey = '|'..sortkey end
trackingCategories[2] = '[[Category:Described in year error|C]]' --invalid century-parent
end
--[[======================== Formal ==========================]]
elseif currYDCF == 'formal' then
if nav == nil then
nav = frame:expandTemplate{ title = 'Container category' }
end
if parent == 'Group' then
if isNilOrEmpty(sortkey) then sortkey = ' Year' end --default to " Year"
categories[iparent] = '[[Category:'..currGroup..'|'..sortkey..']]'
elseif parent == 'Animals' or parent == 'Insects' or parent == 'Molluscs' then
if isNilOrEmpty(sortkey) then sortkey = ' ' end --default to " "
categories[iparent] = '[[Category:'..parent..' by year of formal description|'..sortkey..']]'
elseif parent == 'Species' or parent == 'Taxa' then
if isNilOrEmpty(sortkey) then sortkey = '' --default to none
else sortkey = '|'..sortkey end
categories[iparent] = '[[Category:'..parent..' by year of formal description'..sortkey..']]'
else
trackingCategories[2] = '[[Category:Described in year error|F]]' --invalid formal-parent
end
--[[========================= Error ==========================]]
else
trackingCategories[2] = '[[Category:Described in year error|U]]' --unknown configuration
parenti = 'parent' .. iparent
sortkeyi = 'sortkey' .. iparent
end --while conf[currGroup][currYDCcurrYDCF][parenti] do
end --if bConfError == false then
|