Modulo:Tracce/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
m versione corrente
aggiungo categorie di errore
Riga 1:
local categories = {}
local missing_title = '[[Categoria:Errori di compilazione del template Tracce - titolo mancante]]'
local unknown_format = '[[Categoria:Errori di compilazione del template Tracce - formato durata sconosciuto]]'
 
-- Protects a string that will be wrapped in wiki italic markup '' ... ''
local function safeforitalics( str )
--[[ Note: We can not use <i> for italics, as the expected behavior for
italics specified by ''...'' in the title is that they will be inverted
(i.e. unitalicized) in the resulting references. In addition, <i> and '']]
tend to interact poorly under Mediawiki's HTML tidy. ]]
 
if str == nil or str == '' then
Line 22 ⟶ 25:
local function track(args, i, corsivo)
local titolo = args["Titolo" .. i] or ""
if titolo ~="" then
local row_elements = {}
table.insert(row_elements, '<li value="' .. tostring(i) .. '">')
Line 37 ⟶ 40:
if note ~= "" then table.insert(row_elements, " <small>(" .. note .. ")</small>") end
local string_durata = args["Durata" .. i]
local minuti, secondi
if string_durata then
local string_minuti, string_secondi = mw.ustring.match(string_durata, "(%d+):(%d%d)")
Line 46 ⟶ 50:
end
local durata = minuti * 60 + secondi
if durata > 0 then
table.insert(row_elements, " – ")
table.insert(row_elements, string.format("%d:%02.f", minuti, secondi))
elseif string_durata or args["Minuti" .. i] or args["Secondi" .. i] then
categories[#categories+1] = unknown_format
end
local AutoreTesto = args["Autore testo" .. i] or ""
Line 84 ⟶ 90:
return table.concat(row_elements), durata
else
for arg,_ in pairs(args) do
if arg ~= 'Titolo' .. i and arg:find('%D' .. i .. '$') then
categories[#categories+1] = missing_title
end
end
return nil
end
Line 147 ⟶ 158:
table.insert(tracks, "Durata totale: " .. string.format("%d:%02.f", math.floor(durata/60) , durata % 60) .. "</p>")
end
return table.concat(tracks, "\n") .. table.concat(categories)
end
 
Line 233 ⟶ 244:
if args['Visualizza durata totale'] then args['Visualizza durata totale'] = 'si' end
if primo_titolo then
return componi_tracce(args, primo_titolo) -- table.concat(log, '\n*') --
else
return