From e1ddbff1f52c061ab119df913900de169171f0ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=95=9C=EB=95=80=20=EC=9E=91=EC=97=85=EC=8B=A4?= Date: Sun, 1 Nov 2026 08:08:08 +0000 Subject: [PATCH] =?UTF-8?q?=EB=90=98=EB=8F=8C=EB=A6=AC=EA=B8=B0=20?= =?UTF-8?q?=ED=99=94=EB=A9=B4:=20=ED=8F=B0=20=EB=AA=A9=EB=A1=9D=20?= =?UTF-8?q?=EB=A7=A8=20=EC=95=84=EB=9E=98=20=EC=B5=9C=EA=B7=BC=20=EC=9D=B4?= =?UTF-8?q?=EB=A0=A5=20=E2=86=92=20=EA=B7=B8=20=EC=BB=A4=EB=B0=8B=20revert?= =?UTF-8?q?(=EC=B4=88=EC=95=88=20=EC=9E=88=EC=9C=BC=EB=A9=B4=20=EB=B0=B0?= =?UTF-8?q?=ED=8F=AC=EB=A7=8C=20=EA=B1=B4=EB=84=88=EB=9C=80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 ++ studio/m.html | 42 ++++++++++++++++++++++++++++++++++++++++++ studio/server.py | 11 +++++++++++ 3 files changed, 55 insertions(+) diff --git a/README.md b/README.md index 948045c..cb7babf 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,8 @@ bash scripts/studio.sh # http://localhost:8081 실수 방지로 **첫 페이지 키트(`site.json` 의 `shop.kit_slug`)와 마지막 남은 한 점은 거부**한다. 커밋 안 된 다른 초안이 있으면 삭제는 하되 배포는 건너뛴다(목록의 `사이트에 올리기` 로 마저 올린다). - `/m?slug=<슬러그>` 로 들어가면 그 작품 수정 화면이 바로 열린다. +- 목록 맨 아래 `최근 이력 · 되돌리기` = 최근 커밋 25개 목록. `되돌리기` 를 누르면 그 커밋을 `git revert` 하고(사이트 반영까지) + 지운 작품을 되살린다. 커밋 안 된 초안이 있으면 되돌리기는 하되 배포는 건너뛴다. - `사이트에 올리기` 는 **빌드까지 다시 한 뒤** 복사한다(되돌리기·수동 편집 뒤에도 안전). - 저장 = `사진 축소(Pillow) → content/products/.md → build.py → git commit`(경로만 지정) → `git push`(Gitea). `사이트에 올리기` 를 누르면 `dist/` 를 웹 루트로 복사한다. - 사진은 `studio/_inbox/` 에 잠시 쌓였다가 발행 시 두 곳으로 나뉜다. diff --git a/studio/m.html b/studio/m.html index c29fb77..f7180be 100644 --- a/studio/m.html +++ b/studio/m.html @@ -124,6 +124,12 @@
불러오는 중
+ +
+

UNDO

+ + +
@@ -765,6 +771,42 @@ $('#e-delete').onclick = async () => { await deleteWork(false); }; +/* ---------- 최근 이력 · 되돌리기 ---------- */ +$('#hist-toggle').onclick = async () => { + const box = $('#hist-list'); + if (!box.hidden){ box.hidden = true; return; } + box.hidden = false; + box.innerHTML = ' 불러오는 중'; + try{ + const d = await api('/api/history'); + box.innerHTML = (d.history || []).map(h => ` +
+ ${h.date} · ${h.subject} + +
`).join('') || '

이력이 없습니다.

'; + box.querySelectorAll('[data-undo]').forEach(b => b.onclick = () => undoCommit(b.dataset.undo, b)); + }catch(e){ box.innerHTML = `${e.message}`; } +}; + +async function undoCommit(sha, btn){ + if (!confirm(`${sha} 커밋을 되돌릴까요?\n\n지운 작품을 되살릴 때 이 버튼을 씁니다. 되돌리기도 새 커밋으로 남습니다.`)) return; + const box = $('#hist-list'); + if (btn) btn.disabled = true; + box.innerHTML = ' 되돌리는 중…'; + try{ + const d = await api('/api/revert', { sha, deploy:true }); + const note = d.deployed ? '사이트에도 반영했습니다.' + : (d.deploy_log || '저장소에서만 되돌렸습니다 — 사이트에는 아직 옛 상태입니다.'); + box.hidden = true; box.innerHTML = ''; + toast('되돌렸습니다'); + go('home'); + $('#deploy-status').innerHTML = `${sha} 되돌렸습니다 · 커밋 ${String(d.head || '').slice(0,34)}
${note}`; + }catch(e){ + box.innerHTML = `${e.message}`; + if (btn) btn.disabled = false; + } +} + /* ---------- 시작 ---------- */ go('home'); loadPresets(); // 목록의 링크나 알림에서 바로 열 수 있게: /m?slug=<슬러그> → 그 작품 고치기 화면 diff --git a/studio/server.py b/studio/server.py index 2ef6de1..87c24f8 100644 --- a/studio/server.py +++ b/studio/server.py @@ -434,8 +434,19 @@ def revert(sha: str, redeploy: bool) -> Dict[str, Any]: return {"ok": False, "error": "되돌린 뒤 빌드 실패", "log": build_log} result: Dict[str, Any] = {"ok": True, "message": f"{sha} 되돌림", "head": head_sha(), "log": build_log} if redeploy: + drafts = reg.pending_drafts() + if drafts: + # 초안까지 함께 올라가는 사고를 막는다(삭제 취소 버튼에서도 같은 규칙). + result["drafts"] = drafts + result["deployed"] = False + result["deploy_log"] = ("커밋하지 않은 초안이 있어 배포를 건너뛰었습니다: " + ", ".join(drafts) + + " — 목록에서 [사이트에 올리기]로 마저 올려 주세요.") + result["message"] += " (사이트 반영은 건너뜀)" + return result deployed, deploy_log = deploy() result["deploy"] = {"ok": deployed, "log": deploy_log} + result["deployed"] = deployed + result["deploy_log"] = deploy_log[-400:] result["message"] += " · 배포 완료" if deployed else " (배포 실패)" return result