feat: website FS path construction utility
This commit is contained in:
parent
ec7d698252
commit
c86ca3467f
1 changed files with 7 additions and 0 deletions
|
@ -14,6 +14,9 @@
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* 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
|
/// Get random string of specific length
|
||||||
pub(crate) fn get_random(len: usize) -> String {
|
pub(crate) fn get_random(len: usize) -> String {
|
||||||
use rand::{distributions::Alphanumeric, rngs::ThreadRng, thread_rng, Rng};
|
use rand::{distributions::Alphanumeric, rngs::ThreadRng, thread_rng, Rng};
|
||||||
|
@ -27,3 +30,7 @@ pub(crate) fn get_random(len: usize) -> String {
|
||||||
.take(len)
|
.take(len)
|
||||||
.collect::<String>()
|
.collect::<String>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn get_website_path(s: &Settings, hostname: &str) -> PathBuf {
|
||||||
|
Path::new(&s.page.base_path).join(hostname)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue