feat: website FS path construction utility

This commit is contained in:
Aravinth Manivannan 2022-11-09 14:45:37 +05:30
parent ec7d698252
commit c86ca3467f
Signed by: realaravinth
GPG Key ID: AD9F0F08E855ED88
1 changed files with 7 additions and 0 deletions

View File

@ -14,6 +14,9 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use crate::Settings;
use std::path::{Path, PathBuf};
/// Get random string of specific length
pub(crate) fn get_random(len: usize) -> String {
use rand::{distributions::Alphanumeric, rngs::ThreadRng, thread_rng, Rng};
@ -27,3 +30,7 @@ pub(crate) fn get_random(len: usize) -> String {
.take(len)
.collect::<String>()
}
pub(crate) fn get_website_path(s: &Settings, hostname: &str) -> PathBuf {
Path::new(&s.page.base_path).join(hostname)
}