feat(folders): allow videos in top-level folders too
1단계 폴더에도 영상을 직접 추가할 수 있게 한다 (하위 폴더와 혼합 가능). 플레이리스트 추가는 기존대로 2단계 폴더 한정. - op.ts: editor/upload/youtube start 의 parentId===null 차단 제거 (playlist probe/start/new 차단은 유지) - op/folder.ejs: 1단계에서 "하위 폴더 추가"+"영상 추가" 동시 노출, 서브폴더 그리드와 영상 그리드를 함께 표시 - folder.ejs(public): 1단계에서 하위 폴더 + 영상 함께 표시 - README: 폴더 구조/버튼 설명 갱신 Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
This commit is contained in:
@@ -54,7 +54,7 @@ data/
|
|||||||
|
|
||||||
공개:
|
공개:
|
||||||
- `/` — 최상위 폴더 목록
|
- `/` — 최상위 폴더 목록
|
||||||
- `/folder/:topName` — 1단계 폴더 (하위 폴더만 표시)
|
- `/folder/:topName` — 1단계 폴더 (하위 폴더 + 영상 혼합 표시)
|
||||||
- `/folder/:topName/:subName` — 2단계 폴더 (영상만 표시, 더 깊이 들어갈 수 없음)
|
- `/folder/:topName/:subName` — 2단계 폴더 (영상만 표시, 더 깊이 들어갈 수 없음)
|
||||||
- `/video/:topName/:videoId` 또는 `/video/:topName/:subName/:videoId` — 외부 공유용 짧은 URL. 경로의 폴더 부분이 영상 위치와 일치할 때만 200.
|
- `/video/:topName/:videoId` 또는 `/video/:topName/:subName/:videoId` — 외부 공유용 짧은 URL. 경로의 폴더 부분이 영상 위치와 일치할 때만 200.
|
||||||
- `/file/video/:videoId` — 실제 파일 스트림 (편집본 있으면 편집본). `?edited=0` 으로 원본 강제.
|
- `/file/video/:videoId` — 실제 파일 스트림 (편집본 있으면 편집본). `?edited=0` 으로 원본 강제.
|
||||||
@@ -71,7 +71,7 @@ data/
|
|||||||
- 폴더를 누르면 `/folder/:폴더이름` 으로 이동.
|
- 폴더를 누르면 `/folder/:폴더이름` 으로 이동.
|
||||||
|
|
||||||
### 폴더 화면 (`/folder/:topName[/:subName]`)
|
### 폴더 화면 (`/folder/:topName[/:subName]`)
|
||||||
- 1단계 폴더 화면: **하위 폴더 카드만** 보여줍니다 (영상은 2단계로 내려야 표시).
|
- 1단계 폴더 화면: **하위 폴더 카드 + 이 폴더에 직접 담긴 영상**을 함께 보여줍니다.
|
||||||
- 2단계 폴더 화면: **영상만** 보여줍니다 (썸네일 + 제목). 더 깊이 들어갈 수 없습니다.
|
- 2단계 폴더 화면: **영상만** 보여줍니다 (썸네일 + 제목). 더 깊이 들어갈 수 없습니다.
|
||||||
- 영상 카드 클릭 → `/video/:topName[/:subName]/:videoId` 로 이동, 플레이어가 뜨고 재생.
|
- 영상 카드 클릭 → `/video/:topName[/:subName]/:videoId` 로 이동, 플레이어가 뜨고 재생.
|
||||||
|
|
||||||
@@ -83,8 +83,8 @@ data/
|
|||||||
### 관리자 폴더 화면 (`/op/folder/...`)
|
### 관리자 폴더 화면 (`/op/folder/...`)
|
||||||
- 영상/서브폴더 목록을 유튜브 스타일로 나열. 우클릭으로 수정/삭제.
|
- 영상/서브폴더 목록을 유튜브 스타일로 나열. 우클릭으로 수정/삭제.
|
||||||
- 영상 ID 인라인 편집 가능 (전체 영상에 걸쳐 고유, 안전한 ID 형태만 허용. 변경하면 공유 URL 의 마지막 세그먼트가 같이 바뀝니다).
|
- 영상 ID 인라인 편집 가능 (전체 영상에 걸쳐 고유, 안전한 ID 형태만 허용. 변경하면 공유 URL 의 마지막 세그먼트가 같이 바뀝니다).
|
||||||
- 오른쪽 위 "영상 추가" → `/op/folder/.../video/editor` 로 이동.
|
- 오른쪽 위 "영상 추가" → `/op/folder/.../video/editor` 로 이동. 1단계·2단계 폴더 어디서나 영상을 추가할 수 있습니다 (1단계 폴더에는 "하위 폴더 추가" 버튼도 함께 노출).
|
||||||
- 2단계 폴더에서만 노출되는 "플레이리스트 임포트" 버튼: YouTube 플레이리스트 URL 을 넣으면 항목을 미리 보여주고 시작할 수 있습니다.
|
- 2단계 폴더에서만 노출되는 "플레이리스트 추가" 버튼: YouTube 플레이리스트 URL 을 넣으면 항목을 미리 보여주고 시작할 수 있습니다.
|
||||||
- 항목별 **드래그 정렬** (정렬 UI 는 플레이리스트 임포트 화면 한정), 제목 / ID 인라인 편집.
|
- 항목별 **드래그 정렬** (정렬 UI 는 플레이리스트 임포트 화면 한정), 제목 / ID 인라인 편집.
|
||||||
- ID 정책 토글:
|
- ID 정책 토글:
|
||||||
- **랜덤** — 항목별로 24자 hex (crypto.randomUUID 압축, 폴백은 16진수 24자) 자동 생성.
|
- **랜덤** — 항목별로 24자 hex (crypto.randomUUID 압축, 폴백은 16진수 24자) 자동 생성.
|
||||||
|
|||||||
@@ -200,11 +200,7 @@ opRouter.get(
|
|||||||
res.status(404).send('폴더를 찾을 수 없습니다.')
|
res.status(404).send('폴더를 찾을 수 없습니다.')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 영상은 2단계(서브) 폴더에만 둔다. 1단계 폴더는 컨테이너 전용.
|
// 영상은 1단계·2단계 폴더 어디서나 추가할 수 있다. (플레이리스트만 2단계 한정)
|
||||||
if (folder.parentId === null) {
|
|
||||||
res.status(400).send('영상은 하위 폴더에서만 추가할 수 있습니다.')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const videoId = typeof req.query.id === 'string' ? req.query.id : null
|
const videoId = typeof req.query.id === 'string' ? req.query.id : null
|
||||||
const video = videoId ? getVideo(videoId) : null
|
const video = videoId ? getVideo(videoId) : null
|
||||||
res.render('op/editor', {
|
res.render('op/editor', {
|
||||||
@@ -275,7 +271,6 @@ opRouter.post(
|
|||||||
try {
|
try {
|
||||||
const folder = getFolderByPath(collectFolderSegments(req.params))
|
const folder = getFolderByPath(collectFolderSegments(req.params))
|
||||||
if (!folder) throw new Error('폴더를 찾을 수 없습니다.')
|
if (!folder) throw new Error('폴더를 찾을 수 없습니다.')
|
||||||
if (folder.parentId === null) throw new Error('영상은 하위 폴더에서만 추가할 수 있습니다.')
|
|
||||||
const file = req.file
|
const file = req.file
|
||||||
if (!file) throw new Error('파일이 없습니다.')
|
if (!file) throw new Error('파일이 없습니다.')
|
||||||
const title = pickStr(req.body?.title).trim() || file.originalname
|
const title = pickStr(req.body?.title).trim() || file.originalname
|
||||||
@@ -321,7 +316,6 @@ opRouter.post(
|
|||||||
try {
|
try {
|
||||||
const folder = getFolderByPath(collectFolderSegments(req.params))
|
const folder = getFolderByPath(collectFolderSegments(req.params))
|
||||||
if (!folder) throw new Error('폴더를 찾을 수 없습니다.')
|
if (!folder) throw new Error('폴더를 찾을 수 없습니다.')
|
||||||
if (folder.parentId === null) throw new Error('영상은 하위 폴더에서만 추가할 수 있습니다.')
|
|
||||||
const url = pickStr(req.body.url).trim()
|
const url = pickStr(req.body.url).trim()
|
||||||
const title = pickStr(req.body.title).trim() || undefined
|
const title = pickStr(req.body.title).trim() || undefined
|
||||||
if (!url) throw new Error('URL 을 입력해 주세요.')
|
if (!url) throw new Error('URL 을 입력해 주세요.')
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
<% if (!isSubFolder) { %>
|
<% if (!isSubFolder) { %>
|
||||||
<section class="folderGrid">
|
<section class="folderGrid">
|
||||||
<% if (!subFolders || subFolders.length === 0) { %>
|
<% if ((!subFolders || subFolders.length === 0) && videos.length === 0) { %>
|
||||||
<p class="muted">아직 하위 폴더가 없습니다.</p>
|
<p class="muted">아직 하위 폴더가 없습니다.</p>
|
||||||
<% } %>
|
<% } %>
|
||||||
<% (subFolders || []).forEach(function (sf) { %>
|
<% (subFolders || []).forEach(function (sf) { %>
|
||||||
@@ -40,22 +40,22 @@
|
|||||||
</a>
|
</a>
|
||||||
<% }) %>
|
<% }) %>
|
||||||
</section>
|
</section>
|
||||||
<% } 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>
|
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
|
<section class="videoGrid">
|
||||||
|
<% if (videos.length === 0 && isSubFolder) { %>
|
||||||
|
<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>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<div class="ctxMenu" id="ctxMenu" hidden>
|
<div class="ctxMenu" id="ctxMenu" hidden>
|
||||||
|
|||||||
@@ -26,8 +26,9 @@
|
|||||||
<div class="dashboardActions">
|
<div class="dashboardActions">
|
||||||
<% if (!isSubFolder) { %>
|
<% if (!isSubFolder) { %>
|
||||||
<button type="button" class="primaryButton" id="addSubFolderBtn">하위 폴더 추가</button>
|
<button type="button" class="primaryButton" id="addSubFolderBtn">하위 폴더 추가</button>
|
||||||
<% } else { %>
|
<% } %>
|
||||||
<a class="primaryButton" href="<%= editorHref %>">영상 추가</a>
|
<a class="primaryButton" href="<%= editorHref %>">영상 추가</a>
|
||||||
|
<% if (isSubFolder) { %>
|
||||||
<a class="primaryButton" href="<%= playlistHref %>">플레이리스트 추가</a>
|
<a class="primaryButton" href="<%= playlistHref %>">플레이리스트 추가</a>
|
||||||
<% } %>
|
<% } %>
|
||||||
</div>
|
</div>
|
||||||
@@ -36,7 +37,7 @@
|
|||||||
<% if (!isSubFolder) { %>
|
<% if (!isSubFolder) { %>
|
||||||
<section class="folderGrid" id="subFolderGrid">
|
<section class="folderGrid" id="subFolderGrid">
|
||||||
<% if (!subFolders || subFolders.length === 0) { %>
|
<% if (!subFolders || subFolders.length === 0) { %>
|
||||||
<p class="muted">아직 하위 폴더가 없습니다. 우측 상단에서 하위 폴더를 추가하세요. (영상은 하위 폴더 안에서만 추가할 수 있습니다.)</p>
|
<p class="muted">아직 하위 폴더가 없습니다. 우측 상단에서 하위 폴더를 추가하세요. (영상도 이 폴더에 바로 추가할 수 있습니다.)</p>
|
||||||
<% } %>
|
<% } %>
|
||||||
<% (subFolders || []).forEach(function (sf) { %>
|
<% (subFolders || []).forEach(function (sf) { %>
|
||||||
<div class="folderCard adminFolder" data-folder-id="<%= sf.id %>" data-name="<%= sf.name %>">
|
<div class="folderCard adminFolder" data-folder-id="<%= sf.id %>" data-name="<%= sf.name %>">
|
||||||
@@ -47,28 +48,28 @@
|
|||||||
</div>
|
</div>
|
||||||
<% }) %>
|
<% }) %>
|
||||||
</section>
|
</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) { %>
|
||||||
|
<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>
|
</main>
|
||||||
|
|
||||||
<div class="ctxMenu" id="ctxMenu" hidden>
|
<div class="ctxMenu" id="ctxMenu" hidden>
|
||||||
|
|||||||
Reference in New Issue
Block a user