refactor: move static assets out of templates/ into static/
Move CSS, JS, favicon files to static/ directory to separate compiled-in assets from Askama templates. Update all include paths, build.rs, flake.nix, and Tailwind @source directives.
This commit is contained in:
parent
4a54834424
commit
4e917cee75
9 changed files with 14 additions and 10 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -5,4 +5,4 @@ TODO.md
|
|||
SPEC.md
|
||||
backup.json
|
||||
.env
|
||||
templates/styles.css
|
||||
static/css/styles.css
|
||||
7
build.rs
7
build.rs
|
|
@ -20,13 +20,16 @@ fn git_hash() {
|
|||
}
|
||||
|
||||
fn tailwind() {
|
||||
// Rerun when any template file changes (Tailwind scans them for classes)
|
||||
// Rerun when any template or static file changes
|
||||
for entry in walkdir("templates") {
|
||||
println!("cargo:rerun-if-changed={entry}");
|
||||
}
|
||||
for entry in walkdir("static") {
|
||||
println!("cargo:rerun-if-changed={entry}");
|
||||
}
|
||||
|
||||
let mut cmd = Command::new("tailwindcss");
|
||||
cmd.args(["-i", "templates/input.css", "-o", "templates/styles.css"]);
|
||||
cmd.args(["-i", "static/css/input.css", "-o", "static/css/styles.css"]);
|
||||
|
||||
if std::env::var("PROFILE").as_deref() == Ok("release") {
|
||||
cmd.arg("--minify");
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@
|
|||
buildInputs = [ pkgs.openssl ];
|
||||
|
||||
preBuild = ''
|
||||
tailwindcss -i templates/input.css -o templates/styles.css --minify
|
||||
tailwindcss -i static/css/input.css -o static/css/styles.css --minify
|
||||
'';
|
||||
|
||||
meta = {
|
||||
|
|
|
|||
|
|
@ -149,35 +149,35 @@ async fn scan_redirect() -> Redirect {
|
|||
async fn styles() -> impl IntoResponse {
|
||||
(
|
||||
[("content-type", "text/css; charset=utf-8")],
|
||||
include_str!("../../../templates/styles.css"),
|
||||
include_str!("../../../static/css/styles.css"),
|
||||
)
|
||||
}
|
||||
|
||||
async fn webauthn_js() -> impl IntoResponse {
|
||||
(
|
||||
[("content-type", "application/javascript; charset=utf-8")],
|
||||
include_str!("../../../templates/webauthn.js"),
|
||||
include_str!("../../../static/js/webauthn.js"),
|
||||
)
|
||||
}
|
||||
|
||||
async fn photo_capture_js() -> impl IntoResponse {
|
||||
(
|
||||
[("content-type", "application/javascript; charset=utf-8")],
|
||||
include_str!("../../../templates/components/photo-capture.js"),
|
||||
include_str!("../../../static/js/components/photo-capture.js"),
|
||||
)
|
||||
}
|
||||
|
||||
async fn searchable_select_js() -> impl IntoResponse {
|
||||
(
|
||||
[("content-type", "application/javascript; charset=utf-8")],
|
||||
include_str!("../../../templates/components/searchable-select.js"),
|
||||
include_str!("../../../static/js/components/searchable-select.js"),
|
||||
)
|
||||
}
|
||||
|
||||
async fn favicon() -> impl IntoResponse {
|
||||
(
|
||||
[("content-type", "image/x-icon")],
|
||||
include_bytes!("../../../templates/favicon.ico").as_ref(),
|
||||
include_bytes!("../../../static/favicon.ico").as_ref(),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
@import "tailwindcss";
|
||||
@source "./";
|
||||
@source "../../templates/";
|
||||
@source "../../static/js/";
|
||||
|
||||
/* ── Dark mode variant (selector-based) ────────────────────────── */
|
||||
|
||||
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.8 KiB |
Loading…
Reference in a new issue