feat: ecosystem consistency improvements

- Add custom 404 pages for Kits, Collabs, and TinyTorch
- Update OG images to use high-res book cover (1200x630px)
- Add PWA support with site.webmanifest and apple-touch-icon
- Enable TOC for Collabs (was disabled)
- Move subscribe-modal.js to _brand as shared asset
- Add theme-color meta tags matching project accent colors
This commit is contained in:
Vijay Janapa Reddi
2025-12-30 22:23:09 -05:00
parent fddbca7e2f
commit 9b4888f0ea
13 changed files with 776 additions and 11 deletions

View File

@@ -0,0 +1,587 @@
/**
* Subscribe Modal Component
* Elegant popup subscription form for ML Systems Textbook
*/
(function() {
'use strict';
// Create modal HTML structure
function createModalHTML() {
return `
<div id="subscribe-modal" class="modal-overlay" style="display: none;">
<div class="modal-container">
<button class="modal-close" data-close-modal aria-label="Close">&times;</button>
<div class="modal-content">
<div class="modal-header">
<div class="modal-brand-row">
<span class="modal-brand-item">📚 MLSysBook</span>
</div>
<h2 class="modal-title">Stay in the Loop</h2>
<p class="modal-subtitle">Get updates on new chapters, hands-on labs, and ML systems resources.</p>
</div>
<form id="subscribe-modal-form" class="subscribe-form" action="https://buttondown.email/api/emails/embed-subscribe/mlsysbook" method="post">
<div class="form-row">
<div class="form-group">
<label for="modal-first-name">First name</label>
<input type="text" id="modal-first-name" name="metadata__first_name" required placeholder="Jane">
</div>
<div class="form-group">
<label for="modal-last-name">Last name</label>
<input type="text" id="modal-last-name" name="metadata__last_name" required placeholder="Smith">
</div>
</div>
<div class="form-group">
<label for="modal-email">Email</label>
<input type="email" id="modal-email" name="email" required placeholder="jane@university.edu">
</div>
<div class="form-group">
<label>I am a...</label>
<div class="role-options role-options-three-compact">
<label class="role-option">
<input type="radio" name="metadata__role" value="educator" required>
<span class="role-label">👩‍🏫 Educator</span>
</label>
<label class="role-option">
<input type="radio" name="metadata__role" value="student">
<span class="role-label">🎓 Student</span>
</label>
<label class="role-option">
<input type="radio" name="metadata__role" value="industry">
<span class="role-label">💼 Industry</span>
</label>
</div>
</div>
<div class="form-group">
<label for="modal-organization">Organization <span class="optional-label">(optional)</span></label>
<input type="text" id="modal-organization" name="metadata__organization" placeholder="University or company">
</div>
<div class="form-group">
<label for="modal-motivation">What brings you here? <span class="optional-label">(optional)</span></label>
<textarea id="modal-motivation" name="metadata__motivation" rows="2" placeholder="e.g., teaching a course, learning ML systems, building edge devices..."></textarea>
</div>
<input type="hidden" name="tag" value="mlsysbook-site">
<button type="submit" class="btn btn-primary subscribe-btn">Subscribe</button>
<p class="form-note">No spam, ever. Unsubscribe anytime.</p>
</form>
<div id="modal-subscribe-success" class="subscribe-success" style="display: none;">
<div class="success-icon">🎉</div>
<h3>You're subscribed!</h3>
<p>Thanks for signing up. We'll keep you updated on new chapters, labs, and resources.</p>
</div>
</div>
</div>
</div>
`;
}
// Create modal CSS
function createModalCSS() {
const style = document.createElement('style');
style.textContent = `
/* Modal Overlay and Container */
.modal-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(15, 23, 42, 0.6);
backdrop-filter: blur(4px);
z-index: 10001;
align-items: center;
justify-content: center;
padding: 1rem;
animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
@keyframes slideUp {
from {
opacity: 0;
transform: translateY(20px) scale(0.98);
}
to {
opacity: 1;
transform: translateY(0) scale(1);
}
}
.modal-container {
background: white;
border-radius: 16px;
max-width: 440px;
width: 100%;
max-height: 90vh;
overflow-y: auto;
position: relative;
box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1), 0 0 0 1px rgba(0,0,0,0.05);
animation: slideUp 0.3s ease;
margin: auto;
}
.modal-close {
position: absolute;
top: 1rem;
right: 1rem;
width: 36px;
height: 36px;
border: none;
background: #f8fafc;
border-radius: 50%;
font-size: 1.5rem;
color: #64748b;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s ease;
z-index: 10;
line-height: 1;
}
.modal-close:hover {
background: white;
color: #0f172a;
transform: scale(1.05);
}
.modal-content {
padding: 2rem 2.5rem 2.5rem 2.5rem;
}
.modal-header {
text-align: center;
margin-bottom: 1.5rem;
display: flex;
flex-direction: column;
align-items: center;
}
.modal-brand-row {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
margin-bottom: 1rem;
}
.modal-brand-item {
font-size: 0.8rem;
font-weight: 600;
color: #374151;
background: #f3f4f6;
padding: 0.3rem 0.6rem;
border-radius: 5px;
white-space: nowrap;
}
.modal-brand-plus {
font-size: 0.9rem;
font-weight: 300;
color: #9ca3af;
}
.modal-title {
font-size: 1.5rem;
font-weight: 700;
color: #0f172a;
margin: 0 0 0.4rem 0;
line-height: 1.2;
width: 100%;
}
.modal-subtitle {
font-size: 0.9rem;
color: #64748b;
margin: 0;
line-height: 1.5;
max-width: 320px;
}
/* Form Styles */
.subscribe-form {
display: flex;
flex-direction: column;
gap: 1.25rem;
}
.form-row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 0.75rem;
}
.form-row .form-group {
min-width: 0;
}
.form-row .form-group input {
width: 100%;
box-sizing: border-box;
}
.form-group {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.form-group label {
font-size: 0.9rem;
font-weight: 600;
color: #0f172a;
}
.optional-label {
font-weight: 400;
color: #64748b;
}
.form-group input[type="text"],
.form-group input[type="email"],
.form-group textarea {
padding: 0.875rem 1rem;
border: 1px solid #cbd5e1;
border-radius: 8px;
font-size: 1rem;
transition: all 0.2s ease;
background: #f8fafc;
font-family: inherit;
}
.form-group textarea {
resize: vertical;
min-height: 60px;
}
.form-group input[type="text"]:focus,
.form-group input[type="email"]:focus,
.form-group textarea:focus {
outline: none;
border-color: #3b82f6;
background: white;
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.form-group input::placeholder,
.form-group textarea::placeholder {
color: #94a3b8;
}
/* Role Options - compact style */
.role-options {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 0.75rem;
}
.role-options-three-compact {
grid-template-columns: repeat(3, 1fr);
}
.role-option {
cursor: pointer;
}
.role-option input[type="radio"] {
position: absolute;
opacity: 0;
width: 0;
height: 0;
}
.role-label {
display: flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
padding: 0.75rem 1rem;
border: 2px solid #e2e8f0;
border-radius: 8px;
font-size: 0.9rem;
font-weight: 500;
color: #475569;
transition: all 0.2s ease;
background: #f8fafc;
}
.role-options-three-compact .role-label {
padding: 0.625rem 0.5rem;
font-size: 0.8rem;
text-align: center;
}
.role-option input[type="radio"]:checked + .role-label {
border-color: #3b82f6;
background: rgba(59, 130, 246, 0.08);
color: #3b82f6;
}
.role-option:hover .role-label {
border-color: #cbd5e1;
background: white;
}
/* Button Styles */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
padding: 0.75rem 1.5rem;
border-radius: 8px;
text-decoration: none;
font-weight: 600;
font-size: 0.95rem;
transition: all 0.2s ease;
border: none;
cursor: pointer;
font-family: inherit;
}
.btn-primary {
background: #3b82f6;
color: white;
}
.btn-primary:hover {
background: #1e3a8a;
transform: translateY(-1px);
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}
.subscribe-btn {
width: 100%;
padding: 1rem;
font-size: 1rem;
margin-top: 0.5rem;
}
.form-note {
text-align: center;
font-size: 0.85rem;
color: #64748b;
margin: 0;
}
/* Success Message */
.subscribe-success {
text-align: center;
padding: 2rem 1rem;
}
.success-icon {
font-size: 3rem;
margin-bottom: 1rem;
}
.subscribe-success h3 {
font-size: 1.5rem;
font-weight: 600;
color: #0f172a;
margin-bottom: 0.5rem;
}
.subscribe-success p {
color: #475569;
font-size: 1rem;
}
/* Dark mode support */
body.quarto-dark .modal-container {
background: #1e293b;
}
body.quarto-dark .modal-close {
background: #0f172a;
color: #94a3b8;
}
body.quarto-dark .modal-close:hover {
background: #334155;
color: #f1f5f9;
}
body.quarto-dark .modal-brand-item {
background: #334155;
color: #e2e8f0;
}
body.quarto-dark .modal-brand-plus {
color: #64748b;
}
body.quarto-dark .modal-title,
body.quarto-dark .form-group label,
body.quarto-dark .subscribe-success h3 {
color: #f1f5f9;
}
body.quarto-dark .modal-subtitle,
body.quarto-dark .subscribe-success p {
color: #cbd5e1;
}
body.quarto-dark .form-group input[type="text"],
body.quarto-dark .form-group input[type="email"],
body.quarto-dark .form-group textarea {
background: #0f172a;
border-color: #334155;
color: #f1f5f9;
}
body.quarto-dark .role-label {
background: #0f172a;
border-color: #334155;
color: #cbd5e1;
}
body.quarto-dark .role-option input[type="radio"]:checked + .role-label {
border-color: #3b82f6;
background: rgba(59, 130, 246, 0.15);
color: #60a5fa;
}
/* Responsive */
@media (max-width: 640px) {
.modal-content {
padding: 2rem 1.5rem;
}
.form-row {
grid-template-columns: 1fr;
}
.role-options-three-compact {
grid-template-columns: repeat(3, 1fr);
}
}
`;
return style;
}
// Initialize modal
function initModal() {
// Add CSS
document.head.appendChild(createModalCSS());
// Add HTML
const modalDiv = document.createElement('div');
modalDiv.innerHTML = createModalHTML();
document.body.appendChild(modalDiv.firstElementChild);
const modal = document.getElementById('subscribe-modal');
const form = document.getElementById('subscribe-modal-form');
const success = document.getElementById('modal-subscribe-success');
// Open modal function
window.openModal = function() {
modal.style.display = 'flex';
document.body.style.overflow = 'hidden';
// Focus first input
setTimeout(() => {
const firstInput = document.getElementById('modal-first-name');
if (firstInput) firstInput.focus();
}, 100);
};
// Close modal function
window.closeModal = function() {
modal.style.display = 'none';
document.body.style.overflow = '';
// Reset form after closing
setTimeout(() => {
form.style.display = 'flex';
form.reset();
success.style.display = 'none';
}, 300);
};
// Close on overlay click
modal.addEventListener('click', (e) => {
if (e.target === modal) {
closeModal();
}
});
// Close button click
const closeBtn = modal.querySelector('[data-close-modal]');
if (closeBtn) {
closeBtn.addEventListener('click', closeModal);
}
// Close on Escape key
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape' && modal.style.display === 'flex') {
closeModal();
}
});
// Handle form submission
form.addEventListener('submit', function() {
// Let the form submit to Buttondown
setTimeout(() => {
form.style.display = 'none';
success.style.display = 'block';
// Close modal after 5 seconds
setTimeout(closeModal, 5000);
}, 100);
});
// Check if URL has #subscribe hash on page load - auto-open modal
if (window.location.hash === '#subscribe') {
// Small delay to ensure page is fully loaded
setTimeout(() => {
openModal();
}, 300);
}
// Also listen for hash changes (e.g., user clicks back/forward)
window.addEventListener('hashchange', function() {
if (window.location.hash === '#subscribe') {
openModal();
}
});
// Intercept navbar subscribe link
setTimeout(() => {
// Look for subscribe links in navbar
const subscribeSelectors = [
'a[href*="buttondown.email/mlsysbook"]',
'a[href="#subscribe"]',
'a[href*="subscribe"]',
'#navbar-subscribe-btn',
'.subscribe-link'
];
subscribeSelectors.forEach(selector => {
try {
const links = document.querySelectorAll(selector);
links.forEach(link => {
link.addEventListener('click', function(e) {
e.preventDefault();
openModal();
});
});
} catch (err) {
// Selector not supported, continue
}
});
}, 1000);
}
// Initialize when DOM is ready
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initModal);
} else {
initModal();
}
})();

