Module:Category described in year: Difference between revisions

Content deleted Content added
m Rem unnecessary <br />, from sandbox
Implement Category:Described in year unknown category, --ce, from sandbox
Line 8:
'Spiders' use year -> decade -> century.
Any category group (i.e. Birds/Crustaceans/Molluscs/etc.) NOT explicitly outlined here in map{} will follow the 'Fish' tree for that group.
To create a customized tree, like 'Spiders' below, add it to the bottom of the map{} table, following the same general table format.
Line 56:
elseif lastd == '3' then return s..'rd'
elseif lastd ~= nil then return s..'th'
else return '' end
else
return ''
end
return ''
end
 
Line 70 ⟶ 69:
local description = nil
local categories = {}
local trackingCategories = {
[1] = '' --placeholder for [[Category:Described in year unknown category]]
}
local outString = nil
Line 166 ⟶ 168:
iparent = iparent + 1
parenti = 'parent' .. iparent
end --end while map[currGroup][currYDC][parenti]
end
--TODO: check for cat existence & output to tracking category if template attempts to link to a non-existing cat
for _, category in pairs(categories) do
local cat = mw.ustring.match(category, '%[%[Category:([%w%s]+)')
if mw.title.new(cat, 14).exists == false then
trackingCategories[1] = '[[Category:Described in year unknown category]]'
break
end
end
end
Line 182 ⟶ 191:
--append cats to outString
if currentTitle.namespace == 14 then --Category:
outString = outString .. table.concat(categories) .. table.concat(trackingCategories)
else
outString = outString .. '<br />' ..
mw.ustring.gsub(table.concat(categories, '<br />'), '%[%[', '[[:') .. '<br />' ..
mw.ustring.gsub(table.concat(trackingCategories, '<br />'), '%[%[', '[[:') .. '<br />'
end