add custom logo parameter
This commit is contained in:
parent
a685f5db84
commit
11543af683
|
@ -58,6 +58,11 @@ instance_motto="A minute file sharing service"
|
|||
# Used as the icon where icon images are not available
|
||||
instance_emoji="🌠"
|
||||
|
||||
# Custom logo
|
||||
# This will be displayed at the main page
|
||||
# It is best to use a webp or jpg image.
|
||||
# custom_logo=/path/to/logo.webp
|
||||
|
||||
# API settings
|
||||
[api]
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use serde::{Serialize, Deserialize};
|
||||
use std::{error::Error, fs};
|
||||
use std::{error::Error, fs, path::Path};
|
||||
|
||||
use crate::env::Env;
|
||||
|
||||
|
@ -68,6 +68,10 @@ pub struct Branding {
|
|||
/// 🌠 blek! File
|
||||
#[serde(default)]
|
||||
pub instance_emoji: char,
|
||||
|
||||
/// Custom logo to display on the main page
|
||||
#[serde(default)]
|
||||
pub custom_logo: Option<String>
|
||||
}
|
||||
|
||||
impl Default for Branding {
|
||||
|
@ -76,6 +80,7 @@ impl Default for Branding {
|
|||
instance_name: "blek! File".into(),
|
||||
instance_motto: "A minute file sharing".into(),
|
||||
instance_emoji: '🌠',
|
||||
custom_logo: None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -142,6 +147,12 @@ impl FilesPolicy {
|
|||
|
||||
impl Branding {
|
||||
fn validate(self: &Self) -> Result<(), String> {
|
||||
if let Some(logo_path) = self.custom_logo.clone() {
|
||||
let logo_path = Path::new(&logo_path);
|
||||
if ! logo_path.is_file() {
|
||||
return Err("Config parameter branding.custom_logo is not a file. It must be a valid path that should be accessible from fileD's filesystem".into())
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue