Content deleted Content added
Tom.Reding (talk | contribs) m -something |
Tom.Reding (talk | contribs) Mini working example for Fish cats |
||
Line 1:
require('Module:No globals')
local map = {
['Fish'] = { --group
['year'] = { --smallest branch, [[Category:Fish described in 1901]]
['parent1'] = 'century', --'year', 'decade', 'century'
['parent2'] = 'Animals', --[[Category:Animals described in the 20th century]]
},
['century'] = { --parent branch, [[Category:Fish described in the 20th century]]
['parent1'] = 'formal', --[[Category:Fish by year of formal description]]
['parent2'] = 'Animals', --[[Category:Animals described in the 20th century]]
},
},
}
local p = {}
Line 10 ⟶ 23:
if currentTitle.namespace == 14 then --Category:
--determine current cat's properties
local
local group = mw.ustring.match(cat, '^%w+')▼
local
local
local currCent = mw.ustring.match(currCat, 'the (%d+)[snrt][tdh] century')
if currYear then currYDC = 'year' end
if currCent then currYDC = 'century' end
local parentCent = ''
local ord = ''
if
if
local lastd = mw.ustring.match(
if lastd == 1 then ord = 'st'
elseif lastd == 2 then ord = 'nd'
Line 23 ⟶ 42:
else ord = 'th' end
end
if group and group == 'Fish' then▼
local iparent = 1
categories[1] = '[[Fish described in the ' .. century .. ord .. ' century]]' ..▼
local parenti = 'parent' .. iparent
'[[Animals described in ' .. year .. ']]'▼
while currYDC and map[currGroup][currYDC][parenti] do
if map[currGroup][currYDC][parenti] == 'century' then
categories[iparent] = '[[:Category:' .. currGroup .. ' described in the ' .. parentCent .. ord .. ' century]]'
end
if map[currGroup][currYDC][parenti] == 'Animals' then
end
elseif currYDC == 'decade' then
elseif currYDC == 'century' then
if map[currGroup][currYDC][parenti] == 'formal' then
categories[iparent] = '[[:Category:' .. currGroup .. ' by year of formal description|' .. currCent .. ord .. ']]'
end
if map[currGroup][currYDC][parenti] == 'Animals' then
▲ categories[
end
end
iparent = iparent + 1
parenti = 'parent' .. iparent
end
elseif currentTitle.namespace == 10 then --Module:/Template: sandbox/testcases/doc
end
outString = header .. outString
if string.sub(currentTitle.subpageText,1,9) == 'testcases' then
outString = outString .. mw.text.nowiki(table.concat(categories)) .. '<br />'
elseif currentTitle.namespace == 14 then --Category:
outString =
else
outString = ''
|