From 36b2e61e26d373fa5b986965393258374dd83990 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sat, 27 Jul 2024 21:47:26 +0100 Subject: [PATCH] main: Serve static files from /static path Static files served with FileServer have a low priority : all other possible routes a this root will be checked first, before they get returned. As we have a lot of routes at the root, they will be hit a lot before we get to the static files. Move the static files to a dedicated path to reduce those internal redirections, update the paths in the HTML and add one for the favicon so it continues to work. --- src/main.rs | 2 +- templates/index.html.tera | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index a7d56c7..7a8e434 100644 --- a/src/main.rs +++ b/src/main.rs @@ -35,7 +35,7 @@ async fn index(mut db: Connection) -> Redirect { #[launch] fn rocket() -> _ { rocket::build() - .mount("/", FileServer::from(relative!("static_files"))) + .mount("/static/", FileServer::from(relative!("static_files"))) .attach(auth::stage()) .attach(week::stage()) .attach(truth::stage()) diff --git a/templates/index.html.tera b/templates/index.html.tera index e10d6f5..ff9a273 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -4,12 +4,13 @@ {{ title }} - + + {% if user.logged_in == true and not user.is_admin %} - + {% endif %} - + {#{% import "week_change_arrows" as week_macro %}#}