Jump to content

Module:Taxobox

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by SWinxy (talk | contribs) at 19:59, 23 August 2022. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local p = {}

local infobox = require("Module:Infobox")
local infoboxImage = require("Module:InfoboxImage")
local arguments = require("Module:Arguments")

local colors = {
	["animalia"] = "ebebd2",
	["archaea"] = "c3f5fa",
	["archaeplastida"] = "b4fab4",
	["bacteria"] = "dcebf5",
	["eukaryota"] = "f5d7ff",
	["fungi"] = "91fafa",
	["ichnotaxa"] = "e6ded6",
	["incertae sedis"] = "faf0e6",
	["SAR"] = "c8fa50",
	["ootaxa"] = "fafadc",
	["virus"] = "fafabe",
}

local colorAlts = {
	["nanoarchaeota"] = "archaea",
	["nanarchaeota"] = "archaea",
	["korarchaeota"] = "archaea",
	["thaumarchaeota"] = "archaea",
	["crenarchaeota"] = "archaea",
	["euryarchaeota"] = "archaea",
	
	["plantae"] = "archaeplastida",
	["viridiplantae"] = "archaeplastida",
	
	["excavata"] = "eukaryota",
	["amoebozoa"] = "eukaryota",
	["Opisthokonta"] = "eukaryota",
	
	["chromalveolata"] = "SAR",
	
	["viroids"] = "viruses",
}

local function getColor(args)
	local e = args["regnum"] or ""
	
	local g = mw.ustring.lower(e)
	
	local f = mw.ustring.gsub(g, "[\]\[]", "") -- catches potential [[ ]] around the input parameter
	
	local a = colorAlts[f] or f
	
	return colors[a]
end

function p.main(frame)
	local args = arguments.getArgs(frame)
	return p._main(args)
end

local function genImage(args)
	
end

function p._main(args)
	local color = getColor(args)
	
	local image = genImage(args)
	
	local passing = {
		["subheader"] = args["name"] or mw.title.getCurrentTitle(),
		["above"] = color
	}
	
	if color then
		passing["headerstyle"] = "background-color: #" .. color
		-- passing["subheaderstyle"] = "background-color: #" .. color
	end
	
	if image then
		passing["image"] = image
		passing["caption"] = args["caption"]
	end
	
	return infobox.infobox(passing)
end

return p