Wowpedia
Advertisement

Documentation for this module may be created at Module:API info/util/infobox/doc

local m, p = {}, {}

function m:main(info, items)
	return p:GetInfobox(info, items)
end

local DARKTABLE_START = '{| class="darktable" style="min-width:142px;"'
local DARKTABLE_END = '|}'
local INFOBOX_STYLE = '<div class="nomobile" style="float:right; clear:right">\n%s\n</div>'

function p:GetInfobox(info, items)
	local t = {}
	table.insert(t, DARKTABLE_START)
	for _, v in pairs(items) do
		if type(v) == "table" then
			table.insert(t, "| "..self:GetList(info, v))
		else
			table.insert(t, v)
		end
	end
	table.insert(t, DARKTABLE_END)
	local darktable = table.concat(t, "\n|-\n")
	return INFOBOX_STYLE:format(darktable)
end

local LIST_START = '<ul class="plainlinks elinks">'
local LIST_ITEM = '<li style="padding-left: 0px; min-height: 25px">%s</li>'
local LIST_END = '</ul>'

local function FormatListItem(info, item)
	local fs = "[[Image:%s|%dpx|link=%s]] &nbsp;[%s %s]"
	return fs:format(item.icon, item.iconsize or 16, item.url, item.url, item.text)
end

function p:GetList(info, listitems)
	local t = {}
	table.insert(t, LIST_START)
	for _, v in pairs(listitems) do
		table.insert(t, LIST_ITEM:format(FormatListItem(info, v)))
	end
	table.insert(t, LIST_END)
	return table.concat(t, "\n")
end

return m
Advertisement