Module:Category described in year/sandbox: Difference between revisions

Content deleted Content added
m unind
m Sync from live
Line 3:
--case sensitive conf/map table
local conf = {
--[[============================================================================
'Fish' is the default category tree: year -> century -> Species, no decades.
'Spiders' & 'Plants' use year -> decade -> century -> Species.
Any category group (i.e.g. BirdsBacteria/Crustaceans/MolluscsPlants/etc.) NOT explicitly outlined here
outlined here in conf{} will follow the 'FishDefault' tree for that group. when the template is
used on that cateogry.
The default-style category tree is:
To create a customized tree, like 'Spiders' below, add it to the bottom of
year -> century -> formal
the conf{} table, following the same general table format.
year -> Animals:year -> Animals:century
Decadal categories are discouraged.
========================================================================]]--
To create a new tree, only if 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/Spiders)
['Fish'] = { --group
['yearmin'] = 1758, --integer; lowest possible year displayed in nav bars; 0/nil defaults to 1758 per ICZN Art. 5
['year'] = { --[[Category:FishBirds described in 1901]]
['parent1'] = 'century', --[[Category:Birds described in the 20th century]] --decade, century, or formal
['description'] = 'This category should only contain species-level articles.',
['parent1'] = 'century', --year/decade/century/formal, i.e. 'century' for [[Category:Fish described in the 20th century]]
['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:FishBirds described in the 20th century]]
['descriptionparent1'] = 'formal', --'Description[[Category:Birds tbd;by century;year containerof category,formal etc....',description]]
['parent1'] = 'formal', --[[Category:Fish by year of formal description]]
['parent2'] = 'Animals', --[[Category:Animals described in the 20th century]]
['description'] = '', --Century description tbd; container category, etc...
},
},
['SpidersAnimals'] = { --"group"
['yearmin'] = 1757, --integer; lowest possible year (and thus decade) displayed in nav bars; 0/nil defaults to 1758 per ICZN Art. 5
['year'] = { --[[Category:SpidersAnimals described in 1901]]
['parent1'] = 'century', --[[Category:Animals described in the 20th century]]
['description'] = '', --'Description tbd; year; This category should only contain species articles, etc....',
['parent1parent2'] = 'decadeSpecies', --[[Category:SpidersSpecies described in the 1900s1901]]
['parent2description'] = 'Animals', --[[Category:AnimalsYear describeddescription intbd; 1900]]*not* a container cat
},
['decadecentury'] = { --[[Category:SpidersAnimals described in the 1900s20th century]]
['descriptionparent1'] = 'formal', --'Description[[Category:Animals tbd;by decade;year containerof category,formal etc....',description]]
['parent1parent2'] = 'centurySpecies', --[[Category:SpidersSpecies described in the 20th century]]
['parent2description'] = 'Animals', --[[Category:AnimalsCentury describeddescription intbd; thecontainer 1900s]]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...
},
},
--[[============================ Insects tree ============================]]
['Insects'] = { --"group"
['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:SpidersInsects described in the 20th century]]
['descriptionparent1'] = 'formal', --'Description[[Category:Insects tbd;by century;year containerof category,formal etc....',description]]
['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...
},
},
 
