feat: sidebar de navegación por módulos + soporte video local

This commit is contained in:
Ricardo Monla
2026-05-03 02:32:33 -03:00
parent 83aef9bdab
commit cfa48d9552
+335 -115
View File
@@ -621,23 +621,191 @@ function generarHTML(datos) {
for (const s of m.secciones) totalTemas += s.temas.length; for (const s of m.secciones) totalTemas += s.temas.length;
} }
// Leer mapa de videos descargados si existe
const mapaVideosPath = path.join(__dirname, ".mapa_videos.json");
let videosMap = {};
try {
if (fs.existsSync(mapaVideosPath)) {
videosMap = JSON.parse(fs.readFileSync(mapaVideosPath, "utf-8"));
}
} catch { /* sin mapa */ }
const css = ` const css = `
* { margin: 0; padding: 0; box-sizing: border-box; } * { margin: 0; padding: 0; box-sizing: border-box; }
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');
:root {
--sidebar-w: 280px;
--color-bg: #f5f3ef;
--color-surface: #ffffff;
--color-primary: #1a5276;
--color-primary-dark: #0d2b3e;
--color-accent: #2980b9;
--color-text: #2c2c2c;
--color-text-muted: #6b7280;
}
body { body {
font-family: 'Segoe UI', 'Georgia', 'Times New Roman', serif; font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
background: #f5f3ef; background: var(--color-bg);
color: #2c2c2c; color: var(--color-text);
line-height: 1.8; line-height: 1.8;
font-size: 17px; font-size: 16px;
}
/* ── LAYOUT ── */
.app-layout {
display: flex;
min-height: 100vh;
}
/* ── SIDEBAR ── */
.sidebar {
width: var(--sidebar-w);
background: var(--color-primary-dark);
color: rgba(255,255,255,0.85);
position: fixed;
top: 0;
left: 0;
bottom: 0;
overflow-y: auto;
z-index: 100;
display: flex;
flex-direction: column;
transition: transform 0.3s ease;
}
.sidebar-header {
padding: 1.5rem 1.2rem 1rem;
border-bottom: 1px solid rgba(255,255,255,0.08);
flex-shrink: 0;
}
.sidebar-header .logo {
font-size: 1.8rem;
margin-bottom: 0.3rem;
}
.sidebar-header h1 {
font-size: 0.95rem;
font-weight: 700;
line-height: 1.3;
margin-bottom: 0.2rem;
}
.sidebar-header p {
font-size: 0.72rem;
opacity: 0.5;
font-weight: 400;
}
.sidebar-stats {
display: flex;
gap: 0.5rem;
padding: 0.8rem 1.2rem;
border-bottom: 1px solid rgba(255,255,255,0.08);
flex-shrink: 0;
}
.sidebar-stats .stat {
background: rgba(255,255,255,0.08);
padding: 0.3rem 0.6rem;
border-radius: 6px;
font-size: 0.7rem;
font-weight: 500;
flex: 1;
text-align: center;
}
.sidebar-nav {
flex: 1;
overflow-y: auto;
padding: 0.8rem 0;
}
.sidebar-nav .nav-modulo {
padding: 0.6rem 1.2rem 0.3rem;
font-size: 0.68rem;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 1px;
color: rgba(255,255,255,0.4);
}
.sidebar-nav a {
display: block;
padding: 0.45rem 1.2rem 0.45rem 1.6rem;
color: rgba(255,255,255,0.7);
text-decoration: none;
font-size: 0.82rem;
font-weight: 400;
transition: all 0.2s;
border-left: 3px solid transparent;
}
.sidebar-nav a:hover {
background: rgba(255,255,255,0.06);
color: white;
border-left-color: var(--color-accent);
}
.sidebar-nav a.active {
background: rgba(41,128,185,0.15);
color: white;
border-left-color: var(--color-accent);
font-weight: 600;
}
.sidebar-nav .nav-count {
font-size: 0.65rem;
opacity: 0.4;
margin-left: 0.3rem;
}
/* ── HAMBURGER ── */
.hamburger {
display: none;
position: fixed;
top: 1rem;
left: 1rem;
z-index: 200;
background: var(--color-primary-dark);
border: none;
color: white;
width: 44px;
height: 44px;
border-radius: 10px;
font-size: 1.4rem;
cursor: pointer;
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
transition: transform 0.2s;
}
.hamburger:hover { transform: scale(1.05); }
.sidebar-overlay {
display: none;
position: fixed;
inset: 0;
background: rgba(0,0,0,0.4);
z-index: 99;
}
/* ── MAIN CONTENT ── */
.main-content {
flex: 1;
margin-left: var(--sidebar-w);
min-width: 0;
} }
/* ── PORTADA ── */ /* ── PORTADA ── */
.portada { .portada {
background: linear-gradient(135deg, #0d2b3e 0%, #1a5276 50%, #2980b9 100%); background: linear-gradient(135deg, var(--color-primary-dark) 0%, var(--color-primary) 50%, var(--color-accent) 100%);
color: white; color: white;
padding: 5rem 2rem; padding: 4rem 2rem;
text-align: center; text-align: center;
min-height: 70vh; min-height: 50vh;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
@@ -645,141 +813,102 @@ body {
position: relative; position: relative;
overflow: hidden; overflow: hidden;
} }
.portada::before { .portada::before {
content: ''; content: '';
position: absolute; position: absolute;
top: -50%; top: -50%; left: -50%;
left: -50%; width: 200%; height: 200%;
width: 200%;
height: 200%;
background: radial-gradient(circle at 30% 70%, rgba(255,255,255,0.05) 0%, transparent 50%); background: radial-gradient(circle at 30% 70%, rgba(255,255,255,0.05) 0%, transparent 50%);
pointer-events: none; pointer-events: none;
} }
.portada h1 { font-size: 2.6rem; margin-bottom: 0.6rem; font-weight: 700; letter-spacing: -0.5px; }
.portada h2 { font-size: 1.3rem; font-weight: 300; opacity: 0.9; margin-bottom: 1.5rem; }
.portada p { opacity: 0.7; font-size: 0.95rem; }
.portada .stats {
margin-top: 2rem;
display: flex;
gap: 1.5rem;
flex-wrap: wrap;
justify-content: center;
}
.portada .stat {
background: rgba(255,255,255,0.12);
backdrop-filter: blur(4px);
padding: 0.6rem 1.4rem;
border-radius: 8px;
font-size: 0.9rem;
border: 1px solid rgba(255,255,255,0.08);
}
.portada .icono-grande {
font-size: 4rem;
margin-bottom: 1rem;
opacity: 0.3;
}
/* ── ÍNDICE ── */ .portada .icono-grande { font-size: 4rem; margin-bottom: 1rem; opacity: 0.3; }
.indice { .portada h1 { font-size: 2.4rem; margin-bottom: 0.5rem; font-weight: 800; letter-spacing: -1px; }
background: white; .portada h2 { font-size: 1.15rem; font-weight: 300; opacity: 0.8; margin-bottom: 1rem; }
padding: 2.5rem; .portada p { opacity: 0.6; font-size: 0.9rem; }
max-width: 820px;
margin: 0 auto;
border-bottom: 1px solid #e8e4df;
}
.indice h2 {
color: #0d2b3e;
margin-bottom: 1.5rem;
font-size: 1.3rem;
display: flex;
align-items: center;
gap: 0.5rem;
}
.indice ul { list-style: none; }
.indice li { padding: 0.35rem 0; }
.indice a {
color: #1a5276;
text-decoration: none;
border-bottom: 1px solid transparent;
transition: border-color 0.2s;
}
.indice a:hover { border-bottom-color: #2980b9; }
.indice .modulo-titulo {
font-weight: 600;
font-size: 1.05rem;
margin-top: 1rem;
padding-top: 0.8rem;
border-top: 1px solid #eee;
color: #0d2b3e;
}
.indice .modulo-titulo:first-child { border-top: none; margin-top: 0; padding-top: 0; }
.indice .seccion-link { padding-left: 1.2rem; font-size: 0.93rem; }
/* ── CONTENIDO ── */ /* ── CONTENIDO ── */
.contenido { .contenido {
max-width: 820px; max-width: 820px;
margin: 0 auto; margin: 0 auto;
padding: 2.5rem; padding: 2.5rem;
background: white; background: var(--color-surface);
min-height: 60vh;
} }
.contenido h1.modulo-titulo { .contenido h1.modulo-titulo {
color: #0d2b3e; color: var(--color-primary-dark);
font-size: 2rem; font-size: 1.8rem;
border-bottom: 3px solid #2980b9; font-weight: 800;
border-bottom: 3px solid var(--color-accent);
padding-bottom: 0.5rem; padding-bottom: 0.5rem;
margin: 3rem 0 1.5rem; margin: 3rem 0 1.5rem;
letter-spacing: -0.5px;
} }
.contenido h2.seccion-titulo { .contenido h2.seccion-titulo {
color: #1a5276; color: var(--color-primary);
font-size: 1.5rem; font-size: 1.35rem;
font-weight: 700;
margin: 2.5rem 0 1rem; margin: 2.5rem 0 1rem;
border-left: 4px solid #2980b9; border-left: 4px solid var(--color-accent);
padding-left: 0.8rem; padding-left: 0.8rem;
scroll-margin-top: 1rem;
} }
.contenido h3.tema-titulo { .contenido h3.tema-titulo {
color: #2c3e50; color: #2c3e50;
font-size: 1.15rem; font-size: 1.1rem;
margin: 1.8rem 0 0.8rem; margin: 1.8rem 0 0.8rem;
font-weight: 600; font-weight: 600;
} }
.contenido h4 { .contenido h4 {
color: #34495e; color: #34495e;
font-size: 1.05rem; font-size: 1rem;
margin: 1.3rem 0 0.6rem; margin: 1.3rem 0 0.6rem;
font-weight: 600; font-weight: 600;
} }
.contenido p { margin: 0.8rem 0; text-align: justify; } .contenido p { margin: 0.8rem 0; text-align: justify; }
.contenido ul, .contenido ol { margin: 0.8rem 0; padding-left: 1.8rem; } .contenido ul, .contenido ol { margin: 0.8rem 0; padding-left: 1.8rem; }
.contenido li { margin: 0.4rem 0; } .contenido li { margin: 0.4rem 0; }
.contenido strong { color: #1a3a4a; font-weight: 600; } .contenido strong { color: #1a3a4a; font-weight: 600; }
.contenido hr { .contenido hr {
border: none; border: none;
border-top: 1px solid #e8e4df; border-top: 1px solid #e8e4df;
margin: 1.8rem 0; margin: 1.8rem 0;
} }
.contenido table { .contenido table {
width: 100%; width: 100%;
border-collapse: collapse; border-collapse: collapse;
margin: 1.2rem 0; margin: 1.2rem 0;
font-size: 0.9rem; font-size: 0.88rem;
overflow-x: auto; overflow-x: auto;
display: block; display: block;
} }
.contenido th, .contenido td { .contenido th, .contenido td {
border: 1px solid #ddd; border: 1px solid #ddd;
padding: 0.6rem 0.8rem; padding: 0.6rem 0.8rem;
text-align: left; text-align: left;
vertical-align: top; vertical-align: top;
} }
.contenido th { .contenido th {
background: #0d2b3e; background: var(--color-primary-dark);
color: white; color: white;
font-weight: 600; font-weight: 600;
} }
.contenido tr:nth-child(even) { background: #f8f6f3; } .contenido tr:nth-child(even) { background: #f8f6f3; }
.contenido tr:hover { background: #efece7; } .contenido tr:hover { background: #efece7; }
.contenido blockquote { .contenido blockquote {
border-left: 4px solid #2980b9; border-left: 4px solid var(--color-accent);
margin: 1rem 0; margin: 1rem 0;
padding: 0.8rem 1.2rem; padding: 0.8rem 1.2rem;
background: #f0f5fa; background: #f0f5fa;
@@ -787,6 +916,20 @@ body {
border-radius: 0 4px 4px 0; border-radius: 0 4px 4px 0;
} }
/* ── VIDEO PLAYER ── */
.video-container {
margin: 1rem 0;
border-radius: 10px;
overflow: hidden;
background: #000;
box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.video-container video {
width: 100%;
display: block;
}
/* ── NOTAS ESPECIALES ── */ /* ── NOTAS ESPECIALES ── */
.nota-video { .nota-video {
background: #fef9e7; background: #fef9e7;
@@ -795,26 +938,26 @@ body {
padding: 0.6rem 1rem; padding: 0.6rem 1rem;
margin: 0.8rem 0; margin: 0.8rem 0;
border-radius: 0 4px 4px 0; border-radius: 0 4px 4px 0;
font-size: 0.9rem; font-size: 0.88rem;
color: #7d6608; color: #7d6608;
} }
.nota-recurso { .nota-recurso {
background: #eaf2f8; background: #eaf2f8;
border: 1px solid #aed6f1; border: 1px solid #aed6f1;
border-left: 4px solid #2980b9; border-left: 4px solid var(--color-accent);
padding: 0.6rem 1rem; padding: 0.6rem 1rem;
margin: 0.8rem 0; margin: 0.8rem 0;
border-radius: 0 4px 4px 0; border-radius: 0 4px 4px 0;
font-size: 0.9rem; font-size: 0.88rem;
} }
.nota-recurso a { .nota-recurso a {
color: #1a5276; color: var(--color-primary);
font-weight: 600; font-weight: 600;
} }
.nota-vacio { .nota-vacio {
color: #999; color: var(--color-text-muted);
font-style: italic; font-style: italic;
font-size: 0.9rem; font-size: 0.88rem;
margin: 0.5rem 0; margin: 0.5rem 0;
} }
.contenido .tema-separador { .contenido .tema-separador {
@@ -825,35 +968,38 @@ body {
/* ── PIE DE PÁGINA ── */ /* ── PIE DE PÁGINA ── */
.footer { .footer {
text-align: center; text-align: center;
padding: 3rem 2rem; padding: 2rem;
color: #999; color: var(--color-text-muted);
font-size: 0.85rem; font-size: 0.8rem;
max-width: 820px; max-width: 820px;
margin: 0 auto; margin: 0 auto;
border-top: 1px solid #e8e4df; border-top: 1px solid #e8e4df;
background: white; background: var(--color-surface);
} }
/* ── RESPONSIVE ── */ /* ── RESPONSIVE ── */
@media (max-width: 600px) { @media (max-width: 900px) {
body { font-size: 15px; } .sidebar { transform: translateX(-100%); }
.portada { padding: 2rem 1rem; min-height: 50vh; } .sidebar.open { transform: translateX(0); }
.sidebar-overlay.open { display: block; }
.hamburger { display: block; }
.main-content { margin-left: 0; }
.portada { padding: 3rem 1rem 2rem; min-height: 40vh; }
.portada h1 { font-size: 1.6rem; } .portada h1 { font-size: 1.6rem; }
.portada h2 { font-size: 1rem; } .portada h2 { font-size: 0.95rem; }
.contenido { padding: 1rem; } .contenido { padding: 1.5rem 1rem; }
.indice { padding: 1.5rem; }
} }
`; `;
// ─── ÍNDICE ─── // ─── SIDEBAR NAV ───
let indiceHTML = '<div class="indice"><h2>📑 Índice de contenidos</h2><ul>'; let sidebarNav = "";
for (const modulo of datos) { for (const modulo of datos) {
indiceHTML += `<li class="modulo-titulo">${modulo.titulo}</li>`; sidebarNav += `<div class="nav-modulo">${modulo.titulo.replace(/Módulo \d+ — /i, "")}</div>\n`;
for (const seccion of modulo.secciones) { for (const seccion of modulo.secciones) {
indiceHTML += `<li class="seccion-link"><a href="#sec-${slugify(seccion.titulo)}">${seccion.titulo}</a> (${seccion.temas.length} temas)</li>`; const secID = `sec-${slugify(seccion.titulo)}`;
sidebarNav += `<a href="#${secID}" data-section="${secID}">${seccion.titulo}<span class="nav-count">${seccion.temas.length}</span></a>\n`;
} }
} }
indiceHTML += "</ul></div>";
// ─── CONTENIDO ─── // ─── CONTENIDO ───
let bodyHTML = ""; let bodyHTML = "";
@@ -870,9 +1016,14 @@ body {
bodyHTML += `<h3 class="tema-titulo" id="${temaID}">${t + 1}. ${tema.titulo}</h3>\n`; bodyHTML += `<h3 class="tema-titulo" id="${temaID}">${t + 1}. ${tema.titulo}</h3>\n`;
// Video // Video — local player o referencia
if (tema.vimeoID) { if (tema.vimeoID) {
bodyHTML += `<div class="nota-video">📹 <strong>Video disponible</strong> — ID: ${tema.vimeoID}</div>\n`; const videoFile = videosMap[tema.vimeoID];
if (videoFile) {
bodyHTML += `<div class="video-container"><video controls preload="metadata"><source src="videos_offline/${videoFile}" type="video/mp4">Tu navegador no soporta video HTML5.</video></div>\n`;
} else {
bodyHTML += `<div class="nota-video">📹 <strong>Video disponible</strong> — Vimeo ID: ${tema.vimeoID}</div>\n`;
}
} }
// Contenido de estudio // Contenido de estudio
@@ -885,8 +1036,7 @@ body {
// Recurso descargable o enlace // Recurso descargable o enlace
if (tema.recursoURL) { if (tema.recursoURL) {
const icono = tema.recursoTexto === "Abrir Archivo" ? "📄" : "🔗"; const icono = tema.recursoTexto === "Abrir Archivo" ? "📄" : "🔗";
const etiqueta = const etiqueta = tema.recursoTexto === "Abrir Archivo" ? "Archivo" : "Enlace";
tema.recursoTexto === "Abrir Archivo" ? "Archivo" : "Enlace";
bodyHTML += `<div class="nota-recurso">${icono} <strong>${etiqueta}:</strong> <a href="${tema.recursoURL}" target="_blank">${tema.titulo}</a></div>\n`; bodyHTML += `<div class="nota-recurso">${icono} <strong>${etiqueta}:</strong> <a href="${tema.recursoURL}" target="_blank">${tema.titulo}</a></div>\n`;
} }
@@ -898,29 +1048,95 @@ body {
} }
} }
const jsCode = `
// Hamburger menu
const hamburger = document.getElementById('hamburger');
const sidebar = document.getElementById('sidebar');
const overlay = document.getElementById('sidebar-overlay');
hamburger.addEventListener('click', () => {
sidebar.classList.toggle('open');
overlay.classList.toggle('open');
});
overlay.addEventListener('click', () => {
sidebar.classList.remove('open');
overlay.classList.remove('open');
});
// Close sidebar on nav click (mobile)
sidebar.querySelectorAll('a').forEach(link => {
link.addEventListener('click', () => {
if (window.innerWidth <= 900) {
sidebar.classList.remove('open');
overlay.classList.remove('open');
}
});
});
// Highlight active section on scroll
const sections = document.querySelectorAll('.seccion-titulo');
const navLinks = document.querySelectorAll('.sidebar-nav a[data-section]');
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
navLinks.forEach(link => link.classList.remove('active'));
const id = entry.target.id;
const activeLink = document.querySelector('.sidebar-nav a[data-section="' + id + '"]');
if (activeLink) {
activeLink.classList.add('active');
activeLink.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
}
}
});
}, { rootMargin: '-10% 0px -80% 0px' });
sections.forEach(section => observer.observe(section));
`;
return `<!DOCTYPE html> return `<!DOCTYPE html>
<html lang="es"> <html lang="es">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Curso de Vóley — Material de Estudio</title> <title>Curso de Vóley — Material de Estudio</title>
<meta name="description" content="Material de estudio offline del Curso de Entrenador Nacional de Vóley">
<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@300;400;500;600;700;800&display=swap" rel="stylesheet">
<style>${css}</style> <style>${css}</style>
</head> </head>
<body> <body>
<button class="hamburger" id="hamburger" aria-label="Menú">☰</button>
<div class="sidebar-overlay" id="sidebar-overlay"></div>
<div class="app-layout">
<nav class="sidebar" id="sidebar">
<div class="sidebar-header">
<div class="logo">🏐</div>
<h1>Entrenador Nacional de Vóley</h1>
<p>Material de Estudio</p>
</div>
<div class="sidebar-stats">
<div class="stat">📚 ${totalModulos} mód.</div>
<div class="stat">📂 ${totalSecciones} secc.</div>
<div class="stat">📖 ${totalTemas} temas</div>
</div>
<div class="sidebar-nav">
${sidebarNav}
</div>
</nav>
<main class="main-content">
<div class="portada"> <div class="portada">
<div class="icono-grande">🏐</div> <div class="icono-grande">🏐</div>
<h1>Curso de Entrenador Nacional de Vóley</h1> <h1>Curso de Entrenador Nacional de Vóley</h1>
<h2>Material de Estudio — Versión Offline</h2> <h2>Material de Estudio — Versión Offline</h2>
<p>Contenido extraído del campus virtual</p> <p>Contenido extraído del campus virtual</p>
<div class="stats"> <p style="margin-top: 1.5rem; opacity: 0.4; font-size: 0.75rem;">Generado el ${fecha}</p>
<div class="stat">📚 ${totalModulos} módulos</div>
<div class="stat">📂 ${totalSecciones} secciones</div>
<div class="stat">📖 ${totalTemas} temas</div>
</div> </div>
<p style="margin-top: 2rem; opacity: 0.5; font-size: 0.8rem;">Generado el ${fecha}</p>
</div>
${indiceHTML}
<div class="contenido"> <div class="contenido">
${bodyHTML} ${bodyHTML}
@@ -928,8 +1144,12 @@ body {
<div class="footer"> <div class="footer">
<p>Online Education Center — Material de estudio offline</p> <p>Online Education Center — Material de estudio offline</p>
<p style="margin-top: 0.3rem; font-size: 0.8rem;">Generado el ${fecha}</p> <p style="margin-top: 0.3rem; font-size: 0.75rem;">Generado el ${fecha}</p>
</div> </div>
</main>
</div>
<script>${jsCode}</script>
</body> </body>
</html>`; </html>`;
} }