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

De Nefald
Hiob (discussion | contributions)
m Retrait catégorie:Plugin Minecraft
Hiob (discussion | contributions)
statut > autocatégorisation
Ligne 19 : Ligne 19 :
         return nil
         return nil
     end,
     end,
    -- Configuration des valeurs validées
    statusField = {
        allowedValues = {
            ['installé'] = {
                display = '[[Plugin installé|Installé]]',
                category = 'Plugins installés'
            },
            ['non-installé'] = {
                display = '[[Plugin non-installé|Non-installé]]',
                category = 'Plugins non-installés'
            }
        }
    },
    typeField = {
        allowedValues = {
            ['économie'] = {
                display = 'Économie',
                category = 'Plugins d\'économie'
            },
            ['pvp'] = {
                display = 'PvP',
                category = 'Plugins de PvP'
            },
            ['roleplay'] = {
                display = 'Roleplay',
                category = 'Plugins de roleplay'
            },
            ['administration'] = {
                display = 'Administration',
                category = 'Plugins d\'administration'
            },
            ['protection'] = {
                display = 'Protection',
                category = 'Plugins de protection'
            },
            ['cosmétique'] = {
                display = 'Cosmétique',
                category = 'Plugins cosmétiques'
            },
            ['communication'] = {
                display = 'Communication',
                category = 'Plugins de communication'
            },
            ['utilitaire'] = {
                display = 'Utilitaire',
                category = 'Plugins utilitaires'
            },
            ['mini-jeu'] = {
                display = 'Mini-jeu',
                category = 'Plugins de mini-jeux'
            },
            ['monde'] = {
                display = 'Monde',
                category = 'Plugins de monde'
            },
            ['inventaire'] = {
                display = 'Inventaire',
                category = 'Plugins d\'inventaire'
            },
            ['transport'] = {
                display = 'Transport',
                category = 'Plugins de transport'
            },
            ['magie'] = {
                display = 'Magie',
                category = 'Plugins de magie'
            },
            ['mob'] = {
                display = 'Mob',
                category = 'Plugins de mobs'
            }
        }
    },


     sections = {
     sections = {
         {
         {
             champs = {
             champs = {
                 { cle = 'type', label = 'Type',  
                 {  
                  process = function(value, args)
                    cle = 'type',  
                    local types = {
                    label = 'Type',  
                        ['économie'] = 'Économie',
                    process = function(value, args)
                         ['pvp'] = 'PvP',
                        if not value or value == '' then
                         ['roleplay'] = 'Roleplay',
                            return nil
                         ['administration'] = 'Administration',
                         end
                         ['protection'] = 'Protection',
                          
                         ['cosmétique'] = 'Cosmétique',
                         local cleanValue = mw.text.trim(mw.ustring.lower(value))
                         ['communication'] = 'Communication',
                         local typeConfig = config.typeField.allowedValues[cleanValue]
                         ['utilitaire'] = 'Utilitaire',
                          
                        ['mini-jeu'] = 'Mini-jeu',
                         if typeConfig then
                        ['monde'] = 'Monde',
                            return typeConfig.display
                        ['inventaire'] = 'Inventaire',
                         else
                        ['transport'] = 'Transport',
                            return '<span style="color: red; font-weight: bold;">Type invalide: "' .. value .. '"</span>[[Catégorie:Pages avec erreurs]]'
                        ['magie'] = 'Magie',
                         end
                         ['mob'] = 'Mob'
                     end
                     }
                    return types[value] or value
                  end
                 },
                 },
                 { cle = 'dev', label = 'Développeur' },
                 { cle = 'dev', label = 'Développeur' },
                 { cle = 'status', label = 'Statut' },
                 {  
                    cle = 'status',  
                    label = 'Statut',
                    process = function(value, args)
                        if not value or value == '' then
                            return nil
                        end
                       
                        local cleanValue = mw.text.trim(mw.ustring.lower(value))
                        local statusConfig = config.statusField.allowedValues[cleanValue]
                       
                        if statusConfig then
                            return statusConfig.display
                        else
                            return '<span style="color: red; font-weight: bold;">Statut invalide: "' .. value .. '"</span>[[Catégorie:Pages avec erreurs]]'
                        end
                    end
                },
                 { cle = 'grade', label = 'Grade requis' }
                 { cle = 'grade', label = 'Grade requis' }
             }
             }
Ligne 95 : Ligne 184 :
                   process = function(value, args, frame)
                   process = function(value, args, frame)
                     if value and value ~= '' then
                     if value and value ~= '' then
                        -- Si c'est déjà un lien complet, le garder tel quel
                         if value:match('^%[.+%]$') then
                         if value:match('^%[.+%]$') then
                             return frame:preprocess(value)
                             return frame:preprocess(value)
                        -- Sinon, créer un lien automatique
                         elseif value:match('^https?://') then
                         elseif value:match('^https?://') then
                             local domain = value:match('://([^/]+)')
                             local domain = value:match('://([^/]+)')
Ligne 131 : Ligne 218 :
         local cats = {}
         local cats = {}
          
          
        -- Catégorie basée sur le type
         if args.type then
         if args.type then
             local typeCategories = {
             local cleanType = mw.text.trim(mw.ustring.lower(args.type))
                ['économie'] = 'Plugins d\'économie',
            local typeConfig = config.typeField.allowedValues[cleanType]
                ['pvp'] = 'Plugins de PvP',
            if typeConfig then
                ['roleplay'] = 'Plugins de roleplay',
                 table.insert(cats, typeConfig.category)
                 ['administration'] = 'Plugins d\'administration',
            end
                ['protection'] = 'Plugins de protection',
        end
                ['cosmétique'] = 'Plugins cosmétiques',
       
                ['communication'] = 'Plugins de communication',
        -- Catégorie basée sur le statut
                ['utilitaire'] = 'Plugins utilitaires',
        if args.status then
                ['mini-jeu'] = 'Plugins de mini-jeux',
            local cleanStatus = mw.text.trim(mw.ustring.lower(args.status))
                ['monde'] = 'Plugins de monde',
            local statusConfig = config.statusField.allowedValues[cleanStatus]
                ['inventaire'] = 'Plugins d\'inventaire',
             if statusConfig then
                ['transport'] = 'Plugins de transport',
                 table.insert(cats, statusConfig.category)
                ['magie'] = 'Plugins de magie',
                ['mob'] = 'Plugins de mobs'
            }
             if typeCategories[args.type] then
                 table.insert(cats, typeCategories[args.type])
             end
             end
         end
         end

Version du 3 octobre 2025 à 09:54

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

local config = {
    titre = function(args) 
        return args.nom or '{{PAGENAME}}' 
    end,
    
    icone = {
        type = 'fas',
        nom = 'puzzle-piece'
    },
    
    image = function(args) 
        if args.image then
            return {
                nom = args.image,
                taille = args.tailleimage or "280x200px",
                legende = args.legende or args.nom or '{{PAGENAME}}'
            }
        end
        return nil
    end,

    -- Configuration des valeurs validées
    statusField = {
        allowedValues = {
            ['installé'] = {
                display = '[[Plugin installé|Installé]]',
                category = 'Plugins installés'
            },
            ['non-installé'] = {
                display = '[[Plugin non-installé|Non-installé]]',
                category = 'Plugins non-installés'
            }
        }
    },

    typeField = {
        allowedValues = {
            ['économie'] = {
                display = 'Économie',
                category = 'Plugins d\'économie'
            },
            ['pvp'] = {
                display = 'PvP',
                category = 'Plugins de PvP'
            },
            ['roleplay'] = {
                display = 'Roleplay',
                category = 'Plugins de roleplay'
            },
            ['administration'] = {
                display = 'Administration',
                category = 'Plugins d\'administration'
            },
            ['protection'] = {
                display = 'Protection',
                category = 'Plugins de protection'
            },
            ['cosmétique'] = {
                display = 'Cosmétique',
                category = 'Plugins cosmétiques'
            },
            ['communication'] = {
                display = 'Communication',
                category = 'Plugins de communication'
            },
            ['utilitaire'] = {
                display = 'Utilitaire',
                category = 'Plugins utilitaires'
            },
            ['mini-jeu'] = {
                display = 'Mini-jeu',
                category = 'Plugins de mini-jeux'
            },
            ['monde'] = {
                display = 'Monde',
                category = 'Plugins de monde'
            },
            ['inventaire'] = {
                display = 'Inventaire',
                category = 'Plugins d\'inventaire'
            },
            ['transport'] = {
                display = 'Transport',
                category = 'Plugins de transport'
            },
            ['magie'] = {
                display = 'Magie',
                category = 'Plugins de magie'
            },
            ['mob'] = {
                display = 'Mob',
                category = 'Plugins de mobs'
            }
        }
    },

    sections = {
        {
            champs = {
                { 
                    cle = 'type', 
                    label = 'Type', 
                    process = function(value, args)
                        if not value or value == '' then
                            return nil
                        end
                        
                        local cleanValue = mw.text.trim(mw.ustring.lower(value))
                        local typeConfig = config.typeField.allowedValues[cleanValue]
                        
                        if typeConfig then
                            return typeConfig.display
                        else
                            return '<span style="color: red; font-weight: bold;">Type invalide: "' .. value .. '"</span>[[Catégorie:Pages avec erreurs]]'
                        end
                    end
                },
                { cle = 'dev', label = 'Développeur' },
                { 
                    cle = 'status', 
                    label = 'Statut',
                    process = function(value, args)
                        if not value or value == '' then
                            return nil
                        end
                        
                        local cleanValue = mw.text.trim(mw.ustring.lower(value))
                        local statusConfig = config.statusField.allowedValues[cleanValue]
                        
                        if statusConfig then
                            return statusConfig.display
                        else
                            return '<span style="color: red; font-weight: bold;">Statut invalide: "' .. value .. '"</span>[[Catégorie:Pages avec erreurs]]'
                        end
                    end
                },
                { cle = 'grade', label = 'Grade requis' }
            }
        },
        {
            titre = 'Téléchargements',
            champs = {
                { cle = 'bukkit', label = 'Bukkit',
                  process = function(value, args, frame) 
                    if value and value ~= '' then
                        return frame:preprocess('[https://dev.bukkit.org/projects/' .. value .. ' Bukkit]')
                    end
                    return nil 
                  end
                },
                { cle = 'hangar', label = 'Hangar (PaperMC)',
                  process = function(value, args, frame) 
                    if value and value ~= '' then
                        return frame:preprocess('[https://hangar.papermc.io/' .. value .. ' Hangar]')
                    end
                    return nil 
                  end
                },
                { cle = 'modrinth', label = 'Modrinth',
                  process = function(value, args, frame) 
                    if value and value ~= '' then
                        return frame:preprocess('[https://modrinth.com/plugin/' .. value .. ' Modrinth]')
                    end
                    return nil 
                  end
                },
                { cle = 'builtbybit', label = 'BuiltByBit',
                  process = function(value, args, frame) 
                    if value and value ~= '' then
                        return frame:preprocess('[https://builtbybit.com/resources/' .. value .. ' BuiltByBit]')
                    end
                    return nil 
                  end
                },
                { cle = 'spigot', label = 'Spigot',
                  process = function(value, args, frame) 
                    if value and value ~= '' then
                        return frame:preprocess('[https://www.spigotmc.org/resources/' .. value .. ' Spigot]')
                    end
                    return nil 
                  end
                },
                { cle = 'sources', label = 'Code source',
                  process = function(value, args, frame)
                    if value and value ~= '' then
                        if value:match('^%[.+%]$') then
                            return frame:preprocess(value)
                        elseif value:match('^https?://') then
                            local domain = value:match('://([^/]+)')
                            local siteName = 'Source'
                            if domain:match('github%.com') then
                                siteName = 'GitHub'
                            elseif domain:match('gitlab%.com') then
                                siteName = 'GitLab'
                            elseif domain:match('bitbucket%.org') then
                                siteName = 'Bitbucket'
                            end
                            return frame:preprocess('[' .. value .. ' ' .. siteName .. ']')
                        else
                            return value
                        end
                    end
                    return nil
                  end
                }
            }
        },
        {
            titre = 'Compatibilité',
            champs = {
                { cle = 'dépendance', label = 'Dépendances' },
                { cle = 'compatibilité', label = 'Compatible avec' }
            }
        }
    },

    categories = function(args, config, frame)
        local cats = {}
        
        -- Catégorie basée sur le type
        if args.type then
            local cleanType = mw.text.trim(mw.ustring.lower(args.type))
            local typeConfig = config.typeField.allowedValues[cleanType]
            if typeConfig then
                table.insert(cats, typeConfig.category)
            end
        end
        
        -- Catégorie basée sur le statut
        if args.status then
            local cleanStatus = mw.text.trim(mw.ustring.lower(args.status))
            local statusConfig = config.statusField.allowedValues[cleanStatus]
            if statusConfig then
                table.insert(cats, statusConfig.category)
            end
        end
        
        return cats
    end
}

return config