-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
611 lines (550 loc) · 24.6 KB
/
Copy pathindex.html
File metadata and controls
611 lines (550 loc) · 24.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Python Libraries — Reference Tree</title>
<link rel="preconnect" href="https://fonts.googleapis.com"/>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap" rel="stylesheet"/>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: 'Inter', system-ui, sans-serif;
background: #ffffff;
min-height: 100vh;
overflow-x: hidden;
}
#bg-canvas {
position: fixed;
top: 0; left: 0;
width: 100%; height: 100%;
pointer-events: none;
z-index: 0;
}
.content {
position: relative;
z-index: 1;
max-width: 960px;
margin: 0 auto;
padding: 80px 28px 100px;
}
header {
text-align: center;
margin-bottom: 70px;
}
header .eyebrow {
font-size: 0.72rem;
font-weight: 600;
letter-spacing: 3px;
text-transform: uppercase;
color: #94a3b8;
margin-bottom: 16px;
}
header h1 {
font-size: clamp(2.4rem, 6vw, 3.8rem);
font-weight: 900;
color: #0f172a;
letter-spacing: -2px;
line-height: 1.08;
margin-bottom: 18px;
}
header p {
font-size: 1rem;
color: #64748b;
font-weight: 400;
max-width: 420px;
margin: 0 auto;
line-height: 1.6;
}
.divider {
width: 40px;
height: 3px;
background: linear-gradient(90deg, #6366f1, #8b5cf6);
border-radius: 2px;
margin: 24px auto 0;
}
/* status banner */
#status-bar {
display: none;
align-items: center;
gap: 10px;
background: #f8fafc;
border: 1.5px solid #e2e8f0;
border-radius: 12px;
padding: 10px 16px;
margin-bottom: 28px;
font-size: 0.78rem;
color: #64748b;
}
#status-bar.visible { display: flex; }
#status-bar .dot {
width: 7px; height: 7px;
border-radius: 50%;
background: #22c55e;
flex-shrink: 0;
animation: pulse 1.8s ease infinite;
}
#status-bar.error .dot { background: #f97316; animation: none; }
@keyframes pulse {
0%,100% { opacity:1; transform:scale(1); }
50% { opacity:.5; transform:scale(1.3); }
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: 22px;
}
.card {
background: rgba(255,255,255,.88);
backdrop-filter: blur(12px);
border: 1.5px solid #e8edf4;
border-radius: 18px;
padding: 28px 26px 24px;
cursor: pointer;
text-decoration: none;
display: flex;
flex-direction: column;
transition: transform .22s cubic-bezier(.22,.68,0,1.2), box-shadow .22s ease, border-color .2s;
position: relative;
overflow: hidden;
animation: fadeUp .35s ease both;
}
@keyframes fadeUp {
from { opacity:0; transform:translateY(14px); }
to { opacity:1; transform:translateY(0); }
}
.card::before {
content: '';
position: absolute;
top: 0; left: 0; right: 0;
height: 3px;
background: var(--accent);
opacity: 0;
transition: opacity .2s;
}
.card:hover {
transform: translateY(-5px);
box-shadow: 0 24px 48px rgba(0,0,0,.09), 0 4px 12px rgba(0,0,0,.04);
border-color: var(--accent-light);
}
.card:hover::before { opacity: 1; }
.card-icon { font-size: 2rem; margin-bottom: 14px; display: block; line-height: 1; }
.card-name { font-size: 1.15rem; font-weight: 800; color: #0f172a; margin-bottom: 5px; letter-spacing: -.3px; }
.card-libs {
font-size: 0.72rem;
font-weight: 600;
color: var(--accent);
letter-spacing: .5px;
margin-bottom: 10px;
text-transform: uppercase;
}
.card-desc { font-size: .8rem; color: #64748b; line-height: 1.6; flex: 1; }
/* NEW badge */
.card-new {
position: absolute;
top: 14px; right: 14px;
font-size: .62rem;
font-weight: 700;
letter-spacing: .8px;
text-transform: uppercase;
background: var(--accent);
color: #fff;
padding: 2px 7px;
border-radius: 20px;
}
.card-arrow {
margin-top: 18px;
font-size: .78rem;
font-weight: 600;
color: var(--accent);
display: flex;
align-items: center;
gap: 5px;
opacity: 0;
transform: translateX(-6px);
transition: opacity .2s, transform .2s;
}
.card:hover .card-arrow { opacity: 1; transform: translateX(0); }
/* skeleton loader */
.skeleton {
background: #f1f5f9;
border: 1.5px solid #e8edf4;
border-radius: 18px;
padding: 28px 26px 24px;
display: flex; flex-direction: column; gap: 10px;
animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer {
0%,100% { opacity:.7; }
50% { opacity:.4; }
}
.sk-icon { width:36px; height:36px; border-radius:8px; background:#e2e8f0; }
.sk-title { width:55%; height:16px; border-radius:6px; background:#e2e8f0; }
.sk-sub { width:35%; height:10px; border-radius:4px; background:#e8edf4; }
.sk-line { width:100%; height:9px; border-radius:4px; background:#e8edf4; }
.sk-line.short { width:75%; }
footer {
text-align: center;
margin-top: 80px;
font-size: .75rem;
color: #cbd5e1;
}
</style>
</head>
<body>
<canvas id="bg-canvas"></canvas>
<div class="content">
<header>
<p class="eyebrow">Reference Guide</p>
<h1>Python Libraries</h1>
<p>Complete API reference trees for the most-used Python libraries — all in one place.</p>
<div class="divider"></div>
</header>
<div id="status-bar"><span class="dot"></span><span id="status-text">Scanning repo…</span></div>
<div class="grid" id="grid"></div>
<footer id="footer"></footer>
</div>
<script>
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
CONFIG — set your GitHub owner + repo name here (one-time).
Everything else is fully automatic.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
const GITHUB_OWNER = 'PoorUt'; // ← your GitHub username
const GITHUB_REPO = 'pyref'; // ← your repo name
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
METADATA OVERRIDES
Keys = exact filename (without .html), case-insensitive.
For any file NOT listed here the system auto-generates
name, icon, description, and colour from the filename.
To add a library: just drop the .html into the repo — done.
To customise its card: add an optional entry below.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
const META_OVERRIDES = {
'numpy_tree': {
icon: '🔢', name: 'NumPy', libs: 'numpy',
desc: 'Numerical computing, N-dimensional arrays, linear algebra, FFT, random, and broadcasting.',
accent: '#3b82f6', accentLight: '#bfdbfe'
},
'pandas_tree': {
icon: '🐼', name: 'Pandas', libs: 'pandas',
desc: 'DataFrames, Series, groupby, merging, time series, IO, and data wrangling tools.',
accent: '#f97316', accentLight: '#fed7aa'
},
'sklearn_tree': {
icon: '🤖', name: 'Scikit-learn', libs: 'sklearn',
desc: 'ML algorithms, preprocessing, pipelines, model selection, metrics, and cross-validation.',
accent: '#ec4899', accentLight: '#fbcfe8'
},
'matplotlib_tree': {
icon: '📊', name: 'Matplotlib', libs: 'matplotlib',
desc: '2D plotting, figures, axes, colormaps, animations, backends, and pyplot API.',
accent: '#22c55e', accentLight: '#bbf7d0'
},
'seaborn_tree': {
icon: '🌊', name: 'Seaborn', libs: 'seaborn',
desc: 'Statistical visualization, themes, distribution plots, categorical plots, and facet grids.',
accent: '#06b6d4', accentLight: '#a5f3fc'
},
'pytorch_tree': {
icon: '🔥', name: 'PyTorch', libs: 'torch',
desc: 'Tensors, autograd, neural network modules, optimizers, CUDA, and TorchScript.',
accent: '#ef4444', accentLight: '#fecaca'
},
'lang chain, sci py, google adk, lang graph': {
icon: '🔗', name: 'AI & Scientific Stack', libs: 'LangChain · SciPy · LangGraph · Google ADK',
desc: 'LLM chains, agents, tools, scientific computing, graph-based workflows, and AI agent SDKs.',
accent: '#8b5cf6', accentLight: '#ddd6fe'
},
'streamlit_reference': {
icon: '🌀', name: 'Streamlit', libs: 'streamlit',
desc: 'App framework for Python — widgets, layouts, state management, caching, charts, and media.',
accent: '#ff4b4b', accentLight: '#fecaca'
},
};
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
AUTO-DETECT: known library palette for filenames not in META_OVERRIDES
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
const KNOWN = {
tensorflow: { icon:'🧠', accent:'#ff6f00', accentLight:'#ffe0b2', desc:'Deep learning, Keras layers, estimators, datasets, and deployment.' },
keras: { icon:'🧬', accent:'#d00000', accentLight:'#ffd6d6', desc:'High-level neural network API built on TensorFlow.' },
scipy: { icon:'🔬', accent:'#0077b6', accentLight:'#ade8f4', desc:'Scientific computing: integrate, optimize, stats, signal, and sparse.' },
statsmodels: { icon:'📉', accent:'#7b2d8b', accentLight:'#e9d5f5', desc:'Statistical models, hypothesis tests, and time-series analysis.' },
xgboost: { icon:'🌳', accent:'#2d6a4f', accentLight:'#b7e4c7', desc:'Gradient boosting framework for classification and regression.' },
lightgbm: { icon:'⚡', accent:'#f4a261', accentLight:'#fddcb5', desc:'Fast gradient boosting with leaf-wise tree growth.' },
catboost: { icon:'🐱', accent:'#e9c46a', accentLight:'#fef3c7', desc:'Gradient boosting with built-in categorical feature support.' },
plotly: { icon:'📈', accent:'#636efa', accentLight:'#dde3ff', desc:'Interactive charts, 3D plots, dashboards, and animations.' },
bokeh: { icon:'🎯', accent:'#2196f3', accentLight:'#bbdefb', desc:'Interactive web-based visualization for large datasets.' },
altair: { icon:'🔭', accent:'#4ecdc4', accentLight:'#b2dfdb', desc:'Declarative statistical visualization based on Vega-Lite.' },
requests: { icon:'🌐', accent:'#20bf6b', accentLight:'#b8f0d4', desc:'HTTP library for making web requests, sessions, and authentication.' },
fastapi: { icon:'⚡', accent:'#009688', accentLight:'#b2dfdb', desc:'High-performance async web framework for building APIs.' },
flask: { icon:'🍶', accent:'#333333', accentLight:'#cccccc', desc:'Lightweight WSGI web framework with routing, templates, and extensions.' },
django: { icon:'🎸', accent:'#0c4b33', accentLight:'#a8d5c2', desc:'Full-stack web framework with ORM, admin, auth, and templates.' },
sqlalchemy: { icon:'🗄️', accent:'#b5451b', accentLight:'#f5cfc5', desc:'SQL toolkit and ORM for Python database access.' },
langchain: { icon:'🔗', accent:'#1c7ed6', accentLight:'#d0ebff', desc:'LLM chains, agents, tools, memory, and retrieval pipelines.' },
openai: { icon:'🤖', accent:'#10a37f', accentLight:'#b2f2e0', desc:'OpenAI API: completions, embeddings, vision, and function calling.' },
anthropic: { icon:'🧿', accent:'#c0392b', accentLight:'#f5b7b1', desc:'Anthropic Claude API: messages, streaming, and tool use.' },
transformers:{ icon:'🤗', accent:'#ff9000', accentLight:'#ffe0b2', desc:'HuggingFace Transformers: pretrained models, tokenizers, and pipelines.' },
pydantic: { icon:'🛡️', accent:'#e91e63', accentLight:'#f8bbd0', desc:'Data validation and settings management using Python type hints.' },
polars: { icon:'🐻', accent:'#cd5c5c', accentLight:'#f5c6c6', desc:'Blazing-fast DataFrame library built on Apache Arrow.' },
dask: { icon:'🔀', accent:'#fc4f30', accentLight:'#ffd0c9', desc:'Parallel computing with task graphs and distributed DataFrames.' },
networkx: { icon:'🕸️', accent:'#2e86de', accentLight:'#bee3f8', desc:'Graph and network analysis algorithms and visualization.' },
cv2: { icon:'👁️', accent:'#3498db', accentLight:'#d6eaf8', desc:'OpenCV: image processing, computer vision, and video analysis.' },
pillow: { icon:'🖼️', accent:'#9b59b6', accentLight:'#e8daef', desc:'PIL/Pillow: image manipulation, drawing, filtering, and IO.' },
sympy: { icon:'∑', accent:'#16a085', accentLight:'#a2d9ce', desc:'Symbolic mathematics: algebra, calculus, and equation solving.' },
pytest: { icon:'🧪', accent:'#0f9d58', accentLight:'#b7e1cd', desc:'Testing framework with fixtures, parametrize, mocking, and plugins.' },
pyspark: { icon:'✨', accent:'#e25822', accentLight:'#f5cba7', desc:'Distributed computing with Spark DataFrames, SQL, MLlib, and streaming.' },
arrow: { icon:'🏹', accent:'#e44d26', accentLight:'#f5cba7', desc:'Apache Arrow: columnar in-memory format and cross-language data.' },
};
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
COLOUR PALETTE — assigned round-robin to unknown libs
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
const PALETTE = [
['#6366f1','#c7d2fe'],['#f43f5e','#fecdd3'],['#14b8a6','#99f6e4'],
['#f59e0b','#fde68a'],['#8b5cf6','#ddd6fe'],['#06b6d4','#a5f3fc'],
['#10b981','#a7f3d0'],['#ef4444','#fecaca'],['#3b82f6','#bfdbfe'],
['#ec4899','#fbcfe8'],
];
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
HELPERS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/** Strip suffixes like _tree, _reference, _api, _docs from slug */
function coreSlug(slug) {
return slug.replace(/[_\-](tree|reference|ref|api|docs|cheatsheet|guide|sheet)$/i, '').trim();
}
/** Convert a filename slug to a display name */
function slugToName(slug) {
const core = coreSlug(slug);
// known pretty-print overrides
const pretty = {
numpy:'NumPy', pandas:'Pandas', sklearn:'Scikit-learn',
matplotlib:'Matplotlib', seaborn:'Seaborn', pytorch:'PyTorch',
tensorflow:'TensorFlow', keras:'Keras', scipy:'SciPy',
statsmodels:'StatsModels', xgboost:'XGBoost', lightgbm:'LightGBM',
catboost:'CatBoost', plotly:'Plotly', bokeh:'Bokeh', altair:'Altair',
requests:'Requests', fastapi:'FastAPI', flask:'Flask', django:'Django',
sqlalchemy:'SQLAlchemy', langchain:'LangChain', openai:'OpenAI',
anthropic:'Anthropic', transformers:'Transformers', pydantic:'Pydantic',
polars:'Polars', dask:'Dask', networkx:'NetworkX', cv2:'OpenCV',
pillow:'Pillow', sympy:'SymPy', pytest:'Pytest', pyspark:'PySpark',
streamlit:'Streamlit', arrow:'Arrow',
};
if (pretty[core.toLowerCase()]) return pretty[core.toLowerCase()];
// title-case with space splits on _ and -
return core.replace(/[_\-]+/g, ' ')
.replace(/\w\S*/g, w => w[0].toUpperCase() + w.slice(1).toLowerCase());
}
/** Palette colour based on filename hash (stable) */
function hashColor(str) {
let h = 0;
for (let i = 0; i < str.length; i++) h = (h * 31 + str.charCodeAt(i)) & 0xffffffff;
return PALETTE[Math.abs(h) % PALETTE.length];
}
/** Build a card data object from a GitHub file entry */
let _paletteIdx = 0;
function buildCard(ghFile, existingFileNames) {
const rawName = ghFile.name.replace(/\.html$/i, '');
const key = rawName.toLowerCase();
// 1. Check META_OVERRIDES first (exact key match)
const override = META_OVERRIDES[key];
if (override) {
return { ...override, file: ghFile.name };
}
// 2. Check KNOWN library palette
const core = coreSlug(key);
const known = KNOWN[core] || KNOWN[core.replace(/[_\-]/g, '')];
if (known) {
const displayName = slugToName(rawName);
return {
icon: known.icon,
name: displayName,
libs: core,
desc: known.desc,
file: ghFile.name,
accent: known.accent,
accentLight: known.accentLight,
};
}
// 3. Fully auto-generated
const displayName = slugToName(rawName);
const [accent, accentLight] = hashColor(key);
return {
icon: '📘',
name: displayName,
libs: core.replace(/[_\-]/g, ' '),
desc: `Complete API reference for the ${displayName} Python library.`,
file: ghFile.name,
accent,
accentLight,
};
}
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
RENDER
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
function isNew(ghFile) {
// Flag files committed within the last 7 days
if (!ghFile._sha || !ghFile._ts) return false;
return (Date.now() - ghFile._ts) < 7 * 24 * 60 * 60 * 1000;
}
function renderCards(cards, newFiles = new Set()) {
const grid = document.getElementById('grid');
const footer = document.getElementById('footer');
if (!cards.length) {
grid.innerHTML = `<div style="grid-column:1/-1;text-align:center;color:#94a3b8;padding:40px 0">
No reference HTML files found in the repo yet.</div>`;
return;
}
grid.innerHTML = cards.map((c, i) => `
<a class="card" href="${encodeURI(c.file)}"
style="--accent:${c.accent};--accent-light:${c.accentLight};animation-delay:${i*0.05}s">
${newFiles.has(c.file) ? `<span class="card-new">New</span>` : ''}
<span class="card-icon">${c.icon}</span>
<div class="card-name">${c.name}</div>
<div class="card-libs">${c.libs}</div>
<div class="card-desc">${c.desc}</div>
<div class="card-arrow">Explore →</div>
</a>
`).join('');
footer.textContent = `${cards.length} ${cards.length === 1 ? 'library' : 'libraries'} · Python Reference Trees`;
}
function showSkeletons(n = 6) {
const grid = document.getElementById('grid');
grid.innerHTML = Array.from({length: n}, () => `
<div class="skeleton">
<div class="sk-icon"></div>
<div class="sk-title"></div>
<div class="sk-sub"></div>
<div class="sk-line"></div>
<div class="sk-line short"></div>
</div>
`).join('');
}
function setStatus(msg, isError = false) {
const bar = document.getElementById('status-bar');
const text = document.getElementById('status-text');
bar.classList.add('visible');
bar.classList.toggle('error', isError);
text.textContent = msg;
if (!isError) setTimeout(() => bar.classList.remove('visible'), 3500);
}
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
MAIN — fetch repo contents via GitHub API
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
const EXCLUDE = new Set(['index.html']);
async function loadLibraries() {
showSkeletons();
setStatus('Scanning repo for HTML files…');
try {
const apiURL = `https://api.github.com/repos/${GITHUB_OWNER}/${GITHUB_REPO}/contents/`;
const res = await fetch(apiURL, { headers: { Accept: 'application/vnd.github.v3+json' } });
if (!res.ok) throw new Error(`GitHub API ${res.status}: ${res.statusText}`);
const files = await res.json();
// Filter: only .html files, exclude index.html
const htmlFiles = files.filter(f =>
f.type === 'file' &&
f.name.toLowerCase().endsWith('.html') &&
!EXCLUDE.has(f.name.toLowerCase())
);
if (!htmlFiles.length) {
throw new Error('No reference HTML files found. Drop a .html file into the repo to get started.');
}
// Fetch commit dates to detect "new" files (last 7 days)
// We do this via the commits endpoint with a shallow per-file lookup
const newFiles = new Set();
const sevenDaysAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString();
try {
const commitRes = await fetch(
`https://api.github.com/repos/${GITHUB_OWNER}/${GITHUB_REPO}/commits?since=${sevenDaysAgo}&per_page=100`,
{ headers: { Accept: 'application/vnd.github.v3+json' } }
);
if (commitRes.ok) {
const commits = await commitRes.json();
// collect all files touched in recent commits
await Promise.all(commits.slice(0, 10).map(async c => {
try {
const cr = await fetch(c.url, { headers: { Accept: 'application/vnd.github.v3+json' } });
if (!cr.ok) return;
const cd = await cr.json();
(cd.files || []).forEach(f => {
if (f.filename.endsWith('.html') && !EXCLUDE.has(f.filename.toLowerCase())) {
newFiles.add(f.filename);
}
});
} catch(_) {}
}));
}
} catch(_) { /* new-badge is non-critical */ }
const allFileNames = htmlFiles.map(f => f.name);
const cards = htmlFiles.map(f => buildCard(f, allFileNames));
// Sort: META_OVERRIDES first (known libs), then alphabetical
cards.sort((a, b) => {
const aKnown = !!META_OVERRIDES[a.file.replace(/\.html$/i,'').toLowerCase()];
const bKnown = !!META_OVERRIDES[b.file.replace(/\.html$/i,'').toLowerCase()];
if (aKnown && !bKnown) return -1;
if (!aKnown && bKnown) return 1;
return a.name.localeCompare(b.name);
});
renderCards(cards, newFiles);
setStatus(`Found ${cards.length} ${cards.length === 1 ? 'library' : 'libraries'} — auto-detected from repo`);
} catch (err) {
// Fallback: render from META_OVERRIDES so the page always works
console.warn('GitHub API failed, falling back to built-in list:', err.message);
const fallback = Object.entries(META_OVERRIDES).map(([slug, meta]) => ({
...meta,
file: slug + '.html',
}));
renderCards(fallback, new Set());
setStatus(`⚠ Could not reach GitHub API — showing built-in list. (${err.message})`, true);
}
}
loadLibraries();
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Dot-grid canvas effect
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
(function () {
const canvas = document.getElementById('bg-canvas');
const ctx = canvas.getContext('2d');
const SPACING = 30, DOT_R = 1.6, RADIUS = 180, PULL = 0.72, EASE = 0.13;
let W, H, dots = [];
let mouse = { x: -9999, y: -9999 };
function resize() {
W = canvas.width = window.innerWidth;
H = canvas.height = window.innerHeight;
dots = [];
const cols = Math.ceil(W / SPACING) + 2;
const rows = Math.ceil(H / SPACING) + 2;
for (let r = 0; r < rows; r++)
for (let c = 0; c < cols; c++) {
const bx = c * SPACING, by = r * SPACING;
dots.push({ bx, by, x: bx, y: by });
}
}
window.addEventListener('resize', resize);
window.addEventListener('mousemove', e => { mouse.x = e.clientX; mouse.y = e.clientY; });
window.addEventListener('mouseleave', () => { mouse.x = -9999; mouse.y = -9999; });
function frame() {
ctx.clearRect(0, 0, W, H);
for (const d of dots) {
const dx = mouse.x - d.bx, dy = mouse.y - d.by;
const dist = Math.hypot(dx, dy);
let tx = d.bx, ty = d.by;
if (dist < RADIUS && dist > 0) {
const force = Math.pow(1 - dist / RADIUS, 2) * PULL;
tx = d.bx + dx * force;
ty = d.by + dy * force;
}
d.x += (tx - d.x) * EASE;
d.y += (ty - d.y) * EASE;
const shift = Math.hypot(d.x - d.bx, d.y - d.by);
ctx.beginPath();
ctx.arc(d.x, d.y, DOT_R, 0, Math.PI * 2);
ctx.fillStyle = `rgba(148,163,184,${0.18 + Math.min(shift / 40, 1) * 0.32})`;
ctx.fill();
}
requestAnimationFrame(frame);
}
resize();
frame();
})();
</script>
</body>
</html>