Modulo:Videogioco: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
m fix |
revisione della categorizzazione per aziende, v. dp:Videogiochi#Categorizzazione_per_azienda |
||
(3 versioni intermedie di uno stesso utente non sono mostrate) | |||
Riga 81:
-- da controllare
-- ========================================================================
local function categorizza(args, base_name, table_name, lowercase, must_exist, cat_assenza)
local categories = {}
local name_value = args[base_name] or args[base_name .. " 1"]
Riga 108:
index = index + 1
end
elseif cat_assenza and not args[base_name .. " altro"] then
categories[#categories+1] = 'Videogiochi senza ' .. base_name
end
if args[base_name] and args[base_name .. " 1"] then
Riga 114 ⟶ 116:
return categories
end
-- ========================================================================
-- Categorizzazione per aziende (sviluppo N e pubblicazione N)
-- ========================================================================
local function categoria_azienda(str)
-- converte eventuali alias
str = cfg['alias_aziende'][str] or str
-- se il nome contiene un wikilink, estrae la voce puntata, senza disambiguante
local azienda = mw.ustring.match(str, "%[%[([^%]%(|]+)") or str
azienda = mw.text.trim(azienda)
-- se esiste "cat:Videogiochi Azienda" la seleziona
local cat = "Videogiochi " .. azienda
local titolo = mw.title.new(cat, "Categoria")
if titolo and titolo.exists then
return cat
end
return nil
end
local function categorizza_aziende(args, base_name)
local categories = {}
local name_value = args[base_name] or args[base_name .. " 1"]
if name_value then
local cat = categoria_azienda(name_value)
if cat then
categories[#categories+1] = cat
end
local index = 2
while true do
name_value = args[base_name .. ' ' .. tostring(index)]
if name_value then
cat = categoria_azienda(name_value)
if cat then
categories[#categories+1] = cat
end
else
break
end
index = index + 1
end
end
if args[base_name] and args[base_name .. " 1"] then
errors_msg[#errors_msg+1] = 'Inserire solo uno di ' .. base_name .. ' e ' .. base_name .. ' ' .. tostring(index)
end
return categories
end
-- ========================================================================
-- categorizza
-- ========================================================================
function p.categorie(frame)
local args = getArgs(frame, {parentOnly = not frame.args.debug})
Riga 128 ⟶ 177:
local anno = tonumber(args.anno)
if anno == nil then
categories[#categories+1] = 'Videogiochi annullati'
else
errors_msg[#errors_msg+1] = 'anno di pubblicazione non valido'
end
elseif anno <= 1970 then
categories[#categories+1] = 'Videogiochi fino al 1970'
Riga 134 ⟶ 187:
categories[#categories+1] = 'Videogiochi del ' .. args.anno
end
else
categories[#categories+1] = 'Videogiochi senza anno'
end
append_table(categories, categorizza(args, 'genere', 'genere', true, true, true))
append_table(categories, categorizza(args, 'tema', 'tema', true))
for i = 1, 3 do
Riga 148 ⟶ 203:
end
end
append_table(categories, categorizza(args, 'piattaforma', 'piattaforma', false, true, true))
append_table(categories,
append_table(categories,
append_table(categories, categorizza(args, 'distribuzione digitale', 'distribuzione', false, true))
entity = mw.wikibase.getEntity()
Riga 174 ⟶ 229:
return frame.args.debug and mw.text.nowiki(table.concat(categories)) or table.concat(categories)
end
-- ========================================================================
-- Visualizza le tabelle delle configurazioni per il manuale
-- ========================================================================
function p.tabella_configurazione(frame)
local args = getArgs(frame)
|