rearranged static files

This commit is contained in:
realaravinth 2021-05-29 12:22:31 +05:30
parent 417e008c27
commit c873d152c3
No known key found for this signature in database
GPG key ID: AD9F0F08E855ED88
83 changed files with 49 additions and 44 deletions

4
.gitignore vendored
View file

@ -6,8 +6,10 @@ cobertura.xml
prod/ prod/
node_modules/ node_modules/
/static-assets/bundle /static-assets/bundle
/static static/cache/bundle
./templates/**/*.js ./templates/**/*.js
/static-assets/bundle/* /static-assets/bundle/*
src/cache_buster_data.json src/cache_buster_data.json
coverage coverage
dist
assets

View file

@ -47,8 +47,8 @@ fn cache_bust() {
]; ];
let config = BusterBuilder::default() let config = BusterBuilder::default()
.source("./static-assets") .source("./static/cache")
.result("./static") .result("./assets")
.mime_types(types) .mime_types(types)
.copy(true) .copy(true)
.follow_links(true) .follow_links(true)

View file

@ -51,7 +51,7 @@ pub fn services(cfg: &mut web::ServiceConfig) {
} }
#[derive(RustEmbed)] #[derive(RustEmbed)]
#[folder = "docs/"] #[folder = "static/openapi/"]
struct Asset; struct Asset;
pub fn handle_embedded_file(path: &str) -> HttpResponse { pub fn handle_embedded_file(path: &str) -> HttpResponse {

View file

@ -55,11 +55,11 @@ lazy_static! {
// 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 FILES: FileMap = FileMap::new();
pub static ref JS: &'static str = 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 = 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 = 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 /// points to source files matching build commit
pub static ref SOURCE_FILES_OF_INSTANCE: String = { pub static ref SOURCE_FILES_OF_INSTANCE: String = {

View file

@ -45,8 +45,8 @@ mod tests {
#[test] #[test]
fn filemap_works() { fn filemap_works() {
let files = super::FileMap::new(); 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); println!("{}", css);
assert!(css.contains("/static/bundle/bundle")); assert!(css.contains("/assets/bundle/bundle"));
} }
} }

View file

@ -25,7 +25,7 @@ use rust_embed::RustEmbed;
use crate::CACHE_AGE; use crate::CACHE_AGE;
#[derive(RustEmbed)] #[derive(RustEmbed)]
#[folder = "static/"] #[folder = "assets/"]
struct Asset; struct Asset;
fn handle_assets(path: &str) -> HttpResponse { 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<String>) -> impl Responder { pub async fn static_files(path: web::Path<String>) -> impl Responder {
handle_assets(&path.0) handle_assets(&path.0)
} }
@ -55,7 +55,7 @@ pub async fn static_files(path: web::Path<String>) -> impl Responder {
#[derive(RustEmbed)] #[derive(RustEmbed)]
#[folder = "static-assets/favicons/"] #[folder = "static/favicons/"]
struct Favicons; struct Favicons;
fn handle_favicons(path: &str) -> HttpResponse { fn handle_favicons(path: &str) -> HttpResponse {
@ -90,7 +90,6 @@ mod tests {
use super::*; use super::*;
use crate::*; use crate::*;
use crate::tests::*;
#[actix_rt::test] #[actix_rt::test]
async fn static_assets_work() { async fn static_assets_work() {
@ -102,6 +101,18 @@ mod tests {
) )
.await; .await;
assert_eq!(resp.status(), StatusCode::OK); 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] #[actix_rt::test]

View file

@ -72,20 +72,12 @@ pub fn services(cfg: &mut web::ServiceConfig) {
mod test { mod test {
use actix_web::http::StatusCode; use actix_web::http::StatusCode;
use actix_web::test; use actix_web::test;
use actix_web::web::Bytes;
use crate::*; use crate::*;
#[actix_rt::test] #[actix_rt::test]
async fn captcha_widget_route_works() { async fn captcha_widget_route_works() {
let mut app = test::init_service( let mut app = get_app!().await;
actix_web::App::new()
.wrap(get_identity_service())
.wrap(actix_middleware::NormalizePath::new(
actix_middleware::normalize::TrailingSlash::Trim,
))
.configure(crate::widget::services)
).await;
let list_sitekey_resp = test::call_service( let list_sitekey_resp = test::call_service(

View file

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

View file

Before

Width:  |  Height:  |  Size: 455 KiB

After

Width:  |  Height:  |  Size: 455 KiB

View file

Before

Width:  |  Height:  |  Size: 321 B

After

Width:  |  Height:  |  Size: 321 B

View file

Before

Width:  |  Height:  |  Size: 329 B

After

Width:  |  Height:  |  Size: 329 B

View file

Before

Width:  |  Height:  |  Size: 460 B

After

Width:  |  Height:  |  Size: 460 B

View file

Before

Width:  |  Height:  |  Size: 316 B

After

Width:  |  Height:  |  Size: 316 B

View file

Before

Width:  |  Height:  |  Size: 473 B

After

Width:  |  Height:  |  Size: 473 B

View file

Before

Width:  |  Height:  |  Size: 337 B

After

Width:  |  Height:  |  Size: 337 B

View file

Before

Width:  |  Height:  |  Size: 290 B

After

Width:  |  Height:  |  Size: 290 B

View file

Before

Width:  |  Height:  |  Size: 528 B

After

Width:  |  Height:  |  Size: 528 B

View file

Before

Width:  |  Height:  |  Size: 409 B

After

Width:  |  Height:  |  Size: 409 B

View file

Before

Width:  |  Height:  |  Size: 365 B

After

Width:  |  Height:  |  Size: 365 B

View file

Before

Width:  |  Height:  |  Size: 332 B

After

Width:  |  Height:  |  Size: 332 B

View file

Before

Width:  |  Height:  |  Size: 352 B

After

Width:  |  Height:  |  Size: 352 B

View file

Before

Width:  |  Height:  |  Size: 367 B

After

Width:  |  Height:  |  Size: 367 B

View file

Before

Width:  |  Height:  |  Size: 346 B

After

Width:  |  Height:  |  Size: 346 B

View file

Before

Width:  |  Height:  |  Size: 305 B

After

Width:  |  Height:  |  Size: 305 B

View file

Before

Width:  |  Height:  |  Size: 281 B

After

Width:  |  Height:  |  Size: 281 B

View file

Before

Width:  |  Height:  |  Size: 1,011 B

After

Width:  |  Height:  |  Size: 1,011 B

View file

Before

Width:  |  Height:  |  Size: 405 B

After

Width:  |  Height:  |  Size: 405 B

View file

Before

Width:  |  Height:  |  Size: 279 B

After

Width:  |  Height:  |  Size: 279 B

View file

Before

Width:  |  Height:  |  Size: 355 B

After

Width:  |  Height:  |  Size: 355 B

View file

Before

Width:  |  Height:  |  Size: 323 B

After

Width:  |  Height:  |  Size: 323 B

View file

Before

Width:  |  Height:  |  Size: 325 B

After

Width:  |  Height:  |  Size: 325 B

View file

Before

Width:  |  Height:  |  Size: 313 B

After

Width:  |  Height:  |  Size: 313 B

View file

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View file

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

View file

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 3 KiB

View file

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View file

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

View file

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View file

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View file

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View file

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View file

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View file

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 47 KiB

View file

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

View file

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

View file

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

View file

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

View file

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

View file

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

View file

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View file

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -1,5 +1,5 @@
{ {
"name": "App", "name": "mCaptcha",
"icons": [ "icons": [
{ {
"src": "\/android-icon-36x36.png", "src": "\/android-icon-36x36.png",
@ -38,4 +38,4 @@
"density": "4.0" "density": "4.0"
} }
] ]
} }

View file

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View file

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

View file

Before

Width:  |  Height:  |  Size: 111 KiB

After

Width:  |  Height:  |  Size: 111 KiB

View file

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

View file

Before

Width:  |  Height:  |  Size: 665 B

After

Width:  |  Height:  |  Size: 665 B

View file

Before

Width:  |  Height:  |  Size: 628 B

After

Width:  |  Height:  |  Size: 628 B

View file

@ -4,7 +4,7 @@
<div class="auth-inner-container"> <div class="auth-inner-container">
<img src="<.= <img src="<.=
crate::FILES.get("./static-assets/img/icon-trans.png").unwrap().>" crate::FILES.get("./static/cache/img/icon-trans.png").unwrap().>"
class="auth__logo" alt="mcaptcha logo" /> class="auth__logo" alt="mcaptcha logo" />
<form <form

View file

@ -4,7 +4,7 @@
<div class="auth-inner-container"> <div class="auth-inner-container">
<img src="<.= <img src="<.=
crate::FILES.get("./static-assets/img/icon-trans.png").unwrap().>" crate::FILES.get("./static/cache/img/icon-trans.png").unwrap().>"
class="auth__logo" alt="mcaptcha logo" /> class="auth__logo" alt="mcaptcha logo" />

View file

@ -24,7 +24,7 @@
/> />
<meta name="twitter:creator" content="@realaravinth" /> <meta name="twitter:creator" content="@realaravinth" />
<meta name="twitter:image" <meta name="twitter:image"
content="<.= crate::FILES.get("./static-assets/img/icon-trans.png").unwrap().>" content="<.= crate::FILES.get("./static/cache/img/icon-trans.png").unwrap().>"
/> />
<meta <meta
@ -34,7 +34,7 @@
<meta property="og:type" content="article" /> <meta property="og:type" content="article" />
<meta property="og:url" content="https://mcaptcaha.org" /> <meta property="og:url" content="https://mcaptcaha.org" />
<meta property="og:image" <meta property="og:image"
content="<.= crate::FILES.get("./static-assets/img/icon-trans.png").unwrap().>" content="<.= crate::FILES.get("./static/cache/img/icon-trans.png").unwrap().>"
/> />
<meta <meta

View file

@ -1,6 +1,6 @@
<span class="show-password-container"> <span class="show-password-container">
<img class="show-password--show" src="<.= <img class="show-password--show" src="<.=
crate::FILES.get("./static-assets/img/svg/eye.svg").unwrap() .>" alt="" /> crate::FILES.get("./static/cache/img/svg/eye.svg").unwrap() .>" alt="" />
<img class="show-password--hide" src="<.= <img class="show-password--hide" src="<.=
crate::FILES.get("./static-assets/img/svg/eye-off.svg").unwrap() .>" alt="" /> crate::FILES.get("./static/cache/img/svg/eye-off.svg").unwrap() .>" alt="" />
</span> </span>

View file

@ -12,19 +12,19 @@
</li> </li>
<li class="taskbar__action"> <li class="taskbar__action">
<img class="taskbar__icon" src="<.= <img class="taskbar__icon" src="<.=
crate::FILES.get("./static-assets/img/svg/moon.svg").unwrap() .>" alt="Profile" /> crate::FILES.get("./static/cache/img/svg/moon.svg").unwrap() .>" alt="Profile" />
</li> </li>
<li class="taskbar__action"> <li class="taskbar__action">
<img class="taskbar__icon" src="<.= <img class="taskbar__icon" src="<.=
crate::FILES.get("./static-assets/img/svg/bell.svg").unwrap() .>" crate::FILES.get("./static/cache/img/svg/bell.svg").unwrap() .>"
alt="Notifications" /> alt="Notifications" />
</li> </li>
<li class="taskbar__action"> <li class="taskbar__action">
<a href="<.= crate::V1_API_ROUTES.auth.logout .>"> <a href="<.= crate::V1_API_ROUTES.auth.logout .>">
<img class="taskbar__icon" src="<.= <img class="taskbar__icon" src="<.=
crate::FILES.get("./static-assets/img/svg/log-out.svg").unwrap() .>" alt="Profile" crate::FILES.get("./static/cache/img/svg/log-out.svg").unwrap() .>" alt="Profile"
/></a> /></a>
</li> </li>
</ul> </ul>

View file

@ -1,7 +1,7 @@
<nav class="secondary-menu"> <nav class="secondary-menu">
<ul class="secondary-menu__lsit"> <ul class="secondary-menu__lsit">
<li class="secondary-menu__heading"> <li class="secondary-menu__heading">
<img class="secondary-menu__logo" src="<.= crate::FILES.get("./static-assets/img/icon-trans.png").unwrap() .>" alt="Logo" /> <img class="secondary-menu__logo" src="<.= crate::FILES.get("./static/cache/img/icon-trans.png").unwrap() .>" alt="Logo" />
<div class="secondary-menu__brand-name"> <div class="secondary-menu__brand-name">
mCaptcha mCaptcha
</div> </div>
@ -12,7 +12,7 @@
--> -->
<li class="secondary-menu__item"> <li class="secondary-menu__item">
<a class="secondary-menu__item-link" href="<.= crate::PAGES.home .>"> <a class="secondary-menu__item-link" href="<.= crate::PAGES.home .>">
<img class="secondary-menu__icon" src="<.= crate::FILES.get("./static-assets/img/svg/home.svg").unwrap() .>" alt="" /> <img class="secondary-menu__icon" src="<.= crate::FILES.get("./static/cache/img/svg/home.svg").unwrap() .>" alt="" />
<div class="secondary-menu__item-name"> <div class="secondary-menu__item-name">
Overview Overview
</div> </div>
@ -20,7 +20,7 @@
</li> </li>
<li class="secondary-menu__item"> <li class="secondary-menu__item">
<a class="secondary-menu__item-link" href="<.= crate::PAGES.panel.sitekey.list .>"> <a class="secondary-menu__item-link" href="<.= crate::PAGES.panel.sitekey.list .>">
<img class="secondary-menu__icon" src="<.= crate::FILES.get("./static-assets/img/svg/key.svg").unwrap() .>" alt="" /> <img class="secondary-menu__icon" src="<.= crate::FILES.get("./static/cache/img/svg/key.svg").unwrap() .>" alt="" />
<div class="secondary-menu__item-name"> <div class="secondary-menu__item-name">
Site Keys Site Keys
</div> </div>
@ -29,7 +29,7 @@
<li class="secondary-menu__item"> <li class="secondary-menu__item">
<a class="secondary-menu__item-link" href=""> <a class="secondary-menu__item-link" href="">
<img class="secondary-menu__icon" src="<.= crate::FILES.get("./static-assets/img/svg/settings.svg").unwrap() .>" alt="" /> <img class="secondary-menu__icon" src="<.= crate::FILES.get("./static/cache/img/svg/settings.svg").unwrap() .>" alt="" />
<div class="secondary-menu__item-name"> <div class="secondary-menu__item-name">
Settings Settings
</div> </div>
@ -37,7 +37,7 @@
</li> </li>
<li class="secondary-menu__item"> <li class="secondary-menu__item">
<a class="secondary-menu__item-link" href=""> <a class="secondary-menu__item-link" href="">
<img class="secondary-menu__icon" src="<.= crate::FILES.get("./static-assets/img/svg/credit-card.svg").unwrap() .>" alt="" /> <img class="secondary-menu__icon" src="<.= crate::FILES.get("./static/cache/img/svg/credit-card.svg").unwrap() .>" alt="" />
<div class="secondary-menu__item-name"> <div class="secondary-menu__item-name">
Billing Billing
</div> </div>
@ -45,7 +45,7 @@
</li> </li>
<li class="secondary-menu__item"> <li class="secondary-menu__item">
<a class="secondary-menu__item-link" href=""> <a class="secondary-menu__item-link" href="">
<img class="secondary-menu__icon" src="<.= crate::FILES.get("./static-assets/img/svg/help-circle.svg").unwrap() .>" alt="" /> <img class="secondary-menu__icon" src="<.= crate::FILES.get("./static/cache/img/svg/help-circle.svg").unwrap() .>" alt="" />
<div class="secondary-menu__item-name"> <div class="secondary-menu__item-name">
Help Help
</div> </div>
@ -55,7 +55,7 @@
<a class="secondary-menu__item-link" href=""> <a class="secondary-menu__item-link" href="">
<img <img
class="secondary-menu__icon" class="secondary-menu__icon"
src="<.= crate::FILES.get("./static-assets/img/svg/message-square.svg").unwrap() .>" src="<.= crate::FILES.get("./static/cache/img/svg/message-square.svg").unwrap() .>"
alt="" alt=""
/> />
@ -66,7 +66,7 @@
</li> </li>
<li class="secondary-menu__item"> <li class="secondary-menu__item">
<a class="secondary-menu__item-link" href="<.= crate::DOCS.home .>"> <a class="secondary-menu__item-link" href="<.= crate::DOCS.home .>">
<img class="secondary-menu__icon" src="<.= crate::FILES.get("./static-assets/img/svg/file-text.svg").unwrap() .>" alt="" /> <img class="secondary-menu__icon" src="<.= crate::FILES.get("./static/cache/img/svg/file-text.svg").unwrap() .>" alt="" />
<div class="secondary-menu__item-name"> <div class="secondary-menu__item-name">
API Docs API Docs
</div> </div>
@ -75,7 +75,7 @@
<li class="secondary-menu__item"> <li class="secondary-menu__item">
<a class="secondary-menu__item-link" href="<.= crate::SETTINGS.source_code .>"> <a class="secondary-menu__item-link" href="<.= crate::SETTINGS.source_code .>">
<img class="secondary-menu__icon" <img class="secondary-menu__icon"
src="<.= crate::FILES.get("./static-assets/img/svg/github.svg").unwrap() .>" alt="GitHub Icon" /> src="<.= crate::FILES.get("./static/cache/img/svg/github.svg").unwrap() .>" alt="GitHub Icon" />
<div class="secondary-menu__item-name"> <div class="secondary-menu__item-name">
Source Code Source Code
</div> </div>

View file

@ -9,7 +9,7 @@
<a href="<.= crate::PKG_HOMEPAGE .>" class="logo-container"> <a href="<.= crate::PKG_HOMEPAGE .>" class="logo-container">
<img <img
class="logo" class="logo"
src="<.= crate::FILES.get("./static-assets/img/icon-trans.png").unwrap().>" src="<.= crate::FILES.get("./static/cache/img/icon-trans.png").unwrap().>"
alt="mCaptcha logo" alt="mCaptcha logo"
/> />
<p class="brand-name">mCaptcha</p> <p class="brand-name">mCaptcha</p>

View file

@ -16,7 +16,7 @@ module.exports = {
}, },
output: { output: {
filename: '[name].js', filename: '[name].js',
path: path.resolve(__dirname, './static-assets/bundle/'), path: path.resolve(__dirname, './static/cache/bundle/'),
}, },
module: { module: {
rules: [ rules: [