Module:Category described in year: Difference between revisions

Content deleted Content added
m Style tweaks
Allow sandbox/testcase usage, from sandbox
Line 6:
['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]]
Line 19:
['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:
local outString = nil
if currentTitle.namespace == 14 thenor --Category:
elseif currentTitle.namespace == 10 then --Module:/Template: sandbox/testcases/doc
--prelim cat/mod/temp housekeeping
local currCat = nil
if currentTitle.namespace == 14 then
local currCat = currentTitle.text --without namespace nor interwiki prefixes
else
--accept 1 unnamed category parameter; required for testing/doc purposes only
local parentArg = frame:getParent().args[1]
if parentArg then currCat = mw.ustring.gsub(parentArg, 'Category:', '')
else return end
end
--determine current/related/adjacent cats' properties/vars/etc
local currCat = currentTitle.text --without namespace nor interwiki prefixes
local currGroup = mw.ustring.match(currCat, '^%w+') --Fish/Spiders/etc.
local currYDC = nil --placeholder for year/decade/century
Line 108 ⟶ 120:
end
if parent == 'decade' then
categories[iparent] = '[[:Category:' .. currGroup .. ' described in the ' .. parentDeca .. 's]]'
elseif parent == 'century' then
categories[iparent] = '[[:Category:' .. currGroup .. ' described in the ' .. addOrd(parentCent) .. ' century]]'
else --i.e. Animals; require capital first letter?
categories[iparent] = '[[:Category:' .. parent .. ' described in ' .. currYear .. ']]'
end
Line 122 ⟶ 134:
end
if parent == 'century' then
categories[iparent] = '[[:Category:' .. currGroup .. ' described in the ' .. addOrd(parentCent) .. ' century]]'
else --i.e. Animals; require capital first letter?
categories[iparent] = '[[:Category:' .. parent .. ' described in the ' .. currDeca .. 's]]'
end
Line 135 ⟶ 147:
end
if parent == 'formal' then
categories[iparent] = '[[:Category:' .. currGroup .. ' by year of formal description|' .. addOrd(currCent) .. ']]'
else --i.e. Animals; require capital first letter?
categories[iparent] = '[[:Category:' .. parent .. ' described in the ' .. addOrd(currCent) .. ' century]]'
end
end
Line 144 ⟶ 156:
parenti = 'parent' .. iparent
end
 
elseif currentTitle.namespace == 10 then --Module:/Template: sandbox/testcases/doc
--TODO: check for cat existence & output to tracking category if template attempts to link to a non-existing cat
end
--produce header
if nav then header = nav end
if description then header = header .. '\n\n<br />' .. description end
header = mw.text.trim(header)
Line 159 ⟶ 170:
--append cats to outString
if string.sub(currentTitle.subpageText,1,9)namespace == 'testcases'10 then --Module:/Template: sandbox/testcases/doc
outString = outString .. '<br />' .. mw.textustring.nowikigsub(table.concat(categories, '<br />'), '%[%[', '[[:') .. '<br />'
elseif currentTitle.namespace == 14 then --Category:
outString = outString .. table.concat(categories)