Módulo:Gb
Revisão de 03h58min de 27 de agosto de 2025 por GhoulBlack (discussão | contribs)
A documentação para este módulo pode ser criada em Módulo:Gb/doc
local p = {}
function p.render(frame)
-- Pega argumentos de forma segura (pai ou o próprio frame)
local parent = frame:getParent()
local args = parent and parent.args or frame.args
local imagem = args.imagem or ""
local selo = args.selo or ""
local tag = args.tag or "NOVO"
local titulo = args.titulo or "Título"
local subtitulo = args.subtitulo or "Capítulo"
local data = args.data or "Hoje"
local botao = args.botao or "Ler agora"
local link = args.link or "#"
-- Cria o container principal
local html = mw.html.create("div")
:addClass("widget-capitulo")
-- Adiciona imagem de fundo, se existir
if imagem ~= "" then
local fileTitle = mw.title.makeTitle("File", imagem)
if fileTitle then
html:css("background-image",
"url(" .. mw.uri.encode(fileTitle.fullUrl) .. ")"
)
end
end
-- Barra superior
local top = html:tag("div"):addClass("top-bar")
if selo ~= "" then
top:tag("div"):addClass("chip"):wikitext(selo)
end
if tag ~= "" then
top:tag("div"):addClass("chip novo"):wikitext(tag)
end
-- Gradiente
html:tag("div"):addClass("gradient")
-- Textos
local text = html:tag("div"):addClass("text")
text:tag("div"):addClass("title"):wikitext(titulo)
text:tag("div"):addClass("subtitle"):wikitext(subtitulo)
text:tag("div"):addClass("date"):wikitext(data)
-- Botão
html:tag("a")
:addClass("button")
:attr("href", link)
:wikitext(botao)
return tostring(html)
end
return p