« Module:Bandeau d'avertissement » : différence entre les versions
m Kharmitch a déplacé la page Module:Bandeau de maintenance vers Module:Bandeau d'avertissement sans laisser de redirection |
mAucun résumé des modifications |
||
(Une version intermédiaire par le même utilisateur non affichée) | |||
Ligne 2 : | Ligne 2 : | ||
----------------------------------------------------------- | ----------------------------------------------------------- | ||
----- | ----- Types de bandeau ----- | ||
----------------------------------------------------------- | ----------------------------------------------------------- | ||
local bannerColor = { | |||
info = 'avt-warn-banner-info', | |||
maintenance = 'avt-warn-banner-maintenance', | |||
licence = 'avt-warn-banner-license' | |||
} | } | ||
----------------------------------------------------------- | ----------------------------------------------------------- | ||
function p._build(args) | function p._build(args) | ||
-- Info du bandeau | |||
local image = | local image = args["image"] or 'bandeau de maintenance - defaut.png' | ||
local | local header = args["en-tête"] or 'En-tête ?' | ||
local description = | local description = args["description"] or 'Description ?' | ||
local category = | 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 category ~= '' then | ||
Ligne 79 : | Ligne 35 : | ||
end | end | ||
-- Création du bandeau | |||
local res = mw.html.create( 'div' ) | local res = mw.html.create( 'div' ) | ||
:addClass( 'avt- | :addClass( 'avt-warn-banner noexcerpt ' .. bannerColor[bannerType] ) | ||
:tag( 'div' ) | :tag( 'div' ) | ||
:addClass( 'avt- | :addClass( 'avt-warn-banner-img' ) | ||
:wikitext( '[[Fichier:' .. image .. '|x50px|link=|alt=]]' ) | :wikitext( '[[Fichier:' .. image .. '|x50px|link=|alt=]]' ) | ||
:done() | :done() | ||
:tag( 'div' ) | :tag( 'div' ) | ||
:addClass( 'avt- | :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() | ||
:done() | :done() | ||
Ligne 122 : | Ligne 58 : | ||
return tostring(res) .. category | return tostring(res) .. category | ||
end | 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 | return p |
Dernière version du 2 août 2021 à 23:48
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