Content deleted Content added
Tom.Reding (talk | contribs) Allow freeform formal-parents, as long as they exist (e.g. Category:Prehistoric life); from sandbox |
Tom.Reding (talk | contribs) Implement Category:Described in year with manual category, from sandbox |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 31:
function p.autodetect( frame )
local conf = require( 'Module:Category described in year/
local commonsLink = require('Module:Commons link')
local currentTitle = mw.title.getCurrentTitle()
Line 46:
[1] = '', --placeholder for [[Category:Described in year unknown category]]
[2] = '', --placeholder for [[Category:Described in year error]]
[3] = '', --placeholder for [[Category:Described in year with manual category]]
}
local outString = nil
Line 101 ⟶ 102:
local minYear = tonumber(conf[currGroup].minyear)
if minYear == nil or
(minYear and (minYear <= 1700 or minYear >= 2000))
then minYear = 1758 --default to 1758 per ICZN Art. 5
end
Line 174 ⟶ 176:
if currYDCF == 'year' then
if nav == nil then
local args = { ['min'] = minYear, ['skip-gaps'] = 'yes' }
if parentArg and currentTitle.namespace ~= 14 then
args['testcase'] = parentArg
end
nav = frame:expandTemplate{ title = '
end
if parent == 'century' then
Line 220 ⟶ 222:
end
nav = frame:expandTemplate{ title = 'Container category' } ..
frame:expandTemplate{ title = '
end
if parent == 'formal' then
Line 320 ⟶ 322:
break
end
end
--check for manual cats
if currentTitle.namespace == 14 then --category namespace
local currContent = mw.title.makeTitle( 'Category', currCat or '' ):getContent()
local mancat = mw.ustring.match(currContent or '', '%[%[%s*Category')
if mancat then trackingCats[3] = '[[Category:Described in year with manual category]]' end
end
end --if currCat then
--build header
local br = '<br />'
local n = '\n'
if nav then header = nav end
if portal then header = header..
if commons then header = header..
if wikispecies then header = header..
if description and description ~= '' then
header = header..description
elseif portal or commons or wikispecies then
header = mw.ustring.gsub(header,
end
if toc then header = header..br..toc end
--rem surrounding whitespace
header = mw.text.trim(header)
header = mw.ustring.gsub(header, '^
header = mw.ustring.gsub(header,
--append header to outString
Line 346 ⟶ 358:
--append cats to outString
if currentTitle.namespace == 14 then --category namespace
if table.maxn(categories) > 0 then
outString = outString..table.concat(categories) end outString = outString..table.concat(trackingCats)
else
Line 353 ⟶ 367:
end
outString = outString..br..mw.ustring.gsub(table.concat(trackingCats, br), '%[%[', '[[:')
--ws cleanup
outString = string.gsub(outString, br..br, br)
end
end
|