fix(model): remove unnecessary ./ for files in the root folder

pull/163/head
Romain 5 years ago
parent 7af044df90
commit f10544a6a9

@ -10,15 +10,15 @@ exports.folders = function (filepath, rel, options = {}) {
const photoExt = photoExtension(filepath)
const videoExt = options.videoFormat || 'mp4'
switch (rel) {
case 'photo:thumbnail': return `media/thumbs/${dir}/${name}.${photoExt}`
case 'photo:small': return `media/small/${dir}/${name}.${photoExt}`
case 'photo:large': return `media/large/${dir}/${name}.${photoExt}`
case 'video:thumbnail': return `media/thumbs/${dir}/${name}.jpg`
case 'video:small': return `media/small/${dir}/${name}.jpg`
case 'video:poster': return `media/large/${dir}/${name}.jpg`
case 'video:resized': return `media/large/${dir}/${name}.${videoExt}`
case 'fs:copy': return `media/original/${dir}/${name}.${ext}`
case 'fs:symlink': return `media/original/${dir}/${name}.${ext}`
case 'photo:thumbnail': return path.normalize(`media/thumbs/${dir}/${name}.${photoExt}`)
case 'photo:small': return path.normalize(`media/small/${dir}/${name}.${photoExt}`)
case 'photo:large': return path.normalize(`media/large/${dir}/${name}.${photoExt}`)
case 'video:thumbnail': return path.normalize(`media/thumbs/${dir}/${name}.jpg`)
case 'video:small': return path.normalize(`media/small/${dir}/${name}.jpg`)
case 'video:poster': return path.normalize(`media/large/${dir}/${name}.jpg`)
case 'video:resized': return path.normalize(`media/large/${dir}/${name}.${videoExt}`)
case 'fs:copy': return path.normalize(`media/original/${dir}/${name}.${ext}`)
case 'fs:symlink': return path.normalize(`media/original/${dir}/${name}.${ext}`)
case 'fs:link': return join(options.linkPrefix, filepath)
default: throw new Error(`Invalid relationship: ${rel}`)
}
@ -31,15 +31,15 @@ exports.suffix = function (filepath, rel, options = {}) {
const photoExt = photoExtension(filepath)
const videoExt = options.videoFormat || 'mp4'
switch (rel) {
case 'photo:thumbnail': return `media/${dir}/${name}_${ext}_thumb.${photoExt}`
case 'photo:small': return `media/${dir}/${name}_${ext}_small.${photoExt}`
case 'photo:large': return `media/${dir}/${name}_${ext}_large.${photoExt}`
case 'video:thumbnail': return `media/${dir}/${name}_${ext}_thumb.jpg`
case 'video:small': return `media/${dir}/${name}_${ext}_small.jpg`
case 'video:poster': return `media/${dir}/${name}_${ext}_poster.jpg`
case 'video:resized': return `media/${dir}/${name}_${ext}_large.${videoExt}`
case 'fs:copy': return `media/${dir}/${name}.${ext}`
case 'fs:symlink': return `media/${dir}/${name}.${ext}`
case 'photo:thumbnail': return path.normalize(`media/${dir}/${name}_${ext}_thumb.${photoExt}`)
case 'photo:small': return path.normalize(`media/${dir}/${name}_${ext}_small.${photoExt}`)
case 'photo:large': return path.normalize(`media/${dir}/${name}_${ext}_large.${photoExt}`)
case 'video:thumbnail': return path.normalize(`media/${dir}/${name}_${ext}_thumb.jpg`)
case 'video:small': return path.normalize(`media/${dir}/${name}_${ext}_small.jpg`)
case 'video:poster': return path.normalize(`media/${dir}/${name}_${ext}_poster.jpg`)
case 'video:resized': return path.normalize(`media/${dir}/${name}_${ext}_large.${videoExt}`)
case 'fs:copy': return path.normalize(`media/${dir}/${name}.${ext}`)
case 'fs:symlink': return path.normalize(`media/${dir}/${name}.${ext}`)
case 'fs:link': return join(options.linkPrefix, filepath)
default: throw new Error(`Invalid relationship: ${rel}`)
}

@ -17,6 +17,10 @@ describe('Structure', () => {
should(folders('holidays/IMG_0001.jpg', 'fs:symlink')).startWith('media/')
})
it('can be at the root', () => {
should(folders('IMG_0001.jpg', 'photo:thumbnail')).eql('media/thumbs/IMG_0001.jpg')
})
it('adds thumbnails to a <thumbs> folder', () => {
should(folders('holidays/IMG_0001.jpg', 'photo:thumbnail')).startWith('media/thumbs/holidays/')
should(folders('holidays/IMG_0001.mp4', 'video:thumbnail')).startWith('media/thumbs/holidays/')
@ -87,6 +91,10 @@ describe('Structure', () => {
should(suffix('holidays/IMG_0001.jpg', 'fs:symlink')).startWith('media/')
})
it('can be at the root', () => {
should(suffix('IMG_0001.jpg', 'photo:thumbnail')).eql('media/IMG_0001_jpg_thumb.jpg')
})
it('uses an _thumb suffix to denote thumbnails', () => {
should(suffix('holidays/IMG_0001.jpg', 'photo:thumbnail')).endWith('holidays/IMG_0001_jpg_thumb.jpg')
should(suffix('holidays/IMG_0001.mp4', 'video:thumbnail')).endWith('holidays/IMG_0001_mp4_thumb.jpg')

Loading…
Cancel
Save