mirror of https://github.com/thumbsup/thumbsup
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
550 B
JavaScript
22 lines
550 B
JavaScript
|
|
exports.create = function (ctx) {
|
|
const stats = contextStats(ctx)
|
|
const messages = [
|
|
' Gallery generated successfully',
|
|
` ${stats.albums} albums, ${stats.photos} photos, ${stats.videos} videos`
|
|
]
|
|
return messages.join('\n')
|
|
}
|
|
|
|
function contextStats (ctx) {
|
|
return {
|
|
albums: countAlbums(0, ctx.album) - 1,
|
|
photos: ctx.files.filter(f => f.type === 'image').length,
|
|
videos: ctx.files.filter(f => f.type === 'video').length
|
|
}
|
|
}
|
|
|
|
function countAlbums (total, album) {
|
|
return 1 + album.albums.reduce(countAlbums, total)
|
|
}
|