···44authors = ["Orual <orual@nonbinary.computer>"]
55edition = "2021"
6677-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77+[features]
88+default = ["web"]
99+# 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
1010+web = ["dioxus/web", "chrono/wasmbind"]
1111+# 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
1212+desktop = ["dioxus/desktop"]
1313+# 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
1414+mobile = ["dioxus/mobile"]
1515+# 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
1616+server = ["dioxus/server", "dep:jacquard-axum", "dep:axum"]
817918[dependencies]
1019dashmap = "6.1.0"
···1524weaver-api = { path = "../weaver-api", features = ["streaming"] }
1625markdown-weaver = { workspace = true }
1726weaver-renderer = { path = "../weaver-renderer" }
1818-moka = { version = "0.12", features = ["future"], optional = true }
1919-mini-moka = { version = "0.10" }
2020-dioxus-primitives = { git = "https://github.com/DioxusLabs/components", version = "0.0.1", default-features = false }
2727+mini-moka = { git = "https://github.com/moka-rs/mini-moka", rev = "da864e849f5d034f32e02197fee9bb5d5af36d3d" }
2828+#dioxus-primitives = { git = "https://github.com/DioxusLabs/components", version = "0.0.1", default-features = false }
2129axum = {version = "0.8.6", optional = true}
22302323-[features]
2424-default = ["web"]
2525-# 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
2626-web = ["dioxus/web"]
2727-# 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
2828-desktop = ["dioxus/desktop"]
2929-# 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
3030-mobile = ["dioxus/mobile"]
3131-# 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
3232-server = ["dioxus/server", "dep:jacquard-axum", "dep:moka", "dep:axum"]
3131+chrono = { version = "0.4" }
3232+3333+[target.'cfg(target_arch = "wasm32")'.dependencies]
3434+time = { version = "0.3", features = ["wasm-bindgen"] }
3535+console_error_panic_hook = "0.1"
3636+mini-moka = { git = "https://github.com/moka-rs/mini-moka", rev = "da864e849f5d034f32e02197fee9bb5d5af36d3d", features = ["js"] }
···22//! They can be used to defined common UI elements like buttons, forms, and modals. In this template, we define a Hero
33//! component and an Echo component for fullstack apps to be used in our app.
4455-mod css;
55+pub mod css;
66pub use css::NotebookCss;
7788mod entry;
···10101111mod identity;
1212pub use identity::{Repository, RepositoryIndex};
1313-pub mod avatar;
1313+//pub mod avatar;
···77use views::{Home, Navbar, Notebook, NotebookIndex, NotebookPage};
8899mod blobcache;
1010+mod cache_impl;
1011/// Define a components module that contains all shared components for our app.
1112mod components;
1213mod fetch;
···4950const MAIN_CSS: Asset = asset!("/assets/styling/main.css");
50515152fn main() {
5353+ // Set up better panic messages for wasm
5454+ #[cfg(target_arch = "wasm32")]
5555+ console_error_panic_hook::set_once();
5656+5257 // Run `serve()` on the server only
5358 #[cfg(feature = "server")]
5459 dioxus::serve(|| async move {
5555- use axum::{extract::Request, middleware, middleware::Next};
5656- // Create a new router for our app using the `router` function
5757- let mut router = dioxus::server::router(App).layer(middleware::from_fn(
5858- |mut req: Request, next: Next| async move {
5959- // Attach some extra state to the request
6060+ use crate::blobcache::BlobCache;
6161+ use crate::fetch::CachedFetcher;
6262+ use axum::{
6363+ extract::{Extension, Request},
6464+ middleware,
6565+ middleware::Next,
6666+ };
6767+ use std::convert::Infallible;
6868+ use std::sync::Arc;
60696161- use crate::blobcache::BlobCache;
6262- use crate::fetch::CachedFetcher;
6363- use std::convert::Infallible;
6464- use std::sync::Arc;
6565- req.extensions_mut()
6666- .insert(Arc::new(CachedFetcher::new(Arc::new(
6767- BasicClient::unauthenticated(),
6868- ))));
6969- req.extensions_mut()
7070- .insert(Arc::new(BlobCache::new(Arc::new(
7171- BasicClient::unauthenticated(),
7272- ))));
7070+ // Create shared state
7171+ let fetcher = Arc::new(CachedFetcher::new(Arc::new(BasicClient::unauthenticated())));
7272+ let blob_cache = Arc::new(BlobCache::new(Arc::new(BasicClient::unauthenticated())));
73737474- // And then return the response with `next.run()
7575- Ok::<_, Infallible>(next.run(req).await)
7676- },
7777- ));
7474+ // Create a new router for our app using the `router` function
7575+ let router = dioxus::server::router(App).layer(middleware::from_fn({
7676+ let fetcher = fetcher.clone();
7777+ let blob_cache = blob_cache.clone();
7878+ move |mut req: Request, next: Next| {
7979+ let fetcher = fetcher.clone();
8080+ let blob_cache = blob_cache.clone();
8181+ async move {
8282+ // Attach extensions for dioxus server functions
8383+ req.extensions_mut().insert(fetcher);
8484+ req.extensions_mut().insert(blob_cache);
78857979- // .. customize the router, adding layers and new routes
8080-8686+ // And then return the response with `next.run()
8787+ Ok::<_, Infallible>(next.run(req).await)
8888+ }
8989+ }
9090+ }));
8191 // And then return the router
8292 Ok(router)
8393 });