['PlantsBeetles'] = { --group"subgroup" to Insects
['year'] = { --[[Category:Beetles described in 1901]]
['yearmin'] = 1753, --integer; lowest possible year (and thus decade) displayed in nav bars; 0/nil defaults to 1758 per ICZN Art. 5
['yearparent1'] = { 'century', --[[Category:PlantsBeetles described in 1901the 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'] = 1758, --integer; lowest possible year (and thus decade) 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
['yearmin'] = 1758, --integer; lowest possible year (and thus decade) displayed in nav bars; 0/nil defaults to 1758 per ICZN Art. 5
['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...
},
},
--[[============================= 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'] = 1758, --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]]
['parent1'] = 'century', --[[Category:Plants described in the 1900s]]
['parent2'] = 'Species', --[[Category:Species described in 1900]]
},
['century'] = { --[[Category:Plants 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]]
['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'] = {
['year'] = { --[[Category:Species described in 1901]]
['parent1'] = 'century', --[[Category:Species described in the 20th century]]
['sortkey1'] = ' ',
['parent2'] = 'Taxa', --[[Category:Taxa described in 1901]]
['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]]
['description'] = "*'''[[Species]]''' of [[Biota (taxonomy)|biota]] described in the '''[[%century% century]]'''.", --taken from [[Category:Species described in the 19th century]] & [[Category:Species described in the 20th century]]
},
},
--[[===================== "Taxa described in"-level ======================]]
---Include [[Category:1890 in the environment]]-type cats, which were removed from ~34/~260 [[Category:Species described in 1868]]-type cats
---and 'in science' & 'in biology'
}
 
Line 164 ⟶ 343:
end --if currQID then
--[[======================================================================]]
--[[ Main ]]
--[[======================================================================]]
if currCat then
--determine current/related/adjacent cats' properties/vars/etc.
local currGroup = mw.ustring.match(currCat, '^%w+') --FishBacteria/Spiders/defaultPlants/etc.
if conf[currGroup] == nil then conf[currGroup] = conf['FishDefault'] end --'Fish'default ==to defaultDefault
local currYDC = nil --possible future values: year/decade/century
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 parentDeca = nil --used with currYear (i.e. Spiders) & currDeca (i.e. Spiders)
local parentCent = nil --used with currYear (i.e. Fish) & currDeca (i.e. Spiders)
local lastCent, nextCent = nil, nil --used with currYear (i.e. Fish) & currCent (i.e. Fish)
local minYear = tonumber(conf[currGroup].yearmin)
if (minYear == nil or (minYear and minYear <= 1700)) then
Line 204 ⟶ 386:
--conf error checkng (missing keys)
--Numeric sortkeys are unfortunately grouped together under "0-9".
--Check phab T203355 (Magic word to force category number headings instead of 0-9).
if bConfError == false then
if conf[currGroup] == nil then
bConfError = true
trackingCategories[2] = '[[Category:Described in year error|1]]' --group (e.g. 'Fish', 'Spiders', Bacteria/Plants/etc.) key missing from conf
elseif conf[currGroup][currYDC] == nil then
bConfError = true
Line 227 ⟶ 411:
description = conf[currGroup][currYDC].description
if mw.ustring.match(description, '%%year%%') then
if currYear then description = mw.ustring.gsub(description, '%%year%%', currYear) --"20012011"
else description = mw.ustring.gsub(description, '%%year%%', 'this year') end
end
if mw.ustring.match(description, '%%decade%%') then
if currDeca then description = mw.ustring.gsub(description, '%%decade%%', currDeca .. 's') --"2000s2010s"
else description = mw.ustring.gsub(description, '%%decade%%', 'this decade') end
end
Line 248 ⟶ 432:
local iparent = 1
local parenti = 'parent' .. iparent
local sortkeyi = 'sortkey' .. iparent
while conf[currGroup][currYDC][parenti] do
local parent = conf[currGroup][currYDC][parenti]
local sortkey = conf[currGroup][currYDC][sortkeyi]
if currYDC == 'year' then
if nav == nil then
local args = { yearlinkcatifexists2 = currYear, min = minYear, cat = currGroup .. ' described inyes' }
nav = frame:expandTemplate{ title = 'Category in yearNavseasoncats', args = args }
end
if parent == 'decade' then
if sortkey == nil then sortkey = currYear end --default to currYear
categories[iparent] = '[[Category:' .. currGroup .. ' described in the ' .. parentDeca .. 's]]'
categories[iparent] = '[[Category:'..currGroup..' described in the '..parentDeca..'s|'..sortkey..']]'
elseif parent == 'century' then
if sortkey == nil then sortkey = currYear end --default to currYear
categories[iparent] = '[[Category:' .. currGroup .. ' described in the ' .. addOrd(parentCent) .. ' century]]'
categories[iparent] = '[[Category:'..currGroup..' described in the '..addOrd(parentCent)..' century|'..sortkey..']]'
elseif mw.ustring.match(parent, '^%u%l') then --i.e. Animals
elseif mw.ustring.match(parent, '^%u%l') then --e.g. Animals/Insects
categories[iparent] = '[[Category:' .. parent .. ' described in ' .. currYear .. ']]'
if sortkey == nil then sortkey = '' --default to none
else sortkey = '|'..sortkey end
categories[iparent] = '[[Category:'..parent..' described in '..currYear..sortkey..']]'
else
trackingCategories[2] = '[[Category:Described in year error|Y]]' --invalid year-parent
Line 273 ⟶ 463:
end
if parent == 'century' then
if sortkey == nil then sortkey = currDeca end --default to currDeca
categories[iparent] = '[[Category:' .. currGroup .. ' described in the ' .. addOrd(parentCent) .. ' century]]'
categories[iparent] = '[[Category:'..currGroup..' described in the '..addOrd(parentCent)..' century|'..sortkey..']]'
elseif mw.ustring.match(parent, '^%u%l') then --i.e. Animals
elseif mw.ustring.match(parent, '^%u%l') then --e.g. Animals/Insects
categories[iparent] = '[[Category:' .. parent .. ' described in the ' .. currDeca .. 's]]'
if sortkey == nil then sortkey = '' --default to none
else sortkey = '|'..sortkey end
categories[iparent] = '[[Category:'..parent..' described in the '..currDeca..'s'..sortkey..']]'
else
trackingCategories[2] = '[[Category:Described in year error|D]]' --invalid decade-parent
Line 288 ⟶ 481:
end
if parent == 'formal' then
categories[iparent]if sortkey == '[[Category:'nil ..then currGroupsortkey .. ' by year of formal description|' ..= addOrd(currCent) ..end ']]'--default to currCent
categories[iparent] = '[[Category:'..currGroup..' by year of formal description|'..sortkey..']]'
elseif mw.ustring.match(parent, '^%u%l') then --i.e. Animals
elseif mw.ustring.match(parent, '^%u%l') then --e.g. Animals/Insects
categories[iparent] = '[[Category:' .. parent .. ' described in the ' .. addOrd(currCent) .. ' century]]'
if sortkey == nil then sortkey = '' --default to none
else sortkey = '|'..sortkey end
categories[iparent] = '[[Category:'..parent..' described in the '..addOrd(currCent)..' century'..sortkey..']]'
else
trackingCategories[2] = '[[Category:Described in year error|C]]' --invalid century-parent
Line 301 ⟶ 497:
iparent = iparent + 1
parenti = 'parent' .. iparent
sortkeyi = 'sortkey' .. iparent
end --while conf[currGroup][currYDC][parenti] do
end --if bConfError == false then
Line 318 ⟶ 515:
if nav then header = nav end
if commons then header = header .. commons end
if description and description ~= '' then header = header .. '<br />' .. description end
if toc then header = header .. '<br />' .. toc end
header = mw.text.trim(header)