- Welcome to the Kancolle Wiki!
- If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord
Difference between revisions of "Module:Teasers"
Jump to navigation
Jump to search
(Created page with "local _ = require('Module:Core') function render(frame, args) args = args or _.getTemplateArgs(frame) local from = _.imap(_.split(args.explicit[1], '-'), function(e) ...") |
m |
||
Line 18: | Line 18: | ||
local title = string.format('Teaser-%s-%s-%s-%s.png', year, _.pad(month, 2, '0'), _.pad(day, 2, '0'), label) | local title = string.format('Teaser-%s-%s-%s-%s.png', year, _.pad(month, 2, '0'), _.pad(day, 2, '0'), label) | ||
if mw.title.makeTitle('File', title).exists then | if mw.title.makeTitle('File', title).exists then | ||
− | table.insert(teasers, | + | table.insert(teasers, string.format('[[File:%s]]', title)) |
− | |||
else | else | ||
break | break | ||
Line 25: | Line 24: | ||
end | end | ||
end | end | ||
+ | return table.concat(teasers, '<br>') | ||
end | end | ||
return { render = render } | return { render = render } |
Revision as of 04:48, 15 January 2020
Documentation for this module may be created at Module:Teasers/doc
local _ = require('Module:Core')
function render(frame, args)
args = args or _.getTemplateArgs(frame)
local from = _.imap(_.split(args.explicit[1], '-'), function(e) return tonumber(e) end)
local fromYear = from[1] or 2020
local fromMonth = from[2] or 1
local fromDay = from[3] or 1
local days = tonumber(args.explicit[2]) or 31
local teasers = {}
for i = 0, days - 1 do
local j, day = _.divMod(fromDay - 1 + i, 31)
day = day + 1
local k, month = _.divMod(fromMonth - 1 + j, 12)
month = month + 1
local year = fromYear + k
for i, label in ipairs({'A', 'B', 'C', 'D', 'E'}) do
local title = string.format('Teaser-%s-%s-%s-%s.png', year, _.pad(month, 2, '0'), _.pad(day, 2, '0'), label)
if mw.title.makeTitle('File', title).exists then
table.insert(teasers, string.format('[[File:%s]]', title))
else
break
end
end
end
return table.concat(teasers, '<br>')
end
return { render = render }