Technopedia Center
PMB University Brochure
Faculty of Engineering and Computer Science
S1 Informatics S1 Information Systems S1 Information Technology S1 Computer Engineering S1 Electrical Engineering S1 Civil Engineering

faculty of Economics and Business
S1 Management S1 Accountancy

Faculty of Letters and Educational Sciences
S1 English literature S1 English language education S1 Mathematics education S1 Sports Education
  • Registerasi
  • Brosur UTI
  • Kip Scholarship Information
  • Performance
  1. Weltenzyklopädie
  2. Module:Wikiprojet — Wikipédia
Module:Wikiprojet — Wikipédia 👆 Click Here! Read More..
Cette page est protégée.
Une page de Wikipédia, l'encyclopédie libre.

 Documentation[voir] [modifier] [historique] [purger]

Ce module à risque est inclus sur un très grand nombre de pages et ne peut pas être modifié.

Cette protection ne constitue pas obligatoirement une approbation de la version actuelle. Vous pouvez proposer une modification en page de discussion. Lorsqu'un compromis sera trouvé en page de discussion, vous pourrez demander la modification auprès des administrateurs (voir le journal des protections).

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

  • {{Wikiprojet}}
    • Projet Scribunto Projet Scribunto

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 dataAvancement = {
	default = {
		nom = 'inconnu',
		couleur = '#666666',
		extraCSS = 'color:#fff; white-space:nowrap;',
		texte = 'À évaluer',
	},
	adq = {
		nom = 'AdQ',
		couleur = '#6699ff',
		extraCSS = 'color:#000;',
		texte = '[[Fichier:Article de qualité.svg|14px|AdQ|alt=]] <abbr class="abbr" title="Article de qualité">AdQ</abbr>',
	},
	ba = {
		nom = 'BA',
		couleur = '#66ff66',
		extraCSS = 'color:#000;',
		texte = '[[Fichier:Bon article.svg|14px|BA|alt=]] <abbr class="abbr" title="Bon article">BA</abbr>',
	},
	a = {
		nom = 'A',
		couleur = '#66ffff',
		extraCSS = 'color:#000;',
		texte = '<abbr class="abbr" title="Article avancé">A</abbr>',
	},
	b = {
		nom = 'B',
		couleur = '#ffff66',
		extraCSS = 'color:#000;',
		texte = '<abbr class="abbr" title="Article bien construit">B</abbr>',
	},
	bd = {
		nom = 'BD',
		couleur = '#ffaa66',
		extraCSS = 'color:#000;',
		texte = 'Bon\194\160début',
	},
	['ébauche'] = {
		nom = 'ébauche',
		couleur = '#ff6666',
		extraCSS = 'color:#000;',
		texte = 'Ébauche',
	},
	homonymie = {
		nom = 'homonymie',
		couleur = '#66ff66',
		extraCSS = 'color:#000;',
		texte = 'Homonymie',
	},
}
dataAvancement['bon début'] = dataAvancement.bd
dataAvancement.c = dataAvancement.bd
dataAvancement.d = dataAvancement.bd
dataAvancement.e = dataAvancement['ébauche']

local dataImportance = {
	default = {
		id = 0,
		nom = 'inconnue',
		couleur = '#666666',
		extraCSS = 'color:#fff; white-space:nowrap;',
		texte = 'À évaluer',
	},
	maximum = {
		id = 4,
		nom = 'maximum',
		couleur = '#ff00ff',
		extraCSS = 'color:#000;',
		texte = "Maximum",
	},
	['élevée'] = {
		id = 3,
		nom = 'élevée',
		couleur = '#ff88ff',
		extraCSS = 'color:#000;',
		texte = "Élevée",
	},
	moyenne = {
		id = 2,
		nom = 'moyenne',
		couleur = '#ffccff',
		extraCSS = 'color:#000;',
		texte = "Moyenne",
	},
	faible = {
		id = 1,
		nom = 'faible',
		couleur = '#ffeeff',
		extraCSS = 'color:#000;',
		texte = "Faible",
	},
}

