Ouvrir le menu principal

Modifications

852 octets ajoutés ,  13 avril 2020 à 04:12
m
oups boulet
formatLien = '[[Fichier:%s|%spx|alt=%s|class=noviewer]]',
tailleIcone = '45x45',
public = 'domaine public',
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]].',
ebaucheTitreSujet = '%s est une [[Aide:Ébauche|ébauche]] concernant %s.',
ebaucheCateg = '[[Catégorie:Wikipédia:ébauche %s]]',
}
 
-- CSS inline pour éviter FOUC sur le site mobile
local rustineFoucMobile = {
['display'] = 'table-cell',
['padding-right'] = '0.5em',
}
local cells = mw.html.create()
local icone = trim(args.image) or trim(args['icône'])
local backgroundIcone = class.icones[icone] or ''false
local texte = (trim(args.texte) or erreur('texte', cfg.erreurArgument))
res :attr{ id = args.id }
:addClass('bandeau-container')
:addClass(class.formes[args.forme] or cfg.forme)
:addClass(class.niveau[args.niveau] or cfg.niveau)
end
if icone and not backgroundIcone == '' then
local iconeWiki = icone
if not icone:match('%[') then
local alt = args.alt or args['légende'] or ''
if alt:lower() == cfg.public then
alt = '|link='
end
if yesno( args['domaine public'] ) then
alt = alt .. '|link='
:tag('div')
:addClass('bandeau-cell bandeau-icone')
:css(rustineFoucMobile)
:wikitext(iconeWiki)
:done()
elseif backgroundIcone ~= '' and args.forme == 'section' then
texte = '&ensp;' .. texte
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
 
cells
:tag('div')
:addClass('bandeau-cell ') :css(rustineFoucMobile) :addClass(backgroundIcone and ('bandeau-icone-css ' .. backgroundIcone) or nil)
:wikitext(texte)
:newline()-- ne pas supprimer, sert à la génération automatique de <p> encadrant le contenu
:done()
 
if trim(args.droite) then
cells
:tag('div')
:addClass('bandeau-cell')
:css(rustineFoucMobile)
:css( 'padding-left', '1em' )
:newline()
if suffixeDate then
-- pour rendre insécable, seulement si le paramètre semble bien être une date valide
local dateStr suffixeDate = (require 'Module:Date').modeleDate{suffixeDate, nolinks=true} if not dateStr:find(, onerror='errorinput') then suffixeDate = dateStr end}
titre = titre:gsub('%.$', '')
niveau = args.niveau,
id = args.id,
class = 'bandeau-container metadata ambox ' .. ( args.class or '' ) .. ' metadata ambox',
['icône'] = trim(args['icône']) or trim(args['icône-complexe']) or args.niveau,
alt = args.alt or args['légende'],
return p._bandeau(parametres)
end
 
--[[
TODO - fusionner ces deux méthodes :
* p._bandeau() avec forme=section
* p._bandeauSection()
]]--
function p._bandeauSection(args)
local res = mw.html.create('div')
local icone = trim(args.image) or trim(args['icône'])
local backgroundIcone = class.icones[icone] or ''false local texte = '&ensp;' .. (trim(args.texte) or erreur('texte', cfg.erreurArgument))
res :addClass('bandeau-container bandeau-section metadata')
:addClass(class.niveau[args.niveau] or cfg.niveau)
if icone and not backgroundIcone == '' then
local iconeWiki = icone
if not icone:match('%[') then
local alt = args.alt or args['légende'] or ''
if alt:loweryesno(args['domaine public'] ) == cfg.public then alt = alt .. '|link='
end
iconeWiki = cfg.formatLien:format(icone, 'text-top|20x17', alt)
end
res :tag('div') :addClass('bandeau-cell bandeau-icone') :wikitext(iconeWiki)
:done()
end
res :tag('div') :addClass('bandeau-cell') :addClass(backgroundIconeand ('bandeau-icone-css ' .. backgroundIcone) or nil) :wikitext(texte)
:done()
for i, ebauche in ipairs( ebauches ) do
-- création du lien de l'image
local alt = ebauche.altIcone if not alt then if ebauche.sujet then alt = 'image illustrant ' .. ebauche.sujet else alt = '' end end
if ebauche.icone then
local image = cfg.formatLien:format( ebauche.icone, tailleIcone, alt )
end
table.insert( categs, ebauche.categ )
table.insert( categs, ebauche.categ2 )
end
end
-- ajout d'un texte s'il y a une liste de tâches
local todo = page.talkPageTitle and mw.title.makeTitlenew( mw.site.namespaces[ page.namespace ].talk.id, pagetalkPageTitle.text fullText .. '/À faire' )or nil if todo and todo.exists then
texte = texte .. '\n\n'
.. 'Consultez la liste des <b>tâches à accomplir</b> en [['
function p.tableParametresEbauches( frame )
local paramEbauche = mw.loadData( moduleEbauche )
local params, paramAdj, paramType currentFrame = {}, {}, {}mw.getCurrentFrame() local wikiTab languageObj = { '<table class="wikitable sortable" style="table-layout:fixed;">' }mw.getContentLanguage() wikiTab.insert = function pagesInCategory( t, value category ) table.insertreturn languageObj:formatNum( tonumber( currentFrame:callParserFunction( t'PAGESINCATEGORY', { category, value 'R' } ) ) ) return t
end
local params, paramAdj, paramType = {}, {}, {}
for clef, ebauche in pairs( paramEbauche ) do
local kEbauche = {}
table.sort( paramAdj, comp )
table.sort( paramType, comp )
local wikiTab = { '<table class="wikitable sortable" style="table-layout:fixed;">' }
wikiTab.insert = function ( t, value )
table.insert( t, value )
return t
end
wikiTab
:insert('<th scope=col style="width:20%;">sujet</th>')
:insert('<th scope=col style="width:20%;">catégorie</th>')
:insert('<th scope=col style="width:20%;">compteur</th>')
:insert('<th scope=col>selon</th>')
for k, ebauche in ipairs( params ) do
wikiTab
:insert('<tr><td>')
:insert( ebauche.clef )
:insert( '[[:Catégorie:Wikipédia:ébauche ' .. ebauche.categ .. '|' .. ebauche.categ .. ']]' )
end
wikiTab :insert('</td><td>') if ebauche.cageg2 categ then
wikiTab
:insert('<br>') :insertpagesInCategory( '[[:Catégorie:Wikipédia:ébauche ' .. ebauche.categ2 .. '|' .. ebauche.categ2 .. ']]' categ ) )
end
wikiTab
Utilisateur anonyme