Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions BRIEFING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ the browser, exported as files, and embedded in Canvas.
save examples on the server, sync preferences and hear about new pages. Signing in is never
required; signed out, the site works as before and sends nothing. `PLAN.md` section 18.

- **Learning paths (2026-11-15, defaults taken, awaiting Yusuf):** five curated routes for kinds
of learner, each a page at `/path/<id>/` (`src/paths/`), with stages of 15 to 20 steps. A step is
one page, done when the page is finished (every lesson read, every check right), so progress
comes from what the site already stores and syncs. Free order with a highlighted next step.

## Non-goals (v1)

- LTI grade passback
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -567,3 +567,7 @@
2026-11-15 [doc] HANDOFF.md rewritten as the closing handoff of this session, with a to-do list (shared-code suggestions, two page fixes, CI time); PR to main, merged by fast-forward once CI passes, on Yusuf's "create pr, merge"

2026-11-15 [note] Deployed 08:18 UTC on Yusuf's "create pr, merge": main fb02fc9..17bd730 by fast-forward, which merged PR #2 (footer credit, closing handoff). CI 243 green. Bundle index-Dwyn5AT1.js matches; 276 addresses 200 with the footer and mark once; the footer reads "Created by Yusuf Pisan" with the link; no account requests. Session ready to archive

2026-11-15 [decision] Learning paths: 5 curated routes (data structures, algorithms, interviews, LLMs, theory of computation), 15 to 20 pages each; recommended answers taken after 15 min without a reply, open to reversal

