feat: 초기 프로젝트 구조 설정 및 소스 코드 추가

This commit is contained in:
hyungi
2025-07-24 15:06:29 +09:00
parent 9003616737
commit 5db20e2943
17 changed files with 4840 additions and 0 deletions

468
templates/index.html Normal file
View File

@@ -0,0 +1,468 @@
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI 번역 시스템</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 800px;
margin: 0 auto;
background: white;
border-radius: 20px;
box-shadow: 0 20px 40px rgba(0,0,0,0.1);
overflow: hidden;
}
.header {
background: linear-gradient(135deg, #2563eb, #3b82f6);
color: white;
padding: 40px;
text-align: center;
}
.header h1 {
font-size: 2.5rem;
margin-bottom: 10px;
}
.header p {
font-size: 1.1rem;
opacity: 0.9;
}
.nav-menu {
background: #f8fafc;
padding: 20px 40px;
border-bottom: 1px solid #e5e7eb;
}
.nav-links {
display: flex;
gap: 30px;
}
.nav-link {
color: #374151;
text-decoration: none;
font-weight: 500;
transition: color 0.3s ease;
}
.nav-link:hover {
color: #2563eb;
}
.nav-link.active {
color: #2563eb;
border-bottom: 2px solid #2563eb;
padding-bottom: 5px;
}
.status-bar {
background: #f0f9ff;
padding: 15px 40px;
border-bottom: 1px solid #bae6fd;
display: flex;
justify-content: space-between;
align-items: center;
font-size: 0.9rem;
}
.status-good { color: #065f46; }
.status-bad { color: #dc2626; }
.status-warning { color: #d97706; }
.main-content {
padding: 40px;
}
.upload-section {
text-align: center;
margin-bottom: 40px;
}
.file-drop-zone {
border: 3px dashed #e5e7eb;
border-radius: 16px;
padding: 60px 20px;
margin: 20px 0;
transition: all 0.3s ease;
cursor: pointer;
}
.file-drop-zone:hover {
border-color: #2563eb;
background: #f8fafc;
}
.file-drop-zone.drag-over {
border-color: #2563eb;
background: #eff6ff;
}
.upload-icon {
font-size: 4rem;
color: #9ca3af;
margin-bottom: 20px;
}
.upload-text {
font-size: 1.2rem;
color: #374151;
margin-bottom: 10px;
}
.upload-hint {
color: #6b7280;
font-size: 0.9rem;
}
.file-input {
display: none;
}
.upload-btn {
background: #2563eb;
color: white;
border: none;
padding: 12px 24px;
border-radius: 8px;
font-size: 1rem;
cursor: pointer;
margin-top: 20px;
transition: background 0.3s ease;
}
.upload-btn:hover {
background: #1d4ed8;
}
.upload-btn:disabled {
background: #9ca3af;
cursor: not-allowed;
}
.progress-section {
display: none;
background: #f8fafc;
border-radius: 12px;
padding: 30px;
margin: 20px 0;
}
.progress-title {
font-weight: 600;
margin-bottom: 15px;
color: #374151;
}
.progress-bar {
width: 100%;
height: 12px;
background: #e5e7eb;
border-radius: 6px;
overflow: hidden;
margin-bottom: 10px;
}
.progress-fill {
height: 100%;
background: linear-gradient(90deg, #2563eb, #3b82f6);
width: 0%;
transition: width 0.5s ease;
}
.progress-text {
font-size: 0.9rem;
color: #6b7280;
}
.result-section {
display: none;
background: #f0f9ff;
border: 1px solid #0ea5e9;
border-radius: 12px;
padding: 30px;
margin: 20px 0;
}
.result-title {
color: #0369a1;
font-weight: 600;
margin-bottom: 15px;
}
.result-actions {
display: flex;
gap: 15px;
flex-wrap: wrap;
}
.btn {
padding: 10px 20px;
border-radius: 8px;
text-decoration: none;
font-weight: 500;
transition: all 0.3s ease;
border: none;
cursor: pointer;
}
.btn-primary {
background: #2563eb;
color: white;
}
.btn-primary:hover {
background: #1d4ed8;
}
.btn-secondary {
background: #f8fafc;
color: #374151;
border: 1px solid #e5e7eb;
}
.btn-secondary:hover {
background: #f1f5f9;
}
.error-section {
display: none;
background: #fef2f2;
border: 1px solid #fecaca;
border-radius: 12px;
padding: 20px;
margin: 20px 0;
color: #dc2626;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>🤖 AI 번역 시스템</h1>
<p>PDF/문서를 다국어 HTML로 자동 변환</p>
</div>
<div class="nav-menu">
<div class="nav-links">
<a href="/" class="nav-link active">📤 업로드</a>
<a href="/library" class="nav-link">📚 라이브러리</a>
<a href="/system-status" class="nav-link">📊 시스템</a>
</div>
</div>
<div class="status-bar">
<div>
{% if nas_status.status == "connected" %}
<span class="status-good">✅ NAS 연결됨 (DS1525+)</span>
{% else %}
<span class="status-bad">❌ NAS 연결 실패: {{ nas_status.error }}</span>
{% endif %}
</div>
<div>
<span class="status-good">🚀 Mac Mini Ready</span>
</div>
</div>
<div class="main-content">
{% if nas_status.status != "connected" %}
<div class="error-section" style="display: block;">
<h3>NAS 연결 필요</h3>
<p>{{ nas_status.error }}</p>
<p><strong>해결 방법:</strong></p>
<ul style="margin-left: 20px; margin-top: 10px;">
<li>Finder → 이동 → 서버에 연결</li>
<li>smb://192.168.1.227 입력</li>
<li>DS1525+ 연결 후 페이지 새로고침</li>
</ul>
</div>
{% endif %}
<div class="upload-section">
<div class="file-drop-zone" id="dropZone">
<div class="upload-icon">📁</div>
<div class="upload-text">파일을 드래그하거나 클릭하여 업로드</div>
<div class="upload-hint">PDF, TXT, DOCX 파일 지원 (최대 100MB)</div>
<input type="file" id="fileInput" class="file-input" accept=".pdf,.txt,.docx,.doc">
<button type="button" class="upload-btn" id="uploadBtn"
{% if nas_status.status != "connected" %}disabled{% endif %}
onclick="document.getElementById('fileInput').click()">
{% if nas_status.status == "connected" %}
파일 선택
{% else %}
NAS 연결 필요
{% endif %}
</button>
</div>
</div>
<div class="progress-section" id="progressSection">
<div class="progress-title">처리 진행 상황</div>
<div class="progress-bar">
<div class="progress-fill" id="progressFill"></div>
</div>
<div class="progress-text" id="progressText">준비 중...</div>
</div>
<div class="result-section" id="resultSection">
<div class="result-title">🎉 변환 완료!</div>
<div class="result-actions">
<a href="#" id="downloadBtn" class="btn btn-primary">📥 HTML 다운로드</a>
<a href="#" id="previewBtn" class="btn btn-secondary" target="_blank">👁️ 미리보기</a>
<a href="/library" class="btn btn-secondary">📚 라이브러리 보기</a>
</div>
</div>
</div>
</div>
<script>
let currentJobId = null;
const nasConnected = {{ 'true' if nas_status.status == 'connected' else 'false' }};
// 파일 드래그 앤 드롭
const dropZone = document.getElementById('dropZone');
const fileInput = document.getElementById('fileInput');
const uploadBtn = document.getElementById('uploadBtn');
if (nasConnected) {
dropZone.addEventListener('dragover', (e) => {
e.preventDefault();
dropZone.classList.add('drag-over');
});
dropZone.addEventListener('dragleave', () => {
dropZone.classList.remove('drag-over');
});
dropZone.addEventListener('drop', (e) => {
e.preventDefault();
dropZone.classList.remove('drag-over');
const files = e.dataTransfer.files;
if (files.length > 0) {
handleFileUpload(files[0]);
}
});
dropZone.addEventListener('click', () => {
if (!uploadBtn.disabled) {
fileInput.click();
}
});
fileInput.addEventListener('change', (e) => {
if (e.target.files.length > 0) {
handleFileUpload(e.target.files[0]);
}
});
}
async function handleFileUpload(file) {
if (!nasConnected) {
alert('NAS 연결이 필요합니다.');
return;
}
// 파일 크기 검증 (100MB)
if (file.size > 100 * 1024 * 1024) {
alert('파일 크기는 100MB를 초과할 수 없습니다.');
return;
}
// 파일 형식 검증
const allowedTypes = ['.pdf', '.txt', '.docx', '.doc'];
const fileExt = '.' + file.name.split('.').pop().toLowerCase();
if (!allowedTypes.includes(fileExt)) {
alert('지원되지 않는 파일 형식입니다. PDF, TXT, DOCX 파일만 업로드 가능합니다.');
return;
}
// UI 업데이트
document.getElementById('progressSection').style.display = 'block';
document.getElementById('resultSection').style.display = 'none';
uploadBtn.disabled = true;
// 파일 업로드
const formData = new FormData();
formData.append('file', file);
try {
const response = await fetch('/upload', {
method: 'POST',
body: formData
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.detail || '업로드 실패');
}
const result = await response.json();
currentJobId = result.job_id;
// 진행 상황 모니터링 시작
monitorProgress();
} catch (error) {
alert('업로드 실패: ' + error.message);
document.getElementById('progressSection').style.display = 'none';
uploadBtn.disabled = false;
}
}
async function monitorProgress() {
if (!currentJobId) return;
try {
const response = await fetch(`/status/${currentJobId}`);
const status = await response.json();
// 진행률 업데이트
document.getElementById('progressFill').style.width = status.progress + '%';
document.getElementById('progressText').textContent = status.message;
if (status.status === 'completed') {
// 완료 처리
document.getElementById('progressSection').style.display = 'none';
document.getElementById('resultSection').style.display = 'block';
// 다운로드 링크 설정
document.getElementById('downloadBtn').href = `/download/${currentJobId}`;
uploadBtn.disabled = false;
} else if (status.status === 'error') {
alert('처리 실패: ' + status.message);
document.getElementById('progressSection').style.display = 'none';
uploadBtn.disabled = false;
} else {
// 계속 모니터링
setTimeout(monitorProgress, 2000); // 2초마다 확인
}
} catch (error) {
console.error('상태 확인 오류:', error);
setTimeout(monitorProgress, 5000); // 오류시 5초 후 재시도
}
}
</script>
</body>
</html>

View File

@@ -0,0 +1,373 @@
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>문서 라이브러리 - AI 번역 시스템</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 1400px;
margin: 0 auto;
background: white;
border-radius: 20px;
box-shadow: 0 20px 40px rgba(0,0,0,0.1);
overflow: hidden;
}
.header {
background: linear-gradient(135deg, #2563eb, #3b82f6);
color: white;
padding: 40px;
text-align: center;
}
.header h1 { font-size: 2.5rem; margin-bottom: 10px; }
.header p { font-size: 1.1rem; opacity: 0.9; }
.nav-menu {
background: #f8fafc;
padding: 20px 40px;
border-bottom: 1px solid #e5e7eb;
display: flex;
justify-content: space-between;
align-items: center;
}
.nav-links { display: flex; gap: 30px; }
.nav-link {
color: #374151;
text-decoration: none;
font-weight: 500;
transition: color 0.3s ease;
}
.nav-link:hover { color: #2563eb; }
.nav-link.active {
color: #2563eb;
border-bottom: 2px solid #2563eb;
padding-bottom: 5px;
}
.stats-bar {
background: #f0f9ff;
padding: 15px 40px;
border-bottom: 1px solid #bae6fd;
display: flex;
gap: 30px;
font-size: 0.9rem;
color: #0369a1;
}
.stat-item { display: flex; align-items: center; gap: 8px; }
.main-content { padding: 40px; }
.search-section {
margin-bottom: 30px;
display: flex;
gap: 15px;
align-items: center;
}
.search-box {
flex: 1;
padding: 15px;
border: 2px solid #e5e7eb;
border-radius: 12px;
font-size: 1rem;
}
.filter-select {
padding: 15px;
border: 2px solid #e5e7eb;
border-radius: 12px;
background: white;
min-width: 200px;
}
.category-section {
margin-bottom: 40px;
background: #f8fafc;
border-radius: 16px;
overflow: hidden;
}
.category-header {
background: linear-gradient(135deg, #1e40af, #2563eb);
color: white;
padding: 20px 30px;
display: flex;
justify-content: space-between;
align-items: center;
}
.category-title { font-size: 1.3rem; font-weight: 600; }
.category-count {
background: rgba(255,255,255,0.2);
padding: 5px 12px;
border-radius: 20px;
font-size: 0.9rem;
}
.documents-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
gap: 20px;
padding: 30px;
}
.document-card {
background: white;
border: 1px solid #e5e7eb;
border-radius: 12px;
padding: 24px;
transition: all 0.3s ease;
cursor: pointer;
}
.document-card:hover {
transform: translateY(-4px);
box-shadow: 0 12px 24px rgba(0,0,0,0.1);
border-color: #2563eb;
}
.document-title {
font-size: 1.1rem;
font-weight: 600;
color: #1f2937;
margin-bottom: 12px;
line-height: 1.4;
}
.document-meta {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin-bottom: 16px;
font-size: 0.85rem;
color: #6b7280;
}
.meta-item {
display: flex;
align-items: center;
gap: 6px;
}
.language-badge {
display: inline-block;
padding: 4px 8px;
background: #eff6ff;
color: #1d4ed8;
border-radius: 6px;
font-size: 0.75rem;
font-weight: 500;
margin-bottom: 12px;
}
.document-actions {
display: flex;
gap: 10px;
}
.btn {
padding: 10px 16px;
border-radius: 8px;
text-decoration: none;
font-weight: 500;
font-size: 0.875rem;
transition: all 0.3s ease;
border: none;
cursor: pointer;
flex: 1;
text-align: center;
}
.btn-primary {
background: #2563eb;
color: white;
}
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary {
background: #f8fafc;
color: #374151;
border: 1px solid #e5e7eb;
}
.btn-secondary:hover { background: #f1f5f9; }
.empty-state {
text-align: center;
padding: 80px 20px;
color: #6b7280;
}
.empty-icon { font-size: 4rem; margin-bottom: 20px; }
.empty-title {
font-size: 1.5rem;
font-weight: 600;
margin-bottom: 10px;
color: #374151;
}
@media (max-width: 768px) {
.documents-grid { grid-template-columns: 1fr; }
.nav-menu { flex-direction: column; gap: 20px; }
.stats-bar { flex-wrap: wrap; }
.search-section { flex-direction: column; }
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>📚 문서 라이브러리</h1>
<p>체계적으로 분류된 다국어 번역 문서</p>
</div>
<div class="nav-menu">
<div class="nav-links">
<a href="/" class="nav-link">📤 업로드</a>
<a href="/library" class="nav-link active">📚 라이브러리</a>
<a href="/system-status" class="nav-link">📊 시스템</a>
</div>
</div>
<div class="stats-bar">
<div class="stat-item">
<span>📄</span>
<span>총 {{ total_documents }}개 문서</span>
</div>
<div class="stat-item">
<span>🗂️</span>
<span>{{ categories|length }}개 카테고리</span>
</div>
<div class="stat-item">
<span>🌍</span>
<span>다국어 지원</span>
</div>
</div>
<div class="main-content">
<div class="search-section">
<input type="text" class="search-box" placeholder="🔍 문서 제목으로 검색..." id="searchInput">
<select class="filter-select" id="categoryFilter">
<option value="">모든 카테고리</option>
{% for category_name in categories.keys() %}
<option value="{{ category_name }}">{{ category_name|replace("_", " ")|title }}</option>
{% endfor %}
</select>
</div>
{% if categories %}
{% for category_name, documents in categories.items() %}
<div class="category-section" data-category="{{ category_name }}">
<div class="category-header">
<div class="category-title">
{% if category_name == "English To Korean" %}
🇺🇸→🇰🇷 English to Korean
{% elif category_name == "Japanese To Korean" %}
🇯🇵→🇰🇷 Japanese to Korean
{% elif category_name == "Korean Only" %}
🇰🇷 Korean Documents
{% else %}
{{ category_name }}
{% endif %}
</div>
<div class="category-count">{{ documents|length }}개</div>
</div>
<div class="documents-grid">
{% for doc in documents %}
<div class="document-card" data-title="{{ doc.name.lower() }}" data-category="{{ category_name }}">
<div class="language-badge">{{ doc.language_display }}</div>
<div class="document-title">{{ doc.name }}</div>
<div class="document-meta">
<div class="meta-item">
<span>📅</span>
<span>{{ doc.created }}</span>
</div>
<div class="meta-item">
<span>📊</span>
<span>{{ doc.size }}</span>
</div>
<div class="meta-item">
<span>📁</span>
<span>{{ doc.month }}</span>
</div>
<div class="meta-item">
<span>🌐</span>
<span>{{ doc.language_type.replace("-", " ")|title }}</span>
</div>
</div>
<div class="document-actions">
<a href="{{ doc.url }}" class="btn btn-primary" target="_blank">👁️ 보기</a>
<a href="{{ doc.url }}" class="btn btn-secondary" download="{{ doc.filename }}">📥 다운로드</a>
</div>
</div>
{% endfor %}
</div>
</div>
{% endfor %}
{% else %}
<div class="empty-state">
<div class="empty-icon">📚</div>
<div class="empty-title">아직 변환된 문서가 없습니다</div>
<div class="empty-text">PDF나 텍스트 파일을 업로드하여 다국어 문서를 만들어보세요!</div>
<a href="/" class="btn btn-primary">📤 첫 번째 문서 업로드</a>
</div>
{% endif %}
</div>
</div>
<script>
// 검색 및 필터링
const searchInput = document.getElementById('searchInput');
const categoryFilter = document.getElementById('categoryFilter');
function filterDocuments() {
const query = searchInput.value.toLowerCase();
const selectedCategory = categoryFilter.value;
// 모든 카테고리 섹션 처리
document.querySelectorAll('.category-section').forEach(section => {
const categoryName = section.dataset.category;
let hasVisibleCards = false;
// 카테고리 필터 확인
if (selectedCategory && categoryName !== selectedCategory) {
section.style.display = 'none';
return;
}
// 카드 필터링
section.querySelectorAll('.document-card').forEach(card => {
const title = card.dataset.title;
const matchesSearch = !query || title.includes(query);
if (matchesSearch) {
card.style.display = 'block';
hasVisibleCards = true;
} else {
card.style.display = 'none';
}
});
// 카테고리 섹션 표시/숨김
section.style.display = hasVisibleCards ? 'block' : 'none';
});
}
searchInput.addEventListener('input', filterDocuments);
categoryFilter.addEventListener('change', filterDocuments);
</script>
</body>
</html>