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
|
# Used as the icon where icon images are not available
|
||||||
instance_emoji="🌠"
|
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 settings
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Serialize, Deserialize};
|
||||||
use std::{error::Error, fs};
|
use std::{error::Error, fs, path::Path};
|
||||||
|
|
||||||
use crate::env::Env;
|
use crate::env::Env;
|
||||||
|
|
||||||
|
@ -68,6 +68,10 @@ pub struct Branding {
|
||||||
/// 🌠 blek! File
|
/// 🌠 blek! File
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub instance_emoji: char,
|
pub instance_emoji: char,
|
||||||
|
|
||||||
|
/// Custom logo to display on the main page
|
||||||
|
#[serde(default)]
|
||||||
|
pub custom_logo: Option<String>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Branding {
|
impl Default for Branding {
|
||||||
|
@ -76,6 +80,7 @@ impl Default for Branding {
|
||||||
instance_name: "blek! File".into(),
|
instance_name: "blek! File".into(),
|
||||||
instance_motto: "A minute file sharing".into(),
|
instance_motto: "A minute file sharing".into(),
|
||||||
instance_emoji: '🌠',
|
instance_emoji: '🌠',
|
||||||
|
custom_logo: None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,6 +147,12 @@ impl FilesPolicy {
|
||||||
|
|
||||||
impl Branding {
|
impl Branding {
|
||||||
fn validate(self: &Self) -> Result<(), String> {
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue