« Module:Infobox/Configs/Geopolitique » : différence entre les versions
De Nefald
Autres actions
Page créée avec « local config = { titre = function(args) return args.nom or '{{PAGENAME}}' end, image = function(args) if args.image then return '300px' end return nil end, sections = { { titre = 'Informations générales', champs = { { cle = 'type', label = 'Type' }, { cle = 'date', label = 'Date' }, {... » |
Aucun résumé des modifications |
||
| (12 versions intermédiaires par 2 utilisateurs non affichées) | |||
| Ligne 3 : | Ligne 3 : | ||
return args.nom or '{{PAGENAME}}' | return args.nom or '{{PAGENAME}}' | ||
end, | end, | ||
-- Icône avec type et nom | |||
icone = { | |||
type = 'fas', -- ou 'fab', 'far', 'fal', 'fad' | |||
nom = 'landmark-dome' | |||
}, | |||
image = function(args) | image = function(args) | ||
if args.image then | if args.image then | ||
| Ligne 10 : | Ligne 16 : | ||
return nil | return nil | ||
end, | end, | ||
typeField = { | |||
required = false, -- Optionnel pour les localités | |||
allowedValues = { | |||
['guerre'] = { | |||
display = 'Guerre', | |||
category = 'Conflit' | |||
}, | |||
['bataille'] = { | |||
display = 'Bataille', | |||
category = 'Conflit' | |||
}, | |||
['escarmouche'] = { | |||
display = 'Escarmouche', | |||
category = 'Conflit' | |||
}, | |||
['traité'] = { | |||
display = 'Traité', | |||
category = 'Diplomatie' | |||
}, | |||
['alliance'] = { | |||
display = 'Alliance', | |||
category = 'Diplomatie' | |||
}, | |||
['serment'] = { | |||
display = 'Serment', | |||
category = 'Diplomatie' | |||
}, | |||
['événement'] = { | |||
display = 'Évènement', | |||
category = 'Évènement' | |||
} | |||
}, | |||
errorMessage = 'Type non reconnu. Types autorisés : Traité, Alliance, Serment, Guerre,Évènement, Escarmouche, Bataille ' | |||
}, | |||
sections = { | sections = { | ||
{ | { | ||
| Ligne 21 : | Ligne 63 : | ||
} | } | ||
} | } | ||
} | }, | ||
-- 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 | return config | ||