support for configs now there but requries docs
This commit is contained in:
parent
c4b1b20187
commit
5f281e587b
@ -1,3 +1,7 @@
|
|||||||
|
url="freechat.io"
|
||||||
|
favicon="/static/media/favicon.png"
|
||||||
|
motto="Freely chat with freechat!"
|
||||||
|
|
||||||
# NOTE: discord/slack/linked(especially) love caching things so make sure you
|
# NOTE: discord/slack/linked(especially) love caching things so make sure you
|
||||||
# write something that yo're proud of the first time lest u doom yourself to have the
|
# write something that yo're proud of the first time lest u doom yourself to have the
|
||||||
# wrong things cahced for a few months
|
# wrong things cahced for a few months
|
||||||
@ -5,15 +9,11 @@
|
|||||||
|
|
||||||
# Used to help sites embed some information about your site
|
# Used to help sites embed some information about your site
|
||||||
# Especially when the server's site is linked in another freechat/slack/discord server
|
# Especially when the server's site is linked in another freechat/slack/discord server
|
||||||
[open-graph]
|
|
||||||
|
[opengraph]
|
||||||
title="Freechat"
|
title="Freechat"
|
||||||
type="Decentralized chat"
|
# again this has a prefix because `type` is a keyword in rust so just yea
|
||||||
|
og_type="Decentralized chat"
|
||||||
url="freechat.io"
|
url="freechat.io"
|
||||||
|
description="Free and open chat platform"
|
||||||
image="/static/media/logo.png"
|
image="/static/media/logo.png"
|
||||||
|
|
||||||
|
|
||||||
[general]
|
|
||||||
url="freechat.io"
|
|
||||||
favicon:"/static/media/favicon.png"
|
|
||||||
quip:"Freely chat with freechat!"
|
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use rocket_contrib::templates::Template;
|
use rocket_contrib::templates::Template;
|
||||||
use rocket::response::NamedFile;
|
use rocket::response::NamedFile;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::fs::File;
|
use std::fs::read_to_string;
|
||||||
use serde_derive::Deserialize;
|
use serde_derive::Deserialize;
|
||||||
|
|
||||||
// Purely for backend purposes
|
// Purely for backend purposes
|
||||||
@ -60,18 +60,36 @@ pub fn init() {
|
|||||||
image="/static/media/logo.png"
|
image="/static/media/logo.png"
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
if let Ok(mut cfg_file) = File::open(default_path) {
|
// TODO: when we read from the file we should elegantly say there are errors in the config
|
||||||
// here we take the file and parse it as toml
|
// instead of going through the basic panic
|
||||||
|
if let Ok(file) = read_to_string(default_path) {
|
||||||
|
// This is the only time we should ever write to CTX thus the unsafe is mostly fine
|
||||||
|
let config: WebsiteConfig = toml::from_str(&file).unwrap();
|
||||||
|
println!("file contents: {:?}", config);
|
||||||
unsafe {
|
unsafe {
|
||||||
println!("config found ok{:?}", &CTX);
|
CTX.url = config.url;
|
||||||
|
CTX.favicon = config.favicon;
|
||||||
|
CTX.motto = config.motto;
|
||||||
|
|
||||||
|
if let Some(og) = config.opengraph {
|
||||||
|
CTX.opengraph = Some(OpenGraph {
|
||||||
|
title: config.opengraph.title,
|
||||||
|
config.opengraph_type: config.opengraph.config.opengraph_type,
|
||||||
|
url: config.opengraph.url,
|
||||||
|
description: config.opengraph.description,
|
||||||
|
image: config.opengraph.image,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// No check because default_config is hardcoded into place
|
||||||
let config: WebsiteConfig = toml::from_str(default_config).unwrap();
|
let config: WebsiteConfig = toml::from_str(default_config).unwrap();
|
||||||
unsafe {
|
unsafe {
|
||||||
CTX.url = config.url;
|
CTX.url = config.url;
|
||||||
CTX.favicon = config.favicon;
|
CTX.favicon = config.favicon;
|
||||||
CTX.motto = config.motto;
|
CTX.motto = config.motto;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user