Módulo:Infobox: mudanças entre as edições

De Cronicas Eternas Wiki
Sem resumo de edição
Sem resumo de edição
Linha 3: Linha 3:
function p.infobox(frame)
function p.infobox(frame)
     local args = frame:getParent().args
     local args = frame:getParent().args
    local title = args['title'] or 'Título Padrão'
    local description = args['description'] or 'Sem descrição'
    local date = args['date'] or 'Desconhecido'
    local image = args['image'] or ''


     return string.format([[
     local sections = {
     <div style="width:22em; background:#f9f9f9; border:1px solid #aaa; float:right; padding:5px; font-size:90%%;">
        ["Geografia"] = {
         <div style="text-align:center; background:#ccc; font-size:120%%;">%s</div>
            {"Conhecido(a) como", args["known_as"]},
         <div><strong>Descrição:</strong> %s</div>
            {"Tipo", args["type"]},
        <div><strong>Criado em:</strong> %s</div>
            {"Região", args["region"]},
         <div style="text-align:center;">%s</div>
            {"Tamanho", args["size"]},
    </div>
            {"Elevação", args["elevation"]},
     ]], title, description, date, image)
            {"Profundidade", args["depth"]},
            {"Capital", args["capital"]},
        },
        ["Sociedade"] = {
            {"Gentílico", args["demonym"]},
            {"População", args["population"]},
            {"Espécies", args["species"]},
            {"Linguagens", args["languages"]},
            {"Religiões", args["religions"]},
        },
        ["Comércio"] = {
            {"Importações", args["imports"]},
            {"Exportações", args["exports"]},
            {"Cunhagem", args["currency"]},
        },
        ["Política"] = {
            {"Tipo de Governo", args["government_type"]},
            {"Tipo de Regente", args["ruler_type"]},
            {"Regente Atual", args["current_ruler"]},
            {"Poder Executivo", args["executive"]},
            {"Poder Legislativo", args["legislative"]},
            {"Poder Judiciário", args["judiciary"]},
            {"Alianças", args["alliances"]},
        },
    }
 
     local infobox = '<div style="width:22em; background:#f9f9f9; border:1px solid #aaa; float:right; padding:5px; font-size:90%;">'
 
    for section, fields in pairs(sections) do
         infobox = infobox .. string.format('<div style="text-align:center; background:#ccc; font-size:120%%; padding:4px;">%s</div>', section)
         for _, field in ipairs(fields) do
            local label, value = field[1], field[2]
            if value and value ~= "" then
                infobox = infobox .. string.format('<div style="padding:2px 5px;"><strong>%s:</strong> %s</div>', label, value)
            end
         end
    end
 
    infobox = infobox .. '</div>'
 
     return infobox
end
end


return p
return p

Edição das 20h01min de 22 de novembro de 2024

A documentação para este módulo pode ser criada em Módulo:Infobox/doc

local p = {}

function p.infobox(frame)
    local args = frame:getParent().args

    local sections = {
        ["Geografia"] = {
            {"Conhecido(a) como", args["known_as"]},
            {"Tipo", args["type"]},
            {"Região", args["region"]},
            {"Tamanho", args["size"]},
            {"Elevação", args["elevation"]},
            {"Profundidade", args["depth"]},
            {"Capital", args["capital"]},
        },
        ["Sociedade"] = {
            {"Gentílico", args["demonym"]},
            {"População", args["population"]},
            {"Espécies", args["species"]},
            {"Linguagens", args["languages"]},
            {"Religiões", args["religions"]},
        },
        ["Comércio"] = {
            {"Importações", args["imports"]},
            {"Exportações", args["exports"]},
            {"Cunhagem", args["currency"]},
        },
        ["Política"] = {
            {"Tipo de Governo", args["government_type"]},
            {"Tipo de Regente", args["ruler_type"]},
            {"Regente Atual", args["current_ruler"]},
            {"Poder Executivo", args["executive"]},
            {"Poder Legislativo", args["legislative"]},
            {"Poder Judiciário", args["judiciary"]},
            {"Alianças", args["alliances"]},
        },
    }

    local infobox = '<div style="width:22em; background:#f9f9f9; border:1px solid #aaa; float:right; padding:5px; font-size:90%;">'

    for section, fields in pairs(sections) do
        infobox = infobox .. string.format('<div style="text-align:center; background:#ccc; font-size:120%%; padding:4px;">%s</div>', section)
        for _, field in ipairs(fields) do
            local label, value = field[1], field[2]
            if value and value ~= "" then
                infobox = infobox .. string.format('<div style="padding:2px 5px;"><strong>%s:</strong> %s</div>', label, value)
            end
        end
    end

    infobox = infobox .. '</div>'

    return infobox
end

return p