-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from neon-mmd/put-the-themes-on-different-paths
Ability to have themes on different paths
- Loading branch information
Showing
6 changed files
with
52 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod public_path_handler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//! This module provides the functionality to handle theme folder present on different paths and | ||
//! provide one appropriate path on which it is present and can be used. | ||
use std::io::Error; | ||
use std::path::Path; | ||
|
||
// ------- Constants -------- | ||
static PUBLIC_DIRECTORY_NAME: &str = "public"; | ||
|
||
/// A function which returns an appropriate theme directory path checking if the theme | ||
/// directory exists on that path. | ||
/// | ||
/// # Error | ||
/// | ||
/// Returns a `Theme (public) folder not found!!` error if the theme folder is not present under following | ||
/// paths which are: | ||
/// 1. `/opt/websurfx` if it not present here then it fallbacks to the next one (2) | ||
/// 2. Under project folder ( or codebase in other words) if it is not present | ||
/// here then it returns an error as mentioned above. | ||
pub fn handle_different_public_path() -> Result<String, Error> { | ||
if Path::new(format!("/opt/websurfx/{}/", PUBLIC_DIRECTORY_NAME).as_str()).exists() { | ||
Ok(format!("/opt/websurfx/{}", PUBLIC_DIRECTORY_NAME)) | ||
} else if Path::new(format!("./{}/", PUBLIC_DIRECTORY_NAME).as_str()).exists() { | ||
Ok(format!("./{}", PUBLIC_DIRECTORY_NAME)) | ||
} else { | ||
Err(Error::new( | ||
std::io::ErrorKind::NotFound, | ||
"Themes (public) folder not found!!", | ||
)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters