display demo mode notice
This commit is contained in:
parent
2b632f0a93
commit
4c44767301
@ -12,6 +12,7 @@ mod user;
|
|||||||
use rocket::fairing::{self, AdHoc};
|
use rocket::fairing::{self, AdHoc};
|
||||||
use rocket::fs::FileServer;
|
use rocket::fs::FileServer;
|
||||||
use rocket::response::Redirect;
|
use rocket::response::Redirect;
|
||||||
|
use rocket::State;
|
||||||
use rocket::{Build, Rocket};
|
use rocket::{Build, Rocket};
|
||||||
use rocket_db_pools::{sqlx, Connection, Database};
|
use rocket_db_pools::{sqlx, Connection, Database};
|
||||||
use rocket_dyn_templates::{context, Template};
|
use rocket_dyn_templates::{context, Template};
|
||||||
@ -57,8 +58,9 @@ async fn index_redirect(mut db: Connection<Db>) -> Redirect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/login")]
|
#[get("/login")]
|
||||||
fn login() -> Template {
|
fn login(demo_mode: &State<bool>) -> Template {
|
||||||
Template::render("login", context! {})
|
let demo_mode: bool = **demo_mode;
|
||||||
|
Template::render("login", context! { demo_mode: demo_mode })
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run migrations and setup demo data if needed
|
// Run migrations and setup demo data if needed
|
||||||
@ -125,6 +127,7 @@ fn rocket() -> _ {
|
|||||||
.mount("/static", FileServer::from("static"))
|
.mount("/static", FileServer::from("static"))
|
||||||
.attach(Template::fairing())
|
.attach(Template::fairing())
|
||||||
.attach(Db::init())
|
.attach(Db::init())
|
||||||
|
.manage(args.demo)
|
||||||
.attach(AdHoc::try_on_ignite("DB Setup", move |rocket| async move {
|
.attach(AdHoc::try_on_ignite("DB Setup", move |rocket| async move {
|
||||||
setup_database(args.demo, rocket).await
|
setup_database(args.demo, rocket).await
|
||||||
}))
|
}))
|
||||||
|
@ -535,3 +535,29 @@ button:disabled {
|
|||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
line-height: 1.5;
|
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;
|
||||||
|
}
|
||||||
|
@ -7,6 +7,15 @@
|
|||||||
<link rel="stylesheet" href="/static/css/style.css">
|
<link rel="stylesheet" href="/static/css/style.css">
|
||||||
</head>
|
</head>
|
||||||
<div class="login-container">
|
<div class="login-container">
|
||||||
|
{% if demo_mode %}
|
||||||
|
<div class="demo-notice">
|
||||||
|
<h2>Demo Mode</h2>
|
||||||
|
<p>RSS Reader is currently running in demo mode. You can log in with these credentials:</p>
|
||||||
|
<p>Username: <pre style="display: inline">demo</pre></p>
|
||||||
|
<p>Password: <pre style="display: inline">demo</pre></p>
|
||||||
|
<p>Note: Any data you create will not be persisted after the application restarts.</p>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
<form class="login-form" id="loginForm">
|
<form class="login-form" id="loginForm">
|
||||||
<h1>Login</h1>
|
<h1>Login</h1>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
Loading…
Reference in New Issue
Block a user