Module:Category described in year: Difference between revisions

Content deleted Content added
m fix
Proper error checking, from sandbox
Line 94:
}
local outString = nil
local bConfError = false
--prelim namespace/title determination
Line 198 ⟶ 199:
nextCent = currCent + 1
else
bConfError = true
trackingCategories[2] = '[[Category:Described in year error|N]]' --invalid category name
end
--conf error checkng (missing keys)
--produce description & toc
if currYDCbConfError == false then
if conf[currGroup][currYDC]['description'] == nil then
bConfError = true
description = conf[currGroup][currYDC].description
trackingCategories[2] = '[[Category:Described in year error|T1]]' --nullgroup description(e.g. text'Fish', 'Spiders', etc.) key missing from conf
if mw.ustring.match(description, '%%year%%') then
elseif conf[currGroup][currYDC] == nil then
if currYear then description = mw.ustring.gsub(description, '%%year%%', currYear) --"2001"
bConfError = true
else description = mw.ustring.gsub(description, '%%year%%', 'this year') end
trackingCategories[2] = '[[Category:Described in year error|2]]' --year/decade/century key missing
else
if conf[currGroup][currYDC].description == nil then
bConfError = true
trackingCategories[2] = '[[Category:Described in year error|3]]' --description key missing
end
if conf[currGroup][currYDC].parent1 == nil then
if mw.ustring.match(description, '%%decade%%') then
bConfError = true
if currDeca then description = mw.ustring.gsub(description, '%%decade%%', currDeca .. 's') --"2000s"
trackingCategories[2] = '[[Category:Described in year error|4]]' --parent key missing
else description = mw.ustring.gsub(description, '%%decade%%', 'this decade') end
end
end
if mw.ustring.match(description, '%%century%%') then
end
if currCent then description = mw.ustring.gsub(description, '%%century%%', addOrd(currCent)) --"21st"
else description = mw.ustring.gsub(description, '%%century%%', 'this century') end
--produce description & toc
end
if bConfError == false then
if mw.site.stats.pagesInCategory(currCat, 'pages') >= conf['tocmin'] then --expensive
description = conf[currGroup][currYDC].description
local args = { numerals = 'no' }
if mw.ustring.match(description, '%%year%%') then
toc = frame:expandTemplate{ title = 'Category TOC', args = args }
if currYear then description = mw.ustring.gsub(description, '%%year%%', currYear) --"2001"
end
else description = mw.ustring.gsub(description, '%%year%%', 'this year') end
else
end
trackingCategories[2] = '[[Category:Described in year error|T]]' --null description text
if mw.ustring.match(description, '%%decade%%') then
if currDeca then description = mw.ustring.gsub(description, '%%decade%%', currDeca .. 's') --"2000s"
else description = mw.ustring.gsub(description, '%%decade%%', 'this decade') end
end
if mw.ustring.match(description, '%%century%%') then
if currCent then description = mw.ustring.gsub(description, '%%century%%', addOrd(currCent)) --"21st"
else description = mw.ustring.gsub(description, '%%century%%', 'this century') end
end
if mw.site.stats.pagesInCategory(currCat, 'pages') >= conf['tocmin'] then --expensive
local args = { numerals = 'no' }
toc = frame:expandTemplate{ title = 'Category TOC', args = args }
end
end
--produce cats & navs
if currYDCbConfError == false then
local iparent = 1
local parenti = 'parent' .. iparent
Line 284 ⟶ 302:
parenti = 'parent' .. iparent
end --while conf[currGroup][currYDC][parenti] do
end --if currYDCbConfError == false then
--check for non-existent cats