Modulo:Tracce/sandbox: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
m fix |
ammetto numerazione discontinua delle tracce |
||
Riga 1:
local categories = {}
local discontinuous_num = '[[Categoria:Voci con template Tracce a numerazione discontinua]]'
local missing_title = '[[Categoria:Errori di compilazione del template Tracce - titolo mancante]]'
local unexpected_markup = '[[Categoria:Errori di compilazione del template Tracce - markup inaspettato]]'
Line 19 ⟶ 20:
local function track(args, i, corsivo)
local row_elements = {}
table.insert(row_elements, '<li value="' .. tostring(i) .. '">')
local interprete = args["Interprete" .. i] or ""
corsivo = (corsivo and args["Corsivo" .. i] ~= "no") or
(not corsivo and (args["Corsivo" ..
if
categories[#categories+1] = unexpected_markup
end
if corsivo then
titolo = "''" .. safeforitalics(titolo) .. "''"
end
table.insert(row_elements, titolo)
local featuring = args["Featuring" .. i] or ""
if featuring ~= "" then table.insert(row_elements, " <small>(feat. " .. featuring .. ")</small>") end
local note = args["Note" .. i] or ""
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 =
minuti = tonumber(string_minuti) or 0
else
minuti = tonumber(args["Minuti" .. i]) or 0
end
local durata = minuti * 60 + secondi
table.insert(row_elements, " – ")
else
local args_durata = string_durata or args["Minuti" .. i]
if args_durata ~= "" then
categories[#categories+1] = unknown_format
end
local AutoreTesto = args["Autore testo" .. i] or ""
local no_autore = false
if AutoreTestoeMusica ~= "" then
table.insert(row_elements, " <small>("
elseif AutoreTesto ~= "" then
table.insert(row_elements, " <small>(testo: " .. AutoreTesto)
if AutoreMusica ~="" then
table.insert(row_elements, " – musica: "
end
elseif AutoreMusica ~= "" then
table.insert(row_elements, " <small>(musica: "
else
no_autore = true
end
if edizioni ~= "" then
table.insert(row_elements, " <small>(")
else
table.insert(row_elements, "; ")
end
table.insert(row_elements, "edizioni musicali " .. edizioni .. ")</small>")
elseif not no_autore then
table.insert(row_elements, ")</small>")
end
local extra = args["Extra" .. i] or ""
if extra ~= "" then table.insert(row_elements, " – " .. extra) end
local ListaMedley = args["ListaMedley" .. i] or ""
if ListaMedley ~= "" then table.insert(row_elements, '<div style="padding: 0.3em 0px 0.5em 2.5em;">\n' .. ListaMedley .. '</div>') end
return table.concat(row_elements), durata
end
Line 101 ⟶ 98:
restituisce una stringa contenente l'output da inserire nella voce
]]--
local function componi_tracce(args
-- array per accumulare le righe della lista man mano che vengono elaborate
local tracks = {}
Line 138 ⟶ 135:
table.insert(tracks, testata)
-- compone la lista dei parametri
table.insert(tracks, "<ol>")
local visualizza_durata = args["Visualizza durata totale"] or ""
Line 144 ⟶ 140:
local somma_durata = false
if visualizza_durata == "si" or visualizza_durata == "sì" then somma_durata = true end
local nums = {}
local titolo = args['Titolo' .. numero_titolo] or ''
if v ~= '' and titolo == '' then
categories[#categories+1] = missing_title
elseif k == 'Titolo' .. numero_titolo and titolo ~= '' then
table.insert(nums, tonumber(numero_titolo))
end
end
end
table.sort(nums)
-- estrae le tracce dai parametri e inserisce i valori nella tabella tracks
for k, num in ipairs(nums) do
local new_track, durata_track = track(args, num, corsivo)
table.insert(tracks, new_track)
if somma_durata then durata = durata + durata_track end
if k ~= num then categories[#categories+1] = discontinuous_num end
end
table.insert(tracks, "</ol>")
Line 171 ⟶ 179:
-- estrae tutti i parametri e li memorizza in una tabella
local args = {}
local
for k, v in pairs( pframe.args ) do
if v ~= nil then args[k] = v end
if k:match("^Titolo(%d+)$") then titles = true end
end
-- procede solo se c'è almeno un campo titolo
return titles and componi_tracce(args) or ""
end
|