Modification de Module:Rotation de contenu
La modification peut être annulée. Veuillez vérifier les différences ci-dessous pour voir si c’est bien ce que vous voulez faire, puis publier ces changements pour finaliser l’annulation de cette modification.
Version actuelle | Votre texte | ||
Ligne 1 : | Ligne 1 : | ||
local p = {} | local p = {} | ||
function p.choose(content, | function p.choose(content, size) | ||
-- On retourne tout le contenu | |||
if not size then | |||
if not size | |||
return content | return content | ||
end | end | ||
day_number = os.date("*t").yday | |||
n = day_number % #content | |||
m = (day_number + size - 1) % #content | |||
if n == 0 then | if n == 0 then | ||
n = 1 | n = 1 | ||
m = m + 1 | |||
elseif m == 0 then | |||
m = 1 | |||
n = n - 1 | |||
end | end | ||
local | local fragment = {} | ||
if n < m then | |||
fragment = { unpack(content, n, m) } | |||
if | |||
m | |||
else | else | ||
fragment = { unpack(content, n) } | fragment = { unpack(content, n) } | ||
for i = 1, m do | for i = 1, m do | ||
table.insert(fragment, content[i]) | table.insert(fragment, content[i]) | ||
end | end | ||
end | end | ||
Ligne 38 : | Ligne 34 : | ||
function p.build(frame) | function p.build(frame) | ||
content = frame.args | |||
fragment_size = frame:getParent().args[1] | |||
local list = '<ul | local list = '<ul>' | ||
for i, k in ipairs(p.choose(content, fragment_size)) do | for i, k in ipairs(p.choose(content, fragment_size)) do | ||
list = list .. '<li>' .. k .. '</li>' | list = list .. '<li>' .. k .. '</li>' |