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

271 octets ajoutés ,  29 janvier 2023
aucun résumé des modifications
Aucun résumé des modifications
Balise : Révoqué
Aucun résumé des modifications
 
(7 versions intermédiaires par le même utilisateur non affichées)
Ligne 1 : Ligne 1 :
local p = {}
local p = {}


-- Types de bandeau
-- Types de bandeau autorisés
local shapes = {
local shapes = {
article = "banner-article",
article = "banner-article",
note = "banner-note",
note = "banner-note",
section = "banner-section",
section = "banner-section",
simple = "bandeau-simple",
simple = "banner-simple",
}
}


-- Niveau d'information
-- Niveaux d'information autorisés
local levels = {
local levels = {
ebauche = "banner-stub",
ebauche = "banner-stub",
Ligne 59 : Ligne 59 :
:addClass(shape_class)
:addClass(shape_class)
:addClass(level_class)
:addClass(level_class)
:addClass("noexcerpt")


local image = args.image
local image = args.image
if image then
if image then
local alt = args["image légende"] or ""
local alt = args["image légende"] or ""
local size = args["image taille"] or config.image_size
local size = args["image taille"] or default.image_size
image = cells
image = cells
:tag("div")
:tag("div")
Ligne 78 : Ligne 79 :
:wikitext(title)
:wikitext(title)
:done()
:done()
end
if text then
 
html_text
if text then
:newline()
:newline()
:wikitext(text)
end
elseif text then
html_text
html_text
:newline()
:newline()
:newline()
:wikitext(text)
:wikitext(text)
Ligne 113 : Ligne 117 :
title = string.format(
title = string.format(
default.stub_title_subject,
default.stub_title_subject,
subject.sujet
subject.subject
)
)
category = string.format(
category = string.format(
Ligne 125 : Ligne 129 :
return p._banner({
return p._banner({
forme = 'article',
forme = "article",
niveau = 'ébauche',
niveau = "ébauche",
titre = title,
titre = title,
texte = default.stub_text,
texte = default.stub_text,
image = subject.image,
["image taille"] = subject.size,
}) .. category
}) .. category
end
end


-- Table de correspondance type de bandeau - fonction
function get_args(frame)
local actions = {
local args = {}
banner = p._banner,
local argsParent = frame:getParent().args
stub = p._stub,
for cle, val in pairs(argsParent) do
}
if val then
args[cle] = mw.text.trim(val)
end
end
return args
end
 
-- Fonctions destinées à être appelées dans les modèles


function p.banner(frame)
function p.banner(frame)
local args
return p._banner(get_args(frame))
if frame.args.texte or frame.args.titre then
end
args = frame.args
 
else
function p.stub(frame)
args = frame:getParent().args
return p._stub(get_args(frame))
end
  return actions[shape](args)
end
end


return p
return p