Mudanças entre as edições de "Módulo:MapaJson"
Ir para navegação
Ir para pesquisar
(Página substituída por '-- Módulo:MapaJson -- Carrega JSON de uma página e retorna URL encoded local p = {} function p.loadAndEncode(frame) local pageName = frame.args[1] or ''...') Etiqueta: Substituído |
|||
| (3 revisões intermediárias pelo mesmo usuário não estão sendo mostradas) | |||
| Linha 1: | Linha 1: | ||
local p = {} | local p = {} | ||
function p. | function p.getDados(frame) | ||
local pageName = frame.args[1] or '' | local pageName = frame.args[1] or '' | ||
| Linha 11: | Linha 8: | ||
end | end | ||
local title = mw.title.new(pageName) | local title = mw.title.new(pageName) | ||
if not title or not title.exists then | if not title or not title.exists then | ||
| Linha 19: | Linha 15: | ||
local jsonContent = title:getContent() or '' | local jsonContent = title:getContent() or '' | ||
-- | -- Apenas remover espaços extras | ||
jsonContent = jsonContent:gsub("\n", "") | jsonContent = jsonContent:gsub("\n", "") | ||
jsonContent = jsonContent:gsub("\r", "") | jsonContent = jsonContent:gsub("\r", "") | ||
| Linha 25: | Linha 21: | ||
jsonContent = jsonContent:gsub(" +", " ") | jsonContent = jsonContent:gsub(" +", " ") | ||
return jsonContent | |||
end | end | ||
return p | return p | ||
Edição atual tal como às 14h24min de 11 de abril de 2026
A documentação para este módulo pode ser criada em Módulo:MapaJson/doc
local p = {}
function p.getDados(frame)
local pageName = frame.args[1] or ''
if pageName == '' then
return ''
end
local title = mw.title.new(pageName)
if not title or not title.exists then
return ''
end
local jsonContent = title:getContent() or ''
-- Apenas remover espaços extras
jsonContent = jsonContent:gsub("\n", "")
jsonContent = jsonContent:gsub("\r", "")
jsonContent = jsonContent:gsub("\t", " ")
jsonContent = jsonContent:gsub(" +", " ")
return jsonContent
end
return p