38 lines
1.0 KiB
Plaintext
38 lines
1.0 KiB
Plaintext
|
use rocket::{get, State};
|
||
|
use rocket_dyn_templates::Template;
|
||
|
|
||
|
use crate::routes::authentication::Authenticated;
|
||
|
use crate::{context::scuttlebutt::StatusContext, RocketConfig};
|
||
|
|
||
|
// HELPERS AND ROUTES FOR /status/scuttlebutt
|
||
|
|
||
|
#[get("/scuttlebutt")]
|
||
|
pub async fn scuttlebutt_status(_auth: Authenticated, config: &State<RocketConfig>) -> Template {
|
||
|
let context = StatusContext::build().await;
|
||
|
|
||
|
let back = if config.standalone_mode {
|
||
|
// return to home page
|
||
|
Some("/".to_string())
|
||
|
} else {
|
||
|
// return to status menu
|
||
|
Some("/status".to_string())
|
||
|
};
|
||
|
|
||
|
match context {
|
||
|
Ok(mut context) => {
|
||
|
// define back arrow url based on mode
|
||
|
context.back = back;
|
||
|
|
||
|
Template::render("status/scuttlebutt", &context)
|
||
|
}
|
||
|
Err(_) => {
|
||
|
let mut context = StatusContext::default();
|
||
|
|
||
|
// define back arrow url based on mode
|
||
|
context.back = back;
|
||
|
|
||
|
Template::render("status/scuttlebutt", &context)
|
||
|
}
|
||
|
}
|
||
|
}
|