Content deleted Content added
add line breaks to stop lint issues |
Tom.Reding (talk | contribs) m Sync |
||
Line 1:
require('Module:No globals')
local commonsLink = require('Module:Commons link')▼
local conf = require( 'Module:Category described in year/conf' ) --configuration module▼
--[[==========================================================================]]
Line 34 ⟶ 31:
function p.autodetect( frame )
▲ local conf = require( 'Module:Category described in year/conf' ) --configuration module
▲ local commonsLink = require('Module:Commons link')
local currentTitle = mw.title.getCurrentTitle()
local parentArg = frame:getParent().args[1] --accept 1 unnamed category parameter if not in category namespace; required for testing/doc/etc. purposes
Line 44 ⟶ 43:
local toc = nil
local categories = {}
local
[1] = '', --placeholder for [[Category:Described in year unknown category]]
[2] = '', --placeholder for [[Category:Described in year error]]
Line 60 ⟶ 59:
if parentArg then
currCat = mw.ustring.gsub(parentArg, 'Category:', '')
currQID = mw.wikibase.getEntityIdForTitle('Category:'
else --currQID & currCat both nil
if currentTitle.fullText ~= 'Template:Category described in year' then --ignore self...
end
end
Line 83 ⟶ 82:
if currSpeciesWikiTitle then
wikispecies = frame:expandTemplate{ title = 'Wikispecies', args = { currSpeciesWikiTitle } }
end end end
--[[======================================================================]]
Line 119 ⟶ 114:
currYDCF = 'decade'
bConfError = true
elseif currCent then
currYDCF = 'century'
Line 126 ⟶ 121:
else
bConfError = true
end
Line 135 ⟶ 130:
if conf[currGroup] == nil then
bConfError = true
elseif conf[currGroup][currYDCF] == nil then
bConfError = true
else
if conf[currGroup][currYDCF].description == nil then
bConfError = true
end
if conf[currGroup][currYDCF].parent1 == nil then
bConfError = true
end
end
Line 168 ⟶ 163:
end
--produce cats & navs
local iparent = 1
local parenti = 'parent'
local sortkeyi = 'sortkey'
while conf[currGroup][currYDCF][parenti] do
local parent = conf[currGroup][currYDCF][parenti]
Line 218 ⟶ 204:
categories[iparent] = '[[Category:'..parent..' described in '..currYear..sortkey..']]'
else
end
Line 255 ⟶ 241:
categories[iparent] = '[[Category:'..parent..' described in the '..addOrd(currCent)..' century'..sortkey..']]'
else
end
Line 277 ⟶ 263:
categories[iparent] = '[[Category:Paleontology by year|'..sortkey..']]'
else
end
--[[========================= Error ==========================]]
else
end
iparent = iparent + 1
parenti = 'parent'
sortkeyi = 'sortkey'
end --while conf[currGroup][currYDCF][parenti] do
end --if bConfError == false then
Line 295 ⟶ 281:
local cat = mw.ustring.match(category, '%[%[Category:([%w%s]+)')
if mw.title.new(cat, 14).exists == false then
break
end
Line 303 ⟶ 289:
--build header & rem surrounding whitespace
local br = '<br />'
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
elseif portal or commons or wikispecies then
header = mw.ustring.gsub(header, '<br ?/?>', '')
end
if toc then header = header
header = mw.text.trim(header)
header = mw.ustring.gsub(header, '^<br />', '')
Line 318 ⟶ 305:
--append header to outString
if outString then outString = outString
else outString = header end
--append cats to outString
if currentTitle.namespace == 14 then --category namespace
if table.maxn(categories) > 0 then outString = outString
outString = outString
else
if table.maxn(categories) > 0 then --might be 0 if there's an error before setting cats
outString = outString
end
outString = outString
outString = mw.ustring.gsub(outString,
outString = mw.ustring.gsub(outString,
end
|