Dev server
This commit is contained in:
parent
0b8717aa2b
commit
876d28fac6
291
Cargo.lock
generated
291
Cargo.lock
generated
@ -120,6 +120,60 @@ version = "1.4.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
|
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "axum"
|
||||||
|
version = "0.8.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6d6fd624c75e18b3b4c6b9caf42b1afe24437daaee904069137d8bab077be8b8"
|
||||||
|
dependencies = [
|
||||||
|
"axum-core",
|
||||||
|
"bytes",
|
||||||
|
"form_urlencoded",
|
||||||
|
"futures-util",
|
||||||
|
"http",
|
||||||
|
"http-body",
|
||||||
|
"http-body-util",
|
||||||
|
"hyper",
|
||||||
|
"hyper-util",
|
||||||
|
"itoa",
|
||||||
|
"matchit",
|
||||||
|
"memchr",
|
||||||
|
"mime",
|
||||||
|
"percent-encoding",
|
||||||
|
"pin-project-lite",
|
||||||
|
"rustversion",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"serde_path_to_error",
|
||||||
|
"serde_urlencoded",
|
||||||
|
"sync_wrapper",
|
||||||
|
"tokio",
|
||||||
|
"tower",
|
||||||
|
"tower-layer",
|
||||||
|
"tower-service",
|
||||||
|
"tracing",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "axum-core"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "df1362f362fd16024ae199c1970ce98f9661bf5ef94b9808fee734bc3698b733"
|
||||||
|
dependencies = [
|
||||||
|
"bytes",
|
||||||
|
"futures-util",
|
||||||
|
"http",
|
||||||
|
"http-body",
|
||||||
|
"http-body-util",
|
||||||
|
"mime",
|
||||||
|
"pin-project-lite",
|
||||||
|
"rustversion",
|
||||||
|
"sync_wrapper",
|
||||||
|
"tower-layer",
|
||||||
|
"tower-service",
|
||||||
|
"tracing",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "backtrace"
|
name = "backtrace"
|
||||||
version = "0.3.74"
|
version = "0.3.74"
|
||||||
@ -442,6 +496,12 @@ version = "0.5.7"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99"
|
checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fnv"
|
||||||
|
version = "1.0.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "form_urlencoded"
|
name = "form_urlencoded"
|
||||||
version = "1.2.1"
|
version = "1.2.1"
|
||||||
@ -673,6 +733,58 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "http"
|
||||||
|
version = "1.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea"
|
||||||
|
dependencies = [
|
||||||
|
"bytes",
|
||||||
|
"fnv",
|
||||||
|
"itoa",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "http-body"
|
||||||
|
version = "1.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184"
|
||||||
|
dependencies = [
|
||||||
|
"bytes",
|
||||||
|
"http",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "http-body-util"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f"
|
||||||
|
dependencies = [
|
||||||
|
"bytes",
|
||||||
|
"futures-util",
|
||||||
|
"http",
|
||||||
|
"http-body",
|
||||||
|
"pin-project-lite",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "http-range-header"
|
||||||
|
version = "0.4.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9171a2ea8a68358193d15dd5d70c1c10a2afc3e7e4c5bc92bc9f025cebd7359c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "httparse"
|
||||||
|
version = "1.9.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "httpdate"
|
||||||
|
version = "1.0.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "humansize"
|
name = "humansize"
|
||||||
version = "2.1.3"
|
version = "2.1.3"
|
||||||
@ -688,6 +800,41 @@ version = "2.1.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hyper"
|
||||||
|
version = "1.5.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "256fb8d4bd6413123cc9d91832d78325c48ff41677595be797d90f42969beae0"
|
||||||
|
dependencies = [
|
||||||
|
"bytes",
|
||||||
|
"futures-channel",
|
||||||
|
"futures-util",
|
||||||
|
"http",
|
||||||
|
"http-body",
|
||||||
|
"httparse",
|
||||||
|
"httpdate",
|
||||||
|
"itoa",
|
||||||
|
"pin-project-lite",
|
||||||
|
"smallvec",
|
||||||
|
"tokio",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hyper-util"
|
||||||
|
version = "0.1.10"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4"
|
||||||
|
dependencies = [
|
||||||
|
"bytes",
|
||||||
|
"futures-util",
|
||||||
|
"http",
|
||||||
|
"http-body",
|
||||||
|
"hyper",
|
||||||
|
"pin-project-lite",
|
||||||
|
"tokio",
|
||||||
|
"tower-service",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iana-time-zone"
|
name = "iana-time-zone"
|
||||||
version = "0.1.61"
|
version = "0.1.61"
|
||||||
@ -1039,12 +1186,34 @@ dependencies = [
|
|||||||
"xml5ever",
|
"xml5ever",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "matchit"
|
||||||
|
version = "0.8.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.7.4"
|
version = "2.7.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mime"
|
||||||
|
version = "0.3.17"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mime_guess"
|
||||||
|
version = "2.0.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e"
|
||||||
|
dependencies = [
|
||||||
|
"mime",
|
||||||
|
"unicase",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "miniz_oxide"
|
name = "miniz_oxide"
|
||||||
version = "0.8.2"
|
version = "0.8.2"
|
||||||
@ -1426,6 +1595,12 @@ version = "0.1.24"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
|
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustversion"
|
||||||
|
version = "1.0.19"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
version = "1.0.18"
|
version = "1.0.18"
|
||||||
@ -1479,6 +1654,16 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_path_to_error"
|
||||||
|
version = "0.1.16"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "af99884400da37c88f5e9146b7f1fd0fbcae8f6eec4e9da38b67d05486f814a6"
|
||||||
|
dependencies = [
|
||||||
|
"itoa",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_spanned"
|
name = "serde_spanned"
|
||||||
version = "0.6.8"
|
version = "0.6.8"
|
||||||
@ -1488,6 +1673,18 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_urlencoded"
|
||||||
|
version = "0.7.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd"
|
||||||
|
dependencies = [
|
||||||
|
"form_urlencoded",
|
||||||
|
"itoa",
|
||||||
|
"ryu",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sha2"
|
name = "sha2"
|
||||||
version = "0.10.8"
|
version = "0.10.8"
|
||||||
@ -1604,6 +1801,12 @@ dependencies = [
|
|||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sync_wrapper"
|
||||||
|
version = "1.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "synstructure"
|
name = "synstructure"
|
||||||
version = "0.13.1"
|
version = "0.13.1"
|
||||||
@ -1733,6 +1936,19 @@ dependencies = [
|
|||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tokio-util"
|
||||||
|
version = "0.7.13"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d7fcaa8d55a2bdd6b83ace262b016eca0d79ee02818c5c1bcdf0305114081078"
|
||||||
|
dependencies = [
|
||||||
|
"bytes",
|
||||||
|
"futures-core",
|
||||||
|
"futures-sink",
|
||||||
|
"pin-project-lite",
|
||||||
|
"tokio",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml"
|
name = "toml"
|
||||||
version = "0.8.19"
|
version = "0.8.19"
|
||||||
@ -1767,6 +1983,79 @@ dependencies = [
|
|||||||
"winnow",
|
"winnow",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tower"
|
||||||
|
version = "0.5.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9"
|
||||||
|
dependencies = [
|
||||||
|
"futures-core",
|
||||||
|
"futures-util",
|
||||||
|
"pin-project-lite",
|
||||||
|
"sync_wrapper",
|
||||||
|
"tokio",
|
||||||
|
"tower-layer",
|
||||||
|
"tower-service",
|
||||||
|
"tracing",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tower-http"
|
||||||
|
version = "0.6.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "403fa3b783d4b626a8ad51d766ab03cb6d2dbfc46b1c5d4448395e6628dc9697"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.6.0",
|
||||||
|
"bytes",
|
||||||
|
"futures-util",
|
||||||
|
"http",
|
||||||
|
"http-body",
|
||||||
|
"http-body-util",
|
||||||
|
"http-range-header",
|
||||||
|
"httpdate",
|
||||||
|
"mime",
|
||||||
|
"mime_guess",
|
||||||
|
"percent-encoding",
|
||||||
|
"pin-project-lite",
|
||||||
|
"tokio",
|
||||||
|
"tokio-util",
|
||||||
|
"tower-layer",
|
||||||
|
"tower-service",
|
||||||
|
"tracing",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tower-layer"
|
||||||
|
version = "0.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tower-service"
|
||||||
|
version = "0.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tracing"
|
||||||
|
version = "0.1.41"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0"
|
||||||
|
dependencies = [
|
||||||
|
"log",
|
||||||
|
"pin-project-lite",
|
||||||
|
"tracing-core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tracing-core"
|
||||||
|
version = "0.1.33"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c"
|
||||||
|
dependencies = [
|
||||||
|
"once_cell",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "typenum"
|
name = "typenum"
|
||||||
version = "1.17.0"
|
version = "1.17.0"
|
||||||
@ -1896,6 +2185,7 @@ name = "v7"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
"axum",
|
||||||
"base64",
|
"base64",
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
@ -1918,6 +2208,7 @@ dependencies = [
|
|||||||
"tokio",
|
"tokio",
|
||||||
"tokio-stream",
|
"tokio-stream",
|
||||||
"toml",
|
"toml",
|
||||||
|
"tower-http",
|
||||||
"unicode-normalization",
|
"unicode-normalization",
|
||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
|
@ -17,6 +17,7 @@ serde_json = "1.0"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.95"
|
anyhow = "1.0.95"
|
||||||
|
axum = "0.8.1"
|
||||||
base64 = "0.22.1"
|
base64 = "0.22.1"
|
||||||
chrono = { version = "0.4.39", features = ["serde"] }
|
chrono = { version = "0.4.39", features = ["serde"] }
|
||||||
clap = { version = "4.5.23", features = ["cargo"] }
|
clap = { version = "4.5.23", features = ["cargo"] }
|
||||||
@ -40,5 +41,6 @@ tera = "1.20.0"
|
|||||||
tokio = { version = "1.42.0", features = ["full"] }
|
tokio = { version = "1.42.0", features = ["full"] }
|
||||||
tokio-stream = "0.1.17"
|
tokio-stream = "0.1.17"
|
||||||
toml = "0.8.19"
|
toml = "0.8.19"
|
||||||
|
tower-http = { version = "0.6.2", features = ["fs"] }
|
||||||
unicode-normalization = "0.1.24"
|
unicode-normalization = "0.1.24"
|
||||||
url = "2.5.4"
|
url = "2.5.4"
|
||||||
|
@ -11,7 +11,7 @@ use std::cell::RefCell;
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use compute_graph::{AsyncGraph, builder::GraphBuilder};
|
use compute_graph::{AsyncGraph, builder::GraphBuilder};
|
||||||
use util::{Combine, MapToVoid};
|
use util::Combine;
|
||||||
|
|
||||||
pub use util::content_base_path;
|
pub use util::content_base_path;
|
||||||
pub use util::file_watcher::FileWatcher;
|
pub use util::file_watcher::FileWatcher;
|
||||||
@ -23,8 +23,6 @@ pub async fn generate(watcher: Rc<RefCell<FileWatcher>>) -> anyhow::Result<Async
|
|||||||
|
|
||||||
graph.evaluate_async().await;
|
graph.evaluate_async().await;
|
||||||
|
|
||||||
println!("{}", graph.as_dot_string());
|
|
||||||
|
|
||||||
Ok(graph)
|
Ok(graph)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +31,7 @@ fn make_graph(watcher: Rc<RefCell<FileWatcher>>) -> anyhow::Result<AsyncGraph<()
|
|||||||
|
|
||||||
let default_template = templates::make_graph(&mut builder, &mut *watcher.borrow_mut());
|
let default_template = templates::make_graph(&mut builder, &mut *watcher.borrow_mut());
|
||||||
|
|
||||||
let (void_outputs, posts, all_posts, post_metadatas) =
|
let (void_outputs, posts, all_posts) =
|
||||||
posts::make_graph(&mut builder, default_template.clone(), Rc::clone(&watcher));
|
posts::make_graph(&mut builder, default_template.clone(), Rc::clone(&watcher));
|
||||||
|
|
||||||
let archive = archive::make_graph(
|
let archive = archive::make_graph(
|
||||||
@ -59,15 +57,7 @@ fn make_graph(watcher: Rc<RefCell<FileWatcher>>) -> anyhow::Result<AsyncGraph<()
|
|||||||
|
|
||||||
let css = css::make_graph(&mut builder, Rc::clone(&watcher));
|
let css = css::make_graph(&mut builder, Rc::clone(&watcher));
|
||||||
|
|
||||||
let post_metadatas_voided = builder.add_rule(MapToVoid(post_metadatas));
|
let output = Combine::make(&mut builder, &[void_outputs, archive, tags, home, css]);
|
||||||
let output = Combine::make(&mut builder, &[
|
|
||||||
void_outputs,
|
|
||||||
archive,
|
|
||||||
tags,
|
|
||||||
home,
|
|
||||||
css,
|
|
||||||
post_metadatas_voided,
|
|
||||||
]);
|
|
||||||
builder.set_existing_output(output);
|
builder.set_existing_output(output);
|
||||||
Ok(builder.build()?)
|
Ok(builder.build()?)
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ use compute_graph::{
|
|||||||
};
|
};
|
||||||
use content::{HtmlContent, Post};
|
use content::{HtmlContent, Post};
|
||||||
use log::error;
|
use log::error;
|
||||||
use metadata::PostMetadata;
|
|
||||||
use tera::Context;
|
use tera::Context;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
@ -32,7 +31,6 @@ pub fn make_graph(
|
|||||||
Input<()>,
|
Input<()>,
|
||||||
DynamicInput<ReadPostOutput>,
|
DynamicInput<ReadPostOutput>,
|
||||||
Input<Vec<Post<HtmlContent>>>,
|
Input<Vec<Post<HtmlContent>>>,
|
||||||
Input<Vec<PostMetadata>>,
|
|
||||||
) {
|
) {
|
||||||
let (post_files, invalidate_posts) = builder.add_invalidatable_rule(ListPostFiles);
|
let (post_files, invalidate_posts) = builder.add_invalidatable_rule(ListPostFiles);
|
||||||
watcher.borrow_mut().watch(content_path("posts/"), move || {
|
watcher.borrow_mut().watch(content_path("posts/"), move || {
|
||||||
@ -41,7 +39,7 @@ pub fn make_graph(
|
|||||||
|
|
||||||
let posts = builder.add_dynamic_rule(MakeReadNodes::new(post_files, Rc::clone(&watcher)));
|
let posts = builder.add_dynamic_rule(MakeReadNodes::new(post_files, Rc::clone(&watcher)));
|
||||||
|
|
||||||
let extract_metadatas = builder.add_dynamic_rule(MakeExtractMetadatas::new(posts.clone()));
|
// let extract_metadatas = builder.add_dynamic_rule(MakeExtractMetadatas::new(posts.clone()));
|
||||||
|
|
||||||
let article_path = content_path("layout/article.html");
|
let article_path = content_path("layout/article.html");
|
||||||
let (article_template, invalidate_template) = builder.add_invalidatable_rule(AddTemplate::new(
|
let (article_template, invalidate_template) = builder.add_invalidatable_rule(AddTemplate::new(
|
||||||
@ -60,7 +58,6 @@ pub fn make_graph(
|
|||||||
builder.add_rule(MapDynamicToVoid(write_posts)),
|
builder.add_rule(MapDynamicToVoid(write_posts)),
|
||||||
posts.clone(),
|
posts.clone(),
|
||||||
builder.add_rule(AllPosts(posts)),
|
builder.add_rule(AllPosts(posts)),
|
||||||
builder.add_rule(AllMetadatas(extract_metadatas)),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,52 +159,52 @@ impl Rule for ReadPost {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(InputVisitable)]
|
// #[derive(InputVisitable)]
|
||||||
struct MakeExtractMetadatas {
|
// struct MakeExtractMetadatas {
|
||||||
posts: DynamicInput<ReadPostOutput>,
|
// posts: DynamicInput<ReadPostOutput>,
|
||||||
node_factory: DynamicNodeFactory<PathBuf, ExtractMetadataOutput>,
|
// node_factory: DynamicNodeFactory<PathBuf, ExtractMetadataOutput>,
|
||||||
}
|
// }
|
||||||
impl MakeExtractMetadatas {
|
// impl MakeExtractMetadatas {
|
||||||
fn new(posts: DynamicInput<ReadPostOutput>) -> Self {
|
// fn new(posts: DynamicInput<ReadPostOutput>) -> Self {
|
||||||
Self {
|
// Self {
|
||||||
posts,
|
// posts,
|
||||||
node_factory: DynamicNodeFactory::new(),
|
// node_factory: DynamicNodeFactory::new(),
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
impl DynamicRule for MakeExtractMetadatas {
|
// impl DynamicRule for MakeExtractMetadatas {
|
||||||
type ChildOutput = ExtractMetadataOutput;
|
// type ChildOutput = ExtractMetadataOutput;
|
||||||
fn evaluate(&mut self, ctx: &mut impl DynamicRuleContext) -> Vec<Input<Self::ChildOutput>> {
|
// fn evaluate(&mut self, ctx: &mut impl DynamicRuleContext) -> Vec<Input<Self::ChildOutput>> {
|
||||||
for post_input in self.posts.value().inputs.iter() {
|
// for post_input in self.posts.value().inputs.iter() {
|
||||||
let post_ = post_input.value();
|
// let post_ = post_input.value();
|
||||||
let post = post_.as_ref().unwrap();
|
// let post = post_.as_ref().unwrap();
|
||||||
self.node_factory.add_node(ctx, post.path.clone(), |ctx| {
|
// self.node_factory.add_node(ctx, post.path.clone(), |ctx| {
|
||||||
ctx.add_rule(ExtractMetadata(post_input.clone()))
|
// ctx.add_rule(ExtractMetadata(post_input.clone()))
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
self.node_factory.all_nodes(ctx)
|
// self.node_factory.all_nodes(ctx)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
type ExtractMetadataOutput = Option<PostMetadata>;
|
// type ExtractMetadataOutput = Option<PostMetadata>;
|
||||||
|
|
||||||
#[derive(InputVisitable)]
|
// #[derive(InputVisitable)]
|
||||||
struct ExtractMetadata(Input<ReadPostOutput>);
|
// struct ExtractMetadata(Input<ReadPostOutput>);
|
||||||
impl Rule for ExtractMetadata {
|
// impl Rule for ExtractMetadata {
|
||||||
type Output = ExtractMetadataOutput;
|
// type Output = ExtractMetadataOutput;
|
||||||
|
|
||||||
fn evaluate(&mut self) -> Self::Output {
|
// fn evaluate(&mut self) -> Self::Output {
|
||||||
self.input_0().as_ref().map(|post| post.metadata.clone())
|
// self.input_0().as_ref().map(|post| post.metadata.clone())
|
||||||
}
|
// }
|
||||||
|
|
||||||
fn node_label(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
// fn node_label(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
if let Some(post) = self.input_0().as_ref() {
|
// if let Some(post) = self.input_0().as_ref() {
|
||||||
write!(f, "{}", post.slug)
|
// write!(f, "{}", post.slug)
|
||||||
} else {
|
// } else {
|
||||||
Ok(())
|
// Ok(())
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
#[derive(InputVisitable)]
|
#[derive(InputVisitable)]
|
||||||
struct MakeWritePosts {
|
struct MakeWritePosts {
|
||||||
@ -278,17 +275,3 @@ impl Rule for AllPosts {
|
|||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Flattens Vec<Option<PostMetadata>> into Vec<PostMetadata>
|
|
||||||
#[derive(InputVisitable)]
|
|
||||||
struct AllMetadatas(DynamicInput<ExtractMetadataOutput>);
|
|
||||||
impl Rule for AllMetadatas {
|
|
||||||
type Output = Vec<PostMetadata>;
|
|
||||||
fn evaluate(&mut self) -> Self::Output {
|
|
||||||
self.input_0()
|
|
||||||
.inputs
|
|
||||||
.iter()
|
|
||||||
.flat_map(|inp| inp.value().clone())
|
|
||||||
.collect()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
116
src/main.rs
116
src/main.rs
@ -2,17 +2,20 @@
|
|||||||
|
|
||||||
mod generator;
|
mod generator;
|
||||||
|
|
||||||
use clap::{Command, arg, command};
|
use axum::Router;
|
||||||
|
use clap::{Arg, ArgAction, ArgMatches, Command, command};
|
||||||
|
use compute_graph::AsyncGraph;
|
||||||
use debounced::debounced;
|
use debounced::debounced;
|
||||||
use futures::FutureExt;
|
use futures::join;
|
||||||
use generator::{FileWatcher, content_base_path};
|
use generator::{FileWatcher, content_base_path};
|
||||||
use log::info;
|
use log::info;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use tokio::pin;
|
use tokio::net::TcpListener;
|
||||||
use tokio_stream::StreamExt;
|
use tokio_stream::StreamExt;
|
||||||
use tokio_stream::wrappers::UnboundedReceiverStream;
|
use tokio_stream::wrappers::UnboundedReceiverStream;
|
||||||
|
use tower_http::services::{ServeDir, ServeFile};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
@ -21,14 +24,20 @@ async fn main() {
|
|||||||
let matches = command!()
|
let matches = command!()
|
||||||
.subcommand_required(true)
|
.subcommand_required(true)
|
||||||
.arg_required_else_help(true)
|
.arg_required_else_help(true)
|
||||||
.subcommand(
|
.arg(
|
||||||
Command::new("gen")
|
Arg::new("watch")
|
||||||
.arg(arg!(--watch "Watch the site directory and regenerate on changes")),
|
.long("watch")
|
||||||
|
.help("Watch the site directory and regenerate on changes")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.subcommand(
|
.arg(
|
||||||
Command::new("serve")
|
Arg::new("dump-graph")
|
||||||
.arg(arg!(--watch "Watch the site directory and regenerate on changes")),
|
.long("dump-graph")
|
||||||
|
.help("Print the graphviz representation of the graph after initial generation")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
|
.subcommand(Command::new("gen"))
|
||||||
|
.subcommand(Command::new("serve"))
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
|
||||||
if cfg!(debug_assertions) {
|
if cfg!(debug_assertions) {
|
||||||
@ -37,51 +46,58 @@ async fn main() {
|
|||||||
info!("Running in release mode");
|
info!("Running in release mode");
|
||||||
}
|
}
|
||||||
|
|
||||||
match matches.subcommand() {
|
let watcher = Rc::new(RefCell::new(FileWatcher::new()));
|
||||||
Some(("gen", matches)) => {
|
|
||||||
let watcher = Rc::new(RefCell::new(FileWatcher::new()));
|
|
||||||
|
|
||||||
let mut graph = generator::generate(Rc::clone(&watcher))
|
let graph = generator::generate(Rc::clone(&watcher))
|
||||||
.await
|
.await
|
||||||
.expect("generating");
|
.expect("generating");
|
||||||
|
|
||||||
if matches.contains_id("watch") {
|
if let Some(true) = matches.get_one("dump-graph") {
|
||||||
let (tx, rx) = tokio::sync::mpsc::unbounded_channel::<()>();
|
println!("{}", graph.as_dot_string());
|
||||||
|
}
|
||||||
|
|
||||||
watcher.borrow_mut().watch(content_base_path(), move || {
|
let serve_future = serve(&matches);
|
||||||
tx.send(()).expect("sending regenerate signal");
|
let watch_future = watch(&matches, graph, watcher);
|
||||||
});
|
|
||||||
|
|
||||||
let mut debounced =
|
join!(serve_future, watch_future);
|
||||||
debounced(UnboundedReceiverStream::new(rx), Duration::from_millis(100));
|
}
|
||||||
|
|
||||||
let watch = FileWatcher::start(watcher).fuse();
|
async fn serve(matches: &ArgMatches) {
|
||||||
|
if let Some(("serve", _)) = matches.subcommand() {
|
||||||
let regenerate = async move {
|
// TODO: consider not pulling in all of axum just for this
|
||||||
while let Some(_) = debounced.next().await {
|
let app = Router::new().fallback_service(
|
||||||
info!("Regenerating");
|
ServeDir::new("out/").not_found_service(ServeFile::new("out/404.html")),
|
||||||
graph.evaluate_async().await;
|
);
|
||||||
}
|
let addr = if cfg!(debug_assertions) {
|
||||||
}
|
"0.0.0.0:8084"
|
||||||
.fuse();
|
} else {
|
||||||
|
"127.0.0.1:8084"
|
||||||
pin!(regenerate, watch);
|
};
|
||||||
|
info!("Listening on {}", addr);
|
||||||
loop {
|
let listener = TcpListener::bind(addr).await.unwrap();
|
||||||
futures::select! {
|
axum::serve(listener, app).await.unwrap();
|
||||||
watcher_res = watch => {
|
}
|
||||||
watcher_res.expect("watching files");
|
}
|
||||||
}
|
|
||||||
_ = regenerate => {
|
async fn watch(matches: &ArgMatches, mut graph: AsyncGraph<()>, watcher: Rc<RefCell<FileWatcher>>) {
|
||||||
info!("regenerate channel closed");
|
if let Some(true) = matches.get_one("watch") {
|
||||||
}
|
let (tx, rx) = tokio::sync::mpsc::unbounded_channel::<()>();
|
||||||
}
|
|
||||||
}
|
watcher.borrow_mut().watch(content_base_path(), move || {
|
||||||
}
|
tx.send(()).expect("sending regenerate signal");
|
||||||
}
|
});
|
||||||
Some(("serve", _matches)) => {
|
|
||||||
todo!()
|
let mut debounced = debounced(UnboundedReceiverStream::new(rx), Duration::from_millis(100));
|
||||||
}
|
|
||||||
_ => unreachable!(),
|
let watch = async move { FileWatcher::start(watcher).await.expect("watching files") };
|
||||||
|
|
||||||
|
let regenerate = async move {
|
||||||
|
while let Some(_) = debounced.next().await {
|
||||||
|
info!("Regenerating");
|
||||||
|
graph.evaluate_async().await;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
join!(watch, regenerate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user