diff --git a/.gitignore b/.gitignore index f01bce58..5bb69e0c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,8 +6,10 @@ cobertura.xml prod/ node_modules/ /static-assets/bundle -/static +static/cache/bundle ./templates/**/*.js /static-assets/bundle/* src/cache_buster_data.json coverage +dist +assets diff --git a/build.rs b/build.rs index 531a6502..b4cf8613 100644 --- a/build.rs +++ b/build.rs @@ -47,8 +47,8 @@ fn cache_bust() { ]; let config = BusterBuilder::default() - .source("./static-assets") - .result("./static") + .source("./static/cache") + .result("./assets") .mime_types(types) .copy(true) .follow_links(true) diff --git a/src/docs.rs b/src/docs.rs index 27c3b9f2..3df5e5c9 100644 --- a/src/docs.rs +++ b/src/docs.rs @@ -51,7 +51,7 @@ pub fn services(cfg: &mut web::ServiceConfig) { } #[derive(RustEmbed)] -#[folder = "docs/"] +#[folder = "static/openapi/"] struct Asset; pub fn handle_embedded_file(path: &str) -> HttpResponse { diff --git a/src/main.rs b/src/main.rs index 18e2fcc5..0bdc1ffe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -55,11 +55,11 @@ lazy_static! { // 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(); + FILES.get("./static/cache/bundle/bundle.js").unwrap(); pub static ref CSS: &'static str = - FILES.get("./static-assets/bundle/bundle.css").unwrap(); + FILES.get("./static/cache/bundle/bundle.css").unwrap(); pub static ref MOBILE_CSS: &'static str = - FILES.get("./static-assets/bundle/mobile.css").unwrap(); + FILES.get("./static/cache/bundle/mobile.css").unwrap(); /// points to source files matching build commit pub static ref SOURCE_FILES_OF_INSTANCE: String = { diff --git a/src/static_assets/filemap.rs b/src/static_assets/filemap.rs index 2141daa9..1c5a338c 100644 --- a/src/static_assets/filemap.rs +++ b/src/static_assets/filemap.rs @@ -45,8 +45,8 @@ mod tests { #[test] fn filemap_works() { let files = super::FileMap::new(); - let css = files.get("./static-assets/bundle/bundle.css").unwrap(); + let css = files.get("./static/cache/bundle/bundle.css").unwrap(); println!("{}", css); - assert!(css.contains("/static/bundle/bundle")); + assert!(css.contains("/assets/bundle/bundle")); } } diff --git a/src/static_assets/static_files.rs b/src/static_assets/static_files.rs index 4458b87a..06cc7af2 100644 --- a/src/static_assets/static_files.rs +++ b/src/static_assets/static_files.rs @@ -25,7 +25,7 @@ use rust_embed::RustEmbed; use crate::CACHE_AGE; #[derive(RustEmbed)] -#[folder = "static/"] +#[folder = "assets/"] struct Asset; fn handle_assets(path: &str) -> HttpResponse { @@ -47,7 +47,7 @@ fn handle_assets(path: &str) -> HttpResponse { } } -#[get("/static/{_:.*}")] +#[get("/assets/{_:.*}")] pub async fn static_files(path: web::Path) -> impl Responder { handle_assets(&path.0) } @@ -55,7 +55,7 @@ pub async fn static_files(path: web::Path) -> impl Responder { #[derive(RustEmbed)] -#[folder = "static-assets/favicons/"] +#[folder = "static/favicons/"] struct Favicons; fn handle_favicons(path: &str) -> HttpResponse { @@ -90,7 +90,6 @@ mod tests { use super::*; use crate::*; - use crate::tests::*; #[actix_rt::test] async fn static_assets_work() { @@ -102,6 +101,18 @@ mod tests { ) .await; assert_eq!(resp.status(), StatusCode::OK); + + let resp = test::call_service( + &mut app, + test::TestRequest::get().uri( + crate::FILES + .get("./static/cache/img/icon-trans.png") + .unwrap() + ).to_request(), + ) + .await; + assert_eq!(resp.status(), StatusCode::OK); + } #[actix_rt::test] diff --git a/src/widget/mod.rs b/src/widget/mod.rs index 272b0a9a..3a3cdf98 100644 --- a/src/widget/mod.rs +++ b/src/widget/mod.rs @@ -72,20 +72,12 @@ pub fn services(cfg: &mut web::ServiceConfig) { mod test { use actix_web::http::StatusCode; use actix_web::test; - use actix_web::web::Bytes; use crate::*; #[actix_rt::test] async fn captcha_widget_route_works() { - let mut app = test::init_service( - actix_web::App::new() - .wrap(get_identity_service()) - .wrap(actix_middleware::NormalizePath::new( - actix_middleware::normalize::TrailingSlash::Trim, - )) - .configure(crate::widget::services) - ).await; + let mut app = get_app!().await; let list_sitekey_resp = test::call_service( diff --git a/static-assets/img/icon-trans.png b/static/cache/img/icon-trans.png similarity index 100% rename from static-assets/img/icon-trans.png rename to static/cache/img/icon-trans.png diff --git a/static-assets/img/icon.png b/static/cache/img/icon.png similarity index 100% rename from static-assets/img/icon.png rename to static/cache/img/icon.png diff --git a/static-assets/img/svg/bell.svg b/static/cache/img/svg/bell.svg similarity index 100% rename from static-assets/img/svg/bell.svg rename to static/cache/img/svg/bell.svg diff --git a/static-assets/img/svg/credit-card.svg b/static/cache/img/svg/credit-card.svg similarity index 100% rename from static-assets/img/svg/credit-card.svg rename to static/cache/img/svg/credit-card.svg diff --git a/static-assets/img/svg/eye-off.svg b/static/cache/img/svg/eye-off.svg similarity index 100% rename from static-assets/img/svg/eye-off.svg rename to static/cache/img/svg/eye-off.svg diff --git a/static-assets/img/svg/eye.svg b/static/cache/img/svg/eye.svg similarity index 100% rename from static-assets/img/svg/eye.svg rename to static/cache/img/svg/eye.svg diff --git a/static-assets/img/svg/file-text.svg b/static/cache/img/svg/file-text.svg similarity index 100% rename from static-assets/img/svg/file-text.svg rename to static/cache/img/svg/file-text.svg diff --git a/static-assets/img/svg/file.svg b/static/cache/img/svg/file.svg similarity index 100% rename from static-assets/img/svg/file.svg rename to static/cache/img/svg/file.svg diff --git a/static-assets/img/svg/filter.svg b/static/cache/img/svg/filter.svg similarity index 100% rename from static-assets/img/svg/filter.svg rename to static/cache/img/svg/filter.svg diff --git a/static-assets/img/svg/github.svg b/static/cache/img/svg/github.svg similarity index 100% rename from static-assets/img/svg/github.svg rename to static/cache/img/svg/github.svg diff --git a/static-assets/img/svg/globe.svg b/static/cache/img/svg/globe.svg similarity index 100% rename from static-assets/img/svg/globe.svg rename to static/cache/img/svg/globe.svg diff --git a/static-assets/img/svg/help-circle.svg b/static/cache/img/svg/help-circle.svg similarity index 100% rename from static-assets/img/svg/help-circle.svg rename to static/cache/img/svg/help-circle.svg diff --git a/static-assets/img/svg/home.svg b/static/cache/img/svg/home.svg similarity index 100% rename from static-assets/img/svg/home.svg rename to static/cache/img/svg/home.svg diff --git a/static-assets/img/svg/key.svg b/static/cache/img/svg/key.svg similarity index 100% rename from static-assets/img/svg/key.svg rename to static/cache/img/svg/key.svg diff --git a/static-assets/img/svg/log-out.svg b/static/cache/img/svg/log-out.svg similarity index 100% rename from static-assets/img/svg/log-out.svg rename to static/cache/img/svg/log-out.svg diff --git a/static-assets/img/svg/menu.svg b/static/cache/img/svg/menu.svg similarity index 100% rename from static-assets/img/svg/menu.svg rename to static/cache/img/svg/menu.svg diff --git a/static-assets/img/svg/message-square.svg b/static/cache/img/svg/message-square.svg similarity index 100% rename from static-assets/img/svg/message-square.svg rename to static/cache/img/svg/message-square.svg diff --git a/static-assets/img/svg/moon.svg b/static/cache/img/svg/moon.svg similarity index 100% rename from static-assets/img/svg/moon.svg rename to static/cache/img/svg/moon.svg diff --git a/static-assets/img/svg/settings.svg b/static/cache/img/svg/settings.svg similarity index 100% rename from static-assets/img/svg/settings.svg rename to static/cache/img/svg/settings.svg diff --git a/static-assets/img/svg/shield-off.svg b/static/cache/img/svg/shield-off.svg similarity index 100% rename from static-assets/img/svg/shield-off.svg rename to static/cache/img/svg/shield-off.svg diff --git a/static-assets/img/svg/shield.svg b/static/cache/img/svg/shield.svg similarity index 100% rename from static-assets/img/svg/shield.svg rename to static/cache/img/svg/shield.svg diff --git a/static-assets/img/svg/tag.svg b/static/cache/img/svg/tag.svg similarity index 100% rename from static-assets/img/svg/tag.svg rename to static/cache/img/svg/tag.svg diff --git a/static-assets/img/svg/toggle-left.svg b/static/cache/img/svg/toggle-left.svg similarity index 100% rename from static-assets/img/svg/toggle-left.svg rename to static/cache/img/svg/toggle-left.svg diff --git a/static-assets/img/svg/toggle-right.svg b/static/cache/img/svg/toggle-right.svg similarity index 100% rename from static-assets/img/svg/toggle-right.svg rename to static/cache/img/svg/toggle-right.svg diff --git a/static-assets/img/svg/user.svg b/static/cache/img/svg/user.svg similarity index 100% rename from static-assets/img/svg/user.svg rename to static/cache/img/svg/user.svg diff --git a/static-assets/favicons/android-icon-144x144.png b/static/favicons/android-icon-144x144.png similarity index 100% rename from static-assets/favicons/android-icon-144x144.png rename to static/favicons/android-icon-144x144.png diff --git a/static-assets/favicons/android-icon-192x192.png b/static/favicons/android-icon-192x192.png similarity index 100% rename from static-assets/favicons/android-icon-192x192.png rename to static/favicons/android-icon-192x192.png diff --git a/static-assets/favicons/android-icon-36x36.png b/static/favicons/android-icon-36x36.png similarity index 100% rename from static-assets/favicons/android-icon-36x36.png rename to static/favicons/android-icon-36x36.png diff --git a/static-assets/favicons/android-icon-48x48.png b/static/favicons/android-icon-48x48.png similarity index 100% rename from static-assets/favicons/android-icon-48x48.png rename to static/favicons/android-icon-48x48.png diff --git a/static-assets/favicons/android-icon-72x72.png b/static/favicons/android-icon-72x72.png similarity index 100% rename from static-assets/favicons/android-icon-72x72.png rename to static/favicons/android-icon-72x72.png diff --git a/static-assets/favicons/android-icon-96x96.png b/static/favicons/android-icon-96x96.png similarity index 100% rename from static-assets/favicons/android-icon-96x96.png rename to static/favicons/android-icon-96x96.png diff --git a/static-assets/favicons/apple-icon-114x114.png b/static/favicons/apple-icon-114x114.png similarity index 100% rename from static-assets/favicons/apple-icon-114x114.png rename to static/favicons/apple-icon-114x114.png diff --git a/static-assets/favicons/apple-icon-120x120.png b/static/favicons/apple-icon-120x120.png similarity index 100% rename from static-assets/favicons/apple-icon-120x120.png rename to static/favicons/apple-icon-120x120.png diff --git a/static-assets/favicons/apple-icon-144x144.png b/static/favicons/apple-icon-144x144.png similarity index 100% rename from static-assets/favicons/apple-icon-144x144.png rename to static/favicons/apple-icon-144x144.png diff --git a/static-assets/favicons/apple-icon-152x152.png b/static/favicons/apple-icon-152x152.png similarity index 100% rename from static-assets/favicons/apple-icon-152x152.png rename to static/favicons/apple-icon-152x152.png diff --git a/static-assets/favicons/apple-icon-180x180.png b/static/favicons/apple-icon-180x180.png similarity index 100% rename from static-assets/favicons/apple-icon-180x180.png rename to static/favicons/apple-icon-180x180.png diff --git a/static-assets/favicons/apple-icon-57x57.png b/static/favicons/apple-icon-57x57.png similarity index 100% rename from static-assets/favicons/apple-icon-57x57.png rename to static/favicons/apple-icon-57x57.png diff --git a/static-assets/favicons/apple-icon-60x60.png b/static/favicons/apple-icon-60x60.png similarity index 100% rename from static-assets/favicons/apple-icon-60x60.png rename to static/favicons/apple-icon-60x60.png diff --git a/static-assets/favicons/apple-icon-72x72.png b/static/favicons/apple-icon-72x72.png similarity index 100% rename from static-assets/favicons/apple-icon-72x72.png rename to static/favicons/apple-icon-72x72.png diff --git a/static-assets/favicons/apple-icon-76x76.png b/static/favicons/apple-icon-76x76.png similarity index 100% rename from static-assets/favicons/apple-icon-76x76.png rename to static/favicons/apple-icon-76x76.png diff --git a/static-assets/favicons/apple-icon-precomposed.png b/static/favicons/apple-icon-precomposed.png similarity index 100% rename from static-assets/favicons/apple-icon-precomposed.png rename to static/favicons/apple-icon-precomposed.png diff --git a/static-assets/favicons/apple-icon.png b/static/favicons/apple-icon.png similarity index 100% rename from static-assets/favicons/apple-icon.png rename to static/favicons/apple-icon.png diff --git a/static-assets/favicons/browserconfig.xml b/static/favicons/browserconfig.xml similarity index 100% rename from static-assets/favicons/browserconfig.xml rename to static/favicons/browserconfig.xml diff --git a/static-assets/favicons/favicon-16x16.png b/static/favicons/favicon-16x16.png similarity index 100% rename from static-assets/favicons/favicon-16x16.png rename to static/favicons/favicon-16x16.png diff --git a/static-assets/favicons/favicon-32x32.png b/static/favicons/favicon-32x32.png similarity index 100% rename from static-assets/favicons/favicon-32x32.png rename to static/favicons/favicon-32x32.png diff --git a/static-assets/favicons/favicon-96x96.png b/static/favicons/favicon-96x96.png similarity index 100% rename from static-assets/favicons/favicon-96x96.png rename to static/favicons/favicon-96x96.png diff --git a/static-assets/favicons/favicon.ico b/static/favicons/favicon.ico similarity index 100% rename from static-assets/favicons/favicon.ico rename to static/favicons/favicon.ico diff --git a/static-assets/favicons/manifest.json b/static/favicons/manifest.json similarity index 96% rename from static-assets/favicons/manifest.json rename to static/favicons/manifest.json index 013d4a6a..e7fba85b 100644 --- a/static-assets/favicons/manifest.json +++ b/static/favicons/manifest.json @@ -1,5 +1,5 @@ { - "name": "App", + "name": "mCaptcha", "icons": [ { "src": "\/android-icon-36x36.png", @@ -38,4 +38,4 @@ "density": "4.0" } ] -} \ No newline at end of file +} diff --git a/static-assets/favicons/ms-icon-144x144.png b/static/favicons/ms-icon-144x144.png similarity index 100% rename from static-assets/favicons/ms-icon-144x144.png rename to static/favicons/ms-icon-144x144.png diff --git a/static-assets/favicons/ms-icon-150x150.png b/static/favicons/ms-icon-150x150.png similarity index 100% rename from static-assets/favicons/ms-icon-150x150.png rename to static/favicons/ms-icon-150x150.png diff --git a/static-assets/favicons/ms-icon-310x310.png b/static/favicons/ms-icon-310x310.png similarity index 100% rename from static-assets/favicons/ms-icon-310x310.png rename to static/favicons/ms-icon-310x310.png diff --git a/static-assets/favicons/ms-icon-70x70.png b/static/favicons/ms-icon-70x70.png similarity index 100% rename from static-assets/favicons/ms-icon-70x70.png rename to static/favicons/ms-icon-70x70.png diff --git a/docs/favicon-16x16.png b/static/openapi/favicon-16x16.png similarity index 100% rename from docs/favicon-16x16.png rename to static/openapi/favicon-16x16.png diff --git a/docs/favicon-32x32.png b/static/openapi/favicon-32x32.png similarity index 100% rename from docs/favicon-32x32.png rename to static/openapi/favicon-32x32.png diff --git a/docs/index.html b/static/openapi/index.html similarity index 100% rename from docs/index.html rename to static/openapi/index.html diff --git a/docs/oauth2-redirect.html b/static/openapi/oauth2-redirect.html similarity index 100% rename from docs/oauth2-redirect.html rename to static/openapi/oauth2-redirect.html diff --git a/docs/swagger-ui-bundle.js b/static/openapi/swagger-ui-bundle.js similarity index 100% rename from docs/swagger-ui-bundle.js rename to static/openapi/swagger-ui-bundle.js diff --git a/docs/swagger-ui-bundle.js.map b/static/openapi/swagger-ui-bundle.js.map similarity index 100% rename from docs/swagger-ui-bundle.js.map rename to static/openapi/swagger-ui-bundle.js.map diff --git a/docs/swagger-ui-es-bundle-core.js b/static/openapi/swagger-ui-es-bundle-core.js similarity index 100% rename from docs/swagger-ui-es-bundle-core.js rename to static/openapi/swagger-ui-es-bundle-core.js diff --git a/docs/swagger-ui-es-bundle-core.js.map b/static/openapi/swagger-ui-es-bundle-core.js.map similarity index 100% rename from docs/swagger-ui-es-bundle-core.js.map rename to static/openapi/swagger-ui-es-bundle-core.js.map diff --git a/docs/swagger-ui-es-bundle.js b/static/openapi/swagger-ui-es-bundle.js similarity index 100% rename from docs/swagger-ui-es-bundle.js rename to static/openapi/swagger-ui-es-bundle.js diff --git a/docs/swagger-ui-es-bundle.js.map b/static/openapi/swagger-ui-es-bundle.js.map similarity index 100% rename from docs/swagger-ui-es-bundle.js.map rename to static/openapi/swagger-ui-es-bundle.js.map diff --git a/docs/swagger-ui-standalone-preset.js b/static/openapi/swagger-ui-standalone-preset.js similarity index 100% rename from docs/swagger-ui-standalone-preset.js rename to static/openapi/swagger-ui-standalone-preset.js diff --git a/docs/swagger-ui-standalone-preset.js.map b/static/openapi/swagger-ui-standalone-preset.js.map similarity index 100% rename from docs/swagger-ui-standalone-preset.js.map rename to static/openapi/swagger-ui-standalone-preset.js.map diff --git a/docs/swagger-ui.css b/static/openapi/swagger-ui.css similarity index 100% rename from docs/swagger-ui.css rename to static/openapi/swagger-ui.css diff --git a/docs/swagger-ui.css.map b/static/openapi/swagger-ui.css.map similarity index 100% rename from docs/swagger-ui.css.map rename to static/openapi/swagger-ui.css.map diff --git a/docs/swagger-ui.js b/static/openapi/swagger-ui.js similarity index 100% rename from docs/swagger-ui.js rename to static/openapi/swagger-ui.js diff --git a/docs/swagger-ui.js.map b/static/openapi/swagger-ui.js.map similarity index 100% rename from docs/swagger-ui.js.map rename to static/openapi/swagger-ui.js.map diff --git a/templates/auth/login/index.html b/templates/auth/login/index.html index bb266005..66e2e7e7 100644 --- a/templates/auth/login/index.html +++ b/templates/auth/login/index.html @@ -4,7 +4,7 @@
" + crate::FILES.get("./static/cache/img/icon-trans.png").unwrap().>" class="auth__logo" alt="mcaptcha logo" />
" + crate::FILES.get("./static/cache/img/icon-trans.png").unwrap().>" class="auth__logo" alt="mcaptcha logo" /> diff --git a/templates/components/headers/raw-headers.html b/templates/components/headers/raw-headers.html index 23d8fc86..47d75466 100644 --- a/templates/components/headers/raw-headers.html +++ b/templates/components/headers/raw-headers.html @@ -24,7 +24,7 @@ /> " + content="<.= crate::FILES.get("./static/cache/img/icon-trans.png").unwrap().>" /> " + content="<.= crate::FILES.get("./static/cache/img/icon-trans.png").unwrap().>" /> " alt="" /> + crate::FILES.get("./static/cache/img/svg/eye.svg").unwrap() .>" alt="" /> " alt="" /> + crate::FILES.get("./static/cache/img/svg/eye-off.svg").unwrap() .>" alt="" /> diff --git a/templates/panel/header/taskbar/index.html b/templates/panel/header/taskbar/index.html index 464af33c..0c377572 100644 --- a/templates/panel/header/taskbar/index.html +++ b/templates/panel/header/taskbar/index.html @@ -12,19 +12,19 @@
  • " alt="Profile" /> + crate::FILES.get("./static/cache/img/svg/moon.svg").unwrap() .>" alt="Profile" />
  • " + crate::FILES.get("./static/cache/img/svg/bell.svg").unwrap() .>" alt="Notifications" />
  • " alt="Profile" + crate::FILES.get("./static/cache/img/svg/log-out.svg").unwrap() .>" alt="Profile" />
  • diff --git a/templates/panel/navbar/index.html b/templates/panel/navbar/index.html index bdc17e3c..4256ecbc 100644 --- a/templates/panel/navbar/index.html +++ b/templates/panel/navbar/index.html @@ -1,7 +1,7 @@