Module:Category described in year: Difference between revisions

Content deleted Content added
top: bypass redirect
 
(3 intermediate revisions by the same user not shown)
Line 31:
 
function p.autodetect( frame )
local conf = require( 'Module:Category described in year/confconfig' ) --configuration module
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
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 & rem surrounding whitespace
local br = '<br />'
local n = '\n'
if nav then header = nav end
if portal then header = header..'\n'..portal end
if commons then header = header..'\n'..commons end
if wikispecies then header = header..'\n'..wikispecies end
if description and description ~= '' then
header = header..description
elseif portal or commons or wikispecies then
header = mw.ustring.gsub(header, '<br ?/?>', '')
end
if toc then header = header..br..toc end
--rem surrounding whitespace
header = mw.text.trim(header)
header = mw.ustring.gsub(header, '^<br />'..br, '')
header = mw.ustring.gsub(header, '<br />..'$', '')
--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 = mw.ustring.gsub(outString, br..br, br) --produced by empty ('') first/consecutive tracking cat/s
outStringwhile = mw.ustringstring.gsubmatch(outString, br..br,) br)do --jicrem (usedup whilebrs loopproduced ifby #trackingCatsempty >=('') 3first/consecutive ortracking 4)cat/s
outString = string.gsub(outString, br..br, br)
end
end