Jump to content

Module:Autovirusbox and Module:Autovirusbox/sandbox: Difference between pages

(Difference between pages)
Page 1
Page 2
Content deleted Content added
Wasted ten minutes of my life. Lmao.
 
Multi-infra experiment, destroyed by how taxobox/core works.
 
Line 40: Line 40:
-- set the taxobox parameters determined by this function
-- set the taxobox parameters determined by this function
-- ------------------------------------------------------
-- ------------------------------------------------------
local autoTaxon, autoTaxonType, infraTaxon, infraTaxonRank, targetTaxon, targetTaxonRank = l.paramChk(frame, taxon, parent, species, strain, serotype, virus)
local autoTaxon, autoTaxonType, infraTaxa, infraTaxaRanks, targetTaxon, targetTaxonRank = l.paramChk(frame, taxon, parent, species, strain, serotype, virus)
-- set default taxobox name/title
-- set default taxobox name/title
local italicsRequired = frame:expandTemplate{ title = 'Is italic taxon', args = {targetTaxonRank, virus='yes'} } == 'yes' and args["italic_title"] ~= "no"
local italicsRequired = frame:expandTemplate{ title = 'Is italic taxon', args = {targetTaxonRank, virus='yes'} } == 'yes' and args["italic_title"] ~= "no"
Line 71: Line 71:
end
end
-- embolden lowest rank
-- embolden lowest rank
-- oops, here goes the problem
if infraTaxon ~= '' then
if infraTaxon ~= '' then
infraTaxon = "'''"..infraTaxon.."'''"
infraTaxon = "'''"..infraTaxon.."'''"
Line 147: Line 148:
function l.paramChk(frame, taxon, parent, species, strain, serotype, virus)
function l.paramChk(frame, taxon, parent, species, strain, serotype, virus)
-- set target taxon and infra-taxon
-- set target taxon and infra-taxon
local infraTaxon = ''
local infraTaxa = {}
local infraTaxonRank = ''
local infraTaxaRanks = {}
local targetTaxon
local targetTaxon = ''
local targetTaxonRank
local targetTaxonRank

-- populate infraTaxa
if virus ~= '' then
infraTaxa[#infraTaxa+1] = virus
infraTaxaRanks[#infraTaxaRanks+1] = 'virus'
end
if serotype ~= '' then
infraTaxa[#infraTaxa+1] = serotype
infraTaxaRanks[#infraTaxaRanks+1] = 'serotype'
end
if strain ~= '' then
if strain ~= '' then
infraTaxon = strain
infraTaxa[#infraTaxa+1] = strain
infraTaxonRank = 'strain'
infraTaxaRanks[#infraTaxaRanks+1] = 'strain'
targetTaxon = infraTaxon
targetTaxonRank = infraTaxonRank
elseif serotype ~= '' then
infraTaxon = serotype
infraTaxonRank = 'serotype'
targetTaxon = infraTaxon
targetTaxonRank = infraTaxonRank
elseif virus ~= '' then
infraTaxon = virus
infraTaxonRank = 'virus'
targetTaxon = infraTaxon
targetTaxon = infraTaxon
targetTaxonRank = infraTaxonRank
targetTaxonRank = infraTaxonRank
end
-- populate targetTaxon using lowest
if #infraTaxa > 1 then
targetTaxon = infraTaxa[#infraTaxa]
targetTaxonRank = infraTaxaRanks[#infraTaxaRanks]
elseif species ~= '' then
elseif species ~= '' then
targetTaxon = species
targetTaxon = species
Line 178: Line 184:
local autoTaxonType = 'ERROR'
local autoTaxonType = 'ERROR'
if taxon ~= '' then
if taxon ~= '' then
if parent..species..infraTaxon == '' then
if parent..species..(table.concat(infraTaxa, '')) == '' then
autoTaxon = taxon
autoTaxon = taxon
autoTaxonType = 'TAXON'
autoTaxonType = 'TAXON'
end
end
elseif parent ~= '' and (species ~='' or infraTaxon ~= '') then
elseif parent ~= '' and (species ~='' or #infraTaxa > 1) then
autoTaxon = parent
autoTaxon = parent
autoTaxonType = 'PARENT'
autoTaxonType = 'PARENT'
end
end
return autoTaxon, autoTaxonType, infraTaxa, infraTaxaRanks, targetTaxon, targetTaxonRank
-- check for multiple infra-taxa
-- This is not this module's limitation: go blame Template:Taxobox/core!
local count = 0
if strain ~= '' then count = count + 1 end
if serotype ~= '' then count = count + 1 end
if virus ~= '' then count = count + 1 end
if count > 1 then autoTaxonType = 'ERROR' end
return autoTaxon, autoTaxonType, infraTaxon, infraTaxonRank, targetTaxon, targetTaxonRank
end
end