-- la classe "intro-wikiprojet" permet de masquer le texte d'introduction avec du CSS utilisateur
-- refs [[Discussion modèle:Wikiprojet#Supprimer le lien "masquer/afficher"]]
local introduction = '<div class="intro-wikiprojet" style="margin-bottom:1em"><p>Cet article est indexé par %s %s.</p>'
	.. '<p>Les [[Projet:Accueil|projets]] ont pour but d’enrichir le contenu de Wikipédia en aidant à la coordination du travail des contributeurs. '
	.. 'Vous pouvez [%s modifier directement cet article] '
	.. 'ou visiter les pages de projets pour prendre conseil ou consulter la liste des tâches et des objectifs.</p></div>'
local lienProjet = '[[Projet:%s|%s]]'
local liensProjet = '<b>[[Projet:¤|¤]]</b> ([[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é]]'
	.. '\194\160• [[Projet:¤/Pages populaires|stats vues]])'
local chaineCategorie = "[[Catégorie:Article d\'avancement %s/Liste complète]][[Catégorie:%s d\'avancement %s]][[Catégorie:%s d\'importance %s]]%s"

local function switch( key, table )
	return table[key] or table['default']
end

local function analyseArgs( args )
	local newArgs = {
		[0] = {},  -- pour éviter une erreur sur i-1
		avancement = switch( mw.ustring.lower( args.avancement or '' ), dataAvancement ),
		nocat = ( args.nocat and args.nocat ~= '' ),
	}
	local frame = mw.getCurrentFrame()
	local i = 1
	while args[i] and mw.text.trim( args[i] ) ~= '' do
		local nomProjet = frame:expandTemplate{
			title = 'Wikiprojet/alias',
			args = { projet = args[i] }
		}
		local projet = {
			importance = switch( mw.ustring.lower( mw.text.trim( args[ i + 1 ] or '' ) ), dataImportance ),
			nom = nomProjet,
			image = frame:expandTemplate{
				title = 'Wikiprojet/image',
				args = { projet = nomProjet }
			},
			nomCategorie = 'Article du projet ' .. nomProjet,
			extraCategorie = frame:expandTemplate{
				title = 'Wikiprojet/extra',
				args = { projet = nomProjet }
			},
		}
		if projet.image == '' then
			local bandeau = require 'Module:Bandeau'
			local icone = bandeau.parametreEbauche( frame:newChild { args = { nomProjet, 'icone' } } )
			projet.image = icone or 'Emojione 2754.svg'
			projet.extraCategorie = projet.extraCategorie .. '[[Catégorie:Page avec image Wikiprojet déduite|' .. nomProjet .. ']]'
		end
		table.insert( newArgs, projet )
		i = i + 2
	end

	-- fonction de triage selon
	-- 1. importance
	-- 2. nom
	table.sort( newArgs, function ( a, b )
		if a.importance.id == b.importance.id then
			function normalize( value )
				value = mw.ustring.lower( value )
				value = mw.ustring.gsub( value, '[âéî]', {
					['â'] = 'a', -- Projet:Âge d'or de l'Islam...
					['é'] = 'e', -- Projet:Économie, Projet:États-Unis...
					['î'] = 'i', -- Projet:Île-de-France, Projet:Île de Man, Projet:Îles...
				} )
				return value
			end
			return normalize( a.nom ) < normalize( b.nom )
		end
		return a.importance.id > b.importance.id
	end )

	return newArgs
end

function p.introduction( args )
	local sp = 'le projet'
	if #args > 1 then
		sp = 'les projets'
	end
	local listeProjets = {}
	for i = 1, #args do
		local nom = args[i].nom
		table.insert( listeProjets, string.format( lienProjet, nom, nom ) )
	end
	return string.format( introduction,
		sp,
		mw.text.listToText( listeProjets ),
		mw.title.getCurrentTitle().subjectPageTitle:fullUrl( 'action=edit' )
	)
end

function p.tableauAvancement( args )
	local page = mw.title.getCurrentTitle()
	local pageName = page.text
	local frame = mw.getCurrentFrame()
	local titreAvancement = {
		default = '[[Projet:Évaluation/Avancement|Avancement]]',
		AdQ = '[[Wikipédia:Articles de qualité|Label]]',
		BA = '[[Wikipédia:Bons articles|Label]]',
	}
	local evalTable = mw.html.create( 'table' )
	evalTable
		-- le "border-collapse:separate" est pour la version mobile
		:cssText( 'background:var(--couleur-fond-gris-alternance, #ededed); color:inherit; width:100%; border-spacing:0; padding:0.4em 0.6em calc(0.4em + 2px); border:1px solid #a7d7f9; border-radius:10px; border-collapse:separate;' )
		:tag( 'caption' )
			:cssText( 'padding-bottom:5px;' )
			:wikitext( '[[Fichier:Fairytale bookmark half gold silverlight.png|20px|alt=]] <b>[[Projet:Évaluation|Évaluation]]</b> de l’article « <b>' )
			:wikitext( mw.text.nowiki( pageName ) )
			:wikitext( '</b> »' )
			:done()
		:tag( 'tr' )
			:tag( 'th' )
				:attr{ scope = 'col' }
				:cssText( 'width:6em; font-weight:normal;' )
				:wikitext( switch( args.avancement.nom, 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', #args )
				:cssText( 'text-align:center; font-weight:bold; background-color:' .. args.avancement.couleur )
				:cssText( args.avancement.extraCSS or nil )
				:wikitext( args.avancement.texte )
			:done()

	for numProjet, projet in ipairs( args ) do
		if projet.importance ~= args[numProjet-1].importance then
			local span = 1
			while numProjet + span <= #args
				and args[numProjet + span].importance == projet.importance
			do
				span = span + 1
			end
			ligne
				:tag( 'td' )
					:attr( 'rowspan', span )
					:cssText( 'text-align:center; font-weight:bold; background-color:' .. projet.importance.couleur )
					:cssText( projet.importance.extraCSS or nil )
					:wikitext( projet.importance.texte )
					:done()
		end

		local avancementCommun = args.avancement.nom

		local categories = ''
		if not args.nocat and page.namespace == 1 then
			categories = string.format( chaineCategorie,
				avancementCommun,
				projet.nomCategorie,
				avancementCommun,
				projet.nomCategorie,
				projet.importance.nom,
				projet.extraCategorie
			)
		end

		-- https://www.mediawiki.org/wiki/Extension:PageAssessments
		-- https://phabricator.wikimedia.org/T153393
		local assessment = frame:callParserFunction( '#assessment', { projet.nom, avancementCommun, projet.importance.nom } )

		ligne
			:tag( 'td' )
				:cssText( 'text-align:center; width:40px' )
				:wikitext( string.format( '[[Fichier:%s|40x20px|alt=]]', projet.image ) )
				:done()
			:tag( 'td' )
				:wikitext( ( string.gsub( liensProjet, '¤', projet.nom ) ) )
				:wikitext( categories )
				:wikitext( assessment )
				:done()

		evalTable:node( ligne )
		ligne = mw.html.create( 'tr' )
	end
	if #args == 0 then
		evalTable:node( ligne )
	end
	return tostring( evalTable )
end

function p.projet( frame )
	local args
	if type( frame.getParent ) == 'function' then
		args = analyseArgs( frame:getParent().args )
	else
		args = analyseArgs( frame.args )  -- pour tester dans la console
	end
	if args[1] then
		return p.introduction(args) .. p.tableauAvancement( args )
	else
		return p.tableauAvancement( args )
	end
end

return p
Ce document provient de « https://fr.teknopedia.teknokrat.ac.id/w/index.php?title=Module:Wikiprojet&oldid=223089652 ».
Catégorie :
  • Module en langage Lua
Catégorie cachée :
  • Module protégé

  • indonesia
  • Polski
  • الرية
  • Deutsch
  • English
  • Español
  • Français
  • Italiano
  • مصر
  • Nederlands
  • 本語
  • Português
  • Sinugboanong Binisaya
  • Svenska
  • Українска
  • Tiếng Việt
  • Winaray
  • 中文
  • Русски
Sunting pranala
Pusat Layanan

UNIVERSITAS TEKNOKRAT INDONESIA | ASEAN's Best Private University
Jl. ZA. Pagar Alam No.9 -11, Labuhan Ratu, Kec. Kedaton, Kota Bandar Lampung, Lampung 35132
Phone: (0721) 702022
Email: pmb@teknokrat.ac.id