fix(folders): enforce videos-only at depth 2 (P1 review fix)
- routes/op.ts: editor / upload / youtube-start reject when folder.parentId === null - op/folder.ejs: at depth 1 show only "하위 폴더 추가"; at depth 2 show "영상 추가" + "플레이리스트 추가". Video grid and sub-folder modal rendered conditionally. - folder.ejs (public): at depth 1 render only sub-folder grid; at depth 2 render only video grid. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -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 을 입력해 주세요.')
|
||||
|
||||
@@ -28,32 +28,34 @@
|
||||
<h1>📁 <%= breadcrumb.join(' / ') %></h1>
|
||||
</section>
|
||||
|
||||
<% if (subFolders && subFolders.length > 0) { %>
|
||||
<% if (!isSubFolder) { %>
|
||||
<section class="folderGrid">
|
||||
<% subFolders.forEach(function (sf) { %>
|
||||
<% if (!subFolders || subFolders.length === 0) { %>
|
||||
<p class="muted">아직 하위 폴더가 없습니다.</p>
|
||||
<% } %>
|
||||
<% (subFolders || []).forEach(function (sf) { %>
|
||||
<a class="folderCard" href="/folder/<%= folderPathEnc %>/<%= encodeURIComponent(sf.name) %>">
|
||||
<span class="folderIcon">📁</span>
|
||||
<span class="folderName"><%= sf.name %></span>
|
||||
</a>
|
||||
<% }) %>
|
||||
</section>
|
||||
<% } %>
|
||||
|
||||
<section class="videoGrid">
|
||||
<% if (videos.length === 0 && (!subFolders || subFolders.length === 0)) { %>
|
||||
<p class="muted">이 폴더에 영상이 없습니다.</p>
|
||||
<% } %>
|
||||
<% videos.forEach(function (v) { %>
|
||||
<%
|
||||
var shareUrl = '/video/' + folderPathEnc + '/' + encodeURIComponent(v.id)
|
||||
<% } else { %>
|
||||
<section class="videoGrid">
|
||||
<% if (videos.length === 0) { %>
|
||||
<p class="muted">이 폴더에 영상이 없습니다.</p>
|
||||
<% } %>
|
||||
<% videos.forEach(function (v) {
|
||||
var shareUrl = '/video/' + folderPathEnc + '/' + encodeURIComponent(v.id)
|
||||
%>
|
||||
<a class="videoCard" href="<%= shareUrl %>"
|
||||
data-video-id="<%= v.id %>" data-share-url="<%= shareUrl %>">
|
||||
<div class="videoThumb">▶</div>
|
||||
<div class="videoTitle"><%= v.title %></div>
|
||||
</a>
|
||||
<% }) %>
|
||||
</section>
|
||||
<a class="videoCard" href="<%= shareUrl %>"
|
||||
data-video-id="<%= v.id %>" data-share-url="<%= shareUrl %>">
|
||||
<div class="videoThumb">▶</div>
|
||||
<div class="videoTitle"><%= v.title %></div>
|
||||
</a>
|
||||
<% }) %>
|
||||
</section>
|
||||
<% } %>
|
||||
</main>
|
||||
|
||||
<div class="ctxMenu" id="ctxMenu" hidden>
|
||||
|
||||
@@ -25,18 +25,20 @@
|
||||
</div>
|
||||
<div class="dashboardActions">
|
||||
<% if (!isSubFolder) { %>
|
||||
<button type="button" class="secondaryButton" id="addSubFolderBtn">하위 폴더 추가</button>
|
||||
<% } %>
|
||||
<a class="primaryButton" href="<%= editorHref %>">영상 추가</a>
|
||||
<% if (isSubFolder) { %>
|
||||
<button type="button" class="primaryButton" id="addSubFolderBtn">하위 폴더 추가</button>
|
||||
<% } else { %>
|
||||
<a class="primaryButton" href="<%= editorHref %>">영상 추가</a>
|
||||
<a class="primaryButton" href="<%= playlistHref %>">플레이리스트 추가</a>
|
||||
<% } %>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<% if (!isSubFolder && subFolders && subFolders.length > 0) { %>
|
||||
<% if (!isSubFolder) { %>
|
||||
<section class="folderGrid" id="subFolderGrid">
|
||||
<% subFolders.forEach(function (sf) { %>
|
||||
<% if (!subFolders || subFolders.length === 0) { %>
|
||||
<p class="muted">아직 하위 폴더가 없습니다. 우측 상단에서 하위 폴더를 추가하세요. (영상은 하위 폴더 안에서만 추가할 수 있습니다.)</p>
|
||||
<% } %>
|
||||
<% (subFolders || []).forEach(function (sf) { %>
|
||||
<div class="folderCard adminFolder" data-folder-id="<%= sf.id %>" data-name="<%= sf.name %>">
|
||||
<a class="folderCardLink" href="/op/folder/<%= folderPathEnc %>/<%= encodeURIComponent(sf.name) %>">
|
||||
<span class="folderIcon">📁</span>
|
||||
@@ -45,28 +47,28 @@
|
||||
</div>
|
||||
<% }) %>
|
||||
</section>
|
||||
<% } else { %>
|
||||
<section class="videoGrid" id="videoGrid">
|
||||
<% if (videos.length === 0) { %>
|
||||
<p class="muted">이 폴더에 영상이 없습니다. 우측 상단에서 영상을 추가하세요.</p>
|
||||
<% } %>
|
||||
<% videos.forEach(function (v) {
|
||||
var shareUrl = '/video/' + folderPathEnc + '/' + encodeURIComponent(v.id)
|
||||
%>
|
||||
<div class="videoCard adminVideo"
|
||||
data-id="<%= v.id %>"
|
||||
data-video-id="<%= v.id %>"
|
||||
data-title="<%= v.title %>"
|
||||
data-share-url="<%= shareUrl %>">
|
||||
<div class="videoThumb">▶</div>
|
||||
<div class="videoTitle"><%= v.title %></div>
|
||||
<% if (v.sourceType === 'youtube') { %>
|
||||
<div class="muted">YouTube</div>
|
||||
<% } %>
|
||||
</div>
|
||||
<% }) %>
|
||||
</section>
|
||||
<% } %>
|
||||
|
||||
<section class="videoGrid" id="videoGrid">
|
||||
<% if (videos.length === 0 && (isSubFolder || !subFolders || subFolders.length === 0)) { %>
|
||||
<p class="muted">이 폴더에 영상이 없습니다. 우측 상단에서 영상을 추가하세요.</p>
|
||||
<% } %>
|
||||
<% videos.forEach(function (v) {
|
||||
var shareUrl = '/video/' + folderPathEnc + '/' + encodeURIComponent(v.id)
|
||||
%>
|
||||
<div class="videoCard adminVideo"
|
||||
data-id="<%= v.id %>"
|
||||
data-video-id="<%= v.id %>"
|
||||
data-title="<%= v.title %>"
|
||||
data-share-url="<%= shareUrl %>">
|
||||
<div class="videoThumb">▶</div>
|
||||
<div class="videoTitle"><%= v.title %></div>
|
||||
<% if (v.sourceType === 'youtube') { %>
|
||||
<div class="muted">YouTube</div>
|
||||
<% } %>
|
||||
</div>
|
||||
<% }) %>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<div class="ctxMenu" id="ctxMenu" hidden>
|
||||
@@ -90,19 +92,21 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modalOverlay" id="addSubFolderModal" hidden>
|
||||
<div class="modalCard">
|
||||
<h2>하위 폴더 추가</h2>
|
||||
<label>
|
||||
<span>폴더 이름</span>
|
||||
<input type="text" id="addSubFolderInput" autofocus />
|
||||
</label>
|
||||
<div class="modalActions">
|
||||
<button type="button" class="secondaryButton" id="addSubFolderCancel">취소</button>
|
||||
<button type="button" class="primaryButton" id="addSubFolderConfirm">생성</button>
|
||||
<% if (!isSubFolder) { %>
|
||||
<div class="modalOverlay" id="addSubFolderModal" hidden>
|
||||
<div class="modalCard">
|
||||
<h2>하위 폴더 추가</h2>
|
||||
<label>
|
||||
<span>폴더 이름</span>
|
||||
<input type="text" id="addSubFolderInput" autofocus />
|
||||
</label>
|
||||
<div class="modalActions">
|
||||
<button type="button" class="secondaryButton" id="addSubFolderCancel">취소</button>
|
||||
<button type="button" class="primaryButton" id="addSubFolderConfirm">생성</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<script>
|
||||
window.__OP__ = {
|
||||
|
||||
Reference in New Issue
Block a user