Módulo:InfoboxOrganization: mudanças entre as edições
De Cronicas Eternas Wiki
Criou página com 'local p = {} -- Lista de valores que indicam ausência de informação local ignoredValues = { ["Unknown"] = true, ["None"] = true, ["Nenhum"] = true, ["-"] = true } function p.infobox(frame) local args = frame:getParent().args local sections = { { title = "INFORMAÇÃO BÁSICA", fields = { {"Nome", args["name"]}, {"Conhecido como", args["known_as"]}, {"Tipo", args[...' |
(Sem diferença)
|
Edição atual tal como às 13h42min de 26 de novembro de 2024
A documentação para este módulo pode ser criada em Módulo:InfoboxOrganization/doc
local p = {}
-- Lista de valores que indicam ausência de informação
local ignoredValues = {
["Unknown"] = true,
["None"] = true,
["Nenhum"] = true,
["-"] = true
}
function p.infobox(frame)
local args = frame:getParent().args
local sections = {
{
title = "INFORMAÇÃO BÁSICA",
fields = {
{"Nome", args["name"]},
{"Conhecido como", args["known_as"]},
{"Tipo", args["type"]},
{"Base", args["base"]},
{"Líder", args["leader"]},
{"Símbolo", args["symbol"]},
{"Divindade favorita", args["favored_deity"]},
{"Arma favorita", args["favored_weapon"]},
{"Domínios", args["domains"]},
{"Formação", args["formation"]},
{"Dissolução", args["dissolution"]},
},
},
{
title = "MEMBROS",
fields = {
{"Alinhamento", args["alignment"]},
{"Espécies", args["species"]},
},
},
{
title = "RELACIONAMENTOS",
fields = {
{"Aliados", args["allies"]},
{"Inimigos", args["enemies"]},
},
},
}
-- Início da infobox
local infobox = '<div style="width:22em; background:#f9f9f9; border:1px solid #aaa; float:right; padding:5px; font-size:90%;">'
-- Adiciona a imagem no topo, se fornecida
if args["image"] and args["image"] ~= "" then
infobox = infobox .. string.format(
'<div style="text-align:center; margin-bottom:10px;">%s</div>',
frame:preprocess(string.format('[[File:%s|center|frameless|200px]]', args["image"]))
)
end
-- Adiciona o nome da organização
infobox = infobox .. string.format(
'<div style="text-align:center; background:#ccc; font-size:120%%; padding:4px;">%s</div>',
args["name"] or "NOME DA ORGANIZAÇÃO"
)
-- Adiciona as seções e os campos
for _, section in ipairs(sections) do
local sectionContent = {}
-- Monta os campos com conteúdo da seção
for _, field in ipairs(section.fields) do
local label, value = field[1], field[2]
if value and value ~= "" and not ignoredValues[value] then
table.insert(sectionContent, string.format('<div style="padding:2px 5px;"><strong>%s:</strong> %s</div>', label, value))
end
end
-- Adiciona a seção somente se tiver conteúdo
if #sectionContent > 0 then
infobox = infobox .. string.format('<div style="text-align:center; background:#ddd; font-size:110%%; padding:4px; margin-top:5px;">%s</div>', section.title)
infobox = infobox .. table.concat(sectionContent)
end
end
infobox = infobox .. '</div>'
return infobox
end
return p