37 lines
1.1 KiB
Rust
37 lines
1.1 KiB
Rust
use rocket::{get, request::FlashMessage};
|
|
use rocket_dyn_templates::{tera::Context, Template};
|
|
|
|
use crate::routes::authentication::Authenticated;
|
|
use crate::STANDALONE_MODE;
|
|
|
|
// HELPERS AND ROUTES FOR / (HOME PAGE)
|
|
|
|
#[get("/")]
|
|
pub fn home(_auth: Authenticated) -> Template {
|
|
let mut context = Context::new();
|
|
context.insert("flash_name", &None::<()>);
|
|
context.insert("flash_msg", &None::<()>);
|
|
context.insert("title", &None::<()>);
|
|
// pass in mode so we can define appropriate urls in template
|
|
context.insert("standalone_mode", &*STANDALONE_MODE);
|
|
|
|
Template::render("home", &context.into_json())
|
|
}
|
|
|
|
// HELPERS AND ROUTES FOR /help
|
|
|
|
#[get("/help")]
|
|
pub fn help(flash: Option<FlashMessage>) -> Template {
|
|
let mut context = Context::new();
|
|
context.insert("back", &Some("/".to_string()));
|
|
context.insert("title", &Some("Help".to_string()));
|
|
|
|
// check to see if there is a flash message to display
|
|
if let Some(flash) = flash {
|
|
context.insert("flash_name", &Some(flash.kind().to_string()));
|
|
context.insert("flash_msg", &Some(flash.message().to_string()));
|
|
};
|
|
|
|
Template::render("help", &context.into_json())
|
|
}
|