Module:Category described in year: Difference between revisions

Content deleted Content added
+formal.parent: 'paleontology' (technically only 1 use in Category:Fossil taxa by year of formal description, but included for continuity/consistency with year & century cats)
Fully deprecate decade cats; tighten minYear constraint (must be b/w 1700-2000); allow 'Fossil taxa' parents, for use on 'Fossil parataxa' children; from sandbox
Line 133:
local currYDCF = 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$') --deprecated
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].minyear)
if (minYear == nil or
(minYear and (minYear <= 1700 or minYear >= 2000)) then
minYear = 1758 --default to 1758 per ICZN Art. 5
end
if currYear then
currYDCF = '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 154:
elseif currDeca then
currYDCF = 'decade'
bConfError = true
parentDeca = mw.ustring.match(currDeca, '^(%d%d%d)%d$') .. '0'
trackingCategories[2] = '[[Category:Described in year error|D]]' --invalid decade-parent (deprecated)
parentCent = mw.ustring.match(parentDeca, '^%d%d') + 1
elseif currCent then
currYDCF = 'century'
Line 176:
elseif conf[currGroup][currYDCF] == nil then
bConfError = true
trackingCategories[2] = '[[Category:Described in year error|2]]' --year/decade/century/formal key missing
else
if conf[currGroup][currYDCF].description == nil then
Line 191:
if bConfError == false then
--produce portal
if currGroup == 'Fossil taxa' or currGroup == 'Fossil parataxa' then
portal = frame:expandTemplate{ title = 'Portal', args = { 'Paleontology' } }
end
--produce description, evaluate %variables%
description = conf[currGroup][currYDCF].description
if mw.ustring.match(description, '%%year%%') then
if currYear then description = mw.ustring.gsub(description, '%%year%%', currYear) --"2011"
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') --"2010s"
else description = mw.ustring.gsub(description, '%%decade%%', 'this decade') end
end
if mw.ustring.match(description, '%%century%%') then
Line 230 ⟶ 226:
nav = frame:expandTemplate{ title = 'Navseasoncats', args = args }
end
if parent == 'decadecentury' then
if isNilOrEmpty(sortkey) then sortkey = currYear end --default to currYear
categories[iparent] = '[[Category:'..currGroup..' described in the '..parentDeca..'s|'..sortkey..']]'
elseif parent == 'century' then
if isNilOrEmpty(sortkey) then sortkey = currYear end --default to currYear
categories[iparent] = '[[Category:'..currGroup..' described in the '..addOrd(parentCent)..' century|'..sortkey..']]'
Line 252 ⟶ 245:
else sortkey = '|'..sortkey end
categories[iparent] = '[[Category:'..currYear..' in the environment'..sortkey..']]'
elseif mw.ustring.match(parent, '^%u[%l ]+') then --e.g. Animals/Insects/Fossil taxa
if isNilOrEmpty(sortkey) then sortkey = '' --default to none
else sortkey = '|'..sortkey end
Line 258 ⟶ 251:
else
trackingCategories[2] = '[[Category:Described in year error|Y]]' --invalid year-parent
end
--[[================== Decade (deprecated) ===================]]
elseif currYDCF == 'decade' then
if nav == nil then
nav = frame:expandTemplate{ title = 'Container category' }
local args = { decade = currDeca, min = minYear, cat = currGroup .. ' described in the' }
nav = frame:expandTemplate{ title = 'Category by decade', args = args }
end
if parent == 'century' then
if isNilOrEmpty(sortkey) then sortkey = currDeca end --default to currDeca
categories[iparent] = '[[Category:'..currGroup..' described in the '..addOrd(parentCent)..' century|'..sortkey..']]'
elseif mw.ustring.match(parent, '^%u%l') then --e.g. Animals/Insects
if isNilOrEmpty(sortkey) 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
end
Line 305 ⟶ 280:
else sortkey = '|'..sortkey end
categories[iparent] = '[[Category:'..addOrd(currCent)..' century in the environment'..sortkey..']]'
elseif mw.ustring.match(parent, '^%u[%l ]+') then --e.g. Animals/Insects/Fossil taxa
if isNilOrEmpty(sortkey) then sortkey = '' --default to none
else sortkey = '|'..sortkey end
Line 324 ⟶ 299:
if isNilOrEmpty(sortkey) then sortkey = ' ' end --default to " "
categories[iparent] = '[[Category:'..parent..' by year of formal description|'..sortkey..']]'
elseif parent == 'Species' or parent == 'Taxa' or parent == 'Fossil taxa' then
if isNilOrEmpty(sortkey) then sortkey = '' --default to none
else sortkey = '|'..sortkey end