diff --git a/src/routes/op.ts b/src/routes/op.ts index 43af09d..1a02257 100644 --- a/src/routes/op.ts +++ b/src/routes/op.ts @@ -197,6 +197,11 @@ opRouter.get( res.status(404).send('폴더를 찾을 수 없습니다.') return } + // 영상은 2단계(서브) 폴더에만 둔다. 1단계 폴더는 컨테이너 전용. + if (folder.parentId === null) { + res.status(400).send('영상은 하위 폴더에서만 추가할 수 있습니다.') + return + } const videoId = typeof req.query.id === 'string' ? req.query.id : null const video = videoId ? getVideo(videoId) : null res.render('op/editor', { @@ -239,6 +244,7 @@ opRouter.post( try { const folder = getFolderByPath(collectFolderSegments(req.params)) if (!folder) throw new Error('폴더를 찾을 수 없습니다.') + if (folder.parentId === null) throw new Error('영상은 하위 폴더에서만 추가할 수 있습니다.') const file = req.file if (!file) throw new Error('파일이 없습니다.') const title = pickStr(req.body?.title).trim() || file.originalname @@ -284,6 +290,7 @@ opRouter.post( try { const folder = getFolderByPath(collectFolderSegments(req.params)) if (!folder) throw new Error('폴더를 찾을 수 없습니다.') + if (folder.parentId === null) throw new Error('영상은 하위 폴더에서만 추가할 수 있습니다.') const url = pickStr(req.body.url).trim() const title = pickStr(req.body.title).trim() || undefined if (!url) throw new Error('URL 을 입력해 주세요.') diff --git a/views/folder.ejs b/views/folder.ejs index 89d160b..a5b7b54 100644 --- a/views/folder.ejs +++ b/views/folder.ejs @@ -28,32 +28,34 @@
아직 하위 폴더가 없습니다.
+ <% } %> + <% (subFolders || []).forEach(function (sf) { %> 📁 <%= sf.name %> <% }) %>이 폴더에 영상이 없습니다.
- <% } %> - <% videos.forEach(function (v) { %> - <% - var shareUrl = '/video/' + folderPathEnc + '/' + encodeURIComponent(v.id) + <% } else { %> +이 폴더에 영상이 없습니다.
+ <% } %> + <% videos.forEach(function (v) { + var shareUrl = '/video/' + folderPathEnc + '/' + encodeURIComponent(v.id) %> - -아직 하위 폴더가 없습니다. 우측 상단에서 하위 폴더를 추가하세요. (영상은 하위 폴더 안에서만 추가할 수 있습니다.)
+ <% } %> + <% (subFolders || []).forEach(function (sf) { %> <% }) %>이 폴더에 영상이 없습니다. 우측 상단에서 영상을 추가하세요.
+ <% } %> + <% videos.forEach(function (v) { + var shareUrl = '/video/' + folderPathEnc + '/' + encodeURIComponent(v.id) + %> +이 폴더에 영상이 없습니다. 우측 상단에서 영상을 추가하세요.
- <% } %> - <% videos.forEach(function (v) { - var shareUrl = '/video/' + folderPathEnc + '/' + encodeURIComponent(v.id) - %> -