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 20:37, 23 August 2022 (conservation status). 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 error = require("Module:Error")

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

local conservation_data = {
	["secure"] = ""
}

local function conservation_status(args)
	if args["status"] and args["status_system"] then
		return {
			["label1"] = "[[Conservation status]]",
			["data2"] = "status image goes here",
			["data3"] = args["status"] .. "",
		}
	end
	if args["status"] and not args["status_system"] then
		error.error({"Infobox:Taxobox: using \"status\" without \"status_system\""})
	end
end

local function virus_classification(args)
	
end

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

return p