« Module:Infobox/Configs/Localite » : différence entre les versions
De Nefald
Autres actions
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| (5 versions intermédiaires par le même utilisateur non affichées) | |||
| Ligne 1 : | Ligne 1 : | ||
local config = { | local config = { | ||
titre = function(args) | titre = function(args) | ||
return args.nom or '{{PAGENAME}}' | return args.nom or '{{PAGENAME}}' | ||
end, | end, | ||
-- Icône | -- Icône de l’infobox | ||
icone = { | icone = { | ||
type = 'fas', | type = 'fas', | ||
nom = 'map-location-dot' | nom = 'map-location-dot' | ||
}, | }, | ||
image = function(args) | -- Gestion de l’image | ||
image = function(args) | |||
if args.image then | if args.image then | ||
return { | return { | ||
| Ligne 21 : | Ligne 22 : | ||
end, | end, | ||
-- Configuration du champ "type" | -- Configuration du champ "type" | ||
typeField = { | typeField = { | ||
required = false, | required = false, | ||
allowedValues = { | allowedValues = { | ||
['ville'] = { | ['ville'] = { display = 'Ville', category = 'Ville' }, | ||
['village'] = { display = 'Village', category = 'Village' }, | |||
['cité'] = { display = 'Cité', category = 'Cité' }, | |||
['capitale'] = { display = 'Capitale', category = 'Capitale' }, | |||
['village'] = { | ['port'] = { display = 'Port', category = 'Port' }, | ||
['forteresse'] = { display = 'Forteresse', category = 'Forteresse' }, | |||
['château'] = { display = 'Château', category = 'Château' }, | |||
['ruine'] = { display = 'Ruine', category = 'Ruine' }, | |||
['cité'] = { | ['avant-poste'] = { display = 'Avant-poste', category = 'Avant-poste' }, | ||
['campement'] = { display = 'Campement', category = 'Campement' }, | |||
['métropole'] = { display = 'Métropole', category = 'Métropole' }, | |||
['sanctuaire'] = { display = 'Sanctuaire', category = 'Sanctuaire' }, | |||
['capitale'] = { | ['cité-état'] = { display = 'Cité-État', category = 'Cité-État' } | ||
['port'] = { | |||
['forteresse'] = { | |||
['château'] = { | |||
['ruine'] = { | |||
['avant-poste'] = { | |||
['campement'] = { | |||
['métropole'] = { | |||
['sanctuaire'] = { | |||
[' | |||
}, | }, | ||
errorMessage = 'Type de localité non reconnu. Types autorisés : ville, village, cité, capitale, port, forteresse, château, ruine, avant-poste, campement, métropole, sanctuaire' | errorMessage = 'Type de localité non reconnu. Types autorisés : ville, village, cité, capitale, port, forteresse, château, ruine, avant-poste, campement, métropole, sanctuaire' | ||
}, | }, | ||
-- Sections de l’infobox | |||
sections = { | sections = { | ||
{ | { | ||
| Ligne 130 : | Ligne 93 : | ||
} | } | ||
} | } | ||
} | }, | ||
-- 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 | ||