« Module:Bandeau » : différence entre les versions

1 956 octets ajoutés ,  23 mai 2025
petites réécritures ; pas de changement fonctionnel, c'est seulement pour rendre le code plus clair
m (1 version importée depuis w:Module:Bandeau)
 
(petites réécritures ; pas de changement fonctionnel, c'est seulement pour rendre le code plus clair)
Ligne 1 : Ligne 1 :
-- luacheck: globals mw, no max line length
--Ce module implémente les modèles de bandeau.
--Ce module implémente les modèles de bandeau.


Ligne 14 : Ligne 16 :
local trim = require('Module:Outils').trim
local trim = require('Module:Outils').trim
local yesno = require('Module:yesno')
local yesno = require('Module:yesno')
local class = mw.loadData('Module:Bandeau/Class')
local classData = mw.loadData('Module:Bandeau/Class')
local moduleEbauche = 'Module:Bandeau/Ébauche'
local moduleEbauche = 'Module:Bandeau/Ébauche'
-- local paramEbauche = mw.loadData(moduleEbauche) -- ne sera chargé que pour un bandeau d'ébauche.
-- local paramEbauche = mw.loadData(moduleEbauche) -- ne sera chargé que pour un bandeau d'ébauche.
Ligne 21 : Ligne 23 :
forme = 'bandeau-simple',
forme = 'bandeau-simple',
niveau = 'bandeau-niveau-neutre',
niveau = 'bandeau-niveau-neutre',
formatLien = '[[Fichier:%s|%spx|alt=%s|class=noviewer]]',
formatLien = '[[Fichier:%s|%spx|alt=%s|class=noviewer %s]]',
tailleIcone = '45x45',
tailleIcone = '45x45',
erreurArgument = 'Paramètre <code>|%s=</code> manquant',
erreurArgument = 'Paramètre <code>|%s=</code> manquant',
erreurEbaucheParam = 'le thème « %s » du modèle [[Modèle:Ébauche|{{ébauche}}]] n’est pas [[Aide:Ébauche/Aide paramètres|défini]].',
erreurEbaucheParam = 'le thème « %s » du modèle [[Modèle:Ébauche|' .. mw.text.nowiki('{{ébauche}}') .. ']] n’est pas [[Aide:Ébauche/Aide paramètres|défini]].',
erreurEbaucheType = 'le thème « %s » doit apparaître en tête de liste du modèle [[Modèle:Ébauche|{{ébauche}}]].',
erreurEbaucheType = 'le thème « %s » doit apparaître en tête de liste du modèle [[Modèle:Ébauche|' .. mw.text.nowiki('{{ébauche}}') .. ']].',
ebaucheImage = '<span style="white-space:nowrap;word-spacing:5px">%s</span>',
ebaucheImage = '<span style="white-space:nowrap;word-spacing:5px">%s</span>',
ebaucheTitre = '%s est une [[Aide:Ébauche|ébauche]].',
ebaucheTitre = '%s est une [[Aide:Ébauche|ébauche]].',
Ligne 33 : Ligne 35 :


-- CSS inline pour éviter FOUC sur le site mobile
-- CSS inline pour éviter FOUC sur le site mobile
-- [2025-03-08] notes ultérieures :
-- * le CSS mobile est dorénavant chargé en synchrone (et dans tous les cas à l'avenir, hors de question de repasser en asynchrone), donc il n'y a en théorie plus de problématique de FOUC
-- * ce code (du CSS inline) a pour effet de bord inattendu de rendre ineffectif le masquage des icônes sur mobile, cf. [[Spécial:Lien permanent/223683963#L-384]] et [[Discussion MediaWiki:Common.css/Archive 1#Disparition inexpliquées]]
-- * pas simple... mais si ça se trouve, à la condition que l'on souhaite bien masquer les icônes sur mobile, il suffirait de virer cette rustine maintenant qu'elle n'est théoriquement plus nécessaire
--    * néanmoins, certaines autres icônes que celles des bandeaux d'homonymie seraient peut-être aussi souhaitables, je pense notamment à celles des bandeaux d'ébauches
local rustineFoucMobile = {
local rustineFoucMobile = {
['display'] = 'table-cell',
['display'] = 'table-cell',
Ligne 56 : Ligne 63 :
local cells = mw.html.create()
local cells = mw.html.create()
local icone = trim(args.image) or trim(args['icône'])
local icone = trim(args.image) or trim(args['icône'])
local backgroundIcone = class.icones[icone] or false
local backgroundIcone = icone and classData.icones[icone:gsub('_', ' ')] or false
local texte = (trim(args.texte) or erreur('texte', cfg.erreurArgument))
local texte = (trim(args.texte) or erreur('texte', cfg.erreurArgument))


res :attr{ id = args.id }
if args.id and args.id ~= '' then
:addClass('bandeau-container')
res:attr('id', args.id)
:addClass(class.formes[args.forme] or cfg.forme)
end
:addClass(class.niveau[args.niveau] or cfg.niveau)
 
:addClass('plainlinks')
res :addClass('bandeau-container metadata')
:addClass(args.class)
:addClass(classData.formes[args.forme] or cfg.forme)
:cssText(args.style)
:addClass(classData.niveau[args.niveau] or cfg.niveau)
 
if args.class and args.class ~= '' then
res:addClass(args.class)
end
 
if args.style and args.style ~= '' then
res:cssText(args.style)
end
 
if yesno(args.centrer) then
if yesno(args.centrer) then
cells = mw.html.create('div')
cells = mw.html.create('div')
Ligne 75 : Ligne 90 :
end
end


if args['icône bma'] == 'oui' then
if args['icône bma'] and args['icône bma'] ~= 'non' then
cells:wikitext( mw.getCurrentFrame():expandTemplate{ title = 'Bma' } )
if args['icône bma'] == 'oui' then
cells:wikitext( mw.getCurrentFrame():expandTemplate{ title = 'Bma' } )
else
cells:wikitext( mw.getCurrentFrame():expandTemplate{ title = 'Bma', args = {args['icône bma']} } )
end
end
end


Ligne 87 : Ligne 106 :
end
end
local taille = args['taille icône'] or cfg.tailleIcone
local taille = args['taille icône'] or cfg.tailleIcone
iconeWiki = cfg.formatLien:format(icone, taille, alt)
local classeIcone = args['classe icône'] or args.classeIcone or ''
iconeWiki = cfg.formatLien:format(icone, taille, alt, classeIcone)
end
end
cells
cells
Ligne 94 : Ligne 114 :
:css(rustineFoucMobile)
:css(rustineFoucMobile)
:wikitext(iconeWiki)
:wikitext(iconeWiki)
:done()
end
-- pour que le texte commence sur une nouvelle ligne (parsage wikicode "*", etc.)
-- (et uniquement dans ce cas de figure, autrement le texte se retrouve encadré par un <p> automatique)
if texte:match('^[*#;:]') then
texte = '\n' .. texte
end
end


Ligne 108 : Ligne 121 :
:css(rustineFoucMobile)
:css(rustineFoucMobile)
:addClass(backgroundIcone and ('bandeau-icone-css ' .. backgroundIcone) or nil)
:addClass(backgroundIcone and ('bandeau-icone-css ' .. backgroundIcone) or nil)
:newline() -- sert à la génération automatique de <p> encadrant le contenu
:wikitext(texte)
:wikitext(texte)
:newline() -- ne pas supprimer, sert à la génération automatique de <p> encadrant le contenu
:newline() -- sert à la génération automatique de <p> encadrant le contenu
:done()


if trim(args.droite) then
if trim(args.droite) then
Ligne 120 : Ligne 133 :
:newline()
:newline()
:wikitext(args.droite)
:wikitext(args.droite)
:done()
end
end
 
res :node(cells)
res :node(cells)
if trim(args['supplément']) then
if trim(args['supplément']) then
res :tag('div')  
res :tag('div')
:wikitext(args['supplément'])
:wikitext(args['supplément'])
:done()
end
end
return tostring(res)
return tostring(res)
Ligne 140 : Ligne 151 :
if suffixeDate then
if suffixeDate then
-- pour rendre insécable, seulement si le paramètre semble bien être une date valide
-- pour rendre insécable, seulement si le paramètre semble bien être une date valide
suffixeDate = (require 'Module:Date').modeleDate{suffixeDate, nolinks=true, onerror='input'}
suffixeDate = (require 'Module:Date').modeleDate{suffixeDate, nolinks=true, afficherErreurs=false, categoriserErreurs=false}


titre = titre:gsub('%.$', '')
titre = titre:gsub('%.$', '')
Ligne 154 : Ligne 165 :
:done()
:done()
:wikitext(suffixeDate)
:wikitext(suffixeDate)
:newline():newline()
 
:wikitext(args.texte)
local texte = trim(args.texte)
if texte then
htmlTexte
:newline()
:newline()
:tag('div')
:addClass('nomobile')
:newline()
:newline()
:wikitext(texte)
end


local parametres = {
local parametres = {
Ligne 161 : Ligne 182 :
niveau = args.niveau,
niveau = args.niveau,
id = args.id,
id = args.id,
class = 'bandeau-container metadata ambox ' .. ( args.class or '' ),
class = args.class,
['icône'] = trim(args['icône']) or trim(args['icône-complexe']) or args.niveau,
['icône'] = trim(args['icône']) or trim(args['icône-complexe']) or args.niveau,
alt = args.alt or args['légende'],
alt = args.alt or args['légende'],
classeIcone = args['classe icône'] or args.classeIcone or '',
['domaine public'] = args['domaine public'],
['domaine public'] = args['domaine public'],
texte = tostring(htmlTexte),
texte = tostring(htmlTexte),
Ligne 182 : Ligne 204 :
local res = mw.html.create('div')
local res = mw.html.create('div')
local icone = trim(args.image) or trim(args['icône'])
local icone = trim(args.image) or trim(args['icône'])
local backgroundIcone = class.icones[icone] or false
local backgroundIcone = icone and classData.icones[icone:gsub('_', ' ')] or false
local texte = (trim(args.texte) or erreur('texte', cfg.erreurArgument))
local texte = (trim(args.texte) or erreur('texte', cfg.erreurArgument))


res :addClass('bandeau-container bandeau-section metadata')
res :addClass('bandeau-container bandeau-section metadata')
:addClass(class.niveau[args.niveau] or cfg.niveau)
:addClass(classData.niveau[args.niveau] or cfg.niveau)
 
if icone and not backgroundIcone then
if icone and not backgroundIcone then
local iconeWiki = icone
local iconeWiki = icone
Ligne 195 : Ligne 217 :
alt = alt .. '|link='
alt = alt .. '|link='
end
end
iconeWiki = cfg.formatLien:format(icone, 'text-top|20x17', alt)
local classeIcone = args['classe icône'] or ''
iconeWiki = cfg.formatLien:format(icone, 'text-top|20x17', alt, classeIcone)
end
end
res :tag('div')
res :tag('div')
:addClass('bandeau-cell bandeau-icone')
:addClass('bandeau-cell bandeau-icone')
:wikitext(iconeWiki)
:wikitext(iconeWiki)
:done()
end
end
res :tag('div')
res :tag('div')
Ligne 206 : Ligne 228 :
:addClass(backgroundIcone and ('bandeau-icone-css ' .. backgroundIcone) or nil)
:addClass(backgroundIcone and ('bandeau-icone-css ' .. backgroundIcone) or nil)
:wikitext(texte)
:wikitext(texte)
:done()


return tostring(res)
return tostring(res)
Ligne 220 : Ligne 241 :
return mw.ustring.lower( premierCar ) .. mw.ustring.sub( str, 2 )
return mw.ustring.lower( premierCar ) .. mw.ustring.sub( str, 2 )
end
end
end
end
end
end


-- fonction qui récupètre la ou les tables d'ébauche correspondant au thème
-- fonction qui récupère la ou les tables d'ébauche correspondant au thème
local function getEbaucheTable( paramEbauche, theme, feminin )
local function getEbaucheTable( paramEbauche, theme, feminin )
-- suprime les marques de direction ltr
-- suprime les marques de direction ltr
theme = theme:gsub( '\226\128\142', '' ):gsub( '_', ' ' )
theme = theme:gsub( '\226\128\142', '' ):gsub( '_', ' ' )
-- récupére les paramètres lié au theme, à partir du module:Bandeau/Ébauche
-- récupère les paramètres lié au theme, à partir du module:Bandeau/Ébauche
local params = {}
local params = {}
local ebauche = paramEbauche[ theme ] or paramEbauche[ inverserCasse( theme ) ]
local ebauche = paramEbauche[ theme ] or paramEbauche[ inverserCasse( theme ) ]
Ligne 233 : Ligne 254 :
-- teste si l'un des mots du thème correspond à un adjectif existant
-- teste si l'un des mots du thème correspond à un adjectif existant
for adj in theme:gmatch( ' ([^ ]+)' ) do
for adj in theme:gmatch( ' ([^ ]+)' ) do
paramsAdj = getEbaucheTable( paramEbauche, adj, feminin )
local paramsAdj = getEbaucheTable( paramEbauche, adj, feminin )
if paramsAdj and paramsAdj.adjectif == true then
if paramsAdj and paramsAdj.adjectif == true then
local nom = theme:gsub( ' ' .. adj:gsub( '(%p)', '%%%1'), '' )
local nom = theme:gsub( ' ' .. adj:gsub( '(%p)', '%%%1'), '' )
Ligne 255 : Ligne 276 :
end
end
end
end
if feminin and ebauche and ebauche.feminin then  
if feminin and ebauche and ebauche.feminin then
ebauche = paramEbauche[ ebauche.feminin ]
ebauche = paramEbauche[ ebauche.feminin ]
end
end
Ligne 296 : Ligne 317 :
local ebauches, gestionErreur = {}, {}
local ebauches, gestionErreur = {}, {}
local humain, feminin = femininFromWikidata()
local humain, feminin = femininFromWikidata()
feminin = yesno( args["féminin"], true, false ) or feminin
if args['féminin'] and args['féminin'] ~= '' then
feminin = yesno( args['féminin'], true )
end
local estFeminin
local estFeminin
 
-- fonction qui retourne la valeur de param pour l'ébauche i, ou une valeur par défaut
-- fonction qui retourne la valeur de param pour l'ébauche i, ou une valeur par défaut
local ebaucheParam = function( i, param )
local ebaucheParam = function( i, param )
return ebauches[ i ] and ebauches[ i ][ param ] or paramEbauche[''][ param ]
if ebauches[ i ] and ebauches[ i ][ param ] ~= nil then
return ebauches[ i ][ param ]
else
return paramEbauche[''][ param ]
end
end
end


Ligne 314 : Ligne 341 :
else
else
table.insert(
table.insert(
gestionErreur,  
gestionErreur,
erreur( theme, cfg.erreurEbaucheParam, 'div' )
erreur( theme, cfg.erreurEbaucheParam, 'div' )
)
)
Ligne 320 : Ligne 347 :
end
end
end
end
 
-- récupération des différents titres, images et catégories
-- récupération des différents titres, images et catégories
local images, titres, categs = {}, {}, {}
local images, titres, categs = {}, {}, {}
Ligne 331 : Ligne 358 :
local alt = ''
local alt = ''
if ebauche.icone then
if ebauche.icone then
local image = cfg.formatLien:format( ebauche.icone, tailleIcone, alt )
local classeIcone = ebauche.classeIcone or ''
local image = cfg.formatLien:format( ebauche.icone, tailleIcone, alt, classeIcone )
table.insert( images, image )
table.insert( images, image )
end
end
if math.fmod( #ebauches, 3 ) == 1 and ( #ebauches - i ) == 2
if math.fmod( #ebauches, 3 ) == 1 and ( #ebauches - i ) == 2
or math.fmod( i, 3 ) == 0 and ( #ebauches - i ) > 1
or math.fmod( i, 3 ) == 0 and ( #ebauches - i ) > 1
then
then
Ligne 340 : Ligne 368 :
table.insert( images, '<br> ' )
table.insert( images, '<br> ' )
end
end
 
if i > 1 and ebauche.type and ebauche.type ~= paramEbauche[''].type then
if i > 1 and ebauche.type and ebauche.type ~= paramEbauche[''].type then
-- remplace "Cet article par "Ce portail" ou autre en fonction du premier thème
-- remplace "Cet article par "Ce portail" ou autre en fonction du premier thème
table.insert(
table.insert(
gestionErreur,  
gestionErreur,
erreur( ebauche.nom, cfg.erreurEbaucheType, 'div' )
erreur( ebauche.nom, cfg.erreurEbaucheType, 'div' )
)
)
end
end
 
-- récupères les différents noms de thème
-- récupère les différents noms de thème
if ebauche.adjectif and #titres > 0 then
if ebauche.adjectif and #titres > 0 then
local sujet = ebauche.sujet or ebauche.nom
local sujet = ebauche.sujet or ebauche.nom
if estFeminin then
if estFeminin then
sujet = ebauche.sujetF or sujet:gsub(
sujet = ebauche.sujetF or sujet:gsub(
ebauche.nom:gsub( '(%p)', '%%%1') .. '%f[%W]',  
ebauche.nom:gsub( '(%p)', '%%%1') .. '%f[%W]',
ebauche.feminin
ebauche.feminin
)
)
end
end
-- ajout du sujet de l'adjectif dans le sujet de l'ébauche précédente
-- ajout du sujet de l'adjectif dans le sujet de l'ébauche précédente
local titre, subst = titres[ #titres ]:gsub(  
local titre, subst = titres[ #titres ]:gsub(
'<(adj[^>]*)>',  
'<(adj[^>]*)>',
{ adjectif = sujet, adj = ebauche.nom, adjF = ebauche.feminin }
{ adjectif = sujet, adj = ebauche.nom, adjF = ebauche.feminin }
)
)
Ligne 372 : Ligne 400 :
estFeminin = ebauche.estFeminin or ( ebauche.sujet == '' and estFeminin )
estFeminin = ebauche.estFeminin or ( ebauche.sujet == '' and estFeminin )
end
end
 
-- mise en forme des catégories
-- mise en forme des catégories
if ebauche.adjectif then
if ebauche.adjectif then
Ligne 378 : Ligne 406 :
local modif = false
local modif = false
for k, v in ipairs( categs ) do
for k, v in ipairs( categs ) do
local cat, subst = v:gsub(  
local cat, subst = v:gsub(
'<(adj[^>]*)>',  
'<(adj[^>]*)>',
{ adj = ebauche.nom, adjF =  ebauche.feminin,  adjectif = ebauche.nom }
{ adj = ebauche.nom, adjF =  ebauche.feminin,  adjectif = ebauche.nom }
)
)
Ligne 390 : Ligne 418 :
end
end
end
end
if not modif  
if not modif
and humain  
and humain
and mw.title.new( 'Catégorie:Wikipédia:ébauche personnalité ' .. ebauche.feminin ).exists
and mw.title.new( 'Catégorie:Wikipédia:ébauche personnalité ' .. ebauche.feminin ).exists
then
then
Ligne 399 : Ligne 427 :
table.insert( categs, ebauche.categ )
table.insert( categs, ebauche.categ )
end
end
 
-- mise en forme des images
-- mise en forme des images
local image  
local image
if trim( args['icône'] ) then
if args['icône'] and args['icône'] ~= '' then
local theme = getEbaucheTable( paramEbauche, args['icône'] )
local theme = getEbaucheTable( paramEbauche, args['icône'] )
if theme and theme.icone then
if theme and theme.icone then
image = cfg.formatLien:format(
image = cfg.formatLien:format(
theme.icone,  
theme.icone,
tailleIcone,  
tailleIcone,
theme.altIcone or ( 'image illustrant ' .. theme.sujet )
theme.altIcone or ( 'image illustrant ' .. theme.sujet ),
theme.classeIcone or ''
)
)
end
end
Ligne 416 : Ligne 445 :
image = cfg.ebaucheImage:format( table.concat( images, ' ' ) )
image = cfg.ebaucheImage:format( table.concat( images, ' ' ) )
end
end
 
-- mise en forme du titre
-- mise en forme du titre
local titre
local titre
if #titres > 0 then
if #titres > 0 then
titre = cfg.ebaucheTitreSujet:format(  
titre = cfg.ebaucheTitreSujet:format(
ebaucheParam( 1, 'type' ),  
ebaucheParam( 1, 'type' ),
mw.text.listToText( titres )
mw.text.listToText( titres )
)
)
Ligne 427 : Ligne 456 :
titre = cfg.ebaucheTitre:format( ebaucheParam( 1, 'type' ) )
titre = cfg.ebaucheTitre:format( ebaucheParam( 1, 'type' ) )
end
end
 
-- mise en forme du texte
-- mise en forme du texte
local texte
local texte
if #ebauches == 0 then
local message = ebaucheParam( 1, 'message' )
texte = ( ebaucheParam( 1, 'message' ) ) .. '.'
local selon = ebaucheParam( 1, 'selon' )
if #ebauches == 0 or selon == '' then
if not message:match( '[.,;:!?]$' ) then
message = message .. '.'
end
texte = message
else
else
local message = ebaucheParam( 1, 'message' )
local selon = ebaucheParam( 1, 'selon' )
-- ajout d'un point si le paramètre selon commence par un retour ligne ou une majuscule
-- ajout d'un point si le paramètre selon commence par un retour ligne ou une majuscule
if message:sub( -1 ) == ')' and ( selon:sub( 1, 3 ) == '<br' or mw.ustring.match( selon, '^%u' ) ) then
if not message:match( '[.,;:!?]$' ) and ( selon:match( '^<[bB][rR] */?>' ) or mw.ustring.match( selon, '^%u' ) ) then
texte = ( ebaucheParam( 1, 'message' ) ) .. '. ' .. ( ebaucheParam( 1, 'selon' ) ) .. '.'
message = message .. '.'
else
end
texte = ( ebaucheParam( 1, 'message' ) ) .. ' ' .. ( ebaucheParam( 1, 'selon' ) ) .. '.'
if not selon:match( '[.,;:!?]$' ) then
selon = selon .. '.'
end
end
texte = message .. ' ' .. selon
end
end
-- ajout d'un texte s'il y a une liste de tâches
-- ajout d'un texte s'il y a une liste de tâches
Ligne 450 : Ligne 484 :
.. '|page de discussion]].'
.. '|page de discussion]].'
end
end
 
-- paramètres pour le bandeau
-- paramètres pour le bandeau
local parametres = {
local parametres = {
Ligne 459 : Ligne 493 :
id = args.id
id = args.id
}
}
 
-- concaténation des différentes catégories (pas de catégorisation si nocat, ou page de discussion, ou espace utilisateur)
-- concaténation des différentes catégories (pas de catégorisation si nocat, ou page de discussion, ou espace utilisateur)
local categ = ''
local categ = ''
local messageErreur = table.concat( gestionErreur )
if not ( yesno( args.nocat, true, false ) or page.isTalkPage or page.namespace == 2 ) then
if not ( yesno( args.nocat, true, false ) or page.isTalkPage or page.namespace == 2 ) then
for i = 1, #categs do
if #categs > 0 then
categs[ i ] = cfg.ebaucheCateg:format( categs[ i ] )
for i = 1, #categs do
end
categs[ i ] = cfg.ebaucheCateg:format( categs[ i ] )
categ = table.concat( categs ):gsub( ' <[^>]*>', '' )
end
if categ == '' then
categ = table.concat( categs ):gsub( ' <[^>]*>', '' )
else
categ = cfg.ebaucheCateg:format('')
categ = cfg.ebaucheCateg:format('')
end
end
if #gestionErreur > 0 then
end
 
local messageErreur = ''
if #gestionErreur > 0 then
messageErreur = table.concat( gestionErreur )
if page.namespace == 2 then
messageErreur = messageErreur .. '[[Catégorie:Ébauche inconnue dans une page utilisateur]]'
else
messageErreur = messageErreur .. '[[Catégorie:Ébauche inconnue]]'
messageErreur = messageErreur .. '[[Catégorie:Ébauche inconnue]]'
end
end
end
end


return p._bandeauAvertissement( parametres ) .. messageErreur .. categ
return p._bandeauAvertissement( parametres ) .. categ .. messageErreur
end
end


Ligne 497 : Ligne 536 :
end
end


---  
---
-- Fonction retournant le féminin d'un théme d'ébauche
-- Fonction retournant le féminin d'un théme d'ébauche
-- Elle est prévue pour être appelée directement par #invoke:
-- Elle est prévue pour être appelée directement par #invoke:
Ligne 509 : Ligne 548 :
local t = getEbaucheTable( paramEbauche, theme )
local t = getEbaucheTable( paramEbauche, theme )
local tF, tAdjF = getEbaucheTable( paramEbauche, theme, true )
local tF, tAdjF = getEbaucheTable( paramEbauche, theme, true )
if t.feminin and tF.categ == t.categ then
if t and tF and t.feminin and tF.categ == t.categ then
if tAdjF then
if tAdjF then
themeF = tF.nom .. ' ' .. tAdjF.feminin
themeF = tF.nom .. ' ' .. tAdjF.feminin
elseif tF then
else
themeF = tF.nom
themeF = tF.nom
end
end
Ligne 524 : Ligne 563 :
function p.tableParametresEbauches( frame )
function p.tableParametresEbauches( frame )
local paramEbauche = mw.loadData( moduleEbauche )
local paramEbauche = mw.loadData( moduleEbauche )
 
local currentFrame = mw.getCurrentFrame()
local currentFrame = mw.getCurrentFrame()
local languageObj = mw.getContentLanguage()
local languageObj = mw.getContentLanguage()
function pagesInCategory( category )
local function pagesInCategory( category )
return languageObj:formatNum( tonumber( currentFrame:callParserFunction( 'PAGESINCATEGORY', { category, 'R' } ) ) )
return languageObj:formatNum( tonumber( currentFrame:callParserFunction( 'PAGESINCATEGORY', { category, 'R' } ) ) )
end
end
 
local params, paramAdj, paramType = {}, {}, {}
local params, paramAdj, paramType = {}, {}, {}
for clef, ebauche in pairs( paramEbauche ) do
for clef, ebauche in pairs( paramEbauche ) do
Ligne 554 : Ligne 593 :
table.sort( paramAdj, comp )
table.sort( paramAdj, comp )
table.sort( paramType, comp )
table.sort( paramType, comp )
 
local wikiTab = { '<table class="wikitable sortable" style="table-layout:fixed;">' }
local wikiTab = { '<table class="wikitable sortable" style="table-layout:fixed;">' }
wikiTab.insert = function ( t, value )
wikiTab.insert = function ( t, value )
Ligne 560 : Ligne 599 :
return t
return t
end
end
 
wikiTab
wikiTab
:insert('\n=== Ébauches normales ===\n')
:insert('\n=== Ébauches normales ===\n')
Ligne 576 : Ligne 615 :
:insert('</td><td>')
:insert('</td><td>')
if ebauche.icone then
if ebauche.icone then
wikiTab:insert( cfg.formatLien:format( ebauche.icone, '45x35', ebauche.altIcone or '' ) )
wikiTab:insert( cfg.formatLien:format( ebauche.icone, '45x35', ebauche.altIcone or '', ebauche.classeIcone or '' ) )
end
end
wikiTab
wikiTab
Ligne 598 : Ligne 637 :
end
end
wikiTab:insert('</table>')
wikiTab:insert('</table>')
 
-- seconde table pour les adjectifs
-- seconde table pour les adjectifs
wikiTab
wikiTab
Ligne 619 : Ligne 658 :
if ebauche.icone then
if ebauche.icone then
wikiTab
wikiTab
:insert( cfg.formatLien:format( ebauche.icone, '45x35', ebauche.altIcone or '' ) )
:insert( cfg.formatLien:format( ebauche.icone, '45x35', ebauche.altIcone or '', ebauche.classeIcone or '' ) )
end
end
wikiTab
wikiTab
Ligne 635 : Ligne 674 :
end
end
wikiTab:insert('</table>')
wikiTab:insert('</table>')
 
-- troisième table pour les types
-- troisième table pour les types
wikiTab
wikiTab
Ligne 653 : Ligne 692 :
:insert('</td><td>')
:insert('</td><td>')
if ebauche.icone then
if ebauche.icone then
wikiTab:insert( cfg.formatLien:format( ebauche.icone, '45x35', ebauche.altIcone or '' ) )
wikiTab:insert( cfg.formatLien:format( ebauche.icone, '45x35', ebauche.altIcone or '', ebauche.classeIcone or '' ) )
end
end
wikiTab
wikiTab
Ligne 670 : Ligne 709 :
end
end
wikiTab:insert('</table>')
wikiTab:insert('</table>')
 
return table.concat( wikiTab ):gsub( ' <adjF?>', '' )
-- parenthèses pour enlever la 2e valeur retournée par gsub (le nombre de remplacements effectués)
return (table.concat( wikiTab ):gsub( ' <adjF?>', '' ))
end
end


Ligne 702 : Ligne 742 :
end
end
end
end
 
local nomsFonction = {'bandeau', 'bandeauAvertissement', 'bandeauSection', 'ébauche' }  
local nomsFonction = {'bandeau', 'bandeauAvertissement', 'bandeauSection', 'ébauche' }
for _, nomFonction in ipairs(nomsFonction) do
for _, nomFonction in ipairs(nomsFonction) do
p[nomFonction] = adaptateur('_' .. nomFonction)
p[nomFonction] = adaptateur('_' .. nomFonction)
Utilisateur anonyme