From 27ba2d97c04a2e21be6ea60c4481e05c89e9d09b Mon Sep 17 00:00:00 2001 From: realaravinth Date: Sat, 29 May 2021 15:53:16 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20=20@=2098cf4?= =?UTF-8?q?a476dd2b196e02ae9fcdd4702c68af9a3a8=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- guard/all.html | 2 +- guard/constant.WIDGET_ROUTES.html | 2 +- guard/pages/panel/sitekey/view/index.html | 2 +- .../panel/sitekey/view/struct.IndexPage.html | 7 +- .../sitekey/view/struct.view_sitekey.html | 4 +- guard/widget/constant.PAGE.html | 2 +- guard/widget/constant.WIDGET_ROUTES.html | 2 +- guard/widget/fn.handle_widget_assets.html | 5 + guard/widget/fn.services.html | 2 +- guard/widget/index.html | 8 +- guard/widget/routes/index.html | 2 +- guard/widget/routes/struct.Widget.html | 8 +- guard/widget/sidebar-items.js | 2 +- guard/widget/struct.INDEX_PAGE.html | 8 +- guard/widget/struct.IndexPage.html | 6 +- guard/widget/struct.WidgetAssets.html | 114 +++++++ guard/widget/struct.show_widget.html | 4 +- guard/widget/struct.widget_assets.html | 112 +++++++ .../service/trait.HttpServiceFactory.js | 2 +- implementors/core/marker/trait.Freeze.js | 2 +- implementors/core/marker/trait.Send.js | 2 +- implementors/core/marker/trait.Sync.js | 2 +- implementors/core/marker/trait.Unpin.js | 2 +- implementors/rust_embed/trait.RustEmbed.js | 2 +- implementors/std/panic/trait.RefUnwindSafe.js | 2 +- implementors/std/panic/trait.UnwindSafe.js | 2 +- search-index.js | 2 +- src/guard/pages/panel/sitekey/view.rs.html | 8 +- src/guard/widget/mod.rs.html | 314 +++++++++++------- 29 files changed, 479 insertions(+), 153 deletions(-) create mode 100644 guard/widget/fn.handle_widget_assets.html create mode 100644 guard/widget/struct.WidgetAssets.html create mode 100644 guard/widget/struct.widget_assets.html diff --git a/guard/all.html b/guard/all.html index 0e9aecd9..2351b8f8 100644 --- a/guard/all.html +++ b/guard/all.html @@ -3,5 +3,5 @@

List of all items[] -

Structs

Enums

Macros

Functions

Typedefs

Statics

Constants

+

Structs

Enums

Macros

Functions

Typedefs

Statics

Constants

\ No newline at end of file diff --git a/guard/constant.WIDGET_ROUTES.html b/guard/constant.WIDGET_ROUTES.html index 1a7f95bb..8f581f00 100644 --- a/guard/constant.WIDGET_ROUTES.html +++ b/guard/constant.WIDGET_ROUTES.html @@ -1,5 +1,5 @@ guard::WIDGET_ROUTES - Rust

Constant guard::WIDGET_ROUTES[][src]

pub const WIDGET_ROUTES: Widget;
+ Change settings

Constant guard::WIDGET_ROUTES[][src]

pub const WIDGET_ROUTES: Widget;
\ No newline at end of file diff --git a/guard/pages/panel/sitekey/view/index.html b/guard/pages/panel/sitekey/view/index.html index d0711996..5fd99ba9 100644 --- a/guard/pages/panel/sitekey/view/index.html +++ b/guard/pages/panel/sitekey/view/index.html @@ -1,7 +1,7 @@ guard::pages::panel::sitekey::view - Rust

Module guard::pages::panel::sitekey::view[][src]

Structs

+ Change settings

Module guard::pages::panel::sitekey::view[][src]

Structs

IndexPage
Level
McaptchaConfig
view_sitekey

route handler that renders individual views for sitekeys

Constants

PAGE
diff --git a/guard/pages/panel/sitekey/view/struct.IndexPage.html b/guard/pages/panel/sitekey/view/struct.IndexPage.html index c6c6153b..3add3293 100644 --- a/guard/pages/panel/sitekey/view/struct.IndexPage.html +++ b/guard/pages/panel/sitekey/view/struct.IndexPage.html @@ -1,12 +1,13 @@ guard::pages::panel::sitekey::view::IndexPage - Rust -

Struct guard::pages::panel::sitekey::view::IndexPage[][src]

struct IndexPage {
+

Struct guard::pages::panel::sitekey::view::IndexPage[][src]

struct IndexPage {
     duration: u32,
     name: String,
+    key: String,
     levels: Vec<Level>,
 }

- Fields

duration: u32name: Stringlevels: Vec<Level>

Implementations

impl IndexPage[src]

fn new(config: McaptchaConfig, levels: Vec<Level>) -> Self[src]

Trait Implementations

impl Clone for IndexPage[src]

