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 Lien (processed)
Hiob (discussion | contributions)
Catégorie:Plugin d'API
 
(12 versions intermédiaires par le même utilisateur non affichées)
Ligne 23 : Ligne 23 :
         {
         {
             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',
                        -- Configuration locale des types
                        ['communication'] = 'Communication',
                        local typeValues = {
                        ['utilitaire'] = 'Utilitaire',
                        ['api'] = 'API',
                        ['mini-jeu'] = 'Mini-jeu',
                            ['économie'] = 'Économie',
                        ['monde'] = 'Monde',
                            ['pvp'] = 'PvP',
                        ['inventaire'] = 'Inventaire',
                            ['roleplay'] = 'Roleplay',
                        ['transport'] = 'Transport',
                            ['administration'] = 'Administration',
                        ['magie'] = 'Magie',
                            ['protection'] = 'Protection',
                        ['mob'] = 'Mob'
                            ['cosmétique'] = 'Cosmétique',
                    }
                            ['communication'] = 'Communication',
                    return types[value] or value
                            ['utilitaire'] = 'Utilitaire',
                  end
                            ['mini-jeu'] = 'Mini-jeu',
                            ['monde'] = 'Monde',
                            ['inventaire'] = 'Inventaire',
                            ['transport'] = 'Transport',
                            ['magie'] = 'Magie',
                            ['mob'] = 'Mob'
                        }
                       
                        local cleanValue = mw.text.trim(mw.ustring.lower(value))
                       
                        if typeValues[cleanValue] then
                            return typeValues[cleanValue]
                        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 = '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
                       
                        -- Configuration locale des statuts
                        local statusValues = {
                            ['installé'] = '[[:Catégorie:Plugin installé|Installé]]',
                            ['non-installé'] = '[[:Catégorie:Plugin non-installé|Non-installé]]'
                        }
                       
                        local cleanValue = mw.text.trim(mw.ustring.lower(value))
                       
                        if statusValues[cleanValue] then
                            return statusValues[cleanValue]
                        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' }
             }
             }
         },
         },
         {
         {
             titre = 'Téléchargements',
             titre = 'Ressources',
             champs = {
             champs = {
                { cle = 'docs', label = 'Documentation',
                  process = function(value, args, frame)
                    if value and value ~= '' then
                        -- Si c'est déjà un lien formaté MediaWiki, le garder tel quel
                        if value:match('^%[.+%]$') then
                            return frame:preprocess(value)
                        -- Si c'est une URL, créer un lien automatique
                        elseif value:match('^https?://') then
                            return frame:preprocess('[' .. value .. ' Documentation]')
                        else
                            -- Si c'est du texte simple, le traiter comme un nom de page
                            return '[[' .. value .. ']]'
                        end
                    end
                    return nil
                  end
                },
                { cle = 'website', label = 'Site web',
                  process = function(value, args, frame)
                    if value and value ~= '' then
                        -- Si c'est déjà un lien formaté MediaWiki, le garder tel quel
                        if value:match('^%[.+%]$') then
                            return frame:preprocess(value)
                        -- Si c'est une URL, créer un lien automatique
                        elseif value:match('^https?://') then
                            return frame:preprocess('[' .. value .. ' Site web]')
                        else
                            -- Si c'est du texte simple, le traiter comme un nom de page
                            return '[[' .. value .. ']]'
                        end
                    end
                    return nil
                  end
                },
                 { cle = 'bukkit', label = 'Bukkit',
                 { cle = 'bukkit', label = 'Bukkit',
                   process = function(value, args, frame)  
                   process = function(value, args, frame)  
Ligne 60 : Ligne 131 :
                   end
                   end
                 },
                 },
                 { cle = 'hangar', label = 'Hangar (PaperMC)',
                 { cle = 'hangar', label = 'Hangar',
                   process = function(value, args, frame)  
                   process = function(value, args, frame)  
                     if value and value ~= '' then
                     if value and value ~= '' then
Ligne 80 : Ligne 151 :
                     if value and value ~= '' then
                     if value and value ~= '' then
                         return frame:preprocess('[https://builtbybit.com/resources/' .. value .. ' BuiltByBit]')
                         return frame:preprocess('[https://builtbybit.com/resources/' .. value .. ' BuiltByBit]')
                    end
                    return nil
                  end
                },
                { cle = 'polymart', label = 'Polymart',
                  process = function(value, args, frame)
                    if value and value ~= '' then
                        return frame:preprocess('[https://polymart.org/product/' .. value .. ' Polymart]')
                     end
                     end
                     return nil  
                     return nil  
Ligne 95 : Ligne 174 :
                   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 122 : Ligne 199 :
             titre = 'Compatibilité',
             titre = 'Compatibilité',
             champs = {
             champs = {
                 { cle = 'dépendance', label = 'Dépendances' },
                 { cle = 'dépendance', label = 'Dépendance(s)' },
                 { cle = 'compatibilité', label = 'Compatible avec' }
                 { cle = 'compatibilité', label = 'Compatible avec' }
             }
             }
Ligne 131 : Ligne 208 :
         local cats = {}
         local cats = {}
          
          
         table.insert(cats, 'Plugins Minecraft')
         -- Configuration des catégories par type
        local typeCategories = {
        ['api'] = 'Plugin d\'API',
            ['économie'] = 'Plugin d\'économie',
            ['pvp'] = 'Plugin de PvP',
            ['roleplay'] = 'Plugin de roleplay',
            ['administration'] = 'Plugin d\'administration',
            ['protection'] = 'Plugin de protection',
            ['cosmétique'] = 'Plugin cosmétique',
            ['communication'] = 'Plugin de communication',
            ['utilitaire'] = 'Plugin utilitaire',
            ['mini-jeu'] = 'Plugin de mini-jeux',
            ['monde'] = 'Plugin de monde',
            ['inventaire'] = 'Plugin d\'inventaire',
            ['transport'] = 'Plugin de transport',
            ['magie'] = 'Plugin de magie',
            ['mob'] = 'Plugin de mobs'
        }
          
          
        -- Configuration des catégories par statut
        local statusCategories = {
            ['installé'] = 'Plugin installé',
            ['non-installé'] = 'Plugin non-installé'
        }
       
        -- 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',
            if typeCategories[cleanType] then
                 ['pvp'] = 'Plugins de PvP',
                 table.insert(cats, typeCategories[cleanType])
                ['roleplay'] = 'Plugins de roleplay',
            end
                ['administration'] = 'Plugins d\'administration',
        end
                ['protection'] = 'Plugins de protection',
       
                ['cosmétique'] = 'Plugins cosmétiques',
        -- Catégorie basée sur le statut
                ['communication'] = 'Plugins de communication',
        if args.status then
                ['utilitaire'] = 'Plugins utilitaires',
            local cleanStatus = mw.text.trim(mw.ustring.lower(args.status))
                ['mini-jeu'] = 'Plugins de mini-jeux',
             if statusCategories[cleanStatus] then
                ['monde'] = 'Plugins de monde',
                 table.insert(cats, statusCategories[cleanStatus])
                ['inventaire'] = 'Plugins d\'inventaire',
                ['transport'] = 'Plugins de transport',
                ['magie'] = 'Plugins de magie',
                ['mob'] = 'Plugins de mobs'
            }
             if typeCategories[args.type] then
                 table.insert(cats, typeCategories[args.type])
             end
             end
         end
         end

Dernière version du 8 octobre 2025 à 14:49

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,

    sections = {
        {
            champs = {
                { 
                    cle = 'type', 
                    label = 'Type', 
                    process = function(value, args)
                        if not value or value == '' then
                            return nil
                        end
                        
                        -- Configuration locale des types
                        local typeValues = {
                        	['api'] = 'API',
                            ['économie'] = 'Économie',
                            ['pvp'] = 'PvP',
                            ['roleplay'] = 'Roleplay',
                            ['administration'] = 'Administration',
                            ['protection'] = 'Protection',
                            ['cosmétique'] = 'Cosmétique',
                            ['communication'] = 'Communication',
                            ['utilitaire'] = 'Utilitaire',
                            ['mini-jeu'] = 'Mini-jeu',
                            ['monde'] = 'Monde',
                            ['inventaire'] = 'Inventaire',
                            ['transport'] = 'Transport',
                            ['magie'] = 'Magie',
                            ['mob'] = 'Mob'
                        }
                        
                        local cleanValue = mw.text.trim(mw.ustring.lower(value))
                        
                        if typeValues[cleanValue] then
                            return typeValues[cleanValue]
                        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
                        
                        -- Configuration locale des statuts
                        local statusValues = {
                            ['installé'] = '[[:Catégorie:Plugin installé|Installé]]',
                            ['non-installé'] = '[[:Catégorie:Plugin non-installé|Non-installé]]'
                        }
                        
                        local cleanValue = mw.text.trim(mw.ustring.lower(value))
                        
                        if statusValues[cleanValue] then
                            return statusValues[cleanValue]
                        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 = 'Ressources',
            champs = {
                { cle = 'docs', label = 'Documentation',
                  process = function(value, args, frame)
                    if value and value ~= '' then
                        -- Si c'est déjà un lien formaté MediaWiki, le garder tel quel
                        if value:match('^%[.+%]$') then
                            return frame:preprocess(value)
                        -- Si c'est une URL, créer un lien automatique
                        elseif value:match('^https?://') then
                            return frame:preprocess('[' .. value .. ' Documentation]')
                        else
                            -- Si c'est du texte simple, le traiter comme un nom de page
                            return '[[' .. value .. ']]'
                        end
                    end
                    return nil
                  end
                },
                { cle = 'website', label = 'Site web',
                  process = function(value, args, frame)
                    if value and value ~= '' then
                        -- Si c'est déjà un lien formaté MediaWiki, le garder tel quel
                        if value:match('^%[.+%]$') then
                            return frame:preprocess(value)
                        -- Si c'est une URL, créer un lien automatique
                        elseif value:match('^https?://') then
                            return frame:preprocess('[' .. value .. ' Site web]')
                        else
                            -- Si c'est du texte simple, le traiter comme un nom de page
                            return '[[' .. value .. ']]'
                        end
                    end
                    return nil
                  end
                },
                { 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',
                  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 = 'polymart', label = 'Polymart',
                  process = function(value, args, frame) 
                    if value and value ~= '' then
                        return frame:preprocess('[https://polymart.org/product/' .. value .. ' Polymart]')
                    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épendance(s)' },
                { cle = 'compatibilité', label = 'Compatible avec' }
            }
        }
    },

    categories = function(args, config, frame)
        local cats = {}
        
        -- Configuration des catégories par type
        local typeCategories = {
        	['api'] = 'Plugin d\'API',
            ['économie'] = 'Plugin d\'économie',
            ['pvp'] = 'Plugin de PvP',
            ['roleplay'] = 'Plugin de roleplay',
            ['administration'] = 'Plugin d\'administration',
            ['protection'] = 'Plugin de protection',
            ['cosmétique'] = 'Plugin cosmétique',
            ['communication'] = 'Plugin de communication',
            ['utilitaire'] = 'Plugin utilitaire',
            ['mini-jeu'] = 'Plugin de mini-jeux',
            ['monde'] = 'Plugin de monde',
            ['inventaire'] = 'Plugin d\'inventaire',
            ['transport'] = 'Plugin de transport',
            ['magie'] = 'Plugin de magie',
            ['mob'] = 'Plugin de mobs'
        }
        
        -- Configuration des catégories par statut
        local statusCategories = {
            ['installé'] = 'Plugin installé',
            ['non-installé'] = 'Plugin non-installé'
        }
        
        -- Catégorie basée sur le type
        if args.type then
            local cleanType = mw.text.trim(mw.ustring.lower(args.type))
            if typeCategories[cleanType] then
                table.insert(cats, typeCategories[cleanType])
            end
        end
        
        -- Catégorie basée sur le statut
        if args.status then
            local cleanStatus = mw.text.trim(mw.ustring.lower(args.status))
            if statusCategories[cleanStatus] then
                table.insert(cats, statusCategories[cleanStatus])
            end
        end
        
        return cats
    end
}

return config