« Module:Infobox/Configs/Plugin » : différence entre les versions
De Nefald
Autres actions
Aucun résumé des modifications |
m terraforming |
||
| (18 versions intermédiaires par le même utilisateur non affichées) | |||
| Ligne 23 : | Ligne 23 : | ||
{ | { | ||
champs = { | champs = { | ||
{ cle = 'type', label = 'Type', | { | ||
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', | |||
['premium'] = 'Premium', | |||
['cosmétique'] = 'Cosmétique', | |||
['communication'] = 'Communication', | |||
['construction'] = 'Construction', | |||
['utilitaire'] = 'Utilitaire', | |||
['mini-jeu'] = 'Mini-jeu', | |||
['modération'] = 'Modération', | |||
['monde'] = 'Monde', | |||
['inventaire'] = 'Inventaire', | |||
['terraforming'] = 'Terraforming', | |||
['transport'] = 'Transport', | |||
['magie'] = 'Magie', | |||
['mob'] = 'Mob' | |||
} | |||
-- Séparer par virgule et traiter chaque type | |||
local types = mw.text.split(value, ',') | |||
local displayTypes = {} | |||
local hasError = false | |||
local errorMsg = '' | |||
for _, typeItem in ipairs(types) do | |||
local cleanValue = mw.text.trim(mw.ustring.lower(typeItem)) | |||
if typeValues[cleanValue] then | |||
table.insert(displayTypes, typeValues[cleanValue]) | |||
else | |||
hasError = true | |||
errorMsg = errorMsg .. '<span style="color: red; font-weight: bold;">Type invalide: "' .. typeItem .. '"</span> ' | |||
end | |||
end | |||
if hasError then | |||
return errorMsg .. '[[Catégorie:Pages avec erreurs]]' | |||
end | |||
-- Joindre les types avec ", " pour l'affichage | |||
return table.concat(displayTypes, ', ') | |||
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 = ' | titre = 'Ressources', | ||
champs = { | champs = { | ||
{ cle = 'docs', label = 'Documentation', | |||
process = function(value, args, frame) | |||
if value and value ~= '' then | |||
if value:match('^%[.+%]$') then | |||
return frame:preprocess(value) | |||
elseif value:match('^https?://') then | |||
return frame:preprocess('[' .. value .. ' Documentation]') | |||
else | |||
return '[[' .. value .. ']]' | |||
end | |||
end | |||
return nil | |||
end | |||
}, | |||
{ cle = 'website', label = 'Site web', | |||
process = function(value, args, frame) | |||
if value and value ~= '' then | |||
if value:match('^%[.+%]$') then | |||
return frame:preprocess(value) | |||
elseif value:match('^https?://') then | |||
return frame:preprocess('[' .. value .. ' Site web]') | |||
else | |||
return '[[' .. value .. ']]' | |||
end | |||
end | |||
return nil | |||
end | |||
}, | |||
{ cle = 'bukkit', label = 'Bukkit', | { cle = 'bukkit', label = 'Bukkit', | ||
process = function(value) | process = function(value, args, frame) | ||
if value and value ~= '' then | |||
return frame:preprocess('[https://dev.bukkit.org/projects/' .. value .. ' Bukkit]') | |||
end | |||
return nil | |||
end | end | ||
}, | }, | ||
{ cle = 'hangar', label = 'Hangar | { cle = 'hangar', label = 'Hangar', | ||
process = function(value) | process = function(value, args, frame) | ||
if value and value ~= '' then | |||
return frame:preprocess('[https://hangar.papermc.io/' .. value .. ' Hangar]') | |||
end | |||
return nil | |||
end | end | ||
}, | }, | ||
{ cle = 'modrinth', label = 'Modrinth', | { cle = 'modrinth', label = 'Modrinth', | ||
process = function(value) | process = function(value, args, frame) | ||
if value and value ~= '' then | |||
return frame:preprocess('[https://modrinth.com/plugin/' .. value .. ' Modrinth]') | |||
end | |||
return nil | |||
end | end | ||
}, | }, | ||
{ cle = 'builtbybit', label = 'BuiltByBit', | { cle = 'builtbybit', label = 'BuiltByBit', | ||
process = function(value) | 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 | end | ||
}, | }, | ||
{ cle = 'spigot', label = 'Spigot', | { cle = 'spigot', label = 'Spigot', | ||
process = function(value) | process = function(value, args, frame) | ||
if value and value ~= '' then | |||
return frame:preprocess('[https://www.spigotmc.org/resources/' .. value .. ' Spigot]') | |||
end | |||
return nil | |||
end | end | ||
}, | }, | ||
{ cle = 'sources', label = 'Code source' } | { 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 | |||
} | |||
} | } | ||
}, | }, | ||
| Ligne 83 : | Ligne 213 : | ||
titre = 'Compatibilité', | titre = 'Compatibilité', | ||
champs = { | champs = { | ||
{ cle = 'dépendance', label = ' | { cle = 'dépendance', label = 'Dépendance(s)' }, | ||
{ cle = 'compatibilité', label = 'Compatible avec' } | { cle = 'compatibilité', label = 'Compatible avec' } | ||
} | } | ||
| Ligne 89 : | Ligne 219 : | ||
}, | }, | ||
categories = function(args, config, frame) | categories = function(args, config, frame) | ||
local cats = {} | 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', | |||
['construction'] = 'Plugin de construction', | |||
['utilitaire'] = 'Plugin utilitaire', | |||
['mini-jeu'] = 'Plugin de mini-jeux', | |||
['modération'] = 'Plugin de modération', | |||
['premium'] = 'Plugin premium', | |||
['monde'] = 'Plugin de monde', | |||
['inventaire'] = 'Plugin d\'inventaire', | |||
['terraforming'] = 'Plugin de terraforming', | |||
['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égories basées sur le(s) type(s) | |||
if args.type then | if args.type then | ||
local | -- Séparer par virgule et traiter chaque type | ||
local types = mw.text.split(args.type, ',') | |||
for _, typeItem in ipairs(types) do | |||
local cleanType = mw.text.trim(mw.ustring.lower(typeItem)) | |||
if typeCategories[cleanType] then | |||
[ | table.insert(cats, typeCategories[cleanType]) | ||
end | |||
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]) | |||
if | |||
table.insert(cats, | |||
end | end | ||
end | end | ||