Mudanças entre as edições de "Módulo:Teste"

De Wiki Gla
Ir para navegação Ir para pesquisar
m
m
 
Linha 8: Linha 8:


   Parâmetros nomeados (opcionais):
   Parâmetros nomeados (opcionais):
     |label=Texto do botão
     |heading=Título da caixa
     |wid=2
     |wid=2


Linha 30: Linha 30:
end
end


local label = args.label or pargs.label or ""
local heading = args.heading or pargs.heading or ""
local wid = args.wid or pargs.wid or ""
local wid = args.wid or pargs.wid or ""


local wikitext = "{{#widget:ReportModal|api_base=" .. base
local wikitext = "{{#widget:ReportModal|api_base=" .. base
if label ~= "" then
if heading ~= "" then
wikitext = wikitext .. "|label=" .. label
wikitext = wikitext .. "|heading=" .. heading
end
end
if wid ~= "" then
if wid ~= "" then

Edição atual tal como às 16h07min de 28 de abril de 2026

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

--[[
  Módulo: opcional para inserir o widget via {{#invoke}}.

  Na wiki: criar página Módulo:GlaReportEmbed com este código.

  Uso num modelo ou página:
    {{#invoke:GlaReportEmbed|embed|api_base=https://teu-deploy.com}}

  Parâmetros nomeados (opcionais):
    |heading=Título da caixa
    |wid=2

  Requer a extensão Scribunto e o widget {{#widget:ReportModal|...}} registrado.
]]

local p = {}

function p.embed(frame)
	local pargs = (frame:getParent() and frame:getParent().args) or {}
	local args = frame.args or {}
	local base = (
		args.api_base
		or pargs.api_base
		or args[1]
		or pargs[1]
		or ""
	):gsub("^%s+", ""):gsub("%s+$", "")
	if base == "" then
		return '<span class="error">GlaReportEmbed: falta <code>api_base</code>.</span>'
	end

	local heading = args.heading or pargs.heading or ""
	local wid = args.wid or pargs.wid or ""

	local wikitext = "{{#widget:ReportModal|api_base=" .. base
	if heading ~= "" then
		wikitext = wikitext .. "|heading=" .. heading
	end
	if wid ~= "" then
		wikitext = wikitext .. "|wid=" .. wid
	end
	wikitext = wikitext .. "}}"

	return frame:preprocess(wikitext)
end

return p