2026-11-15 [code] Learning paths (src/paths): /path/<id>/ pages (prerendered, in sitemap and offline list), cards on the home page, a step bar on pages opened with #path=<id>; step done = page finished
47 changes: 32 additions & 15 deletions scripts/prerender.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,39 @@ try {
if (!template.includes('<div id="app"></div>')) throw new Error('Unexpected dist/index.html');
fs.writeFileSync(path.join(dist, 'index.html'), template);

for (const def of vizzes) {
const title = `${def.title} · ${SITE_NAME}`;
const url = `${SITE_URL}/${def.id}/`;
// A page of the app at /<dir>/ with its own title, description, preview tags and canonical URL.
const writePage = (dir, name, blurb, needs) => {
const title = `${name} · ${SITE_NAME}`;
const url = `${SITE_URL}/${dir}/`;
let html = template.replace(/<title>[^<]*<\/title>/, `<title>${esc(title)}</title>`);
html = setMeta(html, 'name', 'description', def.blurb);
html = setMeta(html, 'name', 'description', blurb);
html = setMeta(html, 'property', 'og:title', title);
html = setMeta(html, 'property', 'og:description', def.blurb);
html = setMeta(html, 'property', 'og:description', blurb);
html = setMeta(html, 'property', 'og:url', url);
html = html.replace('</head>', ` <link rel="canonical" href="${url}" />\n </head>`);
html = html.replace(
'<div id="app"></div>',
`<div id="app"></div>\n <noscript><h1>${esc(def.title)}</h1><p>${esc(def.blurb)}</p>` +
`<p>This interactive visualization needs JavaScript.</p></noscript>`,
`<div id="app"></div>\n <noscript><h1>${esc(name)}</h1><p>${esc(blurb)}</p>` +
`<p>${needs} needs JavaScript.</p></noscript>`,
);
fs.mkdirSync(path.join(dist, def.id), { recursive: true });
fs.writeFileSync(path.join(dist, def.id, 'index.html'), html);
fs.mkdirSync(path.join(dist, dir), { recursive: true });
fs.writeFileSync(path.join(dist, dir, 'index.html'), html);
};
for (const def of vizzes)
writePage(def.id, def.title, def.blurb, 'This interactive visualization');

// Learning paths (src/paths): /path/<id>/. A step on a page that is not live fails the build.
const { paths, pathSteps } = await server.ssrLoadModule('/src/paths/paths.ts');
const liveIds = new Set(vizzes.map((d) => d.id));
for (const p of paths) {
const missing = pathSteps(p).filter((s) => !liveIds.has(s.viz));
if (missing.length)
throw new Error(
`src/paths: path "${p.id}" has steps on pages not live: ${missing.map((s) => s.viz)}`,
);
writePage(`path/${p.id}`, p.title, p.blurb, 'This learning path');
}
const pathDirs = paths.map((p) => `path/${p.id}`);

// Catalog thumbnails: the steps of one example per page, stripped to bare shapes.
// previews.json holds the still pictures; previews/<id>.json the frames, fetched on first play.
Expand All @@ -70,7 +86,11 @@ try {
}
fs.writeFileSync(path.join(dist, 'previews.json'), JSON.stringify(posters));

const urls = [`${SITE_URL}/`, ...vizzes.map((d) => `${SITE_URL}/${d.id}/`)];
const urls = [
`${SITE_URL}/`,
...pathDirs.map((d) => `${SITE_URL}/${d}/`),
...vizzes.map((d) => `${SITE_URL}/${d.id}/`),
];
fs.writeFileSync(
path.join(dist, 'sitemap.xml'),
`<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n` +
Expand All @@ -82,7 +102,7 @@ try {
`User-agent: *\nAllow: /\nSitemap: ${SITE_URL}/sitemap.xml\n`,
);
console.log(
`prerendered ${vizzes.length} visualization pages, ${Object.keys(previews).length} previews`,
`prerendered ${vizzes.length} visualization pages, ${pathDirs.length} paths, ${Object.keys(previews).length} previews`,
);

// The releases (src/releases.ts), for the platform's email about new pages: each page with its
Expand Down Expand Up @@ -120,10 +140,7 @@ try {
.readdirSync(dist, { recursive: true })
.map((f) => String(f).split(path.sep).join('/'))
.filter((f) => fs.statSync(path.join(dist, f)).isFile());
const entries = offlineList(
files,
vizzes.map((d) => d.id),
);
const entries = offlineList(files, [...vizzes.map((d) => d.id), ...pathDirs]);
const read = (f) => fs.readFileSync(path.join(dist, f));
const shell = shellList(entries, read('index.html').toString('utf8'));
const worker = fs.readFileSync(path.resolve('src/pwa/sw.js'), 'utf8');
Expand Down
102 changes: 102 additions & 0 deletions src/paths/PathBar.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<script lang="ts">
import { progress } from '../ui/progress.svelte';
import { vizHref } from '../ui/route';
import { pathHref, pathProgress, pathSteps, stepOf, vizTitle, type PathDef } from './paths';
import PathMeter from './PathMeter.svelte';

/**
* The bar over a visualization page reached from a learning path: which step this is, the
* path's progress, its note, and links to the steps either side and back to the path.
*/
let { path, viz, onleave }: { path: PathDef; viz: string; onleave: () => void } = $props();

const at = $derived(stepOf(path, viz));
const steps = $derived(pathSteps(path));
const state = $derived(pathProgress(progress.current, path));
const before = $derived(at ? steps[at.n - 2] : undefined);
const after = $derived(at ? steps[at.n] : undefined);
const done = $derived(at ? state.steps[at.n - 1]!.summary.finished : false);
</script>

<nav class="path-bar" aria-label="Learning path">
<p class="where">
<span class="label">Path:</span>
<a href={pathHref(path.id)}><strong>{path.title}</strong></a>{#if at}, step {at.n} of
{steps.length}{#if done}<span class="tick"> (done)</span>{/if}{/if}
</p>
<div class="meter"><PathMeter {state} compact /></div>
<div class="buttons">
{#if before}
<a
class="btn small"
href={vizHref(before.viz, { path: path.id })}
title="Previous: {vizTitle(before.viz)}">← Previous</a
>
{/if}
{#if after}
<a
class="btn small"
class:primary={done}
href={vizHref(after.viz, { path: path.id })}
title="Next: {vizTitle(after.viz)}">Next: {vizTitle(after.viz)} →</a
>
{:else if at}
<a class="btn small" href={pathHref(path.id)}>Back to the path</a>
{/if}
<button type="button" class="btn small" onclick={onleave}>Leave the path</button>
</div>
{#if at}
<p class="note">
{at.step.note}
{#if !done}<span class="muted">
This step is done when every lesson under Learn is read and every check is right.</span
>{/if}
</p>
{/if}
</nav>

<style>
.path-bar {
display: grid;
grid-template-columns: 1fr auto;
align-items: center;
gap: 6px 12px;
margin-top: 8px;
padding: 8px 12px;
border: 1px solid var(--line);
border-left: 4px solid var(--c-done);
border-radius: var(--radius);
background: var(--surface);
}

.where,
.note {
margin: 0;
}

.label {
color: var(--text-2);
}

.meter {
min-width: 160px;
}

.buttons {
grid-column: 1 / -1;
display: flex;
flex-wrap: wrap;
gap: 6px;
}

.note {
grid-column: 1 / -1;
font-size: 0.9rem;
}

@media (max-width: 560px) {
.path-bar {
grid-template-columns: 1fr;
}
}
</style>
91 changes: 91 additions & 0 deletions src/paths/PathCards.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<script lang="ts">
import { progress } from '../ui/progress.svelte';
import { pathHref, pathProgress, paths } from './paths';
import PathMeter from './PathMeter.svelte';

/** The home page's learning paths: one card each, with the reader's progress once started. */
const cards = $derived(paths.map((p) => ({ path: p, state: pathProgress(progress.current, p) })));
</script>

<section class="paths" aria-labelledby="paths-title">
<h2 id="paths-title">Learning paths</h2>
<p class="muted lead">Not sure where to start? Pick a path and follow it one page at a time.</p>
<ul>
{#each cards as { path, state } (path.id)}
<li class="card">
<a href={pathHref(path.id)}>
<span class="audience">{path.audience}</span>
<span class="title">{path.title}</span>
<span class="blurb">{path.blurb}</span>
</a>
{#if state.started}
<PathMeter {state} compact />
{:else}
<p class="muted steps">{state.total} steps</p>
{/if}
</li>
{/each}
</ul>
</section>

<style>
.paths {
margin-top: 18px;
}

h2 {
margin: 0;
font-size: 1.05rem;
}

.lead {
margin: 2px 0 0;
}

ul {
display: grid;
/* Five paths fit on one row of a wide screen. */
grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
gap: 10px;
list-style: none;
margin: 8px 0 0;
padding: 0;
}

li {
display: grid;
align-content: space-between;
gap: 8px;
padding: 12px 14px;
}

a {
display: grid;
gap: 2px;
color: var(--text);
text-decoration: none;
}

a:hover .title {
text-decoration: underline;
}

.audience {
font-size: 0.8rem;
color: var(--text-2);
}

.title {
font-weight: 700;
color: var(--accent);
}

.blurb {
font-size: 0.9rem;
}

.steps {
margin: 0;
font-size: 0.85rem;
}
</style>
54 changes: 54 additions & 0 deletions src/paths/PathMeter.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<script lang="ts">
import type { PathProgress } from './paths';

/** A path's progress: a bar, the percent, and the count of steps done. */
let { state, compact = false }: { state: PathProgress; compact?: boolean } = $props();
</script>

<div class="meter" class:compact>
<div
class="bar"
role="progressbar"
aria-valuemin="0"
aria-valuemax="100"
aria-valuenow={state.percent}
aria-valuetext="{state.percent}% complete, {state.finished} of {state.total} steps done"
aria-label="Path progress"
>
<span class="fill" style:width="{state.percent}%"></span>
</div>
<p class="text">
<strong>{state.percent}%</strong>
<span class="muted">· {state.finished} of {state.total} steps done</span>
</p>
</div>

<style>
.meter {
display: grid;
gap: 4px;
}

.bar {
height: 10px;
border-radius: 5px;
background: var(--cell-empty);
border: 1px solid var(--line);
overflow: hidden;
}

.compact .bar {
height: 6px;
}

.fill {
display: block;
height: 100%;
background: var(--c-done);
}

.text {
margin: 0;
font-size: 0.9rem;
}
</style>
Loading