From a3519e32a6b4b799c34a84fd160e68c9bcf897b4 Mon Sep 17 00:00:00 2001 From: shockrah Date: Wed, 29 Jan 2020 23:25:37 -0800 Subject: [PATCH] config issues are being ignored for now there are bigger things to deal with --- server/src/main.rs | 1 + server/src/website.rs | 45 +------------------------------------------ 2 files changed, 2 insertions(+), 44 deletions(-) diff --git a/server/src/main.rs b/server/src/main.rs index 7e25a22..8d9ab8e 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -6,6 +6,7 @@ extern crate rocket_contrib; +use dotenv; use rocket_contrib::serve::StaticFiles; use rocket_contrib::templates::Template; diff --git a/server/src/website.rs b/server/src/website.rs index 8382b26..eb8f9ff 100644 --- a/server/src/website.rs +++ b/server/src/website.rs @@ -2,54 +2,23 @@ // All new servers come with this as a default so that use rocket_contrib::templates::Template; use rocket::response::NamedFile; +use dotenv; use std::env; use std::path::Path; -use std::fs::read_to_string; use serde_derive::Deserialize; // Purely for backend purposes #[derive(Serialize, Deserialize, Debug)] pub struct WebsiteConfig { - url: Option, // default is freechat.io - clean url of domain - favicon: Option, // uri path to the favicon i.e. /media/static/favicon.png - motto: Option, - title: Option, - description: Option, - og_type: Option, stylesheet: String, } pub fn init() { - // Default values which are later overriden - env::set_var("web_url", "freechat.io"); - env::set_var("web_favicon", "/static/images/favicon.png"); - env::set_var("web_motto", "Decentralized free chat platform"); - env::set_var("web_title", "Freechat"); - env::set_var("web_og_type", "Decentralized Chat Platform"); - - - // If there's a problem we're going to panic and that's fine to be completely honest - if let Ok(file) = read_to_string("configs/website.toml") { - let config: WebsiteConfig = toml::from_str(&file).unwrap(); - println!("file contents: {:?}", config); - env::set_var("web_url", config.url.unwrap()); - env::set_var("web_favicon", config.favicon.unwrap()); - env::set_var("web_motto", config.motto.unwrap()); - env::set_var("web_title", config.title.unwrap()); - env::set_var("web_og_type", config.og_type.unwrap()); - } } #[get("/")] pub fn homepage() -> Template { - // look away Template::render("index", WebsiteConfig { - url: Some(env::var("web_url").unwrap()), - favicon: Some(env::var("web_favicon").unwrap()), - motto: Some(env::var("web_motto").unwrap()), - title: Some(env::var("web_title").unwrap()), - description: Some(env::var("web_description").unwrap()), - og_type: Some(env::var("web_og_type").unwrap()), stylesheet: "/static/css/index.css".to_string() }) } @@ -57,12 +26,6 @@ pub fn homepage() -> Template { #[get("/about")] pub fn about_page() -> Template { Template::render("about", WebsiteConfig { - url: Some(env::var("web_url").unwrap()), - favicon: Some(env::var("web_favicon").unwrap()), - motto: Some(env::var("web_motto").unwrap()), - title: Some(env::var("web_title").unwrap()), - description: Some(env::var("web_description").unwrap()), - og_type: Some(env::var("web_og_type").unwrap()), stylesheet: "/static/css/about.css".to_string() }) } @@ -70,12 +33,6 @@ pub fn about_page() -> Template { #[get("/servers")] pub fn server_info() -> Template { Template::render("servers", WebsiteConfig { - url: Some(env::var("web_url").unwrap()), - favicon: Some(env::var("web_favicon").unwrap()), - motto: Some(env::var("web_motto").unwrap()), - title: Some(env::var("web_title").unwrap()), - description: Some(env::var("web_description").unwrap()), - og_type: Some(env::var("web_og_type").unwrap()), stylesheet: "/static/css/about.css".to_string() }) }