Module:Userbox

local string = require('Module:String') local table = require('Module:Table') local getArgs = require('Module:Arguments').getArgs

local p = {}

function p.create(frame) local args = getArgs(frame) local main, id, info = {}, {}, {} local flavor = args[1] main.class = args['class'] main.margin = args['margin'] main.style = args['style'] main.float = args['float'] main.border_Width = args['border-width'] main.border_color = args['border-color'] main.height = args['height'] id.id = args['id'] id.width = args['id-width'] id.color = args['id-color'] id.background = args['id-background'] id.align = args['id-align'] id.size = args['id-size'] id.padding = args['id-padding'] id.css = args['id-css'] info.info = args['info'] info.color = args['info-color'] info.background = args['info-background'] info.align = args['info-align'] info.size = args['info-size'] info.padding = args['info-padding'] info.css = args['info-css'] return p._create(flavor, main, id, info) end

function p._create(flavor, main, id, info) local mainStyle, mainStyleOp, idStyle, infoStyle = {}, {}, {}, {} local mainHtml, idHtml, infoHtml if flavor == 'retro' then idBackgroundDefault = '#542e2e' infoBackgroundDefault = '#7a5252' else idBackgroundDefault = 'transparent' infoBackgroundDefault = 'transparent' end mainStyle["width"] = '330px' mainStyle["min-height"] = "90px" mainStyle["margin"] = main.margin or '.1em .1em' mainStyleOp["float"] = main.float or 'left' mainStyleOp["border"] = (main.border_width or '3')..'px solid '..(main.border_color and (main.border_color:lower == 'none' and 'transparent' or main.border_color) or '#292929') mainStyleOp["height"] = (main.height and main.height:match('^%s*(%d+)') or '90')..'px' idStyle["width"] = (id.width and id.width:match('^%s*(%d+)') or '90')..'px' idStyle["color"] = id.color and (id.color:lower == 'none' and 'transparent' or id.color) or 'white' idStyle["background"] = id.background and (id.background:lower == 'none' and 'transparent' or id.background) or idBackgroundDefault idStyle["text-align"] = id.align or 'center' idStyle["font-size"] = (id.size and id.size:match('^%s*(%d+)') or '14')..'pt' idStyle["padding"] = id.padding or '0 .9em' idStyle["vertical-align"] = 'middle' infoStyle["color"] = info.color and (info.color:lower == 'none' and 'transparent' or info.color) or 'white' infoStyle["background"] = info.background and (info.background:lower == 'none' and 'transparent' or info.background) or idBackgroundDefault infoStyle["text-align"] = info.align or 'left' infoStyle["font-size"] = (info.size and info.size:match('^%s*(%d+)') or '12')..'pt' infoStyle["padding"] = info.padding or '0 .7em' infoStyle["vertical-align"] = 'middle' idHtml = string.wrapHtml(id.id or 'id', 'th', { style = id.css or idStyle }) infoHtml = string.wrapHtml(info.info or "info", 'td', { style = info.css or infoStyle }) main.style = main.style and table.concat(mainStyle, ' ')..' '..main.style main.class = main.class and 'article-userbox '..main.class or 'article-userbox' mainHtml = string.wrapHtml(idHtml..infoHtml, 'table', { cellspacing = "0", class = main.class, style = main.style or table.merge(mainStyle, mainStyleOp) }) return mainHtml end

return p