Module:Infobox/Configs/Geographie
De Nefald
Autres actions
La documentation pour ce module peut être créée à Module:Infobox/Configs/Geographie/doc
local config = {
titre = function(args)
return args.nom or '{{PAGENAME}}'
end,
-- Icône avec type et nom
icone = {
type = 'fas', -- ou 'fab', 'far', 'fal', 'fad'
nom = 'map'
},
image = function(args)
if args.image then
return '[[Fichier:' .. args.image .. '|300px]]'
end
return nil
end,
typeField = {
required = false, -- Optionnel pour les géographie
allowedValues = {
['supercontinent'] = {
display = 'Supercontinent',
category = 'Supercontinent'
},
['continent'] = {
display = 'Continent',
category = 'Continent'
},
["cours d'eau"] = {
display = "Cours deau",
category = "Cour d'eau"
},
['océan'] = {
display = 'Mers & Océans',
category = 'Mers & Océans'
},
['mer'] = {
display = 'Mers & Océans',
category = 'Mers & Océans'
},
['monde'] = {
display = 'Monde',
category = 'Monde'
},
},
errorMessage = "Type de Géographie non reconnu. Types autorisés : Monde, Supercontinent,Continent,Région, Océan, Mer, Cours d'eau"
},
sections = {
{
titre = 'Informations générales',
champs = {
{ cle = 'type', label = 'Type' },
{ cle = 'climat', label = 'Climat' },
{ cle = 'statut', label = 'Statut' },
}
},
{
titre = 'Habitants et culture',
champs = {
{ cle = 'controle', label = 'Contrôle' },
{ cle = 'langues', label = 'Langues' },
{ cle = 'cultes', label = 'Cultes' },
{ cle = 'capitale', label = 'Capitale' },
}
},
{
titre = 'Localisation',
champs = {
{ cle = 'monde', label = 'Monde' },
{ cle = 'localisation', label = 'Localisation' },
}
}
},
-- Catégorisation automatique selon le type
categories = function(args, config, frame)
local cats = {}
local title = mw.title.getCurrentTitle()
-- On ajoute les catégories uniquement dans le namespace principal (0)
if title.namespace ~= 0 then
return cats
end
-- Catégorie selon le type
if args.type and config.typeField and config.typeField.allowedValues then
local cleanType = mw.text.trim(mw.ustring.lower(args.type))
local typeDef = config.typeField.allowedValues[cleanType]
if typeDef and typeDef.category then
table.insert(cats, typeDef.category)
end
end
return cats
end
}
return config