Modulo:Fumetto e animazione/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
riordino
+
Riga 19:
end
return reverse_alias
end
 
-- Sostituisce le parentesi in una stringa coi corrispondenti codici ascii
local function replace_braces(s)
local new_s = mw.ustring.gsub(s, "%[", "[")
new_s = mw.ustring.gsub(new_s, "%]", "]")
new_s = mw.ustring.gsub(new_s, "%(", "(")
new_s = mw.ustring.gsub(new_s, "%)", ")")
new_s = mw.ustring.gsub(new_s, " ", " ")
return new_s
end
 
-- Converte la lettera iniziale di una stringa in minuscola
local function lcfirst(str)
return str:gsub('^%l', string.lower)
end
 
-- Parsifica i parametri rimuovendo le stringhe vuote
local function parse_args(args)
for key, value in pairs(args) do
if value and mw.text.trim(value) == '' then
args[key] = nil
end
end
return args
end
 
Riga 71 ⟶ 46:
end
end
end
 
-- Converte la lettera iniziale di una stringa in minuscola
local function lcfirst(str)
return str:gsub('^%u', string.lower)
end
 
-- Parsifica i parametri rimuovendo le stringhe vuote
local function parse_args(args)
for key, value in pairs(args) do
if value and mw.text.trim(value) == '' then
args[key] = nil
end
end
return args
end
 
-- Sostituisce le parentesi in una stringa coi corrispondenti codici ascii
local function replace_braces(s)
local new_s = mw.ustring.gsub(s, "%[", "[")
new_s = mw.ustring.gsub(new_s, "%]", "]")
new_s = mw.ustring.gsub(new_s, "%(", "(")
new_s = mw.ustring.gsub(new_s, "%)", ")")
new_s = mw.ustring.gsub(new_s, " ", " ")
return new_s
end
 
Riga 95:
function Media:inArray(...)
for _, value in ipairs({ ... }) do
if self.tipo == value or self.sottotipo == value or self.name == value then
return true
end
Riga 137:
self.tables_matched = {}
 
self:_getCategories_addCategories(self.args.categorie == 'no')
 
return self
Riga 145:
function CategoryManager:listCategories()
return table.concat(self.categories)
end
 
-- Formatta e aggiunge una categoria
function CategoryManager:_addCategory(category)
table.insert(self.categories, string.format('[[Categoria:%s]]', category))
return self
end
 
-- Aggiunge categorie per una lista di valori
function CategoryManager:_addCategoriesBy(table_name, gender, callback)
if self:_isCategoryRedundant(table_name) == false then
local base_name = table_name:match('[^_]+')
for value in extract_values(self.args, base_name) do
if table_name == 'paese' then
self:_getCategoryByCountry(value, gender, callback)
else
if callback then value = callback(value) end
local category = self:_getCategory(value, table_name)
if category then
self.tables_matched[table_name] = true
self:_addCategory(category)
end
end
end
end
return self
end
 
-- Categorizza un fumetto per Paese
function CategoryManager:_categorizeComicByCountry(adj)
if adj == 'giapponesi' or adj == 'cinesi' or adj == 'coreani' then
return
elseif adj == 'belgi' or adj == 'francesi' then
adj = 'franco-belgi'
end
self:_addCategory('Fumetti ' .. adj)
end
 
-- Categorizza una serie direct-to-video per Paese
function CategoryManager:_categorizeDTVFilmByCountry(adj)
self:_addCategory("Film d'animazione " .. adj)
if self.year then
self:_addCategory(string.format('Film %s del %s', adj, self.year))
end
end
 
-- Categorizza un film televisivo per Paese
function CategoryManager:_categorizeTVFilmByCountry(adj)
self:_addCategory(string.format("Film d'animazione %s per la televisione", adj))
end
 
-- Categorizza una serie TV per Paese
function CategoryManager:_categorizeTVSeriesByCountry(adj)
if adj ~= 'giapponesi' or self.args['paese 2'] then
self:_addCategory("Serie televisive d'animazione " .. adj)
end
end
 
-- Categorizza una webserie per Paese
function CategoryManager:_categorizeWebseriesByCountry(adj)
self:_addCategory('Webserie ' .. adj)
end
 
