Mudanças entre as edições de "Módulo:Lari1"
Ir para navegação
Ir para pesquisar
(Criou página com 'local p = {} function p.render(frame) local args = frame:getParent().args local nome = mw.text.trim(args['nome'] or '') local root = mw.html.create('div'):attr('...') |
|||
| Linha 1: | Linha 1: | ||
local p = {} | local p = {} | ||
local VIDEO_EXTS = { mp4 = true, webm = true, ogv = true } | |||
local function detectMedia(valor) | |||
if not valor or valor == '' then return nil, nil end | |||
local ext = valor:match('%.(%w+)$') | |||
if ext and VIDEO_EXTS[ext:lower()] then | |||
return 'video', valor | |||
end | |||
return 'youtube', valor | |||
end | |||
function p.render(frame) | function p.render(frame) | ||
| Linha 7: | Linha 18: | ||
local root = mw.html.create('div'):attr('class', 'sv-wrap') | local root = mw.html.create('div'):attr('class', 'sv-wrap') | ||
root:tag('span'):attr('class', 'tema-btn'):wikitext('☾ Dark') | root:tag('span'):attr('class', 'tema-btn'):wikitext('☾ Dark') | ||
if nome ~= '' then | if nome ~= '' then | ||
root:tag('div'):attr('class', 'sv-titulo'):wikitext(nome) | root:tag('div'):attr('class', 'sv-titulo'):wikitext(nome) | ||
end | end | ||
local skills = {} | local skills = {} | ||
local i = 1 | local i = 1 | ||
| Linha 27: | Linha 35: | ||
if #skills == 0 then return tostring(root) end | if #skills == 0 then return tostring(root) end | ||
local box = root:tag('div'):attr('class', 'sv-box') | local box = root:tag('div'):attr('class', 'sv-box') | ||
local tabbar = box:tag('div'):attr('class', 'sv-tabs') | local tabbar = box:tag('div'):attr('class', 'sv-tabs') | ||
for idx, n in ipairs(skills) do | for idx, n in ipairs(skills) do | ||
| Linha 44: | Linha 50: | ||
end | end | ||
for idx, n in ipairs(skills) do | for idx, n in ipairs(skills) do | ||
local px | local px = 'skill' .. n | ||
local titulo | local titulo = mw.text.trim(args[px .. 'titulo'] or '') | ||
local | local media = mw.text.trim(args[px .. 'media'] or '') | ||
local panel = box:tag('div') | local panel = box:tag('div') | ||
| Linha 55: | Linha 59: | ||
:attr('data-panel', tostring(n)) | :attr('data-panel', tostring(n)) | ||
panel:tag('h2'):attr('class', 'sv-skill-titulo'):wikitext(titulo) | panel:tag('h2'):attr('class', 'sv-skill-titulo'):wikitext(titulo) | ||
local descsec = panel:tag('div'):attr('class', 'sv-desc') | local descsec = panel:tag('div'):attr('class', 'sv-desc') | ||
local j = 1 | local j = 1 | ||
| Linha 68: | Linha 70: | ||
end | end | ||
local tipo, valor = detectMedia(media) | |||
if | if tipo == 'youtube' then | ||
panel:tag('div') | |||
:attr('class', 'sv-media') | |||
elseif | :attr('data-youtube', valor) | ||
local | elseif tipo == 'video' then | ||
local mediaDiv = panel:tag('div'):attr('class', 'sv-media') | |||
mediaDiv:tag('video') | |||
:attr(' | :attr('data-wikivideo', valor) | ||
:attr('controls', '') | :attr('controls', '') | ||
:attr('loop', '') | :attr('loop', '') | ||
Edição das 03h04min de 17 de março de 2026
A documentação para este módulo pode ser criada em Módulo:Lari1/doc
local p = {}
local VIDEO_EXTS = { mp4 = true, webm = true, ogv = true }
local function detectMedia(valor)
if not valor or valor == '' then return nil, nil end
local ext = valor:match('%.(%w+)$')
if ext and VIDEO_EXTS[ext:lower()] then
return 'video', valor
end
return 'youtube', valor
end
function p.render(frame)
local args = frame:getParent().args
local nome = mw.text.trim(args['nome'] or '')
local root = mw.html.create('div'):attr('class', 'sv-wrap')
root:tag('span'):attr('class', 'tema-btn'):wikitext('☾ Dark')
if nome ~= '' then
root:tag('div'):attr('class', 'sv-titulo'):wikitext(nome)
end
local skills = {}
local i = 1
while true do
local titulo = mw.text.trim(args['skill' .. i .. 'titulo'] or '')
if titulo == '' then break end
skills[#skills + 1] = i
i = i + 1
end
if #skills == 0 then return tostring(root) end
local box = root:tag('div'):attr('class', 'sv-box')
local tabbar = box:tag('div'):attr('class', 'sv-tabs')
for idx, n in ipairs(skills) do
local img = mw.text.trim(args['skill' .. n .. 'img'] or '')
local tab = tabbar:tag('span')
:attr('class', idx == 1 and 'sv-tab active' or 'sv-tab')
:attr('data-skill', tostring(n))
if img ~= '' then
tab:node(mw.html.create(''):wikitext('[[File:' .. img .. '|32px|link=]]'))
else
tab:wikitext(tostring(n))
end
end
for idx, n in ipairs(skills) do
local px = 'skill' .. n
local titulo = mw.text.trim(args[px .. 'titulo'] or '')
local media = mw.text.trim(args[px .. 'media'] or '')
local panel = box:tag('div')
:attr('class', idx == 1 and 'sv-panel active' or 'sv-panel')
:attr('data-panel', tostring(n))
panel:tag('h2'):attr('class', 'sv-skill-titulo'):wikitext(titulo)
local descsec = panel:tag('div'):attr('class', 'sv-desc')
local j = 1
while true do
local desc = mw.text.trim(args[px .. 'desc' .. j] or '')
if desc == '' then break end
descsec:tag('p'):wikitext(desc)
j = j + 1
end
local tipo, valor = detectMedia(media)
if tipo == 'youtube' then
panel:tag('div')
:attr('class', 'sv-media')
:attr('data-youtube', valor)
elseif tipo == 'video' then
local mediaDiv = panel:tag('div'):attr('class', 'sv-media')
mediaDiv:tag('video')
:attr('data-wikivideo', valor)
:attr('controls', '')
:attr('loop', '')
:attr('muted', '')
:wikitext('')
end
end
return tostring(root)
end
return p