517 lines
16 KiB
HTML
517 lines
16 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Audiobook Library</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Playfair+Display:wght@600;700;900&display=swap" rel="stylesheet">
|
|
|
|
<style>
|
|
* { box-sizing: border-box; }
|
|
|
|
body {
|
|
font-family: 'Inter', sans-serif;
|
|
margin: 0;
|
|
background: #f5e9d6;
|
|
min-height: 100vh;
|
|
color: #3e2723;
|
|
}
|
|
|
|
/* Header */
|
|
.library-header {
|
|
background: linear-gradient(135deg, #4a2c2a 0%, #6b4226 100%);
|
|
color: #f5e9d6;
|
|
padding: 24px 32px;
|
|
box-shadow: 0 4px 20px rgba(0,0,0,0.15);
|
|
position: sticky;
|
|
top: 0;
|
|
z-index: 100;
|
|
}
|
|
|
|
.header-container {
|
|
max-width: 1400px;
|
|
margin: 0 auto;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
gap: 24px;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.library-title {
|
|
font-family: 'Playfair Display', serif;
|
|
font-weight: 900;
|
|
font-size: 1.8rem;
|
|
margin: 0;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
}
|
|
|
|
.library-title i { color: #f0c97a; }
|
|
|
|
.header-actions {
|
|
display: flex;
|
|
gap: 12px;
|
|
align-items: center;
|
|
}
|
|
|
|
.search-box {
|
|
background: rgba(255,255,255,0.1);
|
|
border: 1.5px solid rgba(255,255,255,0.25);
|
|
color: #f5e9d6;
|
|
border-radius: 24px;
|
|
padding: 8px 18px 8px 40px;
|
|
min-width: 240px;
|
|
font-size: 0.9rem;
|
|
position: relative;
|
|
}
|
|
|
|
.search-wrapper {
|
|
position: relative;
|
|
}
|
|
|
|
.search-wrapper i {
|
|
position: absolute;
|
|
left: 14px;
|
|
top: 50%;
|
|
transform: translateY(-50%);
|
|
color: rgba(245,233,214,0.6);
|
|
font-size: 0.9rem;
|
|
}
|
|
|
|
.search-box::placeholder { color: rgba(245,233,214,0.5); }
|
|
.search-box:focus {
|
|
outline: none;
|
|
border-color: #f0c97a;
|
|
background: rgba(255,255,255,0.15);
|
|
}
|
|
|
|
.btn-login-link {
|
|
background: rgba(255,255,255,0.15);
|
|
border: 1.5px solid rgba(255,255,255,0.3);
|
|
color: #f5e9d6;
|
|
padding: 8px 20px;
|
|
border-radius: 24px;
|
|
font-weight: 600;
|
|
font-size: 0.88rem;
|
|
text-decoration: none;
|
|
transition: all 0.2s;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
}
|
|
|
|
.btn-login-link:hover {
|
|
background: rgba(255,255,255,0.25);
|
|
color: #fff;
|
|
}
|
|
|
|
/* Bookcase container */
|
|
.bookcase-container {
|
|
max-width: 1400px;
|
|
margin: 0 auto;
|
|
padding: 40px 24px;
|
|
}
|
|
|
|
.library-intro {
|
|
text-align: center;
|
|
margin-bottom: 32px;
|
|
}
|
|
|
|
.library-intro h2 {
|
|
font-family: 'Playfair Display', serif;
|
|
font-size: 2.2rem;
|
|
font-weight: 700;
|
|
color: #4a2c2a;
|
|
margin-bottom: 8px;
|
|
}
|
|
|
|
.library-intro p {
|
|
color: #6b4226;
|
|
font-size: 1.05rem;
|
|
opacity: 0.85;
|
|
}
|
|
|
|
/* Bookcase shelf */
|
|
.bookcase {
|
|
background: linear-gradient(180deg, #c8a87b 0%, #a67c52 100%);
|
|
border-radius: 16px;
|
|
padding: 24px;
|
|
box-shadow: 0 12px 40px rgba(74,44,42,0.3), inset 0 2px 4px rgba(255,255,255,0.2);
|
|
position: relative;
|
|
}
|
|
|
|
.shelf {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
|
|
gap: 24px;
|
|
padding: 20px 16px 36px;
|
|
position: relative;
|
|
border-bottom: 8px solid #6b4226;
|
|
box-shadow: 0 6px 0 #5a3520, 0 8px 12px rgba(0,0,0,0.2);
|
|
margin-bottom: 24px;
|
|
border-radius: 6px;
|
|
}
|
|
|
|
.shelf:last-child {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
/* Book card */
|
|
.book-card {
|
|
cursor: pointer;
|
|
transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
|
|
transform-origin: bottom center;
|
|
position: relative;
|
|
}
|
|
|
|
.book-card:hover {
|
|
transform: translateY(-12px) scale(1.04);
|
|
}
|
|
|
|
.book-cover {
|
|
width: 100%;
|
|
aspect-ratio: 2 / 3;
|
|
border-radius: 4px 8px 8px 4px;
|
|
overflow: hidden;
|
|
box-shadow:
|
|
-2px 2px 0 rgba(0,0,0,0.1),
|
|
-4px 4px 0 rgba(0,0,0,0.08),
|
|
4px 6px 16px rgba(0,0,0,0.3);
|
|
position: relative;
|
|
background: linear-gradient(135deg, #2c3e50, #4a6278);
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: flex-end;
|
|
padding: 16px;
|
|
color: white;
|
|
}
|
|
|
|
.book-cover::before {
|
|
content: '';
|
|
position: absolute;
|
|
left: 0;
|
|
top: 0;
|
|
bottom: 0;
|
|
width: 4px;
|
|
background: linear-gradient(90deg, rgba(0,0,0,0.3), transparent);
|
|
}
|
|
|
|
.book-cover img {
|
|
position: absolute;
|
|
inset: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: cover;
|
|
z-index: 0;
|
|
}
|
|
|
|
.book-cover-overlay {
|
|
position: absolute;
|
|
inset: 0;
|
|
background: linear-gradient(to bottom, transparent 40%, rgba(0,0,0,0.85));
|
|
z-index: 1;
|
|
}
|
|
|
|
.book-cover-content {
|
|
position: relative;
|
|
z-index: 2;
|
|
}
|
|
|
|
.book-cover-default {
|
|
background: linear-gradient(135deg, #2c3e50 0%, #4a6278 100%);
|
|
}
|
|
|
|
.book-cover-default::after {
|
|
content: '';
|
|
position: absolute;
|
|
top: 12px;
|
|
right: 12px;
|
|
left: 12px;
|
|
bottom: 12px;
|
|
border: 2px solid rgba(255,255,255,0.2);
|
|
border-radius: 2px;
|
|
z-index: 1;
|
|
}
|
|
|
|
.book-title {
|
|
font-family: 'Playfair Display', serif;
|
|
font-size: 1rem;
|
|
font-weight: 700;
|
|
line-height: 1.25;
|
|
margin-bottom: 4px;
|
|
text-shadow: 0 2px 4px rgba(0,0,0,0.5);
|
|
display: -webkit-box;
|
|
-webkit-line-clamp: 3;
|
|
-webkit-box-orient: vertical;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.book-author {
|
|
font-size: 0.75rem;
|
|
opacity: 0.85;
|
|
font-weight: 500;
|
|
font-style: italic;
|
|
}
|
|
|
|
.book-meta {
|
|
margin-top: 12px;
|
|
padding: 0 4px;
|
|
text-align: center;
|
|
}
|
|
|
|
.book-meta-title {
|
|
font-size: 0.85rem;
|
|
font-weight: 600;
|
|
color: #4a2c2a;
|
|
margin-bottom: 2px;
|
|
display: -webkit-box;
|
|
-webkit-line-clamp: 2;
|
|
-webkit-box-orient: vertical;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.book-meta-stats {
|
|
font-size: 0.72rem;
|
|
color: #6b4226;
|
|
opacity: 0.7;
|
|
display: flex;
|
|
justify-content: center;
|
|
gap: 8px;
|
|
align-items: center;
|
|
}
|
|
|
|
.book-meta-stats i { font-size: 0.7rem; }
|
|
|
|
/* Empty state */
|
|
.empty-state {
|
|
text-align: center;
|
|
padding: 80px 24px;
|
|
color: #6b4226;
|
|
}
|
|
|
|
.empty-state i {
|
|
font-size: 4rem;
|
|
opacity: 0.4;
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.empty-state h3 {
|
|
font-family: 'Playfair Display', serif;
|
|
font-weight: 700;
|
|
margin-bottom: 8px;
|
|
}
|
|
|
|
/* Loading */
|
|
.loading-state {
|
|
text-align: center;
|
|
padding: 80px 24px;
|
|
color: #6b4226;
|
|
}
|
|
|
|
/* Responsive */
|
|
@media (max-width: 768px) {
|
|
.header-container {
|
|
flex-direction: column;
|
|
align-items: stretch;
|
|
}
|
|
|
|
.header-actions {
|
|
justify-content: space-between;
|
|
}
|
|
|
|
.search-box {
|
|
min-width: 0;
|
|
width: 100%;
|
|
}
|
|
|
|
.shelf {
|
|
grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
|
|
gap: 16px;
|
|
padding: 16px 12px 28px;
|
|
}
|
|
|
|
.library-intro h2 {
|
|
font-size: 1.6rem;
|
|
}
|
|
|
|
.bookcase {
|
|
padding: 16px;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 480px) {
|
|
.shelf {
|
|
grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
|
|
}
|
|
|
|
.book-title { font-size: 0.85rem; }
|
|
.book-author { font-size: 0.7rem; }
|
|
}
|
|
|
|
/* Footer */
|
|
.library-footer {
|
|
text-align: center;
|
|
padding: 32px 24px;
|
|
color: #6b4226;
|
|
font-size: 0.85rem;
|
|
opacity: 0.7;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<header class="library-header">
|
|
<div class="header-container">
|
|
<h1 class="library-title">
|
|
<i class="bi bi-book-half"></i>
|
|
Audiobook Library
|
|
</h1>
|
|
<div class="header-actions">
|
|
<div class="search-wrapper">
|
|
<i class="bi bi-search"></i>
|
|
<input type="text" class="search-box" id="searchInput"
|
|
placeholder="Search books..." oninput="filterBooks(this.value)">
|
|
</div>
|
|
<a href="/login" class="btn-login-link">
|
|
<i class="bi bi-person-circle"></i>
|
|
<span>Sign In</span>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<main class="bookcase-container">
|
|
<div class="library-intro">
|
|
<h2>Discover Stories That Speak</h2>
|
|
<p>Browse our collection of interactive audiobooks</p>
|
|
</div>
|
|
|
|
<div id="bookcaseContainer">
|
|
<div class="loading-state">
|
|
<div class="spinner-border" role="status" style="color: #6b4226;"></div>
|
|
<p class="mt-3">Loading library...</p>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<footer class="library-footer">
|
|
<p>Powered by Audiobook Maker Pro v4.2</p>
|
|
</footer>
|
|
|
|
<script>
|
|
let allBooks = [];
|
|
|
|
async function loadBooks() {
|
|
try {
|
|
const resp = await fetch('/api/public/books');
|
|
const data = await resp.json();
|
|
allBooks = data.books || [];
|
|
renderBookcase(allBooks);
|
|
} catch (e) {
|
|
document.getElementById('bookcaseContainer').innerHTML = `
|
|
<div class="empty-state">
|
|
<i class="bi bi-exclamation-circle"></i>
|
|
<h3>Failed to load library</h3>
|
|
<p>Please refresh the page to try again.</p>
|
|
</div>
|
|
`;
|
|
}
|
|
}
|
|
|
|
function renderBookcase(books) {
|
|
const container = document.getElementById('bookcaseContainer');
|
|
|
|
if (!books || books.length === 0) {
|
|
container.innerHTML = `
|
|
<div class="empty-state">
|
|
<i class="bi bi-book"></i>
|
|
<h3>No books yet</h3>
|
|
<p>The library is being curated. Check back soon!</p>
|
|
</div>
|
|
`;
|
|
return;
|
|
}
|
|
|
|
// Group books into shelves (6 books per shelf approx)
|
|
const booksPerShelf = 6;
|
|
const shelves = [];
|
|
for (let i = 0; i < books.length; i += booksPerShelf) {
|
|
shelves.push(books.slice(i, i + booksPerShelf));
|
|
}
|
|
|
|
let html = '<div class="bookcase">';
|
|
|
|
for (const shelf of shelves) {
|
|
html += '<div class="shelf">';
|
|
for (const book of shelf) {
|
|
html += renderBookCard(book);
|
|
}
|
|
html += '</div>';
|
|
}
|
|
|
|
html += '</div>';
|
|
container.innerHTML = html;
|
|
}
|
|
|
|
function renderBookCard(book) {
|
|
const thumbnailHtml = book.thumbnail_data
|
|
? `<img src="data:image/${book.thumbnail_format};base64,${book.thumbnail_data}" alt="${escapeHtml(book.name)}">
|
|
<div class="book-cover-overlay"></div>`
|
|
: '';
|
|
|
|
const coverClass = book.thumbnail_data ? '' : 'book-cover-default';
|
|
const author = book.author || 'Unknown Author';
|
|
|
|
return `
|
|
<div class="book-card" onclick="openBook(${book.id})" title="${escapeHtml(book.name)}">
|
|
<div class="book-cover ${coverClass}">
|
|
${thumbnailHtml}
|
|
<div class="book-cover-content">
|
|
<div class="book-title">${escapeHtml(book.name)}</div>
|
|
<div class="book-author">by ${escapeHtml(author)}</div>
|
|
</div>
|
|
</div>
|
|
<!--<div class="book-meta">
|
|
<div class="book-meta-stats">
|
|
<span><i class="bi bi-bookmark"></i> ${book.chapter_count} ch</span>
|
|
<span><i class="bi bi-eye"></i> ${book.view_count}</span>
|
|
</div>
|
|
</div>-->
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
function openBook(bookId) {
|
|
window.location.href = `/read/${bookId}`;
|
|
}
|
|
|
|
function filterBooks(query) {
|
|
query = query.toLowerCase().trim();
|
|
if (!query) {
|
|
renderBookcase(allBooks);
|
|
return;
|
|
}
|
|
const filtered = allBooks.filter(b =>
|
|
b.name.toLowerCase().includes(query) ||
|
|
(b.author && b.author.toLowerCase().includes(query)) ||
|
|
(b.description && b.description.toLowerCase().includes(query))
|
|
);
|
|
renderBookcase(filtered);
|
|
}
|
|
|
|
function escapeHtml(text) {
|
|
const div = document.createElement('div');
|
|
div.textContent = text || '';
|
|
return div.innerHTML;
|
|
}
|
|
|
|
loadBooks();
|
|
</script>
|
|
</body>
|
|
</html>
|