From bccad1118364427ea5c97c08d132fd128368760b Mon Sep 17 00:00:00 2001 From: winter Date: Mon, 23 Dec 2024 18:20:25 +0000 Subject: make a crummy template system and use it for global timeline --- routes/static.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 routes/static.php (limited to 'routes/static.php') diff --git a/routes/static.php b/routes/static.php new file mode 100644 index 0000000..2850d8f --- /dev/null +++ b/routes/static.php @@ -0,0 +1,19 @@ +mount('/static/:path', function (array $args) { + // TODO: support nested paths (needs changes in router i think) + $realPath = __DIR__ . '/../static/' . $args['path']; + if (!is_file($realPath)) { + throw new NotFound('static resource ' . $args['path'] . ' does not exist'); + } + $fileExtension = explode('.', basename($realPath)); + $fileExtension = $fileExtension[count($fileExtension) - 1]; + header('Content-Type: ' . match ($fileExtension) { + 'css' => 'text/css', + default => mime_content_type($realPath) + }); + echo file_get_contents($realPath); +}); \ No newline at end of file -- cgit v1.3