Move rendering into private templates

Add an explicit template renderer with HTML views and partials for the app, bootstrap, package, and catalog pages. Move shared reporting setup into config/reporting.php and relocate stylesheet assets under css/.
This commit is contained in:
www-data
2026-05-26 12:50:26 +02:00
parent 2f2e8869d6
commit 475765e31f
55 changed files with 2328 additions and 1175 deletions
+17 -51
View File
@@ -28,14 +28,12 @@
* RewriteRule ^racket-pkg-index$ rktpkgs.php [L,QSA]
*/
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
ini_set('log_errors', '1');
error_reporting(E_ALL);
require_once __DIR__ . '/config/reporting.php';
require_once __DIR__ . '/private/nexttoken.php';
require_once __DIR__ . '/private/lib/catalog-http.php';
require_once __DIR__ . '/private/lib/racket-data.php';
require_once __DIR__ . '/private/Template.php';
$TOKENS = new NextTokenStore(__DIR__ . '/data/racket-sandbox.sqlite');
@@ -96,9 +94,10 @@ function html_response($html, $status = 200)
function fail_html($message, $status = 500)
{
html_response(
'<!doctype html>' .
'<html><head><meta charset="utf-8"><title>Error</title></head>' .
'<body><h1>Error</h1><pre>' . h($message) . '</pre></body></html>',
RacketSandboxTemplate::renderFile('protocol-error.html', array(
'title' => 'Error',
'message' => $message,
)),
$status
);
}
@@ -135,52 +134,19 @@ function serve_index()
foreach ($names as $i => $name) {
$url = make_url('/package', array('name' => $name));
$rows .=
'<tr id="pkg-' . h($name) . '">' .
'<td>' . h((string)($i + 1)) . '</td>' .
'<td class="pkg-name">' .
'<a class="pkg-link" href="' . h($url) . '">' . h($name) . '</a>' .
'</td>' .
'</tr>' . "\n";
$rows .= RacketSandboxTemplate::renderFile('partials/package-index-row.html', array(
'id' => $name,
'index' => (string)($i + 1),
'url' => $url,
'name' => $name,
)) . "\n";
}
html_response('<!doctype html>
<html lang="nl">
<head>
<meta charset="utf-8">
<title>Racket package index</title>
<link rel="stylesheet" href="/styles.css">
</head>
<body class="simple-doc package-index-page">
<h1>Racket package index</h1>
<p>
Volledige HTML-index van de Racket package catalogus op basis van
<code>pkgs-all</code>. De package-naam is de ophaallink via
<code>rktsndbx.dijkewijk.nl</code>.
</p>
<p>
Aantal packages: <code>' . h((string)count($names)) . '</code><br>
next-id voor alle package-links op deze pagina:
<code>' . h($NEXT_ID) . '</code>
</p>
<table>
<thead>
<tr>
<th>#</th>
<th>package</th>
</tr>
</thead>
<tbody>
' . $rows . '
</tbody>
</table>
</body>
</html>');
html_response(RacketSandboxTemplate::renderFile('racket-pkg-index.html', array(
'package_count' => (string)count($names),
'next_id' => $NEXT_ID,
'package_rows_html' => $rows,
)));
}
$TOKENS->check_valid_next('html');