Module:Wikiprojet
Utilisation
Ce module génère le tableau d'évaluation des bandeaux {{Wikiprojet}}. Il est conçu pour éviter l'imbrication de tableaux HTML.
Il fait pour le moment appel aux modèles {{Wikiprojet/alias}}, {{Wikiprojet/image}} et {{Wikiprojet/extra}}. Il serait préférable de transférer le contenu de ces modèles dans un sous-module, mais c'est fastidieux à faire et cela n’apporterait pas grand chose au final, ce module n'étant utilisé qu'une fois par page.
Fonctions exportables
projet( frame )
– retourne une introduction avec la liste des projets, et le tableau d'évaluation de l'avancement et l'importance de l'article pour chaque projet.
Voir aussi
La documentation de ce module est générée par le modèle {{Documentation module}}.
Elle est incluse depuis sa sous-page de documentation. Veuillez placer les catégories sur cette page-là.
Les éditeurs peuvent travailler dans le bac à sable (modifier).
Voir les statistiques d'appel depuis le wikicode sur l'outil wstat et les appels depuis d'autres modules.
-- Ce module implémente [[Modèle:Wikiprojet/Projet]], pour avoir une structure html plus simple.
local p = {}
local Outils = require( 'Module:Outils' )
local pageName = mw.title.getCurrentTitle().text
local titreAvancement = {
default = '[[Projet:Évaluation/Avancement|Avancement]]',
AdQ = '[[Wikipédia:Articles de qualité|Label]]',
BA = '[[Wikipédia:Bons articles|Label]]',
}
local dataAvancement = {
default = {
nom = 'inconnu',
couleur = '#666666; color:#fff; white-space:nowrap;' ,
texte = 'À évaluer',
},
AdQ = {
nom = 'AdQ',
couleur = '#6699ff' ,
texte = '[[Fichier:Fairytale bookmark gold.svg|14px|AdQ]] ' .. Outils.abr( 'AdQ', 'Article de qualité' ),
},
BA = {
nom = 'BA',
couleur = '#66ff66',
texte = '[[Fichier:Fairytale bookmark silverstar.svg|14px|BA]] ' .. Outils.abr( 'BA', 'Bon article' ),
},
A = {
nom = 'A',
couleur = '#66ffff',
texte = Outils.abr( 'A', 'Article avancé' ),
},
B = {
nom = 'B',
couleur = '#ffff66',
texte = Outils.abr( 'B', 'Article bien construit' ),
},
BD = {
nom = 'BD',
couleur = '#ffaa66',
texte = 'Bon\194\160début' ,
},
['Ébauche'] = {
nom = 'ébauche',
couleur = '#ff6666',
texte = 'Ébauche' ,
},
Homonymie = {
nom = 'homonymie',
couleur = '#66ff66',
texte = 'Homonymie' ,
},
}
dataAvancement['Bon début'] = dataAvancement.BD
dataAvancement['bon début'] = dataAvancement.BD
dataAvancement.C = dataAvancement.BD
dataAvancement.D = dataAvancement.BD
dataAvancement['ébauche'] = dataAvancement['Ébauche']
dataAvancement.E = dataAvancement['Ébauche']
dataAvancement.homonymie = dataAvancement.Homonymie
local dataImportance = {
default = {
nom = 'inconnue',
couleur = '#666666; color:#fff; white-space:nowrap;',
texte = 'À évaluer',
},
maximum = {
nom = 'maximum',
couleur = '#ff00ff',
texte = "Maximum" ,
},
['élevée'] = {
nom = 'élevée',
couleur = '#ff88ff',
texte = "Élevée" ,
},
moyenne = {
nom = 'moyenne',
couleur = '#ffccff',
texte = "Moyenne" ,
},
faible = {
nom = 'faible',
couleur = '#ffeeff',
texte = "Faible" ,
},
}
dataImportance.Maximum = dataImportance.maximum
dataImportance['élevée'] = dataImportance['élevée']
dataImportance.Moyenne = dataImportance.moyenne
dataImportance.Faible = dataImportance.faible
local liensProjet = "'''[[Projet:¤|¤]]''' ([[Discussion Projet:¤|discussion]] "
.. "•\194\160[[Projet:¤/Évaluation|critères]] "
.. "•\194\160[[Projet:¤/Évaluation/Index|liste]] "
.. "•\194\160[[Projet:¤/Évaluation/Statistiques détaillées|stats]] "
.. "•\194\160[[Projet:¤/Évaluation/Historique|hist.]] "
.. "•\194\160[[Projet:¤/Évaluation/Comité|comité]])"
local chaineCategorie = "[[Catégorie:%s d'avancement %s|%s]][[Catégorie:%s d'importance %s|%s]]"
local function switch( value, tab )
return tab[value] or tab['default']
end
local function analyseArg( args, i )
local arg = Outils.trim( args[2 * i - 1] )
if arg then
args[2 * i - 1] = mw.language.getContentLanguage():ucfirst( arg )
args[2 * i] = Outils.trim( args[2 * i] )
return true
end
end
function p.tableauAvancement( args )
local avancement = switch( args.avancement, dataAvancement )
local nbProjet = 0
while analyseArg( args, nbProjet + 1 ) do
nbProjet = nbProjet + 1
end
local evalTable = mw.html.create( 'table' )
evalTable
:cssText( 'background:#ededed; width:100%; margin:0.5em 0; border-spacing:0; padding:0.4em; border:1px solid #a7d7f9; border-radius:10px;' )
:tag( 'caption' )
:cssText( 'padding:5px;' )
:wikitext( "[[Image:Fairytale bookmark half gold silverlight.png|20px|alt=logo évaluation]] '''[[Projet:Évaluation|Évaluation]]''' de l’article « '''" )
:wikitext( pageName )
:wikitext( "''' »" )
:done()
:tag( 'tr' )
:tag( 'th' )
:attr{ scope = 'col' }
:cssText( 'width:6em; font-weight:normal;' )
:wikitext( switch( args.avancement, titreAvancement ) )
:done()
:tag( 'th' )
:attr{ scope = 'col' }
:cssText( 'width:6em; font-weight:normal;' )
:wikitext( '[[Projet:Évaluation/Importance|Importance]]' )
:done()
:tag( 'th' )
:attr{ scope = 'col', colspan = 2 }
:cssText( 'text-align:left; font-weight:normal;' )
:wikitext( 'pour le [[Projet:Accueil|projet]]' )
:allDone()
local ligne = mw.html.create( 'tr' )
:tag( 'td' )
:attr( 'rowspan', nbProjet )
:cssText( 'text-align:center; font-weight:bold; background-color:' .. avancement.couleur )
:wikitext( avancement.texte )
:done()
local inportancePrec
for projet = 1, nbProjet do
local importance = switch( args[2 * projet], dataImportance )
if importance ~= importancePrec then
local span = 1
while projet + span <= nbProjet
and switch( args[2 * (projet + span)], dataImportance ) == importance
do
span = span + 1
end
ligne
:tag( 'td' )
:attr( 'rowspan', span )
:cssText( 'text-align:center; font-weight:bold; background-color:' .. importance.couleur )
:wikitext( importance.texte )
:done()
end
local frame = mw.getCurrentFrame()
local nomProjet = frame:expandTemplate{
title = 'Wikiprojet/alias',
args = { projet = args[2 * projet - 1] }
}
local imageProjet = frame:expandTemplate{
title = 'Wikiprojet/image',
args = { projet = nomProjet }
}
local categProjet = frame:expandTemplate{
title = 'Wikiprojet/catégorisation',
args = { projet = nomProjet }
}
local categories = ''
if not Outils.trim( args.nocat ) then
categories = string.format( chaineCategorie,
categProjet,
avancement.nom,
pageName,
categProjet,
importance.nom,
pageName
)
end
ligne
:tag( 'td' )
:cssText( 'text-align:center; width:40px' )
:wikitext( string.format( '[[Image:%s|40x20px|%s{{{projet}}}]]', imageProjet, nomProjet ) )
:done()
:tag( 'td' )
:wikitext( ( string.gsub( liensProjet, '¤', nomProjet ) ) )
:wikitext( categories )
:done()
evalTable:node( ligne )
ligne = mw.html.create( 'tr' )
importancePrec = importance
end
return evalTable
end
function p.avancementProjet( frame )
args = frame.args
return tableauAvancement( args )
end
return p