Modulo:Gastronomia: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
Nessun oggetto della modifica |
lista categorie gestite |
||
Riga 14:
function p.autocat(frame)
local args = getArgs(frame)
Riga 25 ⟶ 24:
local errori = {}
local new_categories = {}
local categoria = args['categoria']▼
local regioni = {}
local paesi = {}
▲ local categoria = args['categoria'] or ''
categoria = cfg.categorie_alias[categoria] or categoria
local paesi = get_list(args, 'paese', 5)
local regioni = get_list(args, 'regione', 15)
-- Creo categorie in base alla categoria del piatto
if
-- categoria base del piatto
errori[#errori+1] = 'Categoria non riconosciuta o non esistente'▼
else▼
▲ local piatto_cat = cfg.categorie[categoria]
if piatto_cat.cat_base ~= '' then
new_categories[#new_categories+1] = piatto_cat.cat_base
end
-- categoria per regioni e paesi
-- prima parte categoria per regioni
local escludi_paesi = {}▼
if cfg.regioni[regione].use_preposizione ~= '' then
new_cat = piatto_cat.paese_cat .. cfg.regioni[regione][piatto_cat.prefix]
else▼
if mw.title.new('Categoria:' .. new_cat).exists then▼
new_categories[#new_categories+1] = new_cat▼
escludi_paesi[#escludi_paesi+1] = cfg.regioni[regione].paese▼
end
end▼
▲ if mw.title.new('Categoria:' .. new_cat).exists then
▲ new_categories[#new_categories+1] = new_cat
▲ escludi_paesi[#escludi_paesi+1] = cfg.regioni[regione].paese
end
end
-- seconda parte categoria per paese
end▼
for _,paese in ipairs(paesi) do
--
if not escludi_paesi[paese] then
if piatto_cat.internazionale and paese == 'Internazionale' then
new_categories[#new_categories+1] = 'Piatti internazionali'
else
new_categories[#new_categories+1] = piatto_cat.paese_cat .. frame:expandTemplate{ title = 'AggNaz', args = { piatto_cat.prefix , paese }}
▲ end
end
end
Riga 113 ⟶ 115:
end
return table.concat(wrapped)
end
function p.categoria(frame)
local args = getArgs(frame)
local categoria = args['categoria'] or ''
categoria = cfg.categorie_alias[categoria] or categoria
local piatto_cat = cfg.categorie[categoria]
if piatto_cat ~= nil then
return piatto_cat.voce
▲ else
▲
end
end
-- Ritorna la lista di categorie
function p.list_categorie(frame)
local tableNode = mw.html.create("table"):addClass('wikitable'):addClass('sortable')
tableNode:tag('tr')
:tag('th'):wikitext('Categoria'):done()
:tag('th'):wikitext('Alias'):done()
:tag('th'):wikitext('Voce'):done()
local cat_list = {}
for cat, _ in pairs(cfg.categorie) do
cat_list[#cat_list+1] = cat
end
table.sort(cat)
for _,cat in ipairs(cat_list) do
local table_row = tableNode:tag('tr')
table_row:tag('td'):wikitext(cat)
for k,v in pairs(cfg.action_alias) do
if v == cat then alias_cat[#alias_cat+1] = k end
▲ end
table_row:tag('td'):wikitext(table.concat(alias_cat, ', '))
table_row:tag('td'):wikitext(cfg.categorie[cat].voce)
end
return tostring(tableNode)
end
| |||