Content deleted Content added
Tom.Reding (talk | contribs) Implement Category:Described in year configuration error for various errors; cat table length check |
Tom.Reding (talk | contribs) Category:Described in year error is more appropriate (some are config errors, some are template-placement/call errors), sortkey = error-type (*pats self on back*); wrap dependent code-chunks in 'if currYDC then' to allow trackingCategories to pass-through to end |
||
Line 96:
local trackingCategories = {
[1] = '', --placeholder for [[Category:Described in year unknown category]]
[2] = '', --placeholder for [[Category:Described in year
}
local outString = nil
Line 112:
currCat = mw.ustring.gsub(parentArg, 'Category:', '')
currQID = mw.wikibase.getEntityIdForTitle('Category:' .. currCat)
else --currQID & currCat both nil
else▼
trackingCategories[2] = '[[Category:Described in year
end
end
Line 158:
if conf[currGroup] == nil then conf[currGroup] = conf['Fish'] end --'Fish' == default
local currYDC = nil --year/decade/century
local currYear = mw.ustring.match(currCat, 'described in (%d%d%d%d)$')
local currDeca = mw.ustring.match(currCat, 'described the (%d%d%d%d)s$')
local currCent = mw.ustring.match(currCat, 'described the (%d+)[snrt][tdh] century$')
local parentDeca = nil --used with currYear (i.e. Spiders) & currDeca (i.e. Spiders)
local parentCent = nil --used with currYear (i.e. Fish) & currDeca (i.e. Spiders)
Line 187:
nextCent = currCent + 1
else
trackingCategories[2] = '[[Category:Described in year error|N]]' --invalid category name
end
--produce description & toc
if currYDC then
description = conf[currGroup][currYDC].description if mw.ustring.match(description, '%%year%%') then
if currYear then description = mw.ustring.gsub(description, '%%year%%', currYear)
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') --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
local iparent = 1▼
local iparent = 1
local parenti = 'parent' .. iparent while conf[currGroup][currYDC][parenti] do
local parent = conf[currGroup][currYDC][parenti]
▲ if currYDC == 'year' then
if nav == nil then▼
local args = { year = currYear, min = minYear, cat = currGroup .. ' described in' }▼
nav = frame:expandTemplate{ title = 'Category in year', args = args }▼
end▼
if parent == 'decade' then▼
categories[iparent] = '[[Category:' .. currGroup .. ' described in the ' .. parentDeca .. 's]]'▼
elseif parent == 'century' then▼
categories[iparent] = '[[Category:' .. currGroup .. ' described in the ' .. addOrd(parentCent) .. ' century]]'▼
elseif mw.ustring.match(parent, '^%u%l') then --i.e. Animals▼
categories[iparent] = '[[Category:' .. parent .. ' described in ' .. currYear .. ']]'▼
else▼
end▼
if nav == nil then
▲ local args = { year = currYear, min = minYear, cat = currGroup .. ' described in' }
nav = frame:expandTemplate{ title = 'Container category' }▼
▲ nav = frame:expandTemplate{ title = 'Category in year', args = args }
local args = { decade = currDeca, min = minYear, cat = currGroup .. ' described in the' }▼
▲ end
nav = frame:expandTemplate{ title = 'Category by decade', args = args }▼
▲ if parent == 'decade' then
end▼
▲ categories[iparent] = '[[Category:' .. currGroup .. ' described in the ' .. parentDeca .. 's]]'
if parent == 'century' then▼
▲ elseif parent == 'century' then
categories[iparent] = '[[Category:' .. currGroup .. ' described in the ' .. addOrd(parentCent) .. ' century]]'▼
▲ categories[iparent] = '[[Category:' .. currGroup .. ' described in the ' .. addOrd(parentCent) .. ' century]]'
elseif mw.ustring.match(parent, '^%u%l') then --i.e. Animals▼
▲ elseif mw.ustring.match(parent, '^%u%l') then --i.e. Animals
categories[iparent] = '[[Category:' .. parent .. ' described in the ' .. currDeca .. 's]]'▼
▲ categories[iparent] = '[[Category:' .. parent .. ' described in ' .. currYear .. ']]'
else▼
trackingCategories[2] = '[[Category:Described in year error|Y]]' --invalid year-parent
▲ end
▲ 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
▲ categories[iparent] = '[[Category:' .. currGroup .. ' described in the ' .. addOrd(parentCent) .. ' century]]'
▲ elseif mw.ustring.match(parent, '^%u%l') then --i.e. Animals
▲ categories[iparent] = '[[Category:' .. parent .. ' described in the ' .. currDeca .. 's]]'
▲ else
trackingCategories[2] = '[[Category:Described in year error|D]]' --invalid decade-parent
if nav == nil then
nav = frame:expandTemplate{ title = 'Container category' }▼
local args = { currGroup .. ' described in the ' .. addOrd(lastCent) .. ' century',▼
currGroup .. ' described in the ' .. addOrd(nextCent) .. ' century' }▼
nav = nav .. frame:expandTemplate{ title = 'Category pair', args = args }▼
end▼
if parent == 'formal' then
categories[iparent] = '[[Category:' .. currGroup .. ' by year of formal description|' .. addOrd(currCent) .. ']]'▼
elseif mw.ustring.match(parent, '^%u%l') then --i.e. Animals▼
categories[iparent] = '[[Category:' .. parent .. ' described in the ' .. addOrd(currCent) .. ' century]]'▼
▲ else
trackingCategories[2] = '[[Category:Described in year error|C]]' --invalid century-parent
end▼
end
▲ elseif currYDC == 'century' then
▲ nav = frame:expandTemplate{ title = 'Container category' }
end --if currYDC then
▲ local args = { currGroup .. ' described in the ' .. addOrd(lastCent) .. ' century',
▲ currGroup .. ' described in the ' .. addOrd(nextCent) .. ' century' }
▲ nav = nav .. frame:expandTemplate{ title = 'Category pair', args = args }
▲ end
▲ if parent == 'formal' then
▲ categories[iparent] = '[[Category:' .. currGroup .. ' by year of formal description|' .. addOrd(currCent) .. ']]'
▲ elseif mw.ustring.match(parent, '^%u%l') then --i.e. Animals
▲ categories[iparent] = '[[Category:' .. parent .. ' described in the ' .. addOrd(currCent) .. ' century]]'
▲ end
▲ end
▲ end --end while conf[currGroup][currYDC][parenti]
for _, category in pairs(categories) do
|