1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
/*
This file is part of jellything (https://codeberg.org/metamuffin/jellything)
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2023 metamuffin <metamuffin.org>
*/
use serde::{Deserialize, Serialize};
use std::{collections::HashMap, path::PathBuf};
use crate::user::PermissionSet;
#[rustfmt::skip]
#[derive(Debug, Deserialize, Serialize, Default)]
pub struct GlobalConfig {
pub brand: String,
pub slogan: String,
#[serde(default = "default::asset_path")] pub asset_path: PathBuf,
#[serde(default = "default::database_path")] pub database_path: PathBuf,
#[serde(default = "default::library_path")] pub library_path: PathBuf,
#[serde(default = "default::cache_path")] pub cache_path: PathBuf,
#[serde(default = "default::admin_username")] pub admin_username: String,
pub admin_password: String,
#[serde(default)] pub cookie_key: Option<String>,
#[serde(default)] pub session_key: Option<String>,
#[serde(default = "default::login_expire")] pub login_expire: i64,
#[serde(default)] pub remote_credentials: HashMap<String, (String, String, bool)>,
#[serde(default)] pub default_permission_set: PermissionSet,
}
#[rustfmt::skip]
mod default {
use std::path::PathBuf;
pub fn admin_username() -> String { "admin".into() }
pub fn login_expire() -> i64 { 60*60*24 }
pub fn asset_path() -> PathBuf { "data/assets".into() }
pub fn database_path() -> PathBuf { "data/database".into() }
pub fn library_path() -> PathBuf { "data/library".into() }
pub fn cache_path() -> PathBuf { "data/cache".into() }
}
|