Initial commit: Kei Design Agent
콘텐츠를 시각적으로 구조화된 슬라이드 HTML로 변환하는 독립 에이전트. 아키텍처 (4단계 파이프라인): 1. Kei 실장 (Opus) — 콘텐츠 유형 분류 + 블록 배치 2. 디자인 팀장 (Sonnet) — 레이아웃 컨셉 (블록 배치 + 페이지 수) 3. 텍스트 편집자 (Sonnet) — 슬롯 텍스트 정리 (핵심 유지) 4. CSS Grid 렌더러 — HTML 조립 블록 템플릿 7종: comparison, card-grid, relationship, process, quote-block, conclusion-bar, comparison-table 기술 스택: FastAPI + Anthropic API + Jinja2 + CSS Grid Pretendard Variable 한국어 폰트 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
253
static/index.html
Normal file
253
static/index.html
Normal file
@@ -0,0 +1,253 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Design Agent — 슬라이드 생성기</title>
|
||||
<link rel="preconnect" href="https://cdn.jsdelivr.net">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css">
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
body {
|
||||
font-family: 'Pretendard Variable', sans-serif;
|
||||
background: #f1f5f9;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 24px;
|
||||
color: #1e293b;
|
||||
}
|
||||
h1 {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.container {
|
||||
width: 100%;
|
||||
max-width: 1400px;
|
||||
display: grid;
|
||||
grid-template-columns: 400px 1fr;
|
||||
gap: 24px;
|
||||
flex: 1;
|
||||
}
|
||||
.input-panel {
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
.input-panel label {
|
||||
font-weight: 600;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
textarea {
|
||||
width: 100%;
|
||||
height: 400px;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 6px;
|
||||
padding: 12px;
|
||||
font-family: inherit;
|
||||
font-size: 0.85rem;
|
||||
line-height: 1.6;
|
||||
resize: vertical;
|
||||
word-break: keep-all;
|
||||
}
|
||||
textarea:focus {
|
||||
outline: none;
|
||||
border-color: #2563eb;
|
||||
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
|
||||
}
|
||||
button {
|
||||
padding: 12px 24px;
|
||||
background: #2563eb;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
font-size: 0.95rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
font-family: inherit;
|
||||
}
|
||||
button:hover { background: #1d4ed8; }
|
||||
button:disabled { background: #94a3b8; cursor: not-allowed; }
|
||||
.btn-download {
|
||||
background: #16a34a;
|
||||
margin-top: 8px;
|
||||
}
|
||||
.btn-download:hover { background: #15803d; }
|
||||
.progress {
|
||||
font-size: 0.85rem;
|
||||
color: #64748b;
|
||||
padding: 8px 0;
|
||||
}
|
||||
.preview-panel {
|
||||
background: #e2e8f0;
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
overflow: auto;
|
||||
}
|
||||
.preview-label {
|
||||
color: #64748b;
|
||||
font-size: 0.85rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
.iframe-wrapper {
|
||||
width: 100%;
|
||||
aspect-ratio: 16 / 9;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
border-radius: 6px;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.15);
|
||||
background: white;
|
||||
}
|
||||
iframe {
|
||||
width: 1280px;
|
||||
height: 720px;
|
||||
border: none;
|
||||
background: white;
|
||||
transform-origin: top left;
|
||||
/* scale은 JS에서 컨테이너 너비에 맞게 동적 계산 */
|
||||
}
|
||||
.error {
|
||||
color: #dc2626;
|
||||
font-size: 0.85rem;
|
||||
padding: 8px 12px;
|
||||
background: #fef2f2;
|
||||
border-radius: 6px;
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Design Agent — 슬라이드 생성기</h1>
|
||||
<div class="container">
|
||||
<div class="input-panel">
|
||||
<label>콘텐츠 입력</label>
|
||||
<textarea id="content" placeholder="슬라이드로 변환할 텍스트를 붙여넣으세요..."></textarea>
|
||||
<button id="btn-generate" onclick="generate()">슬라이드 생성</button>
|
||||
<div id="progress" class="progress"></div>
|
||||
<div id="error" class="error"></div>
|
||||
<button id="btn-download" class="btn-download" style="display:none" onclick="download()">HTML 다운로드</button>
|
||||
</div>
|
||||
<div class="preview-panel">
|
||||
<div class="preview-label">미리보기</div>
|
||||
<div class="iframe-wrapper" id="iframe-wrapper">
|
||||
<iframe id="preview"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
let generatedHTML = '';
|
||||
|
||||
function scalePreview() {
|
||||
const wrapper = document.getElementById('iframe-wrapper');
|
||||
const iframe = document.getElementById('preview');
|
||||
if (!wrapper || !iframe) return;
|
||||
const wrapperWidth = wrapper.clientWidth;
|
||||
const scale = wrapperWidth / 1280;
|
||||
iframe.style.transform = 'scale(' + scale + ')';
|
||||
wrapper.style.height = (720 * scale) + 'px';
|
||||
}
|
||||
|
||||
window.addEventListener('resize', scalePreview);
|
||||
window.addEventListener('load', scalePreview);
|
||||
|
||||
async function generate() {
|
||||
const content = document.getElementById('content').value.trim();
|
||||
if (!content) return;
|
||||
|
||||
const btn = document.getElementById('btn-generate');
|
||||
const progress = document.getElementById('progress');
|
||||
const error = document.getElementById('error');
|
||||
const downloadBtn = document.getElementById('btn-download');
|
||||
|
||||
btn.disabled = true;
|
||||
error.style.display = 'none';
|
||||
downloadBtn.style.display = 'none';
|
||||
progress.textContent = '시작 중...';
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/generate', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ content }),
|
||||
});
|
||||
|
||||
const reader = response.body.getReader();
|
||||
const decoder = new TextDecoder();
|
||||
let buffer = '';
|
||||
|
||||
while (true) {
|
||||
const { done, value } = await reader.read();
|
||||
if (done) break;
|
||||
|
||||
buffer += decoder.decode(value, { stream: true });
|
||||
|
||||
// SSE 이벤트는 빈 줄(\n\n)로 구분
|
||||
const parts = buffer.split(/\r?\n\r?\n/);
|
||||
buffer = parts.pop() || '';
|
||||
|
||||
for (const part of parts) {
|
||||
if (!part.trim()) continue;
|
||||
|
||||
// 각 이벤트에서 event: 와 data: 추출
|
||||
let eventType = '';
|
||||
let eventData = '';
|
||||
|
||||
for (const line of part.split(/\r?\n/)) {
|
||||
if (line.startsWith('event:')) {
|
||||
eventType = line.slice(6).trim();
|
||||
} else if (line.startsWith('data:')) {
|
||||
eventData = line.slice(5).trim();
|
||||
}
|
||||
}
|
||||
|
||||
if (!eventData) continue;
|
||||
|
||||
try {
|
||||
const parsed = JSON.parse(eventData);
|
||||
|
||||
if (eventType === 'progress') {
|
||||
progress.textContent = parsed;
|
||||
} else if (eventType === 'result') {
|
||||
generatedHTML = parsed;
|
||||
document.getElementById('preview').srcdoc = generatedHTML;
|
||||
downloadBtn.style.display = 'block';
|
||||
progress.textContent = '완료!';
|
||||
setTimeout(scalePreview, 100);
|
||||
} else if (eventType === 'error') {
|
||||
error.textContent = parsed;
|
||||
error.style.display = 'block';
|
||||
}
|
||||
} catch (e) {
|
||||
// ping 등 무시
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
error.textContent = '오류: ' + e.message;
|
||||
error.style.display = 'block';
|
||||
} finally {
|
||||
btn.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
function download() {
|
||||
if (!generatedHTML) return;
|
||||
const blob = new Blob(['\uFEFF' + generatedHTML], { type: 'text/html;charset=utf-8' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = 'slide-' + Date.now() + '.html';
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user