« Module:Charte » : différence entre les versions
Apparence
Aucun résumé des modifications Balises : Révocation manuelle Révoqué |
Aucun résumé des modifications Balise : Révocation manuelle |
||
| Ligne 3 : | Ligne 3 : | ||
local chartes = { | local chartes = { | ||
biographie = { | biographie = { | ||
titre | titre = "#6eacdc9c", | ||
soustitre = "#a9c8e09c", | soustitre = "#a9c8e09c", | ||
hr | hr = "#6eacdc9c", | ||
}, | }, | ||
empire = { | empire = { | ||
titre | titre = "#993333b0", | ||
soustitre = "#831f1fc7", | soustitre = "#831f1fc7", | ||
hr | hr = "#993333b0", | ||
}, | }, | ||
geographie = { | geographie = { | ||
titre | titre = "#209a57d9", | ||
soustitre = "#209a57a8", | soustitre = "#209a57a8", | ||
hr | hr = "#209a57d9", | ||
}, | }, | ||
darkgods = { | darkgods = { | ||
titre | titre = "#000000cc", | ||
soustitre = "#000000a3", | soustitre = "#000000a3", | ||
hr | soustitre_color = "#ffffff", | ||
hr = "#000000a3", | |||
color = "#ffffff", | |||
}, | }, | ||
defaut = { | defaut = { | ||
titre | titre = "#eaecf0", | ||
soustitre = "#a2a9b1", | soustitre = "#a2a9b1", | ||
hr | hr = "#eaecf0", | ||
} | } | ||
} | } | ||
-- Textes par défaut selon la charte (NOUVELLE TABLE) | |||
local soustitres = { | local soustitres = { | ||
biographie = "Informations biographiques", | biographie = "Informations biographiques", | ||
| Ligne 38 : | Ligne 40 : | ||
} | } | ||
-- Fonction pour vérifier si c’est un code hex | |||
local function isHexCode(value) | local function isHexCode(value) | ||
return type(value) == "string" and mw.ustring.match(value, "^#%x%x%x%x%x%x%x?$") ~= nil | return type(value) == "string" and mw.ustring.match(value, "^#%x%x%x%x%x%x%x?$") ~= nil | ||
end | end | ||
-- Fonction principale de couleur | |||
charte = | function p.couleur(frame) | ||
type = type or "titre" | local args = frame.args | ||
local charte = args["charte"] or "defaut" | |||
local type = args["type"] or "titre" | |||
if | if type == "texte" then | ||
return | if chartes[charte] and chartes[charte].color then | ||
return chartes[charte].color | |||
else | |||
return "#000000" | |||
end | |||
end | end | ||
if chartes[charte] and chartes[charte] | if type == "soustitre_color" then | ||
if chartes[charte] and chartes[charte].soustitre_color then | |||
return chartes[charte].soustitre_color | |||
else | |||
return "#000000" | |||
end | |||
end | end | ||
if isHexCode(charte) then | |||
return charte | |||
elseif chartes[charte] and chartes[charte][type] then | |||
return chartes[charte][type] | |||
if | |||
return | |||
return | |||
else | else | ||
return "" | return chartes["defaut"][type] or "#dddddd" | ||
end | end | ||
end | end | ||
-- | -- Fonction pour afficher le texte par défaut du sous-titre | ||
function p.soustitre(frame) | function p.soustitre(frame) | ||
local charte = | local charte = frame.args["charte"] or "defaut" | ||
charte = mw.ustring.lower(charte) | |||
return soustitres[charte] or soustitres["defaut"] | return soustitres[charte] or soustitres["defaut"] | ||
end | end | ||
return p | return p | ||
Version du 7 juin 2025 à 09:15
La documentation pour ce module peut être créée à Module:Charte/doc
local p = {}
local chartes = {
biographie = {
titre = "#6eacdc9c",
soustitre = "#a9c8e09c",
hr = "#6eacdc9c",
},
empire = {
titre = "#993333b0",
soustitre = "#831f1fc7",
hr = "#993333b0",
},
geographie = {
titre = "#209a57d9",
soustitre = "#209a57a8",
hr = "#209a57d9",
},
darkgods = {
titre = "#000000cc",
soustitre = "#000000a3",
soustitre_color = "#ffffff",
hr = "#000000a3",
color = "#ffffff",
},
defaut = {
titre = "#eaecf0",
soustitre = "#a2a9b1",
hr = "#eaecf0",
}
}
-- Textes par défaut selon la charte (NOUVELLE TABLE)
local soustitres = {
biographie = "Informations biographiques",
empire = "Données impériales",
geographie = "Informations géographiques",
darkgods = "Entité obscure",
defaut = "Informations générales"
}
-- Fonction pour vérifier si c’est un code hex
local function isHexCode(value)
return type(value) == "string" and mw.ustring.match(value, "^#%x%x%x%x%x%x%x?$") ~= nil
end
-- Fonction principale de couleur
function p.couleur(frame)
local args = frame.args
local charte = args["charte"] or "defaut"
local type = args["type"] or "titre"
if type == "texte" then
if chartes[charte] and chartes[charte].color then
return chartes[charte].color
else
return "#000000"
end
end
if type == "soustitre_color" then
if chartes[charte] and chartes[charte].soustitre_color then
return chartes[charte].soustitre_color
else
return "#000000"
end
end
if isHexCode(charte) then
return charte
elseif chartes[charte] and chartes[charte][type] then
return chartes[charte][type]
else
return chartes["defaut"][type] or "#dddddd"
end
end
-- Fonction pour afficher le texte par défaut du sous-titre
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