smarter way

This commit is contained in:
2026-05-17 20:36:18 +02:00
parent b959c6b535
commit f865315a67
2 changed files with 71 additions and 43 deletions

67
web/index.php Normal file
View File

@@ -0,0 +1,67 @@
<?php
$url = array_filter(explode('/',ltrim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH),'/')));
if (count($url) === 1 && str_starts_with($url[0], 'seed-')) {
$file = __DIR__ . '/../pages/' . $url[0] . '.html';
if (file_exists($file)) {
header('Content-Type: text/html; charset=UTF-8');
echo file_get_contents($file);
exit;
}
else {
http_response_code(404);
echo 'Page not found';
exit;
}
}
?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Generation Error</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.10/dist/htmx.min.js"></script>
</head>
<body class="min-h-screen bg-zinc-950 text-zinc-100 p-8" hx-get="/generator.php" hx-trigger="load">
<h1 class="text-2xl font-bold mb-4">Page being generated, please wait</h1>
<p class="text-zinc-300 mb-3">
Generating content... this should complete in about 30 seconds.
</p>
<div class="w-full max-w-xl h-3 bg-zinc-800 rounded overflow-hidden mb-2" aria-label="Generation progress">
<div id="progress-bar" class="h-full bg-emerald-500 w-0 transition-[width] duration-100"></div>
</div>
<p id="progress-text" class="text-zinc-400 text-sm mb-3">0%</p>
<script>
(() => {
const durationMs = 30000;
const start = performance.now();
const bar = document.getElementById('progress-bar');
const text = document.getElementById('progress-text');
function tick(now) {
const elapsed = now - start;
const progress = Math.min(elapsed / durationMs, 1);
const percent = Math.round(progress * 100);
bar.style.width = percent + '%';
text.textContent = percent + '%';
if (progress < 1) {
requestAnimationFrame(tick);
}
}
requestAnimationFrame(tick);
})();
</script>
</body>
</html>