use peach_lib::sbot::SbotStatus; use rocket::{get, request::FlashMessage, State}; use rocket_dyn_templates::{tera::Context, Template}; use crate::routes::authentication::Authenticated; use crate::utils; use crate::RocketConfig; // HELPERS AND ROUTES FOR / (HOME PAGE) #[get("/")] pub fn home(_auth: Authenticated, config: &State) -> Template { // retrieve current ui theme let theme = utils::get_theme(); // retrieve go-sbot systemd process status let sbot_status = SbotStatus::read().ok(); let mut context = Context::new(); context.insert("theme", &theme); context.insert("sbot_status", &sbot_status); context.insert("flash_name", &None::<()>); context.insert("flash_msg", &None::<()>); context.insert("title", &None::<()>); // pass in mode from managed state so we can define appropriate urls in template context.insert("standalone_mode", &config.standalone_mode); Template::render("home", &context.into_json()) } // HELPERS AND ROUTES FOR /guide #[get("/guide")] pub fn guide(flash: Option) -> Template { // retrieve current ui theme let theme = utils::get_theme(); let mut context = Context::new(); context.insert("theme", &theme); context.insert("back", &Some("/".to_string())); context.insert("title", &Some("Guide".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("guide", &context.into_json()) }