feat(folders): nested folder tree (max depth 2) + id-based mutations

- new storeDb.ts: DB+FS layer (folders w/ parent_id, videos w/ global id)
- depth cap: sub-folder cannot have children (enforced in createFolder)
- video id: editable anytime (changeVideoId), uniqueness via PK
- routes:
  - public /folder/:topName[/:subName], /video/:topName[/:subName]/:videoId
  - admin /op/folder/:topName[/:subName], id-based /op/folders/:id/*
    and /op/videos/:id/* (rename/changeId/delete/save + idAvailable check)
- views: breadcrumb + subFolder grid; 플레이리스트 추가 button shows at 2단계
- client JS: id-based mutation endpoints, share URL data attribute,
  in-site player pushes share URL to address bar
- store.ts slimmed to Account + readAccounts (FS layer moved to storeDb)
- pickIntId accepts numeric JSON bodies

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-05-31 23:36:02 +09:00
parent 3560dcb802
commit c5faa8808c
17 changed files with 1207 additions and 577 deletions

View File

@@ -1,5 +1,6 @@
(function () {
var ctxMenu = document.getElementById('ctxMenu')
var targetId = null
var targetName = null
function showCtx(x, y) {
@@ -7,11 +8,12 @@
ctxMenu.style.top = y + 'px'
ctxMenu.hidden = false
}
function hideCtx() { ctxMenu.hidden = true; targetName = null }
function hideCtx() { ctxMenu.hidden = true; targetId = null; targetName = null }
document.querySelectorAll('.adminFolder').forEach(function (card) {
card.addEventListener('contextmenu', function (e) {
e.preventDefault()
targetId = card.getAttribute('data-folder-id')
targetName = card.getAttribute('data-name')
showCtx(e.clientX, e.clientY)
})
@@ -23,15 +25,15 @@
ctxMenu.addEventListener('click', function (e) {
var btn = e.target.closest('button')
if (!btn) return
if (!btn || !targetId) return
var action = btn.getAttribute('data-action')
if (action === 'rename') {
var newName = window.prompt('새 폴더 이름', targetName)
if (newName && newName !== targetName) {
fetch('/op/folders/rename', {
fetch('/op/folders/' + encodeURIComponent(targetId) + '/rename', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ oldName: targetName, newName: newName })
body: JSON.stringify({ newName: newName })
}).then(function (r) { return r.json() }).then(function (j) {
if (j.ok) location.reload()
else alert(j.message || '이름 변경 실패')
@@ -39,10 +41,8 @@
}
} else if (action === 'delete') {
if (window.confirm('"' + targetName + '" 폴더를 정말 삭제할까요? 안의 영상이 모두 사라집니다.')) {
fetch('/op/folders/delete', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ name: targetName })
fetch('/op/folders/' + encodeURIComponent(targetId) + '/delete', {
method: 'POST'
}).then(function (r) { return r.json() }).then(function (j) {
if (j.ok) location.reload()
else alert(j.message || '삭제 실패')
@@ -61,20 +61,22 @@
function openModal() { modal.hidden = false; input.value = ''; setTimeout(function () { input.focus() }, 0) }
function closeModal() { modal.hidden = true }
addBtn.addEventListener('click', openModal)
cancelBtn.addEventListener('click', closeModal)
modal.addEventListener('click', function (e) { if (e.target === modal) closeModal() })
input.addEventListener('keydown', function (e) { if (e.key === 'Enter') confirmBtn.click() })
confirmBtn.addEventListener('click', function () {
var name = input.value.trim()
if (!name) return
fetch('/op/folders', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ name: name })
}).then(function (r) { return r.json() }).then(function (j) {
if (j.ok) location.reload()
else alert(j.message || '폴더 생성 실패')
if (addBtn) {
addBtn.addEventListener('click', openModal)
cancelBtn.addEventListener('click', closeModal)
modal.addEventListener('click', function (e) { if (e.target === modal) closeModal() })
input.addEventListener('keydown', function (e) { if (e.key === 'Enter') confirmBtn.click() })
confirmBtn.addEventListener('click', function () {
var name = input.value.trim()
if (!name) return
fetch('/op/folders', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ name: name })
}).then(function (r) { return r.json() }).then(function (j) {
if (j.ok) location.reload()
else alert(j.message || '폴더 생성 실패')
})
})
})
}
})()