 /*
 * Copyright (C) 2021  Aravinth Manivannan <realaravinth@batsense.net>
@@ -196,15 +198,17 @@
 struct IndexPage {
     duration: u32,
     name: String,
+    key: String,
     levels: Vec<Level>,
 }
 
 impl IndexPage {
-    fn new(config: McaptchaConfig, levels: Vec<Level>) -> Self {
+    fn new(config: McaptchaConfig, levels: Vec<Level>, key: String) -> Self {
         IndexPage {
             duration: config.duration as u32,
             name: config.name,
             levels,
+            key,
         }
     }
 }
@@ -244,7 +248,7 @@
 
     let (stats, levels) = try_join!(Stats::new(&key, &data.db), levels_fut)?;
 
-    let body = IndexPage::new(config, levels).render_once().unwrap();
+    let body = IndexPage::new(config, levels, key).render_once().unwrap();
     Ok(HttpResponse::Ok()
         .content_type("text/html; charset=utf-8")
         .body(body))
diff --git a/src/guard/widget/mod.rs.html b/src/guard/widget/mod.rs.html
index f8824ee8..c48900c8 100644
--- a/src/guard/widget/mod.rs.html
+++ b/src/guard/widget/mod.rs.html
@@ -1,100 +1,144 @@
 mod.rs - source
 
 
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
-37
-38
-39
-40
-41
-42
-43
-44
-45
-46
-47
-48
-49
-50
-51
-52
-53
-54
-55
-56
-57
-58
-59
-60
-61
-62
-63
-64
-65
-66
-67
-68
-69
-70
-71
-72
-73
-74
-75
-76
-77
-78
-79
-80
-81
-82
-83
-84
-85
-86
-87
-88
-89
-90
-91
-92
-93
-94
+                Change settings
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
 
 /*
 * Copyright (C) 2021  Aravinth Manivannan <realaravinth@batsense.net>
@@ -112,27 +156,41 @@
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
+use std::borrow::Cow;
+
+use actix_web::body::Body;
+use actix_web::{get, http::header, web, HttpResponse, Responder};
+use mime_guess::from_path;
+use rust_embed::RustEmbed;
+use lazy_static::lazy_static;
+use sailfish::TemplateOnce;
+
+use crate::errors::*;
+
+
+
 
 pub const WIDGET_ROUTES: routes::Widget = routes::Widget::new();
 
 pub mod routes {
     pub struct Widget {
         pub verification_widget: &'static str,
+        pub js: &'static str,
+        pub wasm: &'static str,
     }
 
     impl Widget {
         pub const fn new() -> Self {
-            Widget { verification_widget: "/widget" }
+            Widget { 
+                verification_widget: "/widget",
+                js: "/widget/bundle.js",
+                wasm: "/widget/1476099975f2b060264c.module.wasm",
+            }
         }
     }
 }
 
 
-use actix_web::{web, HttpResponse, Responder};
-use lazy_static::lazy_static;
-use sailfish::TemplateOnce;
-
-use crate::errors::*;
 
 #[derive(TemplateOnce, Clone)]
 #[template(path = "widget/index.html")]
@@ -158,14 +216,42 @@
         .body(&*INDEX_PAGE))
 }
 
+#[derive(RustEmbed)]
+#[folder = "static/widget/"]
+struct WidgetAssets;
 
-pub fn services(cfg: &mut web::ServiceConfig) {
-    cfg.service(show_widget);
+fn handle_widget_assets(path: &str) -> HttpResponse {
+    match WidgetAssets::get(path) {
+        Some(content) => {
+            let body: Body = match content {
+                Cow::Borrowed(bytes) => bytes.into(),
+                Cow::Owned(bytes) => bytes.into(),
+            };
+
+            HttpResponse::Ok()
+                .set(header::CacheControl(vec![header::CacheDirective::MaxAge(
+                    crate::CACHE_AGE,
+                )]))
+                .content_type(from_path(path).first_or_octet_stream().as_ref())
+                .body(body)
+        }
+        None => HttpResponse::NotFound().body("404 Not Found"),
+    }
 }
 
 
 
 
+#[get("/widget/{_:.*}")]
+pub async fn widget_assets(path: web::Path<String>) -> impl Responder {
+    handle_widget_assets(&path.0)
+}
+
+pub fn services(cfg: &mut web::ServiceConfig) {
+    cfg.service(show_widget);
+    cfg.service(widget_assets);
+}
+
 #[cfg(test)]
 mod test {
     use actix_web::http::StatusCode;
@@ -175,19 +261,21 @@
 
     #[actix_rt::test]
     async fn captcha_widget_route_works() {
+
         let mut app  = get_app!().await;
+//            let list_sitekey_resp = test::call_service(
+//                    &mut app,
+//                    test::TestRequest::get()
+//                        .uri(crate::WIDGET_ROUTES.verification_widget)
+//                        .to_request(),
+//            )
+//            .await;
+//            assert_eq!(list_sitekey_resp.status(), StatusCode::OK);
 
-
-        let list_sitekey_resp = test::call_service(
-            &mut app,
-            test::TestRequest::get()
-                .uri(crate::WIDGET_ROUTES.verification_widget)
-                .to_request(),
-        )
-        .await;
-
-        assert_eq!(list_sitekey_resp.status(), StatusCode::OK);
-
+        get_works!(app, crate::WIDGET_ROUTES.verification_widget);
+        get_works!(app, crate::WIDGET_ROUTES.js);
+        get_works!(app, crate::WIDGET_ROUTES.wasm);
+        
     }
 }