Modulo:Bozza

Questo è un modulo scritto in Lua. Le istruzioni che seguono sono contenute nella sottopagina Modulo:Bozza/man (modifica · cronologia)
Sandbox: Modulo:Bozza/sandbox (modifica · cronologia) · Sottopagine: lista · Test: Modulo:Bozza/test (modifica · cronologia · Esegui)
Modulo che implementa le funzionalità del template:Bozza.
Legge i vari template:Richiesta revisione bozza presenti nella pagina e include il template:Bozza/avviso coi parametri adeguati.
require('Modulo:No globals')
local p = {}
local function removeFalsePositives(str)
return str:gsub('<!%-%-.-%-%->', ''):gsub('<nowiki>.-</nowiki>', '')
end
local function getPageContent()
local text = mw.title.getCurrentTitle():getContent() or ''
return removeFalsePositives(text)
end
function p.controllo_categorie(frame)
local text = getPageContent()
if text:find("%[%[ *[Cc][Aa][Tt][Ee][Gg][Oo][Rr][Ii][Aa] *: *[^%s][^\n]-%]%]" ) then
return '[[Categoria:Bozze con categorie da disabilitare]]'
end
end
function p.stato_richiesta(frame)
if frame.args[1] == 'S' then return frame.args[1] end
local text = getPageContent()
local declined = false
for str in text:gmatch('%{%{ *[Rr]ichiesta *revisione *bozza *(%|.-%})%}') do
if str:find('| *data *= *[^ %|%}]') then
if not str:find('%| *1? *=? *respinta *[%|%}]') then
return 'R'
end
declined = true
end
end
if declined then
return frame.args[1] == 'A' and 'A' or 'N'
end
return frame.args[1]
end
return p