« Module:Infobox/Configs/Plugin » : différence entre les versions
De Nefald
Autres actions
m Retrait catégorie:Plugin Minecraft |
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', | { | ||
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 = '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 | ||
if value:match('^%[.+%]$') then | if value:match('^%[.+%]$') then | ||
return frame:preprocess(value) | return frame:preprocess(value) | ||
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 | 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) | |||
if | |||
table.insert(cats, | |||
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