19
_brand/site.webmanifest Normal file
View File

@@ -0,0 +1,19 @@
{
"name": "Machine Learning Systems",
"short_name": "MLSysBook",
"description": "A comprehensive textbook on machine learning systems, covering hardware, software, and deployment.",
"start_url": "/book/",
"scope": "/",
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#A51C30",
"icons": [
{
"src": "/assets/images/favicon.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "any maskable"
}
],
"categories": ["education", "books", "technology"]
}

View File

@@ -543,6 +543,9 @@ format:
<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=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<link rel="manifest" href="/site.webmanifest">
<link rel="apple-touch-icon" href="/assets/images/icons/favicon.png">
<meta name="theme-color" content="#A51C30">
<script type="module" src="/tools/scripts/socratiQ/bundle.js" defer></script>
<script src="/assets/scripts/sidebar-auto-collapse.js" defer></script>

View File

@@ -0,0 +1,19 @@
{
"name": "Machine Learning Systems Textbook",
"short_name": "MLSysBook",
"description": "A comprehensive textbook on machine learning systems, covering hardware, software, and deployment.",
"start_url": "/book/",
"scope": "/book/",
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#A51C30",
"icons": [
{
"src": "assets/images/icons/favicon.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "any maskable"
}
],
"categories": ["education", "books", "technology"]
}

