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/Localite » : différence entre les versions

De Nefald
Annulation des modifications 1052 de Ayd (discussion)
Balise : Annulation
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,
   
 
     -- Icône avec type et nom
     -- Icône de l’infobox
     icone = {
     icone = {
         type = 'fas', -- ou 'fab', 'far', 'fal', 'fad'
         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" avec validation et catégorisation
     -- Configuration du champ "type"
     typeField = {
     typeField = {
         required = false, -- Optionnel pour les localités
         required = false,
         allowedValues = {
         allowedValues = {
             ['ville'] = {
             ['ville'] = { display = 'Ville', category = 'Villes' },
                display = 'Ville',
             ['village'] = { display = 'Village', category = 'Villages' },
                category = 'Villes'
             ['cité'] = { display = 'Cité', category = 'Cités' },
            },
             ['capitale'] = { display = 'Capitale', category = 'Capitales' },
             ['village'] = {
             ['port'] = { display = 'Port', category = 'Ports' },
                display = 'Village',  
             ['forteresse'] = { display = 'Forteresse', category = 'Forteresses' },
                category = 'Villages'
             ['château'] = { display = 'Château', category = 'Châteaux' },
            },
             ['ruine'] = { display = 'Ruine', category = 'Ruines' },
             ['cité'] = {
             ['avant-poste'] = { display = 'Avant-poste', category = 'Avant-postes' },
                display = 'Cité',
             ['campement'] = { display = 'Campement', category = 'Campements' },
                category = 'Cités'
             ['métropole'] = { display = 'Métropole', category = 'Métropoles' },
            },
             ['sanctuaire'] = { display = 'Sanctuaire', category = 'Sanctuaires' },
             ['capitale'] = {
             ['cité-état'] = { display = 'Cité-État', category = 'Cités-États' }
                display = 'Capitale',
                category = 'Capitales'
            },
             ['port'] = {
                display = 'Port',
                category = 'Ports'
            },
             ['forteresse'] = {
                display = 'Forteresse',
                category = 'Forteresses'
            },
             ['château'] = {
                display = 'Château',
                category = 'Châteaux'
            },
             ['ruine'] = {
                display = 'Ruine',
                category = 'Ruines'
            },
             ['avant-poste'] = {
                display = 'Avant-poste',
                category = 'Avant-postes'
            },
             ['campement'] = {
                display = 'Campement',
                category = 'Campements'
            },
             ['métropole'] = {
                display = 'Métropole',
                category = 'Métropoles'
            },
             ['sanctuaire'] = {
                display = 'Sanctuaire',
                category = 'Sanctuaires'
            },
             ['cité-état'] = {
                display = 'Cité-État',
                category = 'Cité-État'
            }
         },
         },
         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

Version du 21 octobre 2025 à 09:18

La documentation pour ce module peut être créée à Module:Infobox/Configs/Localite/doc

local config = {
    titre = function(args)
        return args.nom or '{{PAGENAME}}'
    end,

    -- Icône de l’infobox
    icone = {
        type = 'fas',
        nom = 'map-location-dot'
    },

    -- Gestion de l’image
    image = function(args)
        if args.image then
            return {
                nom = args.image,
                taille = args.tailleimage or "250px",
                legende = args.legende
            }
        end
        return nil
    end,

    -- Configuration du champ "type"
    typeField = {
        required = false,
        allowedValues = {
            ['ville'] = { display = 'Ville', category = 'Villes' },
            ['village'] = { display = 'Village', category = 'Villages' },
            ['cité'] = { display = 'Cité', category = 'Cités' },
            ['capitale'] = { display = 'Capitale', category = 'Capitales' },
            ['port'] = { display = 'Port', category = 'Ports' },
            ['forteresse'] = { display = 'Forteresse', category = 'Forteresses' },
            ['château'] = { display = 'Château', category = 'Châteaux' },
            ['ruine'] = { display = 'Ruine', category = 'Ruines' },
            ['avant-poste'] = { display = 'Avant-poste', category = 'Avant-postes' },
            ['campement'] = { display = 'Campement', category = 'Campements' },
            ['métropole'] = { display = 'Métropole', category = 'Métropoles' },
            ['sanctuaire'] = { display = 'Sanctuaire', category = 'Sanctuaires' },
            ['cité-état'] = { display = 'Cité-État', category = 'Cités-États' }
        },
        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 = {
        {
            titre = 'Informations Générales',
            champs = {
                { cle = 'type', label = 'Type' },
                { cle = 'fondation', label = 'Fondation' },
                { cle = 'destruction', label = 'Destruction' },
                { cle = 'fondateur', label = 'Fondateur(s)' },
                { cle = 'symbole', label = 'Symbole' },
                { cle = 'statut', label = 'Statut' },
                { cle = 'x', label = 'Coordonnée X' },
                { cle = 'y', label = 'Coordonnée Y' },
                { cle = 'z', label = 'Coordonnée Z' }
            }
        },
        {
            titre = 'Organisation Interne',
            champs = {
                { cle = 'dirigeant', label = 'Dirigeant' },
                { cle = 'population', label = 'Population' },
                { cle = 'culte', label = 'Culte' },
                { cle = 'organisation_rattachee', label = 'Organisation rattachée' },
                { cle = 'gouvernement', label = 'Type de gouvernement' },
                { cle = 'quartiers', label = 'Quartiers' }
            }
        },
        {
            titre = 'Économie et Société',
            champs = {
                { cle = 'activite', label = 'Activité' },
                { cle = 'ressources', label = 'Ressources' },
                { cle = 'monnaie', label = 'Monnaie' },
                { cle = 'commerce', label = 'Commerce' },
                { cle = 'culture', label = 'Culture' },
                { cle = 'langues', label = 'Langues' }
            }
        },
        {
            titre = 'Géographie',
            champs = {
                { cle = 'monde', label = 'Monde' },
                { cle = 'climat', label = 'Climat' },
                { cle = 'biome', label = 'Biome' },
                { cle = 'relief', label = 'Relief' },
                { cle = 'superficie', label = 'Superficie' },
                { cle = 'cours_eau', label = 'Cours d\'eau' },
                { cle = 'batiments', label = 'Bâtiments notables' }
            }
        }
    },

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