Module:Category described in year: Difference between revisions

Content deleted Content added
Add description field to year/decade/century cats, add header & nav template(s) from current fish cats
+Spiders tree (uses decades), add header & nav template(s) from current spider cats
Line 5:
['Fish'] = { --group
['year'] = { --[[Category:Fish described in 1901]]
['description'] = 'tbd; year; This category should only contain species articles, etc....',
['parent1'] = 'century', --year/decade/century, 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'] = '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
['year'] = {
['description'] = 'tbd; year; This category should only contain species articles, etc....',
['parent1'] = 'decade',
['parent2'] = 'Animals',
},
['decade'] = {
['description'] = 'tbd; decade; container category, etc....',
['parent1'] = 'century',
['parent2'] = 'Animals',
},
['century'] = {
['description'] = 'tbd; century; container category, etc....',
['parent1'] = 'formal',
['parent2'] = 'Animals',
},
},
Line 37 ⟶ 54:
local nav = nil
local description = nil
local header = ' ' --will contain header template(s), nav bar, and category description text
local categories = {}
local outString = nil
if currentTitle.namespace == 14 then --Category:
--determine current/related/adjacent catcats's properties
local currCat = currentTitle.text --without namespace nor interwiki prefixes
local currGroup = mw.ustring.match(currCat, '^%w+') --Fish/Spiders/etc.
local currYDC = '' --placeholder for year/decade/century
local currYear = mw.ustring.match(currCat, 'in (%d%d%d%d)$')
local currDeca = mw.ustring.match(currCat, 'the (%d%d%d%d)s$')
local currCent = mw.ustring.match(currCat, 'the (%d+)[snrt][tdh] century')
local parentCent = nil --only used whenwith currYear (i.e. Fish) & currDeca (i.e. Spiders)
local lastCent, nextCentparentDeca = nil, nil --used with currYear and(i.e. Spiders) & currDeca (i.e. currCentSpiders)
local lastCent, nextCent = nil, nil --used with currYear (i.e. Fish) & currCent (i.e. Fish)
if currYear then
currYDC = 'year'
parentDeca = mw.ustring.match(currYear, '^(%d%d%d)%d$') .. '0'
if mw.ustring.match(currYear, '^%d%d00') then --1900 in 19th century
parentCent = mw.ustring.match(currYear, '^%d%d')
Line 60 ⟶ 80:
nextCent = parentCent + 1
elseif currDeca then
elseif parentcurrYDC == 'decade' then
parentDeca = mw.ustring.match(currDeca, '^(%d%d%d)%d$') .. '0'
parentCent = mw.ustring.match(parentDeca, '^%d%d') + 1
elseif currCent then
currYDC = 'century'
Line 69 ⟶ 91:
end
--produce cats & navs
local iparent = 1
local parenti = 'parent' .. iparent
Line 84 ⟶ 106:
nav = frame:expandTemplate{ title = 'Category in year', args = args }
end
if parent == 'centurydecade' then
categories[iparent] = '[[:Category:' .. currGroup .. ' described in the ' .. parentDeca .. 's]]'
if parent == 'century' then
elseif parent == 'century' then
categories[iparent] = '[[:Category:' .. currGroup .. ' described in the ' .. addOrd(parentCent) .. ' century]]'
elseif parent == 'decade' then
else --i.e. Animals; require capital first letter?
categories[iparent] = '[[:Category:' .. parent .. ' described in ' .. currYear .. ']]'
end
elseif currYDC == 'decade' then
if nav == nil then
local args = { decade = currDeca, cat = currGroup .. ' described in the' }
nav = frame:expandTemplate{ title = 'Category by decade', args = args }
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
elseif currYDC == 'century' then
if nav == nil then