Module:Bandeau d'avertissement
La documentation pour ce module peut être créée à Module:Bandeau d'avertissement/doc
local p = {}
-----------------------------------------------------------
----- Types de bandeau -----
-----------------------------------------------------------
local bannerColor = {
info = 'avt-warn-banner-info',
maintenance = 'avt-warn-banner-maintenance',
licence = 'avt-warn-banner-license'
}
-----------------------------------------------------------
function p._build(args)
-- Info du bandeau
local image = args["image"] or 'bandeau de maintenance - defaut.png'
local header = args["en-tête"] or 'En-tête ?'
local description = args["description"] or 'Description ?'
local category = args["catégorie"] or ''
local game = args["jeu"] or ''
local bannerType = args["type"]
-- Création de la catégorie si présente avec éventuel jeu
if category ~= '' then
if game ~= '' then
game = require( 'Module:Abréviation' ).name(game) or ''
if game ~= '' then
game = ' (' .. game .. ')'
end
end
category = '[[Catégorie:' .. category .. game .. ']]'
end
-- Création du bandeau
local res = mw.html.create( 'div' )
:addClass( 'avt-warn-banner noexcerpt ' .. bannerColor[bannerType] )
:tag( 'div' )
:addClass( 'avt-warn-banner-img' )
:wikitext( '[[Fichier:' .. image .. '|x50px|link=|alt=]]' )
:done()
:tag( 'div' )
:addClass( 'avt-warn-banner-text' )
:tag( 'p' )
:addClass( 'avt-warn-banner-header' )
:wikitext( header )
:done()
:tag( 'p' )
:addClass( 'avt-warn-banner-desc' )
:wikitext( description )
:done()
:done()
:done()
return tostring(res) .. category
end
-----------------------------------------------------------
----- Points d'entrée -----
-----------------------------------------------------------
function p.build(frame)
local args = {}
for cle, val in pairs(frame.args) do
if val then
val = mw.text.trim(val)
if val ~= '' then
args[cle] = val
end
end
end
return p._build(args)
end
-----------------------------------------------------------
return p