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/
node_modules/
/static-assets/bundle
/static
static/cache/bundle
./templates/**/*.js
/static-assets/bundle/*
src/cache_buster_data.json
coverage
dist
assets

View file

@ -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)

View file

@ -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 {

View file

@ -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 = {

View file

@ -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"));
}
}

View file

@ -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<String>) -> impl Responder {
handle_assets(&path.0)
}
@ -55,7 +55,7 @@ pub async fn static_files(path: web::Path<String>) -> 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]

View file

@ -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(

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": [
{
"src": "\/android-icon-36x36.png",
@ -38,4 +38,4 @@
"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">
<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" />
<form

View file

@ -4,7 +4,7 @@
<div class="auth-inner-container">
<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" />

View file

@ -24,7 +24,7 @@
/>
<meta name="twitter:creator" content="@realaravinth" />
<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
@ -34,7 +34,7 @@
<meta property="og:type" content="article" />
<meta property="og:url" content="https://mcaptcaha.org" />
<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

View file

@ -1,6 +1,6 @@
<span class="show-password-container">
<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="<.=
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>

View file

@ -12,19 +12,19 @@
</li>
<li class="taskbar__action">
<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 class="taskbar__action">
<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" />
</li>
<li class="taskbar__action">
<a href="<.= crate::V1_API_ROUTES.auth.logout .>">
<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>
</li>
</ul>

View file

@ -1,7 +1,7 @@
<nav class="secondary-menu">
<ul class="secondary-menu__lsit">
<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">
mCaptcha
</div>
@ -12,7 +12,7 @@
-->
<li class="secondary-menu__item">
<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">
Overview
</div>
@ -20,7 +20,7 @@
</li>
<li class="secondary-menu__item">
<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">
Site Keys
</div>
@ -29,7 +29,7 @@
<li class="secondary-menu__item">
<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">
Settings
</div>
@ -37,7 +37,7 @@
</li>
<li class="secondary-menu__item">
<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">
Billing
</div>
@ -45,7 +45,7 @@
</li>
<li class="secondary-menu__item">
<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">
Help
</div>
@ -55,7 +55,7 @@
<a class="secondary-menu__item-link" href="">
<img
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=""
/>
@ -66,7 +66,7 @@
</li>
<li class="secondary-menu__item">
<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">
API Docs
</div>
@ -75,7 +75,7 @@
<li class="secondary-menu__item">
<a class="secondary-menu__item-link" href="<.= crate::SETTINGS.source_code .>">
<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">
Source Code
</div>

View file

@ -9,7 +9,7 @@
<a href="<.= crate::PKG_HOMEPAGE .>" class="logo-container">
<img
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"
/>
<p class="brand-name">mCaptcha</p>

View file

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