Modulo:Tracce/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
m indentazione con tab
semplifico
Riga 6:
 
-- Protects a string that will be wrapped in wiki italic markup '' ... ''
local function safeforitalics( str )
if str:sub(1,1) ~== nil"'" andthen str ~= ''"<span></span>" then.. str end
if str:sub(-1,-1) == "'" then str = str .. "<span></span>" .. str end
if str:sub(-1,-1) == "'" then str = str .. "<span></span>" end
end
return str
end
Line 23 ⟶ 21:
local row_elements = {}
table.insert(row_elements, '<li value="' .. tostring(i) .. '">')
local interprete = args["Interprete" .. i] or ""
if interprete ~= "" then table.insert(row_elements, interprete .. " – ") end
corsivo = (corsivo and args["Corsivo" .. i] ~= "no") or
(not corsivo and (args["Corsivo" .. i] == "sì" or args["Corsivo" .. i] == "si"))
Line 34 ⟶ 32:
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
Line 52 ⟶ 50:
table.insert(row_elements, " – ")
table.insert(row_elements, string.format("%d:%02.f", minuti, secondi))
local args_durata = elseif string_durata or args["Minuti" .. i] or args["Secondi" .. i] then
else
categories[#categories+1] = unknown_format
local args_durata = string_durata or args["Minuti" .. i]
or args["Secondi" .. i] or ""
if args_durata ~= "" then
categories[#categories+1] = unknown_format
end
end
local AutoreTesto = args["Autore testo" .. i] or ""
local AutoreMusica = args["Autore musica" .. i] or ""
local AutoreTestoeMusica = args["Autore testo e musica" .. i] or ""
local edizioni = args["Edizioni" .. i] or ""
local no_autore = false
if AutoreTestoeMusica ~= "" then
table.insert(row_elements, " <small>(" .. AutoreTestoeMusica )
elseif AutoreTesto ~= "" then
table.insert(row_elements, " <small>(testo: " .. AutoreTesto)
if AutoreMusica ~="" then
table.insert(row_elements, " – musica: " .. AutoreMusica)
end
elseif AutoreMusica ~= "" then
table.insert(row_elements, " <small>(musica: " .. AutoreMusica)
else
no_autore = true
end
if edizioni ~= "" then
if no_autore then
table.insert(row_elements, " <small>(")
Line 86 ⟶ 80:
table.insert(row_elements, ")</small>")
end
local extra = args["Extra" .. i] or ""
if extra ~= "" then table.insert(row_elements, " – " .. extra) end
table.insert(row_elements, "</li>\n")
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
 
--[[
Riceve una tabella di parametri e l'indicerestituisce deluna primostringa gruppo di parametri del template tracce,contenente
restituisce una stringa contenente l'output da inserire nella voce
]]--
local function componi_tracce(args)
Line 104 ⟶ 98:
local testata = ""
local no_autore = false
local autoreTestoeMusica = args["Autore testi e musiche"] or ""
if autoreTestoeMusica ~= "" then
testata = "Testi e musiche di " .. autoreTestoeMusica
else
local autoreTesti, autoreMusiche = args["Autore testi"], orargs["Autore musiche""]
if autoreTesti ~= "" then
local autoreMusiche = args["Autore musiche"] or ""
if autoreTesti ~= "" then
testata = "Testi di " .. autoreTesti
if autoreMusiche ~= "" then testata = testata .. ", musiche di " .. autoreMusiche end
elseif autoreMusiche ~= "" then
testata = "Musiche di " .. autoreMusiche
else
Line 119 ⟶ 112:
end
end
local edizioni = args["Edizioni"] or ""
if edizioni ~= "" then
if no_autore then
testata = "Edizioni musicali " .. edizioni .."."
Line 129 ⟶ 122:
testata = testata .. "."
end
local corsivo = args["Corsivo"] == "no" and false or true
if args["Corsivo"] == "no" then
corsivo = false
end
table.insert(tracks, testata)
-- compone la lista dei parametri
table.insert(tracks, "<ol>")
local visualizza_durata = args["Visualizza durata totale"] or ""
local durata = 0
local somma_durata = false
Line 144 ⟶ 134:
local numero_titolo = k:match('%D(%d+)$')
if tonumber(numero_titolo) then
local titolo = args['Titolo' .. numero_titolo] or ''
if v ~= '' andnot titolo == '' then
categories[#categories+1] = missing_title
elseif k == 'Titolo' .. numero_titolo and titolo ~= '' then
table.insert(nums, tonumber(numero_titolo))
end
Line 180 ⟶ 170:
local args = {}
local titles = false
for k, v in pairs( pframe.args ) do
if v ~= nil thenand args[k]v ~= v'' endthen
args[k] = v
if not titles and k:match("^Titolo(%d+)$") then titles = true end
titles = true
end
end
end
-- procede solo se c'è almeno un campo titolo
return titles and componi_tracce(args) or ""''
end