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
|
SPEC.md
|
||||||
backup.json
|
backup.json
|
||||||
.env
|
.env
|
||||||
templates/styles.css
|
static/css/styles.css
|
||||||
7
build.rs
7
build.rs
|
|
@ -20,13 +20,16 @@ fn git_hash() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tailwind() {
|
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") {
|
for entry in walkdir("templates") {
|
||||||
println!("cargo:rerun-if-changed={entry}");
|
println!("cargo:rerun-if-changed={entry}");
|
||||||
}
|
}
|
||||||
|
for entry in walkdir("static") {
|
||||||
|
println!("cargo:rerun-if-changed={entry}");
|
||||||
|
}
|
||||||
|
|
||||||
let mut cmd = Command::new("tailwindcss");
|
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") {
|
if std::env::var("PROFILE").as_deref() == Ok("release") {
|
||||||
cmd.arg("--minify");
|
cmd.arg("--minify");
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@
|
||||||
buildInputs = [ pkgs.openssl ];
|
buildInputs = [ pkgs.openssl ];
|
||||||
|
|
||||||
preBuild = ''
|
preBuild = ''
|
||||||
tailwindcss -i templates/input.css -o templates/styles.css --minify
|
tailwindcss -i static/css/input.css -o static/css/styles.css --minify
|
||||||
'';
|
'';
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
|
|
|
||||||
|
|
@ -149,35 +149,35 @@ async fn scan_redirect() -> Redirect {
|
||||||
async fn styles() -> impl IntoResponse {
|
async fn styles() -> impl IntoResponse {
|
||||||
(
|
(
|
||||||
[("content-type", "text/css; charset=utf-8")],
|
[("content-type", "text/css; charset=utf-8")],
|
||||||
include_str!("../../../templates/styles.css"),
|
include_str!("../../../static/css/styles.css"),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn webauthn_js() -> impl IntoResponse {
|
async fn webauthn_js() -> impl IntoResponse {
|
||||||
(
|
(
|
||||||
[("content-type", "application/javascript; charset=utf-8")],
|
[("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 {
|
async fn photo_capture_js() -> impl IntoResponse {
|
||||||
(
|
(
|
||||||
[("content-type", "application/javascript; charset=utf-8")],
|
[("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 {
|
async fn searchable_select_js() -> impl IntoResponse {
|
||||||
(
|
(
|
||||||
[("content-type", "application/javascript; charset=utf-8")],
|
[("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 {
|
async fn favicon() -> impl IntoResponse {
|
||||||
(
|
(
|
||||||
[("content-type", "image/x-icon")],
|
[("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";
|
@import "tailwindcss";
|
||||||
@source "./";
|
@source "../../templates/";
|
||||||
|
@source "../../static/js/";
|
||||||
|
|
||||||
/* ── Dark mode variant (selector-based) ────────────────────────── */
|
/* ── 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