From c92aa1032739a70fb636b78e8474e678dd08c473 Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Tue, 24 Jan 2023 19:00:31 +0530 Subject: [PATCH] feat: load project links from configuration --- config/default.toml | 8 ++++++++ src/settings.rs | 20 ++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/config/default.toml b/config/default.toml index 5c9e668..fb94538 100644 --- a/config/default.toml +++ b/config/default.toml @@ -2,6 +2,7 @@ debug = true allow_registration = true source_code = "https://github.com/mcaptcha/survey" default_campaign = "b6b261fa-3ef9-4d7f-8852-339b8f81bb01" +support_email="support@example.org" [server] # Please set a unique value, your kaizen instance's security depends on this being @@ -32,3 +33,10 @@ username = "postgres" password = "password" name = "postgres" pool = 4 + +[footer] +about = "https://mcapthca.org/about" +donate = "https://mcapthca.org/donate" +thanks = "https://mcapthca.org/thanks" +privacy = "https://mcapthca.org/privacy" +security = "https://mcapthca.org/security" diff --git a/src/settings.rs b/src/settings.rs index 2654ff9..638e9a7 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -20,10 +20,11 @@ use std::path::Path; use config::{Config, ConfigError, Environment, File}; use log::{debug, warn}; use serde::Deserialize; +use serde::Serialize; use url::Url; use uuid::Uuid; -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct Server { pub port: u32, pub domain: String, @@ -40,7 +41,7 @@ impl Server { } } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize)] struct DatabaseBuilder { pub port: u32, pub hostname: String, @@ -68,20 +69,31 @@ impl DatabaseBuilder { } } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct Database { pub url: String, pub pool: u32, } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Footer { + pub about: Url, + pub privacy: Url, + pub security: Url, + pub donate: Url, + pub thanks: Url, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct Settings { pub debug: bool, pub allow_registration: bool, pub database: Database, pub server: Server, pub source_code: String, + pub support_email: String, pub default_campaign: String, + pub footer: Footer, } #[cfg(not(tarpaulin_include))]