Modulo:Criteri cancellazione immediata/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
aggiungo virgolette
caricamento dinamico della configurazione; entrypoint per ottenere i valori di default; altre migliorie
Riga 6:
require('strict')
 
local-- cfgLegge = mw.loadJsonData('Modulo:Criteri cancellazione immediata/Configurazione/sandbox.json')
-- oppure Modulo:Criteri cancellazione immediata/sandbox/Configurazione.json
local getArgs = require('Module:Arguments').getArgs
local cfg = mw.loadJsonData(mw.getCurrentFrame():getTitle() .. '/Configurazione.json')
 
-- =============================================================================
Riga 117 ⟶ 118:
end
end
end
elseif key == 'getDefault' then
return function ()
return t.DROPDOWN_LIST
end
end
Riga 146 ⟶ 151:
end
end
end
elseif key == 'getDefault' then
return function ()
return t.SYSTEM_MESSAGE
end
end
Riga 323 ⟶ 332:
 
local function get_args(frame)
local args = require('Module:Arguments').getArgs(frame, { parentOnly = true })
 
if args[1] and args.criterio == nil then
Riga 330 ⟶ 339:
 
args.ns = Namespace.findByName(args.ns) or Namespace.findById(args.ns) or Namespace.DEFAULT
args['tipo elenco'] = ListType.findByArg(args['tipo elenco']) or ListType.DROPDOWN_LISTgetDefault()
args['tipo testo'] = TextType.findByArg(args['tipo testo']) or TextType.SYSTEM_MESSAGEgetDefault()
args.link = args.link ~= 'no' and true or false
args.ancore = (args.ancore == 'sì' or args.ancore == 'si') and true or false
Riga 344 ⟶ 353:
 
local p = {}
 
function p.get_default_list_type()
return ListType.getDefault()
end
 
function p.get_default_text_type()
return TextType.getDefault()
end
 
function p.get_list_types()
Riga 349 ⟶ 366:
 
for _, list_type in pairs(ListType) do
table.insert(list_types, string.format('"%s"' .., list_type.arg .. '"'))
end
 
Riga 359 ⟶ 376:
 
for _, text_type in pairs(TextType) do
table.insert(text_types, string.format('"%s"' .., text_type.arg .. '"'))
end
 
Riga 370 ⟶ 387:
local ns, criterion_code, add_link = args.ns, args.criterio, args.link
 
if criterion_code == nil orand cfg[criterion_code] == nil then
local criterion = to_criterion(criterion_code, cfg[criterion_code])
return
end
 
criterion:setCurrentNs(ns):setAddLink(add_link)
local criterion = to_criterion(criterion_code, cfg[criterion_code])
 
if criterion:setCurrentNsisValid(ns):setAddLink(add_link) then
return criterion[text_type.get](criterion)
 
end
if criterion:isValid() then
return criterion[text_type.get](criterion)
end
end
Riga 404 ⟶ 419:
 
for _, criterion in ipairs(valid_criteria) do
list = list string.. format('%s\n%s ', ..list, list_type.prefix .. ' ')
 
if add_anchor then
list = list .. string.format('%s<span id=%s></span>', list, criterion:getCode())
end