Module:Category described in year/sandbox: Difference between revisions

Content deleted Content added
t
Properly handle 'default to none' sortkeys
Line 269:
end
return ''
end
 
local function isNilOrEmpty( thing )
return (thing == nil or thing == '')
end
 
Line 464 ⟶ 468:
end
if parent == 'decade' then
if isNilOrEmpty(sortkey == nil) then sortkey = currYear end --default to currYear
categories[iparent] = '[[Category:'..currGroup..' described in the '..parentDeca..'s|'..sortkey..']]'
elseif parent == 'century' then
if isNilOrEmpty(sortkey == nil) then sortkey = currYear end --default to currYear
categories[iparent] = '[[Category:'..currGroup..' described in the '..addOrd(parentCent)..' century|'..sortkey..']]'
elseif parent == 'biology' then
if isNilOrEmpty(sortkey == nil) then sortkey = '' end --default to none
else sortkey = '|'..sortkey end
categories[iparent] = '[[Category:'..currYear..' in biology|'..sortkey..']]'
elseif parent == 'environment' then
if isNilOrEmpty(sortkey == nil) then sortkey = ' ' end --default to none
categories[iparent]else sortkey = '[[Category:2015 in the environment|'..sortkey..']]' end
categories[iparent] = '[[Category:'..currYear..' in the environment'..sortkey..']]'
elseif mw.ustring.match(parent, '^%u%l') then --e.g. Animals/Insects
if isNilOrEmpty(sortkey == nil) then sortkey = '' --default to none
else sortkey = '|'..sortkey end
categories[iparent] = '[[Category:'..parent..' described in '..currYear..sortkey..']]'
Line 490 ⟶ 496:
end
if parent == 'century' then
if isNilOrEmpty(sortkey == nil) 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 == nil) then sortkey = '' --default to none
else sortkey = '|'..sortkey end
categories[iparent] = '[[Category:'..parent..' described in the '..currDeca..'s'..sortkey..']]'
Line 508 ⟶ 514:
end
if parent == 'formal' then
if isNilOrEmpty(sortkey == nil) then sortkey = addOrd(currCent) end --default to currCent
categories[iparent] = '[[Category:'..currGroup..' by year of formal description|'..sortkey..']]'
elseif parent == 'biology' then
if isNilOrEmpty(sortkey == nil) then sortkey = '' end --default to none
categories[iparent]else sortkey = '[[Category:'..currCent..' in biology|'..sortkey..']]' end
categories[iparent] = '[[Category:'..addOrd(currCent)..' century in biology'..sortkey..']]'
elseif parent == 'environment' then
if isNilOrEmpty(sortkey == nil) then sortkey = '' end --default to none
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
if isNilOrEmpty(sortkey == nil) then sortkey = '' --default to none
else sortkey = '|'..sortkey end
categories[iparent] = '[[Category:'..parent..' described in the '..addOrd(currCent)..' century'..sortkey..']]'