read values from managed state
This commit is contained in:
parent
bfb53747db
commit
43344566de
|
@ -14,8 +14,8 @@ use crate::routes::{
|
||||||
/// catchers. This gives us everything we need to run PeachPub and excludes
|
/// catchers. This gives us everything we need to run PeachPub and excludes
|
||||||
/// settings and status routes related to networking and the device (memory,
|
/// settings and status routes related to networking and the device (memory,
|
||||||
/// hard disk, CPU etc.).
|
/// hard disk, CPU etc.).
|
||||||
pub fn mount_peachpub_routes() -> Rocket<Build> {
|
pub fn mount_peachpub_routes(rocket: Rocket<Build>) -> Rocket<Build> {
|
||||||
rocket::build()
|
rocket
|
||||||
.mount(
|
.mount(
|
||||||
"/",
|
"/",
|
||||||
routes![
|
routes![
|
||||||
|
@ -66,8 +66,8 @@ pub fn mount_peachpub_routes() -> Rocket<Build> {
|
||||||
/// Create a Rocket instance with PeachPub routes, fileserver and catchers by
|
/// Create a Rocket instance with PeachPub routes, fileserver and catchers by
|
||||||
/// calling `mount_peachpub_routes()` and then mount all additional routes
|
/// calling `mount_peachpub_routes()` and then mount all additional routes
|
||||||
/// required to run a complete PeachCloud build.
|
/// required to run a complete PeachCloud build.
|
||||||
pub fn mount_peachcloud_routes() -> Rocket<Build> {
|
pub fn mount_peachcloud_routes(rocket: Rocket<Build>) -> Rocket<Build> {
|
||||||
mount_peachpub_routes()
|
mount_peachpub_routes(rocket)
|
||||||
.mount(
|
.mount(
|
||||||
"/settings/network",
|
"/settings/network",
|
||||||
routes![
|
routes![
|
||||||
|
|
|
@ -1,19 +1,20 @@
|
||||||
use rocket::{get, request::FlashMessage};
|
use rocket::{get, request::FlashMessage, State};
|
||||||
use rocket_dyn_templates::{tera::Context, Template};
|
use rocket_dyn_templates::{tera::Context, Template};
|
||||||
|
|
||||||
use crate::routes::authentication::Authenticated;
|
use crate::routes::authentication::Authenticated;
|
||||||
use crate::STANDALONE_MODE;
|
use crate::RocketConfig;
|
||||||
|
|
||||||
// HELPERS AND ROUTES FOR / (HOME PAGE)
|
// HELPERS AND ROUTES FOR / (HOME PAGE)
|
||||||
|
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
pub fn home(_auth: Authenticated) -> Template {
|
pub fn home(_auth: Authenticated, config: &State<RocketConfig>) -> Template {
|
||||||
let mut context = Context::new();
|
let mut context = Context::new();
|
||||||
context.insert("flash_name", &None::<()>);
|
context.insert("flash_name", &None::<()>);
|
||||||
context.insert("flash_msg", &None::<()>);
|
context.insert("flash_msg", &None::<()>);
|
||||||
context.insert("title", &None::<()>);
|
context.insert("title", &None::<()>);
|
||||||
// pass in mode so we can define appropriate urls in template
|
|
||||||
context.insert("standalone_mode", &*STANDALONE_MODE);
|
// 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())
|
Template::render("home", &context.into_json())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use rocket::{get, request::FlashMessage};
|
use rocket::get;
|
||||||
use rocket_dyn_templates::{tera::Context, Template};
|
use rocket_dyn_templates::{tera::Context, Template};
|
||||||
|
|
||||||
use crate::routes::authentication::Authenticated;
|
use crate::routes::authentication::Authenticated;
|
||||||
|
|
Loading…
Reference in New Issue