diff options
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/config.rs | 4 | ||||
-rw-r--r-- | server/src/routes/mod.rs | 3 | ||||
-rw-r--r-- | server/src/routes/ui/home.rs | 13 |
3 files changed, 14 insertions, 6 deletions
diff --git a/server/src/config.rs b/server/src/config.rs index 86f7068..0534f22 100644 --- a/server/src/config.rs +++ b/server/src/config.rs @@ -5,6 +5,10 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Deserialize, Serialize, Default)] pub struct GlobalConfig { pub brand: String, + pub slogan: String, + pub icon: PathBuf, + pub asset_dir: PathBuf, + pub database_path: PathBuf, pub library_path: PathBuf, pub admin_username: String, diff --git a/server/src/routes/mod.rs b/server/src/routes/mod.rs index b791c5a..e7db40f 100644 --- a/server/src/routes/mod.rs +++ b/server/src/routes/mod.rs @@ -1,6 +1,6 @@ use crate::{database::Database, library::Library, CONF}; use jellyremuxer::RemuxerContext; -use rocket::{catchers, config::SecretKey, routes, Build, Config, Rocket}; +use rocket::{catchers, config::SecretKey, fs::FileServer, routes, Build, Config, Rocket}; use stream::r_stream; use ui::{ account::{ @@ -39,6 +39,7 @@ pub fn build_rocket( .manage(library) .manage(database) .register("/", catchers![r_catch]) + .mount("/assets", FileServer::from(&CONF.asset_dir)) .mount( "/", routes![ diff --git a/server/src/routes/ui/home.rs b/server/src/routes/ui/home.rs index b9e9289..165fbb7 100644 --- a/server/src/routes/ui/home.rs +++ b/server/src/routes/ui/home.rs @@ -1,12 +1,14 @@ use super::account::session::Session; use super::layout::LayoutPage; +use crate::routes::ui::error::MyResult; use crate::routes::ui::layout::DynLayoutPage; use crate::CONF; use crate::{library::Library, routes::ui::node::NodePage}; use rocket::{get, State}; +use tokio::fs::read_to_string; #[get("/")] -pub async fn r_home(_sess: Session, library: &State<Library>) -> DynLayoutPage { +pub fn r_home(_sess: Session, library: &State<Library>) -> DynLayoutPage { LayoutPage { title: "Home".to_string(), content: markup::new! { @@ -17,11 +19,12 @@ pub async fn r_home(_sess: Session, library: &State<Library>) -> DynLayoutPage { } #[get("/", rank = 2)] -pub async fn r_home_unpriv() -> DynLayoutPage<'static> { - LayoutPage { +pub async fn r_home_unpriv() -> MyResult<DynLayoutPage<'static>> { + let front = read_to_string(CONF.asset_dir.join("front.htm")).await?; + Ok(LayoutPage { title: "Home".to_string(), content: markup::new! { - h1 { @CONF.brand } + @markup::raw(&front) }, - } + }) } |