diff --git a/README.md b/README.md index 0a92a4e5..88650d70 100644 --- a/README.md +++ b/README.md @@ -88,8 +88,6 @@ $ docker-compose -d up It takes a while to build the image so please be patient :) -A hosted demo server is in the works... - ## Development: See [DEVELOPMENT.md](./DEVELOPMENT.md) diff --git a/src/main.rs b/src/main.rs index cf6c1a81..866128fb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -50,7 +50,7 @@ pub use crate::middleware::auth::CheckLogin; lazy_static! { pub static ref SETTINGS: Settings = Settings::new().unwrap(); - pub static ref S: String = env::var("S").unwrap(); +// pub static ref S: String = env::var("S").unwrap(); pub static ref FILES: FileMap = FileMap::new(); pub static ref JS: &'static str = FILES.get("./static-assets/bundle/bundle.js").unwrap(); @@ -58,6 +58,19 @@ lazy_static! { FILES.get("./static-assets/bundle/bundle.css").unwrap(); pub static ref MOBILE_CSS: &'static str = FILES.get("./static-assets/bundle/mobile.css").unwrap(); + + /// points to source files matching build commit + pub static ref SOURCE_FILES_OF_INSTANCE: String = { + let mut url = SETTINGS.source_code.clone(); + if url.chars().last() != Some('/') { + url.push('/'); + } + let mut base = url::Url::parse(&url).unwrap(); + base = base.join("tree/").unwrap(); + base = base.join(GIT_COMMIT_HASH).unwrap(); + base.into() + }; + } pub static OPEN_API_DOC: &str = env!("OPEN_API_DOCS"); @@ -127,3 +140,17 @@ pub fn get_identity_service() -> IdentityService { .secure(false), ) } + +#[cfg(test)] +mod test { + #[test] + fn version_source_code_url_works() { + assert_eq!( + &*crate::SOURCE_FILES_OF_INSTANCE, + &format!( + "https://github.com/mCaptcha/guard/tree/{}", + crate::GIT_COMMIT_HASH + ) + ); + } +} diff --git a/templates/components/details-footer/index.html b/templates/components/details-footer/index.html index 2bda97e7..b8744c72 100644 --- a/templates/components/details-footer/index.html +++ b/templates/components/details-footer/index.html @@ -22,7 +22,10 @@ href="<.= crate::PKG_HOMEPAGE .><.= crate::PAGES.thanks .>">Thanks
  • - v<.= crate::VERSION .>-<.= crate::GIT_COMMIT_HASH[0..8] .> + + v<.= crate::VERSION .>-<.= crate::GIT_COMMIT_HASH[0..8] .> +