« Module:Charte » : différence entre les versions
Apparence
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| Ligne 54 : | Ligne 54 : | ||
hr = "#89c7dab0", | hr = "#89c7dab0", | ||
}, | }, | ||
cite_naine = { | |||
titre = "#c8c8c8b0", -- gris pastel | titre = "#c8c8c8b0", -- gris pastel | ||
soustitre = "#d9d9d9a8", | soustitre = "#d9d9d9a8", | ||
hr = "#c8c8c8b0", | hr = "#c8c8c8b0", | ||
}, | }, | ||
cite_independante = { | |||
titre = "#e6b8a2b0", -- | titre = "#e6b8a2b0", -- terracotta pastel | ||
soustitre = "#f1cdb99c", | soustitre = "#f1cdb99c", | ||
hr = "#e6b8a2b0", | hr = "#e6b8a2b0", | ||
}, | }, | ||
ville_etat = { | |||
titre = "#d4d1f0b0", -- lavande/gris bleuté pastel | titre = "#d4d1f0b0", -- lavande/gris bleuté pastel | ||
soustitre = "#e0dff79c", | soustitre = "#e0dff79c", | ||
| Ligne 76 : | Ligne 75 : | ||
} | } | ||
} | } | ||
-- Alias pour noms accentués (compatibilité avec les appels charte="cité-naine", etc.) | |||
chartes["cité-naine"] = chartes.cite_naine | |||
chartes["cité-indépendante"] = chartes.cite_independante | |||
chartes["ville-état"] = chartes.ville_etat | |||
-- Textes par défaut selon la charte | -- Textes par défaut selon la charte | ||
Version du 10 juillet 2025 à 07:04
La documentation pour ce module peut être créée à Module:Charte/doc
local p = {}
-- Tableau des chartes pré-définies
local chartes = {
biographie = {
titre = "#6eacdc9c",
soustitre = "#a9c8e09c",
hr = "#6eacdc9c",
},
empire = {
titre = "#993333b0",
soustitre = "#831f1fc7",
hr = "#993333b0",
},
geographie = {
titre = "#209a57d9",
soustitre = "#209a57a8",
hr = "#209a57d9",
},
conflit = {
titre = "#B0C4DE",
soustitre = "#B0C4DE",
hr = "#B0C4DE",
},
darkgods = {
titre = "#000000",
soustitre = "#000000e8",
hr = "#000000",
color = "#ffffff",
},
langue = {
titre = "#9b59b6b0",
soustitre = "#a674c8a8",
hr = "#9b59b6b0",
},
royaume = {
titre = "#f0b58fb0", -- pêche pastel
soustitre = "#f8caa89c",
hr = "#f0b58fb0",
},
republique = {
titre = "#a4cbb3b0", -- vert pastel doux
soustitre = "#b9ddc3a0",
hr = "#a4cbb3b0",
},
legendes = {
titre = "#cab2d6b0", -- lilas pastel
soustitre = "#ddcae6a8",
hr = "#cab2d6b0",
},
federation = {
titre = "#89c7dab0", -- bleu ciel pastel
soustitre = "#b3dce8a8",
hr = "#89c7dab0",
},
cite_naine = {
titre = "#c8c8c8b0", -- gris pastel
soustitre = "#d9d9d9a8",
hr = "#c8c8c8b0",
},
cite_independante = {
titre = "#e6b8a2b0", -- terracotta pastel
soustitre = "#f1cdb99c",
hr = "#e6b8a2b0",
},
ville_etat = {
titre = "#d4d1f0b0", -- lavande/gris bleuté pastel
soustitre = "#e0dff79c",
hr = "#d4d1f0b0",
},
defaut = {
titre = "#eaecf0",
soustitre = "#a2a9b1",
hr = "#eaecf0",
}
}
-- Alias pour noms accentués (compatibilité avec les appels charte="cité-naine", etc.)
chartes["cité-naine"] = chartes.cite_naine
chartes["cité-indépendante"] = chartes.cite_independante
chartes["ville-état"] = chartes.ville_etat
-- Textes par défaut selon la charte
local soustitres = {
biographie = "Informations biographiques",
empire = "Données impériales",
geographie = "Informations géographiques",
darkgods = "Entité obscure",
defaut = "Informations générales",
}
-- Fonction pour détecter un code hex (#xxxxxx ou #xxxxxxx)
local function isHexCode(value)
return type(value) == "string" and mw.ustring.match(value, "^#%x%x%x%x%x%x%x?$") ~= nil
end
-- Fonction principale pour renvoyer une couleur selon charte et type
function p.couleur(frame)
local args = frame.args
local couleurOuCharte = (args["couleur"] and args["couleur"] ~= "") and args["couleur"]
or (args["charte"] and args["charte"] ~= "") and args["charte"]
or "defaut"
local type = args["type"] or "titre"
-- Si l'utilisateur fournit un code hexadécimal direct
if isHexCode(couleurOuCharte) then
if type == "texte" then
return "#000000"
else
return couleurOuCharte
end
end
-- Si type=texte et une couleur de texte personnalisée est définie
if type == "texte" then
if chartes[couleurOuCharte] and chartes[couleurOuCharte].color then
return chartes[couleurOuCharte].color
else
return "#000000"
end
end
-- Si type=soustitre
if type == "soustitre" then
if chartes[couleurOuCharte] and chartes[couleurOuCharte].soustitre then
return chartes[couleurOuCharte].soustitre
else
return chartes["defaut"].soustitre
end
end
-- Autres types (titre, hr, etc.)
if chartes[couleurOuCharte] and chartes[couleurOuCharte][type] then
return chartes[couleurOuCharte][type]
else
return chartes["defaut"][type] or "#dddddd"
end
end
-- Fonction pour renvoyer un texte de sous-titre par défaut
function p.soustitre(frame)
local charte = frame.args["charte"] or "defaut"
charte = mw.ustring.lower(charte)
return soustitres[charte] or soustitres["defaut"]
end
return p