From 4c44767301109df609fc334e20809b35daea33d8 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Mon, 3 Feb 2025 15:53:08 -0800 Subject: [PATCH] display demo mode notice --- src/main.rs | 7 +++++-- static/css/style.css | 26 ++++++++++++++++++++++++++ templates/login.html.tera | 9 +++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2e26668..373b1ba 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,6 +12,7 @@ mod user; use rocket::fairing::{self, AdHoc}; use rocket::fs::FileServer; use rocket::response::Redirect; +use rocket::State; use rocket::{Build, Rocket}; use rocket_db_pools::{sqlx, Connection, Database}; use rocket_dyn_templates::{context, Template}; @@ -57,8 +58,9 @@ async fn index_redirect(mut db: Connection) -> Redirect { } #[get("/login")] -fn login() -> Template { - Template::render("login", context! {}) +fn login(demo_mode: &State) -> Template { + let demo_mode: bool = **demo_mode; + Template::render("login", context! { demo_mode: demo_mode }) } // Run migrations and setup demo data if needed @@ -125,6 +127,7 @@ fn rocket() -> _ { .mount("/static", FileServer::from("static")) .attach(Template::fairing()) .attach(Db::init()) + .manage(args.demo) .attach(AdHoc::try_on_ignite("DB Setup", move |rocket| async move { setup_database(args.demo, rocket).await })) diff --git a/static/css/style.css b/static/css/style.css index 71b0791..ff414f0 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -534,4 +534,30 @@ button:disabled { .feed-entry-summary { color: var(--text-color); line-height: 1.5; +} + +.demo-notice { + background-color: #f8f9fa; + border: 1px solid #dee2e6; + border-radius: 4px; + padding: 1rem; + margin-bottom: 2rem; + text-align: center; +} + +.demo-notice h2 { + color: #0d6efd; + margin-top: 0; + margin-bottom: 1rem; +} + +.demo-notice p { + margin: 0.5rem 0; +} + +.demo-notice pre { + background-color: #e9ecef; + padding: 0.2rem 0.4rem; + border-radius: 3px; + font-family: monospace; } diff --git a/templates/login.html.tera b/templates/login.html.tera index 6304daf..39b1109 100644 --- a/templates/login.html.tera +++ b/templates/login.html.tera @@ -7,6 +7,15 @@