Basculer le menu
Changer de menu des préférences
Basculer le menu personnel
Non connecté(e)
Votre adresse IP sera visible au public si vous faites des modifications.

« Module:Infobox/Configs/Geopolitique » : différence entre les versions

De Nefald
Aucun résumé des modifications
Aucun résumé des modifications
 
Ligne 37 : Ligne 37 :
                 category = 'Serments'
                 category = 'Serments'
             },
             },
['événement'] = {
                display = 'Évènement',
                category = 'Évènement'
            }
         },
         },
         errorMessage = 'Type non reconnu. Types autorisés : Traité, Alliance, Serment,Guerre'
         errorMessage = 'Type non reconnu. Types autorisés : Traité, Alliance, Serment,Guerre,Évènement'
     },
     },
      
      

Dernière version du 21 octobre 2025 à 09:56

La documentation pour ce module peut être créée à Module:Infobox/Configs/Geopolitique/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 = 'landmark-dome'
    },
    
    image = function(args)
        if args.image then
            return '[[Fichier:' .. args.image .. '|300px]]'
        end
        return nil
    end,
    
    
    typeField = {
        required = false, -- Optionnel pour les localités
        allowedValues = {
            ['guerre'] = {
                display = 'Guerre',
                category = 'Guerres'
            },
            ['traité'] = {
                display = 'Traité', 
                category = 'Traités'
            },
			['alliance'] = {
                display = 'Alliance', 
                category = 'Alliances'
            },
			['serment'] = {
                display = 'Serment', 
                category = 'Serments'
            },
			['événement'] = {
                display = 'Évènement', 
                category = 'Évènement'
            }
        },
        errorMessage = 'Type non reconnu. Types autorisés : Traité, Alliance, Serment,Guerre,Évènement'
    },
    
    sections = {
        {
            titre = 'Informations générales',
            champs = {
                { cle = 'type', label = 'Type' },
                { cle = 'date', label = 'Date' },
                { cle = 'parties', label = 'Parties' },
                { cle = 'lieux', label = 'Lieux' },
            }
        }
    },

    -- 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