« Module:ImageDuJour » : différence entre les versions
Apparence
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| Ligne 2 : | Ligne 2 : | ||
function p.afficher(frame) | function p.afficher(frame) | ||
-- | -- Utilise #lst pour charger le contenu comme une variable wiki | ||
local | local contenu = frame:preprocess("{{Modèle:Liste/ImagesDuJour}}") | ||
if not contenu or contenu == "" then | |||
if not contenu then | return "<span style='color:gray;'>Aucune image trouvée dans la liste.</span>" | ||
return "<span style='color: | |||
end | end | ||
local lignes = mw.text.split(contenu, "\n") | |||
local images = {} | local images = {} | ||
for | for _, ligne in ipairs(lignes) do | ||
local nom = mw.text.trim(ligne) | |||
if nom ~= "" then | |||
table.insert(images, nom) | |||
end | |||
end | end | ||
| Ligne 24 : | Ligne 22 : | ||
end | end | ||
local imageChoisie = images[math.random(#images)] | |||
local | |||
-- Bloc stylisé | -- Bloc stylisé avec l'image | ||
local html = {} | local html = {} | ||
table.insert(html, "<div style='max-width:60em; float:left; margin:auto; border:1px solid #aaa; border-radius:10px; box-shadow:1px 1px 3px #ccc; | table.insert(html, "<div style='max-width:60em;float:left; margin:auto; border:1px solid #aaa; border-radius:10px; box-shadow:1px 1px 3px #ccc; padding:12px;'>") | ||
table.insert(html, "<div style='font-size:1.2em; font-weight:bold;'>🎨 Image du jour</div>") | |||
table.insert(html, "<div style='font-size:1.2em; font-weight:bold;'> | table.insert(html, "<hr style='border:none; border-top:1px solid #aaa; margin:0; margin-bottom:12px;'>") | ||
table.insert(html, "<hr style='border:none; border-top:1px solid # | table.insert(html, "[[Fichier:" .. imageChoisie .. "|300px]]") | ||
table.insert(html, "[[Fichier:" .. | |||
table.insert(html, "</div>") | table.insert(html, "</div>") | ||
return table.concat(html, "\n") | return table.concat(html, "\n") | ||
Version du 13 juillet 2025 à 09:52
La documentation pour ce module peut être créée à Module:ImageDuJour/doc
local p = {}
function p.afficher(frame)
-- Utilise #lst pour charger le contenu comme une variable wiki
local contenu = frame:preprocess("{{Modèle:Liste/ImagesDuJour}}")
if not contenu or contenu == "" then
return "<span style='color:gray;'>Aucune image trouvée dans la liste.</span>"
end
local lignes = mw.text.split(contenu, "\n")
local images = {}
for _, ligne in ipairs(lignes) do
local nom = mw.text.trim(ligne)
if nom ~= "" then
table.insert(images, nom)
end
end
if #images == 0 then
return "<span style='color:gray;'>Aucune image trouvée dans la liste.</span>"
end
local imageChoisie = images[math.random(#images)]
-- Bloc stylisé avec l'image
local html = {}
table.insert(html, "<div style='max-width:60em;float:left; margin:auto; border:1px solid #aaa; border-radius:10px; box-shadow:1px 1px 3px #ccc; padding:12px;'>")
table.insert(html, "<div style='font-size:1.2em; font-weight:bold;'>🎨 Image du jour</div>")
table.insert(html, "<hr style='border:none; border-top:1px solid #aaa; margin:0; margin-bottom:12px;'>")
table.insert(html, "[[Fichier:" .. imageChoisie .. "|300px]]")
table.insert(html, "</div>")
return table.concat(html, "\n")
end
return p