Mudanças entre as edições de "Módulo:Gb"
Ir para navegação
Ir para pesquisar
(Criou página com 'local p = {} function p.render(frame) -- pega parâmetros local args = frame:getParent().args local imagem = args.imagem or "" local selo = args.selo...') |
|||
| Linha 2: | Linha 2: | ||
function p.render(frame) | function p.render(frame) | ||
-- | -- Pega argumentos de forma segura (pai ou o próprio frame) | ||
local | local parent = frame:getParent() | ||
local | 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") | local html = mw.html.create("div") | ||
:addClass("widget-capitulo") | :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") | local top = html:tag("div"):addClass("top-bar") | ||
if selo ~= "" then | if selo ~= "" then | ||
| Linha 27: | Linha 38: | ||
end | end | ||
-- | -- Gradiente | ||
html:tag("div"):addClass("gradient") | html:tag("div"):addClass("gradient") | ||
-- | -- Textos | ||
local text = html:tag("div"):addClass("text") | local text = html:tag("div"):addClass("text") | ||
text:tag("div"):addClass("title"):wikitext(titulo) | text:tag("div"):addClass("title"):wikitext(titulo) | ||
| Linha 36: | Linha 47: | ||
text:tag("div"):addClass("date"):wikitext(data) | text:tag("div"):addClass("date"):wikitext(data) | ||
-- | -- Botão | ||
html:tag("a") | html:tag("a") | ||
:addClass("button") | :addClass("button") | ||
Edição das 03h58min de 27 de agosto de 2025
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