« Module:Infobox/Configs/Personnage » : différence entre les versions
De Nefald
Autres actions
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| 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, | ||
icone = { | icone = { | ||
type = 'fas', | type = 'fas', | ||
nom = 'person' | nom = 'person' | ||
}, | }, | ||
image = function(args) | image = function(args) | ||
if args.image then | if args.image then | ||
| Ligne 16 : | Ligne 17 : | ||
end, | end, | ||
-- | -- TYPE DU PERSONNAGE | ||
typeField = { | |||
required = false, | |||
allowedValues = { | |||
['humain'] = { display = 'Humain', category = 'Humains' }, | |||
['elfe'] = { display = 'Elfe', category = 'Elfes' }, | |||
['nain'] = { display = 'Nain', category = 'Nains' }, | |||
['orc'] = { display = 'Orc', category = 'Orcs' }, | |||
['divinité'] = { display = 'Divinité', category = 'Divinités' } | |||
} | |||
}, | |||
-- STATUT DU PERSONNAGE | |||
statutField = { | |||
required = false, | |||
allowedValues = { | |||
['vivant'] = { display = 'Vivant', category = 'Personnages vivants' }, | |||
['décédé'] = { display = 'Décédé', category = 'Personnages décédés' }, | |||
['disparu'] = { display = 'Disparu', category = 'Personnages disparus' }, | |||
['immortel'] = { display = 'Immortel', category = 'Personnages immortels' } | |||
} | |||
}, | |||
-- CATÉGORIES AUTOMATIQUES | |||
categories = function(args, config, frame) | categories = function(args, config, frame) | ||
local cats = {} | |||
local title = mw.title.getCurrentTitle() | local title = mw.title.getCurrentTitle() | ||
-- | -- uniquement namespace principal | ||
if title.namespace ~= 0 then | if title.namespace ~= 0 then | ||
return | return cats | ||
end | end | ||
-- | -- === catégorie TYPE === | ||
local | 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 | |||
-- === catégorie STATUT === | |||
if args.statut and config.statutField and config.statutField.allowedValues then | |||
local cleanStatut = mw.text.trim(mw.ustring.lower(args.statut)) | |||
local statutDef = config.statutField.allowedValues[cleanStatut] | |||
if statutDef and statutDef.category then | |||
table.insert(cats, statutDef.category) | |||
end | |||
end | |||
return cats | return cats | ||
| Ligne 44 : | Ligne 84 : | ||
{ cle = 'lieu_naissance', label = 'Lieu de naissance' }, | { cle = 'lieu_naissance', label = 'Lieu de naissance' }, | ||
{ cle = 'lieu_residence', label = 'Lieu de résidence' }, | { cle = 'lieu_residence', label = 'Lieu de résidence' }, | ||
{ cle = 'statut', label = 'Statut' } | { cle = 'statut', label = 'Statut' } | ||
} | } | ||
} | } | ||
Version du 20 février 2026 à 08:23
La documentation pour ce module peut être créée à Module:Infobox/Configs/Personnage/doc
local config = {
titre = function(args)
return args.nom or '{{PAGENAME}}'
end,
icone = {
type = 'fas',
nom = 'person'
},
image = function(args)
if args.image then
return '[[Fichier:' .. args.image .. '|300px]]'
end
return nil
end,
-- TYPE DU PERSONNAGE
typeField = {
required = false,
allowedValues = {
['humain'] = { display = 'Humain', category = 'Humains' },
['elfe'] = { display = 'Elfe', category = 'Elfes' },
['nain'] = { display = 'Nain', category = 'Nains' },
['orc'] = { display = 'Orc', category = 'Orcs' },
['divinité'] = { display = 'Divinité', category = 'Divinités' }
}
},
-- STATUT DU PERSONNAGE
statutField = {
required = false,
allowedValues = {
['vivant'] = { display = 'Vivant', category = 'Personnages vivants' },
['décédé'] = { display = 'Décédé', category = 'Personnages décédés' },
['disparu'] = { display = 'Disparu', category = 'Personnages disparus' },
['immortel'] = { display = 'Immortel', category = 'Personnages immortels' }
}
},
-- CATÉGORIES AUTOMATIQUES
categories = function(args, config, frame)
local cats = {}
local title = mw.title.getCurrentTitle()
-- uniquement namespace principal
if title.namespace ~= 0 then
return cats
end
-- === catégorie 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
-- === catégorie STATUT ===
if args.statut and config.statutField and config.statutField.allowedValues then
local cleanStatut = mw.text.trim(mw.ustring.lower(args.statut))
local statutDef = config.statutField.allowedValues[cleanStatut]
if statutDef and statutDef.category then
table.insert(cats, statutDef.category)
end
end
return cats
end,
sections = {
{
titre = 'État civil',
champs = {
{ cle = 'titre', label = 'Titre' },
{ cle = 'surnom', label = 'Surnom' },
{ cle = 'naissance', label = 'Date de naissance' },
{ cle = 'deces', label = 'Date de décès' },
{ cle = 'lieu_naissance', label = 'Lieu de naissance' },
{ cle = 'lieu_residence', label = 'Lieu de résidence' },
{ cle = 'statut', label = 'Statut' }
}
}
}
}
return config