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 masquer section Compatibilité si aucun champ renseigné
Balise : Révoqué
Hiob (discussion | contributions)
Annulation des modifications 670 de Hiob (discussion)
Balise : Annulation
Ligne 1 : Ligne 1 :
local p = {}
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,


function p.main(frame)
    sections = {
    local args = frame:getParent().args
        {
   
            champs = {
    local config = {
                {
        titre = function(args)  
                    cle = 'type',
            return args.nom or '{{PAGENAME}}'  
                    label = 'Type',
        end,
                    process = function(value, args)
       
                        if not value or value == '' then
        icone = {
                            return nil
            type = 'fas',
                        end
            nom = 'puzzle-piece'
                       
                        -- Configuration locale des types
                        local typeValues = {
                            ['é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' }
            }
         },
         },
          
         {
        image = function(args)
             titre = 'Ressources',
             if args.image then
             champs = {
                return {
                { cle = 'docs', label = 'Documentation',
                    nom = args.image,
                  process = function(value, args, frame)
                    taille = args.tailleimage or "280x200px",
                    if value and value ~= '' then
                    legende = args.legende or args.nom or '{{PAGENAME}}'
                        -- Si c'est déjà un lien formaté MediaWiki, le garder tel quel
                }
                        if value:match('^%[.+%]$') then
            end
                            return frame:preprocess(value)
            return nil
                        -- Si c'est une URL, créer un lien automatique
        end,
                        elseif value:match('^https?://') then
 
                            return frame:preprocess('[' .. value .. ' Documentation]')
        sections = {
                        else
             {
                            -- Si c'est du texte simple, le traiter comme un nom de page
                champs = {
                            return '[[' .. value .. ']]'
                    {  
                        cle = 'type',  
                        label = 'Type',  
                        process = function(value, args)
                            if not value or value == '' then
                                return nil
                            end
                           
                            -- Configuration locale des types
                            local typeValues = {
                                ['économie'] = 'Plugin d\'économie',
                                ['pvp'] = 'Plugin de PvP',
                                ['roleplay'] = 'Plugin de roleplay',
                                ['administration'] = 'Plugin d\'administration',
                                ['protection'] = 'Plugin de protection',
                                ['cosmétique'] = 'Plugin cosmétiques',
                                ['communication'] = 'Plugin de communication',
                                ['utilitaire'] = 'Plugin utilitaires',
                                ['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'
                            }
                           
                            -- Nettoyer la valeur d'entrée
                            local cleanValue = mw.text.trim(mw.ustring.lower(value))
                           
                            -- Retourner la valeur formatée ou la valeur originale
                            return typeValues[cleanValue] or value
                         end
                         end
                     },
                     end
                    {
                    return nil
                        cle = 'status',
                  end
                        label = 'Statut',
                },
                        process = function(value, args)
                { cle = 'bukkit', label = 'Bukkit',
                            if not value or value == '' then
                  process = function(value, args, frame)  
                                return nil
                    if value and value ~= '' then
                            end
                        return frame:preprocess('[https://dev.bukkit.org/projects/' .. value .. ' Bukkit]')
                           
                    end
                            -- Configuration locale des statuts
                    return nil  
                            local statusValues = {
                  end
                                ['installé'] = { text = 'Installé', color = 'green' },
                },
                                ['installe'] = { text = 'Installé', color = 'green' },
                { cle = 'hangar', label = 'Hangar',
                                ['non-installé'] = { text = 'Non installé', color = 'red' },
                  process = function(value, args, frame)
                                ['non-installe'] = { text = 'Non installé', color = 'red' },
                    if value and value ~= '' then
                                ['non installé'] = { text = 'Non installé', color = 'red' },
                        return frame:preprocess('[https://hangar.papermc.io/' .. value .. ' Hangar]')
                                ['non installe'] = { text = 'Non installé', color = 'red' },
                    end
                                ['désinstallé'] = { text = 'Désinstallé', color = 'red' },
                    return nil
                                ['desinstalle'] = { text = 'Désinstallé', color = 'red' }
                  end
                             }
                },
                           
                { cle = 'modrinth', label = 'Modrinth',
                            -- Nettoyer la valeur d'entrée
                  process = function(value, args, frame)
                             local cleanValue = mw.text.trim(mw.ustring.lower(value))
                    if value and value ~= '' then
                              
                        return frame:preprocess('[https://modrinth.com/plugin/' .. value .. ' Modrinth]')
                             if statusValues[cleanValue] then
                    end
                                 local status = statusValues[cleanValue]
                    return nil
                                 return '<span style="color: ' .. status.color .. '; font-weight: bold;">' .. status.text .. '</span>'
                  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
                             end
                              
                             return frame:preprocess('[' .. value .. ' ' .. siteName .. ']')
                        else
                             return value
                             return value
                         end
                         end
                     },
                     end
                    { cle = 'version', label = 'Version' },
                     return nil
                    { cle = 'author', label = 'Auteur', aliases = {'auteur'} },
                  end
                    { cle = 'source', label = 'Source' },
                    { cle = 'langue', label = 'Langue' }
                }
            },
            {
                titre = 'Compatibilite',
                visible = function(args)
                    -- La section est visible seulement si au moins un de ces champs est rempli
                     return (args.dependance and args.dependance ~= '') or
                          (args.compatibilite and args.compatibilite ~= '')
                end,
                champs = {
                    { cle = 'dependance', label = 'Dépendance(s)' },
                    { cle = 'compatibilite', label = 'Compatible avec' }
                }
            },
            {
                titre = 'Description',
                champs = {
                    { cle = 'description', label = 'Description', multiligne = true }
                 }
                 }
             }
             }
         },
         },
        {
            titre = 'Compatibilité',
            champs = {
                { cle = 'dépendance', label = 'Dépendance(s)' },
                { cle = 'compatibilité', label = 'Compatible avec' }
            }
        }
    },


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


return p
return config

Version du 3 octobre 2025 à 14:55

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 = {
                            ['é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 = '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 = '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 = {
            ['économie'] = 'Plugin d\'économie',
            ['pvp'] = 'Plugin de PvP',
            ['roleplay'] = 'Plugin de roleplay',
            ['administration'] = 'Plugin d\'administration',
            ['protection'] = 'Plugin de protection',
            ['cosmétique'] = 'Plugin cosmétiques',
            ['communication'] = 'Plugin de communication',
            ['utilitaire'] = 'Plugin utilitaires',
            ['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