Content deleted Content added
Tom.Reding (talk | contribs) min=1753 for plants per current cats |
Tom.Reding (talk | contribs) Automatically place {{Category TOC}} if cat size >= 'tocmin' (initially set to 401 since each cat page displays 200); rename 'map' table to 'conf' due to expanded scope; from sandbox |
||
Line 2:
--case sensitive conf/map table
local
--[[
Line 8:
'Spiders' use year -> decade -> century.
Any category group (i.e. Birds/Crustaceans/Molluscs/etc.) NOT explicitly outlined here in
To create a customized tree, like 'Spiders' below, add it to the bottom of the
]]--
['tocmin'] = 401, --integer; minimum category size to place {{Category TOC}} on
['Fish'] = { --group
Line 87 ⟶ 89:
local nav = nil
local description = nil
local toc = nil
local categories = {}
local trackingCategories = {
Line 107 ⟶ 110:
--determine current/related/adjacent cats' properties/vars/etc
local currGroup = mw.ustring.match(currCat, '^%w+') --Fish/Spiders/default/etc.
if
local currYDC = nil --year/decade/century
local currYear = mw.ustring.match(currCat, 'in (%d%d%d%d)$')
Line 115 ⟶ 118:
local parentCent = nil --used with currYear (i.e. Fish) & currDeca (i.e. Spiders)
local lastCent, nextCent = nil, nil --used with currYear (i.e. Fish) & currCent (i.e. Fish)
local minYear = tonumber(
if (minYear == nil or (minYear and minYear <= 1700)) then
minYear = 1758 --default to 1758 per ICZN Art. 5
Line 141 ⟶ 144:
end
--produce description & toc
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.site.stats.pagesInCategory(currCat, 'pages') >= conf['tocmin'] then --expensive
toc = frame:expandTemplate{ title = 'Category TOC' }
end
Line 151 ⟶ 157:
local iparent = 1
local parenti = 'parent' .. iparent
while
local parent =
if currYDC == 'year' then
Line 195 ⟶ 201:
iparent = iparent + 1
parenti = 'parent' .. iparent
end --end while
for _, category in pairs(categories) do
Line 207 ⟶ 213:
--produce header
--TODO: test/see if a similar commons cat exists and, if so, include it in the header
if nav then header = nav end
if description and description ~= '' then header = header .. '<br />' .. description end
header = mw.text.trim(header)
if toc then header = header .. '<br />' .. toc end
--append header to outString
|