« Module:Pistes » : différence entre les versions
création brouillon |
Aucun résumé des modifications |
||
Ligne 1 : | Ligne 1 : | ||
local p = {} |
|||
local langue = require 'Module:Langue' |
local langue = require 'Module:Langue' |
||
local nbPistes = 0 |
local nbPistes = 0 |
||
local function piste (i) |
|||
if {{{piste1|{{{title1|}}}}}} or {{{note1|}}} or {{{temps1|{{{length1|}}}}}} then |
|||
local ligne = mw.html.create( 'tr' ) |
|||
if i%2 == 0 then |
|||
ligne:css( 'background-color', 'var(--background-color-base, #fff)') |
|||
else |
|||
ligne:css( 'background-color', '#f7f7f7') --couleur pas adaptée selon mode sombre / pas sombre |
|||
end |
|||
ligne |
|||
:tag( 'th' ) |
|||
:attr{ scope = 'row' } |
|||
:cssText( 'padding-right: 10px; text-align: right;font-weight:normal;' ) |
|||
:wikitext( {{{numero1|1}}}. ) |
|||
<td style="text-align: left;"> |
|||
if {{{piste1|{{{title1|}}}}}} then |
|||
if {{{langue|}}} then |
|||
{{#invoke:Langue|{{{langue|}}}|{{#ifeq: {{#invoke:Langue|nonLatin| {{{piste1|{{{title1|}}}}}} }} | true | {{{2}}} | ''<nowiki/>{{{piste1|{{{title1|}}}}}}<nowiki/>'' }}}} |
|||
else |
|||
{{#ifeq: {{#invoke:Langue|nonLatin| {{{piste1|{{{title1|}}}}}} }} | true | {{{piste1|{{{title1|}}}}}} | ''<nowiki/>{{{piste1|{{{title1|}}}}}}<nowiki/>'' |
|||
else |
|||
Sans titre |
|||
if {{{note1|}}} then |
|||
' <small>({{{note1|}}})</small>' |
|||
end |
|||
</td> |
|||
if {{{credits_paroles}}} == 'oui' then |
|||
<td>{{{paroles1|{{{lyrics1|}}}}}}</td> |
|||
end |
|||
if {{{credits_musique}}} == 'oui' then |
|||
<td>{{{musique1|{{{music1|}}}}}}</td> |
|||
end |
|||
if {{{credits_ecriture}}} == 'oui' then |
|||
<td>{{{auteur1|{{{writer1|}}}}}}</td> |
|||
end |
|||
if {{{colonne_extra|}}} then |
|||
<td>{{{extra1|}}}</td> |
|||
end |
|||
<td style="padding-right: 10px; text-align: right;">{{{temps1|{{{length1|}}}}}}</td> |
|||
</tr> |
|||
end |
|||
end |
|||
function p.main( frame ) |
function p.main( frame ) |
||
-- 1. Lecture des paramètres |
|||
local args = {} |
local args = {} |
||
for k, v in pairs(frame:getParent().args) do |
for k, v in pairs(frame:getParent().args) do |
||
local matchNb = mw.ustring.match( k, '(.+)(%d+)' ) |
local matchNb = mw.ustring.match( k, '(.+)(%d+)' ) |
||
if matchNb |
if matchNb then |
||
local param, nb = matchNb[1], matchNb[2] |
local param, nb = matchNb[1], matchNb[2] |
||
if args[nb] == nil then |
if args[nb] == nil then |
||
if nb > nbPistes |
if nb > nbPistes then |
||
nbPistes = nb |
nbPistes = nb |
||
end |
end |
||
Ligne 66 : | Ligne 25 : | ||
end |
end |
||
-- 2. Initialisation du tableau de la liste des titres |
|||
local divPistes = mw.html.create( 'div' ) |
|||
:addClass( "overflow" ) |
|||
:css({ |
|||
margin = '0 auto', |
|||
paddingLeft = '1px', |
|||
['margin-bottom'] = args.total_temps ~= '' and '0.5em' or '1em', |
|||
overflow = 'hidden' |
|||
}) |
|||
local tabPistes = divPistes |
|||
:tag( "table" ) |
|||
:addClass( "tracklist" .. (args.collapsed == 'oui' and "collapsible collapsed" or "" )) |
|||
:attr( 'cellpadding', "0" ) |
|||
:css({ |
|||
width = '100%', |
|||
['border-width'] = '0px', |
|||
['border-collapse'] = 'collapse' |
|||
}) |
|||
-- 3. Éventuel code avant l'entête du tableau (titre ou boîte repliable) |
|||
<div style="margin:0 auto;padding-left:1px; margin-bottom:{{#if:{{{total_temps|}}}|0.5|1}}em;overflow:hidden;" class="overflow"><table class="tracklist{{#ifeq: {{{collapsed}}}|oui|<nowiki> </nowiki>collapsible collapsed}}" cellpadding="0" style="width: 100%;border-width: 0px; border-collapse: collapse;"> |
|||
if args.titre or args.headline then |
|||
tabPistes |
|||
<tr> |
|||
:tag( "tr" ) |
|||
<th class="tlheader" colspan="10" style="text-align: left; background-color: var(--background-color-base, #fff); color:var(--color-base, #202122); border-width: 0;" scope="col"> |
|||
:tag( "th" ) |
|||
{{#if:{{{langue titre|{{{langue titres|}}}}}}|{{langue|{{{langue titre|{{{langue titres|}}}}}}|{{{titre|{{{headline|}}}}}}}}|{{{titre|{{{headline|}}}}}}}}</th> |
|||
:addClass( "tlheader" ) |
|||
</tr> | |
|||
:attr( "scope", "col" ) |
|||
{{#ifeq: {{{collapsed}}}|oui| |
|||
:attr( "colspan", "10" ) |
|||
<tr> |
|||
:css({ |
|||
<th class="tlheader" colspan="10" style="text-align: left; background-color: var(--background-color-base, #fff); color:var(--color-base, #202122); border-width: 0;"> </th> |
|||
['text-align'] = 'left', |
|||
</tr> |
|||
['background-color'] = 'var(--background-color-base, #fff)', |
|||
}} |
|||
color = 'var(--color-base, #202122)', |
|||
}} |
|||
['border-width'] = '0' |
|||
<tr> |
|||
}) |
|||
<th class="tlheader" style="width: 20px; padding-left: 10px; padding-right: 10px; text-align: right; background-color: var(--background-color-neutral, #eaecf0); color:var(--color-base, #202122);" scope="col">{{Numéro avec majuscule|espace=non}}</th> |
|||
:wikitext( (args["langue titre"] or args["langue titres"]) and langue.langue(args["langue titre"] or args["langue titres"], args.titre or args.headline) or (args.titre or args.headline) ) |
|||
<th class="tlheader" scope="col" style="{{#switch: {{#expr: {{#ifeq: {{{credits_paroles|{{{lyrics_credits|}}}}}}|oui|1|0}} + {{#ifeq: {{{credits_musique|{{{music_credits|}}}}}}|oui|1|0}} + {{#ifeq: {{{credits_ecriture|{{{writing_credits|}}}}}}|oui|1|0}} + {{#if: {{{colonne_extra|{{{extra_column|}}}}}}|1|0}} }} | 0 = width: 100%; | 1 = width: 60%; | 2 = width: 40%; | 3 = width: 30%; | 4 = width: 20%;}} text-align: left; background-color: var(--background-color-neutral, #eaecf0); color:var(--color-base, #202122);">Titre</th>{{ #ifeq: {{{credits_paroles|{{{lyrics_credits|}}}}}}|oui|<th scope="col" style="{{#switch: {{#expr: ({{#ifeq: {{{credits_paroles|{{{lyrics_credits|}}}}}}|oui|1|0}} + {{#ifeq: {{{credits_musique|{{{music_credits|}}}}}}|oui|1|0}} + {{#ifeq: {{{credits_ecriture|{{{writing_credits|}}}}}}|oui|1|0}} + {{#if: {{{colonne_extra|{{{extra_column|}}}}}}|1|0}}) }} | 1 = width: 40%; | 2 = width: 30%; | 3 = width: 20%; | 4 = width: 20%;}} text-align: left; background-color: var(--background-color-neutral, #eaecf0); color:var(--color-base, #202122);">Paroles</th>}}{{ #ifeq: {{{credits_musique|{{{music_credits|}}}}}}|oui|<th scope="col" style="{{#switch: {{#expr: ({{#ifeq: {{{credits_paroles|{{{lyrics_credits|}}}}}}|oui|1|0}} + {{#ifeq: {{{credits_musique|{{{music_credits|}}}}}}|oui|1|0}} + {{#ifeq: {{{credits_ecriture|{{{writing_credits|}}}}}}|oui|1|0}} + {{#if: {{{colonne_extra|{{{extra_column|}}}}}}|1|0}}) }} | 1 = width: 40%; | 2 = width: 30%; | 3 = width: 20%; | 4 = width: 20%;}} text-align: left; background-color: var(--background-color-neutral, #eaecf0); color:var(--color-base, #202122);">Musique</th>}}{{ #ifeq: {{{credits_ecriture|{{{writing_credits|}}}}}}|oui|<th scope="col" style="{{#switch: {{#expr: ({{#ifeq: {{{credits_paroles|{{{lyrics_credits|}}}}}}|oui|1|0}} + {{#ifeq: {{{credits_musique|{{{music_credits|}}}}}}|oui|1|0}} + {{#ifeq: {{{credits_ecriture|{{{writing_credits|}}}}}}|oui|1|0}} + {{#if: {{{colonne_extra|{{{extra_column|}}}}}}|1|0}}) }} | 1 = width: 40%; | 2 = width: 30%; | 3 = width: 20%; | 4 = width: 20%;}} text-align: left; background-color: var(--background-color-neutral, #eaecf0); color:var(--color-base, #202122);">Auteur</th>}}{{ #if: {{{colonne_extra|{{{extra_column|}}}}}}|<th scope="col" style="{{#switch: {{#expr: ({{#ifeq: {{{credits_paroles|{{{lyrics_credits|}}}}}}|oui|1|0}} + {{#ifeq: {{{credits_musique|{{{music_credits|}}}}}}|oui|1|0}} + {{#ifeq: {{{credits_ecriture|{{{writing_credits|}}}}}}|oui|1|0}} + {{#if: {{{colonne_extra|{{{extra_column|}}}}}}|1|0}}) }} | 1 = width: 40%; | 2 = width: 30%; | 3 = width: 20%; | 4 = width: 20%;}} text-align: left; background-color: var(--background-color-neutral, #eaecf0); color:var(--color-base, #202122);">{{{colonne_extra|{{{extra_column|}}}}}}</th>}} |
|||
elseif args.collapsed == 'oui' then |
|||
<th class="tlheader" style="width: 60px; padding-right: 10px; text-align: right; background-color: var(--background-color-neutral, #eaecf0); color:var(--color-base, #202122);" scope="col">Durée</th> |
|||
tabPistes |
|||
</tr> |
|||
:tag( "tr" ) |
|||
:tag( "th" ) |
|||
for i = 1, nbPistes do |
|||
:addClass( "tlheader" ) |
|||
piste (i) |
|||
:attr( "colspan", "10" ) |
|||
:css({ |
|||
['text-align'] = 'left', |
|||
['background-color'] = 'var(--background-color-base, #fff)', |
|||
color = 'var(--color-base, #202122)', |
|||
['border-width'] = '0' |
|||
}) |
|||
:wikitext( " " ) |
|||
end |
|||
-- 4. Création de l'entête du tableau |
|||
local nbColonnesExtra = ((args.credits_paroles or args.lyrics_credits) + (args.credits_musique or args.music_credits) + (args.credits_ecriture or args.writing_credits) + (args.colonne_extra or args.extra_column)) or 0 |
|||
local entetesPistes = tabPistes |
|||
:tag( "tr" ) |
|||
:tag( "th" ) -- Colonne « Numéro » |
|||
:addClass( "tlheader" ) |
|||
:attr( "scope", "col" ) |
|||
:css({ |
|||
width = '20px', |
|||
['padding-left'] = '10px', |
|||
['padding-righ'] = '10px', |
|||
['text-align'] = 'right', |
|||
['background-color'] = 'var(--background-color-neutral, #eaecf0)', |
|||
color = 'var(--color-base, #202122)' |
|||
}) |
|||
:wikitext( "{{Numéro avec majuscule|espace=non}}" ) |
|||
:done() |
|||
:tag( "th" ) -- Colonne « Titre » |
|||
:addClass( "tlheader" ) |
|||
:attr( "scope", "col" ) |
|||
:css({ |
|||
width = ({[0]='100%', [1]='60%', [2]='40%', [3]='30%', [4]='20%'})[nbColonnesExtra], |
|||
['text-align'] = 'left', |
|||
['background-color'] = 'var(--background-color-neutral, #eaecf0)', |
|||
color = 'var(--color-base, #202122)' |
|||
}) |
|||
:wikitext( "Titre" ) |
|||
:done() |
|||
if args.credits_paroles == 'oui' or args.lyrics_credits == 'oui' then -- Colonne « Paroles » |
|||
entetesPistes |
|||
:tag( "th" ) |
|||
:attr( "scope", "col" ) |
|||
:css({ |
|||
width = ({[1]='40%', [2]='30%', [3]='20%', [4]='20%'})[nbColonnesExtra], |
|||
['text-align'] = 'left', |
|||
['background-color'] = 'var(--background-color-neutral, #eaecf0)', |
|||
color = 'var(--color-base, #202122)' |
|||
}) |
|||
:wikitext( "Paroles" ) |
|||
:done() |
|||
end |
|||
if args.credits_musique == 'oui' or args.music_credits == 'oui' then -- Colonne « Musique » |
|||
entetesPistes |
|||
:tag( "th" ) |
|||
:attr( "scope", "col" ) |
|||
:css({ |
|||
width = ({[1]='40%', [2]='30%', [3]='20%', [4]='20%'})[nbColonnesExtra], |
|||
['text-align'] = 'left', |
|||
['background-color'] = 'var(--background-color-neutral, #eaecf0)', |
|||
color = 'var(--color-base, #202122)' |
|||
}) |
|||
:wikitext( "Musique" ) |
|||
:done() |
|||
end |
|||
if args.credits_ecriture == 'oui' or args.writing_credits == 'oui' then -- Colonne « Auteur » |
|||
entetesPistes |
|||
:tag( "th" ) |
|||
:attr( "scope", "col" ) |
|||
:css({ |
|||
width = ({[1]='40%', [2]='30%', [3]='20%', [4]='20%'})[nbColonnesExtra], |
|||
['text-align'] = 'left', |
|||
['background-color'] = 'var(--background-color-neutral, #eaecf0)', |
|||
color = 'var(--color-base, #202122)' |
|||
}) |
|||
:wikitext( "Auteur" ) |
|||
:done() |
|||
end |
|||
if args.colonne_extra == 'oui' or args.extra_column == 'oui' then -- Colonne extra |
|||
entetesPistes |
|||
:tag( "th" ) |
|||
:attr( "scope", "col" ) |
|||
:css({ |
|||
width = ({[1]='40%', [2]='30%', [3]='20%', [4]='20%'})[nbColonnesExtra], |
|||
['text-align'] = 'left', |
|||
['background-color'] = 'var(--background-color-neutral, #eaecf0)', |
|||
color = 'var(--color-base, #202122)' |
|||
}) |
|||
:wikitext( args.colonne_extra or args.extra_column ) |
|||
:done() |
|||
end |
|||
entetesPistes -- Durée |
|||
:tag( "th" ) |
|||
:addClass( "tlheader" ) |
|||
:attr( "scope", "col" ) |
|||
:css({ |
|||
width = '60px', |
|||
['padding-right'] = '10px', |
|||
['text-align'] = 'right', |
|||
['background-color'] = 'var(--background-color-neutral, #eaecf0)', |
|||
color = 'var(--color-base, #202122)' |
|||
}) |
|||
:wikitext( "Durée" ) |
|||
:done() |
|||
end |
end |
||
-- 5. Tracé des lignes du tableau |
|||
{{ #if: {{{total_temps|}}} | |
|||
for i = 1, nbPistes do |
|||
<tr> |
|||
<td colspan="10" style="padding-right: 10px; text-align: right; background-color: var(--background-color-base, #fff); border-width: 0;">'''{{{total_temps}}}'''</td> |
|||
if args[i] and (args[i].piste or args[i].title or args[i].note or args[i].temps or args[i].length) then |
|||
</tr> |
|||
local ligne = tabPistes:tag( 'tr' ) |
|||
}}</table></div> |
|||
if i%2 == 0 then |
|||
ligne:css( 'background-color', 'var(--background-color-base, #fff)') |
|||
else |
|||
ligne:css( 'background-color', '#f7f7f7') --couleur pas adaptée selon mode sombre / pas sombre |
|||
end |
|||
ligne |
|||
:tag( 'th' ) |
|||
:attr{ scope = 'row' } |
|||
:css({ |
|||
['padding-right'] = '10px', |
|||
['text-align'] = 'right', |
|||
['font-weight'] = 'normal' |
|||
}) |
|||
:wikitext( (args[i].numero or tostring(i)) .. '.' ) |
|||
local titre |
|||
if args[i].piste or args[i].title then |
|||
local nonLatin = langue.nonLatin( args[i].piste or args[i].title ) |
|||
if nonLatin then |
|||
titre = args[i].piste or args[i].title |
|||
else |
|||
titre = "''" .. (args[i].piste or args[i].title) .. "''" |
|||
end |
|||
if args.langue then |
|||
titre = langue.langue(args.langue, titre) |
|||
end |
|||
else |
|||
titre = 'Sans titre' |
|||
end |
|||
if args[i].note then |
|||
titre = titre .. ' <small>(' .. args[i].note .. ')</small>' |
|||
end |
|||
ligne:tag ( 'td' ):wikitext( titre ) |
|||
if args.credits_paroles == 'oui' or args.lyrics_credits == 'oui' then |
|||
ligne:tag( 'td' ):wikitext( args[i].paroles or args[i].lyrics ) |
|||
end |
|||
if args.credits_musique == 'oui' or args.music_credits == 'oui' then |
|||
ligne:tag( 'td' ):wikitext( args[i].musique or args[i].music ) |
|||
end |
|||
if args.credits_ecriture == 'oui' or args.writing_credits == 'oui' then |
|||
ligne:tag( 'td' ):wikitext( args[i].auteur or args[i].writer ) |
|||
end |
|||
if args.colonne_extra or args.extra_column then |
|||
ligne:tag( 'td' ):wikitext( args[i].extra ) |
|||
end |
|||
ligne:tag('td') |
|||
:css({ |
|||
['padding-right'] = '10px', |
|||
['text-align'] = 'right' |
|||
}) |
|||
:wikitext( args[i].temps or args[i].length ) |
|||
end |
|||
end |
|||
if args.total_temps then |
|||
tabPistes:tag( 'tr' ):tag('td') |
|||
:attr( 'colspan', '10' ) |
|||
:css({ |
|||
['padding-right'] = '10px', |
|||
['text-align'] = 'right', |
|||
['background-color'] = 'var(--background-color-base, #fff)', |
|||
color = 'var(--color-base, #202122)', |
|||
['font-weight'] = 'bold', |
|||
['border-width'] = '0' |
|||
}) |
|||
:wikitext( args.total_temps ) |
|||
return tostring( divPistes ) |
|||
end |
end |
||
return p |
return p |
||
]]-- |
Version du 16 mai 2024 à 22:37
Utilisation
Ce module est conçu pour une utilisation à travers le modèle Modèle:Pistes. Il fournit une fonction permettant la génération du tableau correspondant à une liste de pistes audio, avec indication du titre et de la durée et d'autres paramètres optionnels.
Le style du modèle est géré par Modèle:Pistes/styles.css.
Fonctions exportables
main(frame)
– Prend en argument un frame et retourne une chaîne de caractères contenant le code html d'un tableau.
Modules externes et autres éléments dont ce module a besoin pour fonctionner
mw.ustring.match
– Cherche la première correspondance d'un motif dans une chaine de caractères ;mw.text.trim
– Enlève les espaces au début et à la fin d'une chaine de caractères ;mw.html.create
– Crée un nouvel objet mw.html, équivalent d'un élément HTML ;
Module:Langue
– Module de mise en forme du contenu en langue étrangère.
Modules lua utilisant ce module
Aucun
Modèles appelant directement ce module
Exemples
Dans Modèle:Pistes, ce module est appelé par le code suivant :
{{#invoke:Pistes|main}}
La documentation de ce module est générée par le modèle {{Documentation module}}.
Elle est incluse depuis sa sous-page de documentation. Veuillez placer les catégories sur cette page-là.
Les éditeurs peuvent travailler dans le bac à sable (modifier).
Voir les statistiques d'appel depuis le wikicode sur l'outil wstat et les appels depuis d'autres modules.
local p = {}
local langue = require 'Module:Langue'
local nbPistes = 0
function p.main( frame )
-- 1. Lecture des paramètres
local args = {}
for k, v in pairs(frame:getParent().args) do
local matchNb = mw.ustring.match( k, '(.+)(%d+)' )
if matchNb then
local param, nb = matchNb[1], matchNb[2]
if args[nb] == nil then
if nb > nbPistes then
nbPistes = nb
end
args[nb] = {}
end
args[nb][param] = v
else
args[k] = v -- manque résolution des alias
end
end
-- 2. Initialisation du tableau de la liste des titres
local divPistes = mw.html.create( 'div' )
:addClass( "overflow" )
:css({
margin = '0 auto',
paddingLeft = '1px',
['margin-bottom'] = args.total_temps ~= '' and '0.5em' or '1em',
overflow = 'hidden'
})
local tabPistes = divPistes
:tag( "table" )
:addClass( "tracklist" .. (args.collapsed == 'oui' and "collapsible collapsed" or "" ))
:attr( 'cellpadding', "0" )
:css({
width = '100%',
['border-width'] = '0px',
['border-collapse'] = 'collapse'
})
-- 3. Éventuel code avant l'entête du tableau (titre ou boîte repliable)
if args.titre or args.headline then
tabPistes
:tag( "tr" )
:tag( "th" )
:addClass( "tlheader" )
:attr( "scope", "col" )
:attr( "colspan", "10" )
:css({
['text-align'] = 'left',
['background-color'] = 'var(--background-color-base, #fff)',
color = 'var(--color-base, #202122)',
['border-width'] = '0'
})
:wikitext( (args["langue titre"] or args["langue titres"]) and langue.langue(args["langue titre"] or args["langue titres"], args.titre or args.headline) or (args.titre or args.headline) )
elseif args.collapsed == 'oui' then
tabPistes
:tag( "tr" )
:tag( "th" )
:addClass( "tlheader" )
:attr( "colspan", "10" )
:css({
['text-align'] = 'left',
['background-color'] = 'var(--background-color-base, #fff)',
color = 'var(--color-base, #202122)',
['border-width'] = '0'
})
:wikitext( " " )
end
-- 4. Création de l'entête du tableau
local nbColonnesExtra = ((args.credits_paroles or args.lyrics_credits) + (args.credits_musique or args.music_credits) + (args.credits_ecriture or args.writing_credits) + (args.colonne_extra or args.extra_column)) or 0
local entetesPistes = tabPistes
:tag( "tr" )
:tag( "th" ) -- Colonne « Numéro »
:addClass( "tlheader" )
:attr( "scope", "col" )
:css({
width = '20px',
['padding-left'] = '10px',
['padding-righ'] = '10px',
['text-align'] = 'right',
['background-color'] = 'var(--background-color-neutral, #eaecf0)',
color = 'var(--color-base, #202122)'
})
:wikitext( "{{Numéro avec majuscule|espace=non}}" )
:done()
:tag( "th" ) -- Colonne « Titre »
:addClass( "tlheader" )
:attr( "scope", "col" )
:css({
width = ({[0]='100%', [1]='60%', [2]='40%', [3]='30%', [4]='20%'})[nbColonnesExtra],
['text-align'] = 'left',
['background-color'] = 'var(--background-color-neutral, #eaecf0)',
color = 'var(--color-base, #202122)'
})
:wikitext( "Titre" )
:done()
if args.credits_paroles == 'oui' or args.lyrics_credits == 'oui' then -- Colonne « Paroles »
entetesPistes
:tag( "th" )
:attr( "scope", "col" )
:css({
width = ({[1]='40%', [2]='30%', [3]='20%', [4]='20%'})[nbColonnesExtra],
['text-align'] = 'left',
['background-color'] = 'var(--background-color-neutral, #eaecf0)',
color = 'var(--color-base, #202122)'
})
:wikitext( "Paroles" )
:done()
end
if args.credits_musique == 'oui' or args.music_credits == 'oui' then -- Colonne « Musique »
entetesPistes
:tag( "th" )
:attr( "scope", "col" )
:css({
width = ({[1]='40%', [2]='30%', [3]='20%', [4]='20%'})[nbColonnesExtra],
['text-align'] = 'left',
['background-color'] = 'var(--background-color-neutral, #eaecf0)',
color = 'var(--color-base, #202122)'
})
:wikitext( "Musique" )
:done()
end
if args.credits_ecriture == 'oui' or args.writing_credits == 'oui' then -- Colonne « Auteur »
entetesPistes
:tag( "th" )
:attr( "scope", "col" )
:css({
width = ({[1]='40%', [2]='30%', [3]='20%', [4]='20%'})[nbColonnesExtra],
['text-align'] = 'left',
['background-color'] = 'var(--background-color-neutral, #eaecf0)',
color = 'var(--color-base, #202122)'
})
:wikitext( "Auteur" )
:done()
end
if args.colonne_extra == 'oui' or args.extra_column == 'oui' then -- Colonne extra
entetesPistes
:tag( "th" )
:attr( "scope", "col" )
:css({
width = ({[1]='40%', [2]='30%', [3]='20%', [4]='20%'})[nbColonnesExtra],
['text-align'] = 'left',
['background-color'] = 'var(--background-color-neutral, #eaecf0)',
color = 'var(--color-base, #202122)'
})
:wikitext( args.colonne_extra or args.extra_column )
:done()
end
entetesPistes -- Durée
:tag( "th" )
:addClass( "tlheader" )
:attr( "scope", "col" )
:css({
width = '60px',
['padding-right'] = '10px',
['text-align'] = 'right',
['background-color'] = 'var(--background-color-neutral, #eaecf0)',
color = 'var(--color-base, #202122)'
})
:wikitext( "Durée" )
:done()
end
-- 5. Tracé des lignes du tableau
for i = 1, nbPistes do
if args[i] and (args[i].piste or args[i].title or args[i].note or args[i].temps or args[i].length) then
local ligne = tabPistes:tag( 'tr' )
if i%2 == 0 then
ligne:css( 'background-color', 'var(--background-color-base, #fff)')
else
ligne:css( 'background-color', '#f7f7f7') --couleur pas adaptée selon mode sombre / pas sombre
end
ligne
:tag( 'th' )
:attr{ scope = 'row' }
:css({
['padding-right'] = '10px',
['text-align'] = 'right',
['font-weight'] = 'normal'
})
:wikitext( (args[i].numero or tostring(i)) .. '.' )
local titre
if args[i].piste or args[i].title then
local nonLatin = langue.nonLatin( args[i].piste or args[i].title )
if nonLatin then
titre = args[i].piste or args[i].title
else
titre = "''" .. (args[i].piste or args[i].title) .. "''"
end
if args.langue then
titre = langue.langue(args.langue, titre)
end
else
titre = 'Sans titre'
end
if args[i].note then
titre = titre .. ' <small>(' .. args[i].note .. ')</small>'
end
ligne:tag ( 'td' ):wikitext( titre )
if args.credits_paroles == 'oui' or args.lyrics_credits == 'oui' then
ligne:tag( 'td' ):wikitext( args[i].paroles or args[i].lyrics )
end
if args.credits_musique == 'oui' or args.music_credits == 'oui' then
ligne:tag( 'td' ):wikitext( args[i].musique or args[i].music )
end
if args.credits_ecriture == 'oui' or args.writing_credits == 'oui' then
ligne:tag( 'td' ):wikitext( args[i].auteur or args[i].writer )
end
if args.colonne_extra or args.extra_column then
ligne:tag( 'td' ):wikitext( args[i].extra )
end
ligne:tag('td')
:css({
['padding-right'] = '10px',
['text-align'] = 'right'
})
:wikitext( args[i].temps or args[i].length )
end
end
if args.total_temps then
tabPistes:tag( 'tr' ):tag('td')
:attr( 'colspan', '10' )
:css({
['padding-right'] = '10px',
['text-align'] = 'right',
['background-color'] = 'var(--background-color-base, #fff)',
color = 'var(--color-base, #202122)',
['font-weight'] = 'bold',
['border-width'] = '0'
})
:wikitext( args.total_temps )
return tostring( divPistes )
end
return p