« Module:FonctionsTest » : différence entre les versions
Apparence
Page créée avec « local p = {} function p.main(frame) local args = frame:getParent().args local titre = args["Titre"] or "Aucun titre" local predecesseur = args["Prédécesseur"] or "?" local successeur = args["Successeur"] or "?" local html = {} table.insert(html, "<div style='border: 1px solid black; padding: 1em;'>") table.insert(html, "<b>" .. titre .. "</b><br>") table.insert(html, "← " .. predecesseur .. " · " .. successeur .. " →") table.insert(h... » |
Aucun résumé des modifications |
||
| (2 versions intermédiaires par le même utilisateur non affichées) | |||
| Ligne 1 : | Ligne 1 : | ||
local p = {} | local p = {} | ||
local charteModule = require('Module:Charte') | |||
function | local function FonctionsTest(args, index) | ||
local | local suffix = index == 1 and "" or tostring(index) | ||
local titre = args["Titre"] | local titre = args["Titre" .. suffix] | ||
local predecesseur = args["Prédécesseur"] | local mandat = args["Mandat" .. suffix] | ||
local | local predecesseur = args["Prédécesseur" .. suffix] | ||
local successeur = args["Successeur" .. suffix] | |||
local charte = args["Charte"] or "defaut" | |||
if not (titre or predecesseur or successeur) then | |||
return "" | |||
end | |||
-- Sécurisation des couleurs | |||
local couleurFond = charteModule.couleur{charte = charte, type = "titre"} or "#CCCCCC" | |||
local couleurTexte = charteModule.couleur{charte = charte, type = "texte"} or "#000000" | |||
local couleurHr = charteModule.couleur{charte = charte, type = "hr"} or "#999999" | |||
local html = {} | local html = {} | ||
table.insert(html, "<div style=' | table.insert(html, '<div style="margin: 0.5em 0; overflow: hidden; font-size: 90%;">') | ||
table.insert(html, " | |||
table.insert(html, "← [[ | table.insert(html, '<div style="background-color: ' .. couleurFond .. '; color: ' .. couleurTexte .. '; text-align: center; padding: 0.5em; font-weight: bold;">') | ||
table.insert(html, | table.insert(html, titre or "") | ||
if mandat then | |||
table.insert(html, '<div style="font-weight: normal; font-size: 90%;">' .. mandat .. '</div>') | |||
end | |||
table.insert(html, '</div>') | |||
table.insert(html, '<div style="display: flex; justify-content: space-between; align-items: center; padding: 0.5em;">') | |||
table.insert(html, '<div style="text-align: left; flex: 1;">') | |||
if predecesseur then | |||
table.insert(html, '← [[' .. predecesseur .. ']]') | |||
end | |||
table.insert(html, '</div><div style="flex: 0 0 auto; padding: 0 1em;">·</div><div style="text-align: right; flex: 1;">') | |||
if successeur then | |||
table.insert(html, '[[' .. successeur .. ']] →') | |||
end | |||
table.insert(html, '</div></div>') | |||
table.insert(html, '<hr style="background-color: ' .. couleurHr .. ';">') | |||
table.insert(html, '</div>') | |||
return table.concat(html) | return table.concat(html) | ||
end | |||
function p.main(frame) | |||
local args = frame:getParent().args | |||
local out = {} | |||
for i = 1, 5 do | |||
table.insert(out, genererBloc(args, i)) | |||
end | |||
return table.concat(out) | |||
end | end | ||
return p | return p | ||
Dernière version du 1 juin 2025 à 07:06
La documentation pour ce module peut être créée à Module:FonctionsTest/doc
local p = {}
local charteModule = require('Module:Charte')
local function FonctionsTest(args, index)
local suffix = index == 1 and "" or tostring(index)
local titre = args["Titre" .. suffix]
local mandat = args["Mandat" .. suffix]
local predecesseur = args["Prédécesseur" .. suffix]
local successeur = args["Successeur" .. suffix]
local charte = args["Charte"] or "defaut"
if not (titre or predecesseur or successeur) then
return ""
end
-- Sécurisation des couleurs
local couleurFond = charteModule.couleur{charte = charte, type = "titre"} or "#CCCCCC"
local couleurTexte = charteModule.couleur{charte = charte, type = "texte"} or "#000000"
local couleurHr = charteModule.couleur{charte = charte, type = "hr"} or "#999999"
local html = {}
table.insert(html, '<div style="margin: 0.5em 0; overflow: hidden; font-size: 90%;">')
table.insert(html, '<div style="background-color: ' .. couleurFond .. '; color: ' .. couleurTexte .. '; text-align: center; padding: 0.5em; font-weight: bold;">')
table.insert(html, titre or "")
if mandat then
table.insert(html, '<div style="font-weight: normal; font-size: 90%;">' .. mandat .. '</div>')
end
table.insert(html, '</div>')
table.insert(html, '<div style="display: flex; justify-content: space-between; align-items: center; padding: 0.5em;">')
table.insert(html, '<div style="text-align: left; flex: 1;">')
if predecesseur then
table.insert(html, '← [[' .. predecesseur .. ']]')
end
table.insert(html, '</div><div style="flex: 0 0 auto; padding: 0 1em;">·</div><div style="text-align: right; flex: 1;">')
if successeur then
table.insert(html, '[[' .. successeur .. ']] →')
end
table.insert(html, '</div></div>')
table.insert(html, '<hr style="background-color: ' .. couleurHr .. ';">')
table.insert(html, '</div>')
return table.concat(html)
end
function p.main(frame)
local args = frame:getParent().args
local out = {}
for i = 1, 5 do
table.insert(out, genererBloc(args, i))
end
return table.concat(out)
end
return p