feat: load project links from configuration

This commit is contained in:
Aravinth Manivannan 2023-01-24 19:00:31 +05:30
parent 6fd79446de
commit c92aa10327
Signed by: realaravinth
GPG key ID: AD9F0F08E855ED88
2 changed files with 24 additions and 4 deletions

View file

@ -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"

View file

@ -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))]