bookmatch / index.html
apamplona2011's picture
undefined - Initial Deployment
e055fb3 verified
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Book Recommendation Tool</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.book-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}
.loading-spinner {
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
</head>
<body class="bg-gray-50 min-h-screen">
<div class="container mx-auto px-4 py-8">
<!-- Header -->
<header class="text-center mb-12">
<h1 class="text-4xl md:text-5xl font-bold text-indigo-800 mb-4">BookMatch</h1>
<p class="text-lg text-gray-600 max-w-2xl mx-auto">
Discover your next favorite book based on your preferences, mood, or reading history.
</p>
</header>
<!-- Main Content -->
<main>
<!-- Search Section -->
<section class="bg-white rounded-xl shadow-lg p-6 mb-12 max-w-3xl mx-auto">
<h2 class="text-2xl font-semibold text-gray-800 mb-6">What are you in the mood to read?</h2>
<div class="mb-6">
<label for="userInput" class="block text-sm font-medium text-gray-700 mb-2">
Tell us about your reading preferences:
</label>
<textarea
id="userInput"
rows="5"
class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition"
placeholder="e.g. 'I love mystery novels with strong female protagonists' or 'Looking for sci-fi books similar to Dune'"></textarea>
</div>
<div class="flex flex-col sm:flex-row gap-4">
<div class="flex-1">
<label for="genre" class="block text-sm font-medium text-gray-700 mb-2">Preferred Genre</label>
<select id="genre" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
<option value="">Any Genre</option>
<option value="fiction">Fiction</option>
<option value="mystery">Mystery</option>
<option value="sci-fi">Science Fiction</option>
<option value="fantasy">Fantasy</option>
<option value="romance">Romance</option>
<option value="historical">Historical Fiction</option>
<option value="non-fiction">Non-Fiction</option>
<option value="biography">Biography</option>
<option value="self-help">Self-Help</option>
</select>
</div>
<div class="flex-1">
<label for="length" class="block text-sm font-medium text-gray-700 mb-2">Book Length</label>
<select id="length" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
<option value="">Any Length</option>
<option value="short">Short (under 200 pages)</option>
<option value="medium">Medium (200-400 pages)</option>
<option value="long">Long (400+ pages)</option>
</select>
</div>
</div>
<div class="mt-8">
<button id="recommendBtn" class="w-full sm:w-auto px-8 py-3 bg-indigo-600 text-white font-medium rounded-lg hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition flex items-center justify-center gap-2">
<i class="fas fa-book-open"></i>
Get Recommendations
</button>
</div>
</section>
<!-- Results Section -->
<section id="resultsSection" class="hidden">
<div class="flex justify-between items-center mb-6">
<h2 class="text-2xl font-semibold text-gray-800">Recommended Books</h2>
<button id="newSearchBtn" class="text-indigo-600 hover:text-indigo-800 font-medium flex items-center gap-1">
<i class="fas fa-redo"></i>
New Search
</button>
</div>
<div id="loadingIndicator" class="hidden text-center py-12">
<div class="inline-block loading-spinner text-indigo-600 text-4xl mb-4">
<i class="fas fa-circle-notch"></i>
</div>
<p class="text-gray-600">Finding the perfect books for you...</p>
</div>
<div id="recommendationsContainer" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<!-- Book cards will be inserted here by JavaScript -->
</div>
</section>
<!-- Sample Book Card (hidden template) -->
<div id="bookCardTemplate" class="hidden">
<div class="book-card bg-white rounded-xl shadow-md overflow-hidden transition duration-300">
<div class="h-48 bg-gray-200 flex items-center justify-center">
<i class="fas fa-book text-5xl text-gray-400"></i>
</div>
<div class="p-5">
<h3 class="text-xl font-semibold text-gray-800 mb-1">Book Title</h3>
<p class="text-gray-600 text-sm mb-2">by <span class="author">Author Name</span></p>
<div class="flex flex-wrap gap-1 mb-3">
<span class="px-2 py-1 bg-indigo-100 text-indigo-800 text-xs rounded-full">Genre</span>
<span class="px-2 py-1 bg-indigo-100 text-indigo-800 text-xs rounded-full">Length</span>
</div>
<p class="text-gray-700 text-sm mb-4 line-clamp-3">Book description goes here with a brief summary of what the book is about...</p>
<div class="flex justify-between items-center">
<span class="text-sm text-gray-500">⭐ 4.5</span>
<a href="#" class="text-indigo-600 hover:text-indigo-800 text-sm font-medium">More details</a>
</div>
</div>
</div>
</div>
</main>
<!-- Footer -->
<footer class="mt-16 text-center text-gray-500 text-sm">
<p>© 2023 BookMatch. All rights reserved.</p>
</footer>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const recommendBtn = document.getElementById('recommendBtn');
const newSearchBtn = document.getElementById('newSearchBtn');
const resultsSection = document.getElementById('resultsSection');
const loadingIndicator = document.getElementById('loadingIndicator');
const recommendationsContainer = document.getElementById('recommendationsContainer');
const bookCardTemplate = document.getElementById('bookCardTemplate');
const userInput = document.getElementById('userInput');
// Sample book data (replace with your database query results)
const sampleBooks = [
{
title: "The Silent Patient",
author: "Alex Michaelides",
genre: "Psychological Thriller",
length: "Medium",
rating: 4.5,
description: "A woman shoots her husband and then never speaks another word. A criminal psychotherapist tries to unravel the mystery."
},
{
title: "Project Hail Mary",
author: "Andy Weir",
genre: "Science Fiction",
length: "Long",
rating: 4.8,
description: "An astronaut wakes up alone on a spaceship with no memory of who he is or how he got there. His mission is to save Earth from disaster."
},
{
title: "Where the Crawdads Sing",
author: "Delia Owens",
genre: "Literary Fiction",
length: "Medium",
rating: 4.7,
description: "A murder mystery and coming-of-age story set in the marshes of North Carolina, following a girl who raised herself in the wild."
},
{
title: "Atomic Habits",
author: "James Clear",
genre: "Self-Help",
length: "Medium",
rating: 4.6,
description: "A guide to building good habits and breaking bad ones, with practical strategies for making small changes that yield remarkable results."
},
{
title: "The Midnight Library",
author: "Matt Haig",
genre: "Fantasy Fiction",
length: "Medium",
rating: 4.2,
description: "Between life and death there is a library. Each book provides a chance to try another life you might have lived."
},
{
title: "Educated",
author: "Tara Westover",
genre: "Memoir",
length: "Medium",
rating: 4.7,
description: "A memoir about a woman who grew up in a survivalist family in Idaho and went on to earn a PhD from Cambridge University."
}
];
// Show recommendations
recommendBtn.addEventListener('click', function() {
const userText = userInput.value.trim();
if (!userText) {
alert("Please describe what kind of books you're looking for.");
return;
}
// Show loading indicator
resultsSection.classList.remove('hidden');
loadingIndicator.classList.remove('hidden');
recommendationsContainer.innerHTML = '';
// Simulate API/database call with timeout
setTimeout(() => {
loadingIndicator.classList.add('hidden');
// Filter books based on selected genre if any
const selectedGenre = document.getElementById('genre').value;
const selectedLength = document.getElementById('length').value;
let filteredBooks = sampleBooks;
if (selectedGenre) {
filteredBooks = filteredBooks.filter(book =>
book.genre.toLowerCase().includes(selectedGenre.toLowerCase()));
}
if (selectedLength) {
filteredBooks = filteredBooks.filter(book => {
if (selectedLength === 'short') return book.length === 'Short';
if (selectedLength === 'medium') return book.length === 'Medium';
if (selectedLength === 'long') return book.length === 'Long';
return true;
});
}
// Display recommendations
if (filteredBooks.length === 0) {
recommendationsContainer.innerHTML = `
<div class="col-span-full text-center py-8">
<i class="fas fa-book-open text-4xl text-gray-400 mb-4"></i>
<h3 class="text-xl font-medium text-gray-700 mb-2">No books found matching your criteria</h3>
<p class="text-gray-500">Try broadening your search or removing some filters.</p>
</div>
`;
} else {
filteredBooks.forEach(book => {
const card = bookCardTemplate.cloneNode(true);
card.classList.remove('hidden');
card.querySelector('h3').textContent = book.title;
card.querySelector('.author').textContent = book.author;
card.querySelector('.book-card .line-clamp-3').textContent = book.description;
// Update genre/length tags
const tagsContainer = card.querySelector('.flex-wrap');
tagsContainer.innerHTML = `
<span class="px-2 py-1 bg-indigo-100 text-indigo-800 text-xs rounded-full">${book.genre}</span>
<span class="px-2 py-1 bg-indigo-100 text-indigo-800 text-xs rounded-full">${book.length}</span>
`;
// Update rating
card.querySelector('span').textContent = `⭐ ${book.rating}`;
recommendationsContainer.appendChild(card);
});
}
}, 1500);
});
// New search button
newSearchBtn.addEventListener('click', function() {
resultsSection.classList.add('hidden');
userInput.value = '';
document.getElementById('genre').value = '';
document.getElementById('length').value = '';
userInput.focus();
});
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=apamplona2011/bookmatch" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>