···4authors = ["Orual <orual@nonbinary.computer>"]
5edition = "2021"
67-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
00000000089[dependencies]
10dashmap = "6.1.0"
···15weaver-api = { path = "../weaver-api", features = ["streaming"] }
16markdown-weaver = { workspace = true }
17weaver-renderer = { path = "../weaver-renderer" }
18-moka = { version = "0.12", features = ["future"], optional = true }
19-mini-moka = { version = "0.10" }
20-dioxus-primitives = { git = "https://github.com/DioxusLabs/components", version = "0.0.1", default-features = false }
21axum = {version = "0.8.6", optional = true}
2223-[features]
24-default = ["web"]
25-# The feature that are only required for the web = ["dioxus/web"] build target should be optional and only enabled in the web = ["dioxus/web"] feature
26-web = ["dioxus/web"]
27-# The feature that are only required for the desktop = ["dioxus/desktop"] build target should be optional and only enabled in the desktop = ["dioxus/desktop"] feature
28-desktop = ["dioxus/desktop"]
29-# The feature that are only required for the mobile = ["dioxus/mobile"] build target should be optional and only enabled in the mobile = ["dioxus/mobile"] feature
30-mobile = ["dioxus/mobile"]
31-# The feature that are only required for the server = ["dioxus/server"] build target should be optional and only enabled in the server = ["dioxus/server"] feature
32-server = ["dioxus/server", "dep:jacquard-axum", "dep:moka", "dep:axum"]
···4authors = ["Orual <orual@nonbinary.computer>"]
5edition = "2021"
67+[features]
8+default = ["web"]
9+# The feature that are only required for the web = ["dioxus/web"] build target should be optional and only enabled in the web = ["dioxus/web"] feature
10+web = ["dioxus/web", "chrono/wasmbind"]
11+# The feature that are only required for the desktop = ["dioxus/desktop"] build target should be optional and only enabled in the desktop = ["dioxus/desktop"] feature
12+desktop = ["dioxus/desktop"]
13+# The feature that are only required for the mobile = ["dioxus/mobile"] build target should be optional and only enabled in the mobile = ["dioxus/mobile"] feature
14+mobile = ["dioxus/mobile"]
15+# The feature that are only required for the server = ["dioxus/server"] build target should be optional and only enabled in the server = ["dioxus/server"] feature
16+server = ["dioxus/server", "dep:jacquard-axum", "dep:axum"]
1718[dependencies]
19dashmap = "6.1.0"
···24weaver-api = { path = "../weaver-api", features = ["streaming"] }
25markdown-weaver = { workspace = true }
26weaver-renderer = { path = "../weaver-renderer" }
27+mini-moka = { git = "https://github.com/moka-rs/mini-moka", rev = "da864e849f5d034f32e02197fee9bb5d5af36d3d" }
28+#dioxus-primitives = { git = "https://github.com/DioxusLabs/components", version = "0.0.1", default-features = false }
029axum = {version = "0.8.6", optional = true}
3031+chrono = { version = "0.4" }
32+33+[target.'cfg(target_arch = "wasm32")'.dependencies]
34+time = { version = "0.3", features = ["wasm-bindgen"] }
35+console_error_panic_hook = "0.1"
36+mini-moka = { git = "https://github.com/moka-rs/mini-moka", rev = "da864e849f5d034f32e02197fee9bb5d5af36d3d", features = ["js"] }
0000
···2//! They can be used to defined common UI elements like buttons, forms, and modals. In this template, we define a Hero
3//! component and an Echo component for fullstack apps to be used in our app.
45-mod css;
6pub use css::NotebookCss;
78mod entry;
···1011mod identity;
12pub use identity::{Repository, RepositoryIndex};
13-pub mod avatar;
···2//! They can be used to defined common UI elements like buttons, forms, and modals. In this template, we define a Hero
3//! component and an Echo component for fullstack apps to be used in our app.
45+pub mod css;
6pub use css::NotebookCss;
78mod entry;
···1011mod identity;
12pub use identity::{Repository, RepositoryIndex};
13+//pub mod avatar;
···7use views::{Home, Navbar, Notebook, NotebookIndex, NotebookPage};
89mod blobcache;
010/// Define a components module that contains all shared components for our app.
11mod components;
12mod fetch;
···49const MAIN_CSS: Asset = asset!("/assets/styling/main.css");
5051fn main() {
000052 // Run `serve()` on the server only
53 #[cfg(feature = "server")]
54 dioxus::serve(|| async move {
55- use axum::{extract::Request, middleware, middleware::Next};
56- // Create a new router for our app using the `router` function
57- let mut router = dioxus::server::router(App).layer(middleware::from_fn(
58- |mut req: Request, next: Next| async move {
59- // Attach some extra state to the request
00006061- use crate::blobcache::BlobCache;
62- use crate::fetch::CachedFetcher;
63- use std::convert::Infallible;
64- use std::sync::Arc;
65- req.extensions_mut()
66- .insert(Arc::new(CachedFetcher::new(Arc::new(
67- BasicClient::unauthenticated(),
68- ))));
69- req.extensions_mut()
70- .insert(Arc::new(BlobCache::new(Arc::new(
71- BasicClient::unauthenticated(),
72- ))));
7374- // And then return the response with `next.run()
75- Ok::<_, Infallible>(next.run(req).await)
76- },
77- ));
00000007879- // .. customize the router, adding layers and new routes
80-00081 // And then return the router
82 Ok(router)
83 });
···7use views::{Home, Navbar, Notebook, NotebookIndex, NotebookPage};
89mod blobcache;
10+mod cache_impl;
11/// Define a components module that contains all shared components for our app.
12mod components;
13mod fetch;
···50const MAIN_CSS: Asset = asset!("/assets/styling/main.css");
5152fn main() {
53+ // Set up better panic messages for wasm
54+ #[cfg(target_arch = "wasm32")]
55+ console_error_panic_hook::set_once();
56+57 // Run `serve()` on the server only
58 #[cfg(feature = "server")]
59 dioxus::serve(|| async move {
60+ use crate::blobcache::BlobCache;
61+ use crate::fetch::CachedFetcher;
62+ use axum::{
63+ extract::{Extension, Request},
64+ middleware,
65+ middleware::Next,
66+ };
67+ use std::convert::Infallible;
68+ use std::sync::Arc;
6970+ // Create shared state
71+ let fetcher = Arc::new(CachedFetcher::new(Arc::new(BasicClient::unauthenticated())));
72+ let blob_cache = Arc::new(BlobCache::new(Arc::new(BasicClient::unauthenticated())));
0000000007374+ // Create a new router for our app using the `router` function
75+ let router = dioxus::server::router(App).layer(middleware::from_fn({
76+ let fetcher = fetcher.clone();
77+ let blob_cache = blob_cache.clone();
78+ move |mut req: Request, next: Next| {
79+ let fetcher = fetcher.clone();
80+ let blob_cache = blob_cache.clone();
81+ async move {
82+ // Attach extensions for dioxus server functions
83+ req.extensions_mut().insert(fetcher);
84+ req.extensions_mut().insert(blob_cache);
8586+ // And then return the response with `next.run()
87+ Ok::<_, Infallible>(next.run(req).await)
88+ }
89+ }
90+ }));
91 // And then return the router
92 Ok(router)
93 });