Content deleted Content added
Tom.Reding (talk | contribs) +default 'formal'-level tree (front-end) |
Tom.Reding (talk | contribs) Prelim implement formal cat section |
||
Line 428:
--determine current/related/adjacent cats' properties/vars/etc.
local currGroup = mw.ustring.match(currCat, '^([%w ]+) (?:described in|by year of formal description)') --Bacteria/Plants/etc.
if conf[currGroup] == nil then conf[currGroup] = conf['Default'] end --default to Default
local
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 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
Line 441 ⟶ 442:
end
if currYear then
parentDeca = mw.ustring.match(currYear, '^(%d%d%d)%d$') .. '0'
if mw.ustring.match(currYear, '^%d%d00') then --1900 in 19th century
Line 451 ⟶ 452:
nextCent = parentCent + 1
elseif currDeca then
parentDeca = mw.ustring.match(currDeca, '^(%d%d%d)%d$') .. '0'
parentCent = mw.ustring.match(parentDeca, '^%d%d') + 1
elseif currCent then
lastCent = currCent - 1
nextCent = currCent + 1
elseif currFrml then
currYDCF = 'formal'
else
bConfError = true
Line 470 ⟶ 473:
bConfError = true
trackingCategories[2] = '[[Category:Described in year error|1]]' --group (Bacteria/Plants/etc.) key missing from conf
elseif conf[currGroup][
bConfError = true
trackingCategories[2] = '[[Category:Described in year error|2]]' --year/decade/century/formal key missing
else
if conf[currGroup][
bConfError = true
trackingCategories[2] = '[[Category:Described in year error|3]]' --description key missing
end
if conf[currGroup][
bConfError = true
trackingCategories[2] = '[[Category:Described in year error|4]]' --parent key missing
Line 492 ⟶ 495:
--produce description
description = conf[currGroup][
if mw.ustring.match(description, '%%year%%') then
if currYear then description = mw.ustring.gsub(description, '%%year%%', currYear) --"2011"
Line 516 ⟶ 519:
local parenti = 'parent' .. iparent
local sortkeyi = 'sortkey' .. iparent
while conf[currGroup][
local parent = conf[currGroup][
local sortkey = conf[currGroup][
--[[========================== Year ==========================]]
if
if nav == nil then
local args = { min = minYear }
Line 557 ⟶ 560:
--[[================== Decade (deprecated) ===================]]
elseif
if nav == nil then
nav = frame:expandTemplate{ title = 'Container category' }
Line 575 ⟶ 578:
--[[======================== Century =========================]]
elseif
if nav == nil then
nav = frame:expandTemplate{ title = 'Container category' }
local args = { currGroup .. ' described in the ' .. addOrd(lastCent) .. ' century',
nav = nav .. frame:expandTemplate{ title = 'Category pair', args = args }
end
Line 593 ⟶ 596:
categories[iparent] = '[[Category:'..addOrd(currCent)..' century in biology'..sortkey..']]' --if/when all biology cats exists, merge this elseif with 'paleontology'
end
elseif
if isNilOrEmpty(sortkey) then sortkey = '' --default to none
else sortkey = '|'..sortkey end
Line 608 ⟶ 611:
trackingCategories[2] = '[[Category:Described in year error|C]]' --invalid century-parent
end
--[[======================== Formal ==========================]]
elseif currYDCF == 'formal' then
if nav == nil then
nav = frame:expandTemplate{ title = 'Container category' }
end
if parent == 'Group' then
if isNilOrEmpty(sortkey) then sortkey = ' Year' end --default to " Year"
categories[iparent] = '[[Category:'..currGroup..' by year of formal description|'..sortkey..']]'
elseif parent == 'Animals' or parent == 'Insects' or parent == 'Molluscs' then
if isNilOrEmpty(sortkey) then sortkey = ' ' end --default to " "
categories[iparent] = '[[Category:'..currGroup..' by year of formal description|'..sortkey..']]'
elseif parent == 'Species' then
if isNilOrEmpty(sortkey) then sortkey = '' --default to none
else sortkey = '|'..sortkey end
categories[iparent] = '[[Category:'..currGroup..' by year of formal description'..sortkey..']]'
else
trackingCategories[2] = '[[Category:Described in year error|F]]' --invalid formal-parent
end
--[[========================= Error ==========================]]
else
trackingCategories[2] = '[[Category:Described in year error|U]]' --unknown configuration
Line 616 ⟶ 639:
parenti = 'parent' .. iparent
sortkeyi = 'sortkey' .. iparent
end --while conf[currGroup][
end --if bConfError == false then
|