From b3035e21ef3c48562b9a04989ca0c8b1f22e814b Mon Sep 17 00:00:00 2001
From: Kenneth Koski <kennethkoski@gmail.com>
Date: Sun, 1 Nov 2020 21:21:15 -0600
Subject: [PATCH] Parameterize docs directory (#1245)

Adds `docs_dir` setting for configurable documentation location
---
 config/defaults.hjson       | 2 ++
 lemmy_utils/src/settings.rs | 3 ++-
 src/main.rs                 | 2 +-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/config/defaults.hjson b/config/defaults.hjson
index 0368500b..59b808f8 100644
--- a/config/defaults.hjson
+++ b/config/defaults.hjson
@@ -35,6 +35,8 @@
   tls_enabled: true
   # json web token for authorization between server and client
   jwt_secret: "changeme"
+  # path to built documentation
+  docs_dir: "/app/documentation"
   # address where pictrs is available
   pictrs_url: "http://pictrs:8080"
   # rate limits for various user actions, by user ip
diff --git a/lemmy_utils/src/settings.rs b/lemmy_utils/src/settings.rs
index 797c6fba..9c6eeb28 100644
--- a/lemmy_utils/src/settings.rs
+++ b/lemmy_utils/src/settings.rs
@@ -1,6 +1,6 @@
 use config::{Config, ConfigError, Environment, File};
 use serde::Deserialize;
-use std::{env, fs, io::Error, net::IpAddr, sync::RwLock};
+use std::{env, fs, io::Error, net::IpAddr, path::PathBuf, sync::RwLock};
 
 static CONFIG_FILE_DEFAULTS: &str = "config/defaults.hjson";
 static CONFIG_FILE: &str = "config/config.hjson";
@@ -13,6 +13,7 @@ pub struct Settings {
   pub bind: IpAddr,
   pub port: u16,
   pub tls_enabled: bool,
+  pub docs_dir: PathBuf,
   pub jwt_secret: String,
   pub pictrs_url: String,
   pub rate_limit: RateLimitConfig,
diff --git a/src/main.rs b/src/main.rs
index 811c920a..c55c3655 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -84,7 +84,7 @@ async fn main() -> Result<(), LemmyError> {
       .configure(|cfg| images::config(cfg, &rate_limiter))
       .configure(nodeinfo::config)
       .configure(webfinger::config)
-      .service(actix_files::Files::new("/docs", "/app/documentation"))
+      .service(actix_files::Files::new("/docs", Settings::get().docs_dir))
   })
   .bind((settings.bind, settings.port))?
   .run()
-- 
2.44.1