31
collabs/404.qmd Normal file
View File

@@ -0,0 +1,31 @@
---
title: "Page Not Found"
---
# 💡 Oops! Simulation Error 404
The page you're looking for seems to have drifted into an unexplored region of the parameter space...
## 🧭 **Navigation Help**
**Quick Links:**
- [🏠 Return Home](/)
- [📖 Main Textbook](../book/)
- [🔧 Hardware Kits](../kits/)
- [🔥 TinyTorch](../tinytorch/)
## 🔍 **Search the Site**
Use the search box in the navbar to find what you're looking for!
## 🐛 **Still Lost?**
If you believe this is an error:
- [📝 Report this issue](https://github.com/harvard-edge/cs249r_book/issues) on GitHub
- [💬 Start a discussion](https://github.com/harvard-edge/cs249r_book/discussions) with the community
---
*"In collaborative learning, getting lost is just the first step toward discovery!"* 🧪

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

View File

@@ -19,12 +19,12 @@ website:
open-graph:
locale: en_US
site-name: "Machine Learning Systems"
image: assets/images/favicon.png
image-width: 512
image-height: 512
image: assets/images/covers/cover-hardcover-book.png
image-width: 1200
image-height: 630
twitter-card:
card-style: summary
image: assets/images/favicon.png
card-style: summary_large_image
image: assets/images/covers/cover-hardcover-book.png
page-navigation: true
reader-mode: false
@@ -118,7 +118,8 @@ format:
- assets/styles/style.scss
- assets/styles/dark-mode.scss
respect-user-color-scheme: true
toc: false
toc: true
toc-depth: 3
number-sections: false
code-copy: true
code-overflow: wrap
@@ -131,6 +132,9 @@ format:
<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=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<link rel="manifest" href="/site.webmanifest">
<link rel="apple-touch-icon" href="/assets/images/favicon.png">
<meta name="theme-color" content="#7D3C98">
include-after-body:
- text: |
<script src="assets/scripts/subscribe-modal.js" defer></script>

19
collabs/site.webmanifest Normal file
View File

@@ -0,0 +1,19 @@
{
"name": "Co-Labs - ML Systems",
"short_name": "Co-Labs",
"description": "Interactive ML simulations and collaborative labs for exploring machine learning systems.",
"start_url": "/collabs/",
"scope": "/collabs/",
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#7D3C98",
"icons": [
{
"src": "assets/images/favicon.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "any maskable"
}
],
"categories": ["education", "technology", "simulation"]
}

33
kits/404.qmd Normal file
View File

@@ -0,0 +1,33 @@
---
title: "Page Not Found"
---
# 🔧 Oops! Hardware Error 404
The page you're looking for seems to have escaped the breadboard and is hiding somewhere in the circuit...
## 🧭 **Navigation Help**
**Quick Links:**
- [🏠 Return Home](/)
- [📖 Getting Started](/contents/getting-started.html)
- [🔬 Arduino Nicla Vision](/contents/arduino/nicla_vision/nicla_vision.html)
- [📱 Seeed XIAO ESP32S3](/contents/seeed/xiao_esp32s3/xiao_esp32s3.html)
- [👁️ Grove Vision AI V2](/contents/seeed/grove_vision_ai_v2/grove_vision_ai_v2.html)
- [🍓 Raspberry Pi](/contents/raspi/raspi.html)
## 🔍 **Search the Site**
Use the search box in the sidebar or navbar to find what you're looking for!
## 🐛 **Still Lost?**
If you believe this is an error:
- [📝 Report this issue](https://github.com/harvard-edge/cs249r_book/issues) on GitHub
- [💬 Start a discussion](https://github.com/harvard-edge/cs249r_book/discussions) with the community
---
*"In hardware, there are no bugs, only unexpected features waiting to be debugged!"* 🔌

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

View File

@@ -19,12 +19,12 @@ website:
open-graph:
locale: en_US
site-name: "Machine Learning Systems"
image: assets/images/favicon.png
image-width: 512
image-height: 512
image: assets/images/covers/cover-hardcover-book.png
image-width: 1200
image-height: 630
twitter-card:
card-style: summary
image: assets/images/favicon.png
card-style: summary_large_image
image: assets/images/covers/cover-hardcover-book.png
page-navigation: true
reader-mode: false
@@ -201,6 +201,9 @@ format:
<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=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<link rel="manifest" href="/site.webmanifest">
<link rel="apple-touch-icon" href="/assets/images/favicon.png">
<meta name="theme-color" content="#148F77">
include-after-body:
- text: |
<script src="assets/scripts/subscribe-modal.js" defer></script>

19
kits/site.webmanifest Normal file
View File

@@ -0,0 +1,19 @@
{
"name": "Hardware Kits - ML Systems",
"short_name": "HW Kits",
"description": "Hands-on hardware labs and kits for machine learning systems education.",
"start_url": "/kits/",
"scope": "/kits/",
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#148F77",
"icons": [
{
"src": "assets/images/favicon.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "any maskable"
}
],
"categories": ["education", "technology", "hardware"]
}

28
tinytorch/site/404.md Normal file
View File

@@ -0,0 +1,28 @@
# 🔥 Oops! Torch Error 404
The page you're looking for seems to have vanished into the gradient descent and got stuck in a local minimum...
## 🧭 Navigation Help
**Quick Links:**
- [🏠 Return Home](intro)
- [📚 Module 1: Foundations](modules/1_ABOUT)
- [🏗️ Module 2: Architecture](modules/2_ABOUT)
- [⚡ Module 3: Performance](modules/3_ABOUT)
- [📖 Main Textbook](../book/)
## 🔍 Search the Site
Use the search box in the sidebar to find what you're looking for!
## 🐛 Still Lost?
If you believe this is an error:
- [📝 Report this issue](https://github.com/harvard-edge/cs249r_book/issues) on GitHub
- [💬 Start a discussion](https://github.com/harvard-edge/cs249r_book/discussions) with the community
---
*"In deep learning, every error is just a gradient pointing toward the right answer!"* 🧠