Module:Category described in year: Difference between revisions

Content deleted Content added
Allow sandbox/testcase usage, from sandbox
Make 'Fish' the default cat tree; prep for alpha (Fish only); from sandbox
Line 3:
--case sensitive conf/map table
local map = {
--[[
'Fish' is the default category tree (year -> century, no decades).
'Spiders' use year -> decade -> century.
Any category group (i.e. Birds/Crustaceans/Molluscs/etc.) NOT explicitly outlined here in map{} will follow the 'Fish' tree.
To create a customized tree, like 'Spiders' below, add it to the bottom of the map{} table, following the same general table format.
]]--
['Fish'] = { --group
['min'] = 1758, --integer; lowest possible year (and thus decade) displayed in nav bars; default to 1758 per ICZN Art. 5
['year'] = { --[[Category:Fish described in 1901]]
['description'] = '', --'Description tbd; year; This category should only contain species articles, etc....',
['parent1'] = 'century', --year/decade/century/formal, i.e. 'century' for [[Category:Fish described in the 20th century]]
['parent2'] = 'Animals', --[[Category:Animals described in the 20th century]]
},
['century'] = { --[[Category:Fish described in the 20th century]]
['description'] = '', --'Description tbd; century; container category, etc....',
['parent1'] = 'formal', --[[Category:Fish by year of formal description]]
['parent2'] = 'Animals', --[[Category:Animals described in the 20th century]]
},
},
['Spiders'] = { --group
['min'] = 1757, --integer; lowest possible year (and thus decade) displayed in nav bars; default to 1758 per ICZN Art. 5
['year'] = { --[[Category:Spiders described in 1901]]
['description'] = '', --'Description tbd; year; This category should only contain species articles, etc....',
['parent1'] = 'decade', --[[Category:Spiders described in the 1900s]]
['parent2'] = 'Animals', --[[Category:Animals described in 1900]]
},
['decade'] = { --[[Category:Spiders described in the 1900s]]
['description'] = '', --'Description tbd; decade; container category, etc....',
['parent1'] = 'century', --[[Category:Spiders described in the 20th century]]
['parent2'] = 'Animals', --[[Category:Animals described in the 1900s]]
},
['century'] = { --[[Category:Spiders described in the 20th century]]
['description'] = '', --'Description tbd; century; container category, etc....',
['parent1'] = 'formal', --[[Category:Spiders by year of formal description]]
['parent2'] = 'Animals', --[[Category:Animals described in the 20th century]]
Line 60 ⟶ 72:
local outString = nil
if--prelim currentTitle.namespace/title == 14 or --Category:determination
local currCat = nil
if currentTitle.namespace == 1014 then --ModuleCategory:/Template: sandbox/testcases/doc
currCat = currentTitle.text --without namespace nor interwiki prefixes
--prelim cat/mod/temp housekeeping
else
local currCat = nil
--accept 1 unnamed category parameter if not in Category: space; required for testing/doc/etc purposes only
if currentTitle.namespace == 14 then
local parentArg = frame:getParent().args[1]
currCat = currentTitle.text --without namespace nor interwiki prefixes
if parentArg then currCat = mw.ustring.gsub(parentArg, 'Category:', '')
else
else return end
--accept 1 unnamed category parameter; required for testing/doc purposes only
end
local parentArg = frame:getParent().args[1]
if parentArg then currCat = mw.ustring.gsub(parentArg, 'Category:', '')
if currCat then
else return end
end
--determine current/related/adjacent cats' properties/vars/etc
local currGroup = mw.ustring.match(currCat, '^%w+') --Fish/Spiders/default/etc.
if map[currGroup] == nil then map[currGroup] = map['Fish'] end --'Fish' == default
local currYDC = nil --placeholder for year/decade/century
local currYear = mw.ustring.match(currCat, 'in (%d%d%d%d)$')
Line 170 ⟶ 181:
--append cats to outString
if currentTitle.namespace == 1014 then --ModuleCategory:/Template: sandbox/testcases/doc
outString = outString .. '<br />' .. mw.ustring.gsub(table.concat(categories, '<br />'), '%[%[', '[[:') .. '<br />'
elseif currentTitle.namespace == 14 then --Category:
outString = outString .. table.concat(categories)
else
outString = outString .. '<br />' .. mw.ustring.gsub(table.concat(categories, '<br />'), '%[%[', '[[:') .. '<br />'
outString = ''
end