Add typed text pages; serve CSS as compiled-on-demand /css/main.css
Sidecar-less page bundles whose directory ends in a MediaType extension
(.txt/.css/.xml/.json/.js) now render raw (no HTML layout, autoescape off),
are served with that extension's Content-Type, and cache as a flat file
(public/cache/<path>) so Apache serves them directly via a new .htaccess
rule. They're excluded from the content index.
CSS becomes one of these: novaconium/pages/css/main.css/ holds index.twig
({{ sass('main.sass') }}), main.sass, and _colors.sass. App\SassExtension's
sass() Twig function resolves the entry file through the overlay and shells
out to Dart Sass on a cache miss; Lib\SassCompiler wraps the CLI. This
drops the committed App/css/main.css build artifact and the public/css
bind mount. Override styling by copying the whole bundle to App/pages/.
Also ship robots.txt and humans.txt as framework bundles, and drop the
php -S dev router (public/router.php) - Docker/Apache only now.
New: novaconium/src/MediaType.php, SassExtension.php, lib/SassCompiler.php.
Moved: novaconium/sass/ -> novaconium/pages/css/main.css/ (+ App/sass merged).
Docs: AGENTS.md, new /admin/docs/text-pages, and styling/caching/docker/
design-notes/getting-started/project-layout/config docs updated.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Q9cAXC9xcXYnmP7qjsnw7
This commit is contained in:
+8
-1
@@ -8,7 +8,14 @@ RewriteRule ^(.+)/$ /$1 [R=301,L]
|
||||
RewriteCond %{DOCUMENT_ROOT}/cache/$1/index.html -f
|
||||
RewriteRule ^(.*)$ /cache/$1/index.html [L]
|
||||
|
||||
# 3) Serve real files/directories as-is (css, cache assets, etc.).
|
||||
# 2b) Same, for a cached "typed text page" (/css/main.css, /robots.txt, …).
|
||||
# It's stored as a flat file, not <dir>/index.html, so Apache labels it
|
||||
# with the real extension's MIME type instead of text/html. Extension
|
||||
# list mirrors App\MediaType::MAP.
|
||||
RewriteCond %{DOCUMENT_ROOT}/cache/$1 -f
|
||||
RewriteRule ^(.+\.(?:txt|css|xml|json|js))$ /cache/$1 [L]
|
||||
|
||||
# 3) Serve real files/directories as-is (cache assets, favicon, etc.).
|
||||
RewriteCond %{REQUEST_FILENAME} -f [OR]
|
||||
RewriteCond %{REQUEST_FILENAME} -d
|
||||
RewriteRule ^ - [L]
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
// Dev-only router for `php -S`, mimicking the .htaccess rules for local testing.
|
||||
// Not used in production (Apache reads .htaccess directly).
|
||||
|
||||
$uri = urldecode(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
|
||||
|
||||
if ($uri !== '/' && str_ends_with($uri, '/')) {
|
||||
// Preserve the query string across the canonical redirect — Apache's
|
||||
// .htaccess does this automatically, so dev must too or post/redirect
|
||||
// flows like /contact/?sent=1 lose their flags under `php -S`.
|
||||
$query = parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY);
|
||||
header('Location: ' . rtrim($uri, '/') . ($query !== null ? '?' . $query : ''), true, 301);
|
||||
exit;
|
||||
}
|
||||
|
||||
$file = __DIR__ . $uri;
|
||||
if ($uri !== '/' && (is_file($file) || is_dir($file))) {
|
||||
return false; // let the built-in server handle real files/dirs (css, cache)
|
||||
}
|
||||
|
||||
// Mirror .htaccess's "serve the pre-rendered static file, bypassing PHP"
|
||||
// rule — but skip it when debug is on, so sidecar-less pages render fresh
|
||||
// on every request (Renderer also stops writing the cache in that mode).
|
||||
$novaconiumConfig = require __DIR__ . '/../novaconium/config.php';
|
||||
$appConfigFile = __DIR__ . '/../App/config.php';
|
||||
$config = is_file($appConfigFile)
|
||||
? array_merge($novaconiumConfig, require $appConfigFile)
|
||||
: $novaconiumConfig;
|
||||
$debug = (bool) $config['debug'];
|
||||
|
||||
$cacheFile = __DIR__ . '/cache' . $uri . '/index.html';
|
||||
if (!$debug && is_file($cacheFile)) {
|
||||
readfile($cacheFile);
|
||||
return true;
|
||||
}
|
||||
|
||||
require __DIR__ . '/index.php';
|
||||
Reference in New Issue
Block a user