-- Avvia la categorizzazione automatica dell'opera
function CategoryManager:_getCategories_addCategories(error_only)
if (self.args['data inizio'] or self.args['data fine']) and not self.year then
self:_addCategory(error_category)
Riga 219 ⟶ 158:
self
:_addCategoriesBy('studio_cartoneTV')
:_addCategoriesBy('paese', 'fp', self['._categorizeTVSeriesByCountry'])
elseif self.media.name == "film d'animazione direct-to-video" then
self
:_addCategory(self.media.name)
:_addCategoriesBy('paese', 'mp', self['._categorizeDTVFilmByCountry'])
elseif self.media.name == "webserie d'animazione" then
self:_addCategoriesBy('paese', 'fp', self['._categorizeWebseriesByCountry'])
elseif self.media.name == "film d'animazione per la televisione" then
self:_addCategoriesBy('paese', 'mp', self['._categorizeTVFilmByCountry'])
elseif self.media.tipo == 'manga' then
self
Riga 243 ⟶ 182:
elseif self.media.tipo == 'fumetto' and self.media.name ~= 'fumetti' then
self
:_addCategoriesBy('etichetta_sottotipo', nil, self['._prependSubtype'])
:_addCategoriesBy('etichetta')
:_addCategoriesBy('editore_sottotipo', nil, self['._prependSubtype'])
:_addCategoriesBy('editore')
:_addCategoriesBy('paese', 'mp', self['._categorizeComicByCountry'])
if not self.tables_matched['etichetta_sottotipo'] and
not self.tables_matched['editore_sottotipo'] then
Riga 256 ⟶ 195:
:_addCategoriesBy('etichetta')
:_addCategoriesBy('editore')
:_addCategoriesBy('paese', 'mp', self['._categorizeComicByCountry'])
end
 
Riga 279 ⟶ 218:
-- categorizzazione delle opere suddivise per anno
elseif self.year and self.media.sottotipo ~= 'film direct-to-video' then
local media = self.media.name =~= 'serie televisive anime' == false and
self.media.alias or self.media.name
self:_addCategory(string.format('%s del %s', media, self.year))
end
end
 
-- Aggiunge categorie per una lista di valori
function CategoryManager:_addCategoriesBy(table_name, gender, callback)
if self:_isCategoryRedundant(table_name) == false then
local base_name = table_name:match('[^_]+')
for value in extract_values(self.args, base_name) do
if table_name == 'paese' then
self:_getCategoryByCountry(value, gender, callback)
else
if callback then value = callback(value) end
local category = self:_getCategory(value, table_name)
if category then
self.tables_matched[table_name] = true
self:_addCategory(category)
end
end
end
end
return self
end
 
-- Formatta e aggiunge una categoria
function CategoryManager:_addCategory(category)
table.insert(self.categories, string.format('[[Categoria:%s]]', category))
return self
end
 
-- Categorizza un fumetto per Paese
function CategoryManager:_categorizeComicByCountry(adj)
if adj == 'giapponesi' or adj == 'cinesi' or adj == 'coreani' then
return
elseif adj == 'belgi' or adj == 'francesi' then
adj = 'franco-belgi'
end
self:_addCategory('Fumetti ' .. adj)
end
 
-- Categorizza una serie direct-to-video per Paese
function CategoryManager:_categorizeDTVFilmByCountry(adj)
self:_addCategory("Film d'animazione " .. adj)
if self.year then
self:_addCategory(string.format('Film %s del %s', adj, self.year))
end
end
 
-- Categorizza un film televisivo per Paese
function CategoryManager:_categorizeTVFilmByCountry(adj)
self:_addCategory(string.format("Film d'animazione %s per la televisione", adj))
end
 
-- Categorizza una serie TV per Paese
function CategoryManager:_categorizeTVSeriesByCountry(adj)
if adj ~= 'giapponesi' or self.args['paese 2'] then
self:_addCategory("Serie televisive d'animazione " .. adj)
end
end
 
-- Categorizza una webserie per Paese
function CategoryManager:_categorizeWebseriesByCountry(adj)
self:_addCategory('Webserie ' .. adj)
end
 
Riga 291:
end
 
-- Restituisce la categoria per Paese se presente l'aggettivo adeguato
function CategoryManager:_getCategoryByCountry(value, gender, callback)
local adjective = self:_getCountryAdjective(value, gender)