+11
-1
.cargo/config.toml
+11
-1
.cargo/config.toml
···
1
[target.x86_64-unknown-linux-gnu]
2
linker = "clang"
3
+
rustflags = [
4
+
"-C",
5
+
"link-arg=-fuse-ld=lld",
6
+
"-Zshare-generics=n",
7
+
"-Zthreads=0",
8
+
]
9
10
[target.x86_64-pc-windows-msvc]
11
linker = "rust-lld.exe"
12
+
rustdocflags = ["-Clinker=rust-lld.exe"]
13
+
rustflags = [
14
+
"-Zshare-generics=n",
15
+
"-Zthreads=0",
16
+
]
17
18
[unstable]
19
codegen-backend = true
+19
-37
Cargo.lock
+19
-37
Cargo.lock
···
329
]
330
331
[[package]]
332
name = "futures-channel"
333
version = "0.3.31"
334
source = "registry+https://github.com/rust-lang/crates.io-index"
···
545
]
546
547
[[package]]
548
-
name = "hypertext"
549
-
version = "0.12.1"
550
-
source = "registry+https://github.com/rust-lang/crates.io-index"
551
-
checksum = "eb73b82c6a76434fd87a0668ef3ff1a8182512dfb610eef9138169a7e2d3a0ed"
552
-
dependencies = [
553
-
"axum-core",
554
-
"html-escape",
555
-
"hypertext-macros",
556
-
"itoa",
557
-
"ryu",
558
-
]
559
-
560
-
[[package]]
561
-
name = "hypertext-macros"
562
-
version = "0.12.1"
563
-
source = "registry+https://github.com/rust-lang/crates.io-index"
564
-
checksum = "c120534b9d41bd317a5b111aacc38a34071d15df9462c0e21f6093ade3a03660"
565
-
dependencies = [
566
-
"html-escape",
567
-
"proc-macro2",
568
-
"quote",
569
-
"syn",
570
-
]
571
-
572
-
[[package]]
573
name = "icu_collections"
574
version = "2.0.0"
575
source = "registry+https://github.com/rust-lang/crates.io-index"
···
1041
1042
[[package]]
1043
name = "regex"
1044
-
version = "1.11.1"
1045
source = "registry+https://github.com/rust-lang/crates.io-index"
1046
-
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
1047
dependencies = [
1048
"aho-corasick",
1049
"memchr",
1050
-
"regex-automata 0.4.9",
1051
-
"regex-syntax 0.8.5",
1052
]
1053
1054
[[package]]
···
1062
1063
[[package]]
1064
name = "regex-automata"
1065
-
version = "0.4.9"
1066
source = "registry+https://github.com/rust-lang/crates.io-index"
1067
-
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
1068
dependencies = [
1069
"aho-corasick",
1070
"memchr",
1071
-
"regex-syntax 0.8.5",
1072
]
1073
1074
[[package]]
···
1079
1080
[[package]]
1081
name = "regex-syntax"
1082
-
version = "0.8.5"
1083
source = "registry+https://github.com/rust-lang/crates.io-index"
1084
-
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
1085
1086
[[package]]
1087
name = "reqwest"
···
1295
"anyhow",
1296
"axum",
1297
"axum-htmx",
1298
-
"hypertext",
1299
"reqwest",
1300
"scc",
1301
-
"serde",
1302
-
"serde_json",
1303
"smol_str",
1304
"tikv-jemallocator",
1305
"tokio",
···
329
]
330
331
[[package]]
332
+
name = "fun-html"
333
+
version = "1.8.0"
334
+
source = "git+https://github.com/90-008/fun-html.git#04cdde83b4b548083712ad487e3310683785531c"
335
+
dependencies = [
336
+
"axum-core",
337
+
"html-escape",
338
+
]
339
+
340
+
[[package]]
341
name = "futures-channel"
342
version = "0.3.31"
343
source = "registry+https://github.com/rust-lang/crates.io-index"
···
554
]
555
556
[[package]]
557
name = "icu_collections"
558
version = "2.0.0"
559
source = "registry+https://github.com/rust-lang/crates.io-index"
···
1025
1026
[[package]]
1027
name = "regex"
1028
+
version = "1.11.2"
1029
source = "registry+https://github.com/rust-lang/crates.io-index"
1030
+
checksum = "23d7fd106d8c02486a8d64e778353d1cffe08ce79ac2e82f540c86d0facf6912"
1031
dependencies = [
1032
"aho-corasick",
1033
"memchr",
1034
+
"regex-automata 0.4.10",
1035
+
"regex-syntax 0.8.6",
1036
]
1037
1038
[[package]]
···
1046
1047
[[package]]
1048
name = "regex-automata"
1049
+
version = "0.4.10"
1050
source = "registry+https://github.com/rust-lang/crates.io-index"
1051
+
checksum = "6b9458fa0bfeeac22b5ca447c63aaf45f28439a709ccd244698632f9aa6394d6"
1052
dependencies = [
1053
"aho-corasick",
1054
"memchr",
1055
+
"regex-syntax 0.8.6",
1056
]
1057
1058
[[package]]
···
1063
1064
[[package]]
1065
name = "regex-syntax"
1066
+
version = "0.8.6"
1067
source = "registry+https://github.com/rust-lang/crates.io-index"
1068
+
checksum = "caf4aa5b0f434c91fe5c7f1ecb6a5ece2130b02ad2a590589dda5146df959001"
1069
1070
[[package]]
1071
name = "reqwest"
···
1279
"anyhow",
1280
"axum",
1281
"axum-htmx",
1282
+
"fun-html",
1283
"reqwest",
1284
"scc",
1285
"smol_str",
1286
"tikv-jemallocator",
1287
"tokio",
+7
-3
Cargo.toml
+7
-3
Cargo.toml
···
1
[package]
2
name = "sightline"
3
version = "0.1.0"
···
15
smol_str = { version = "0.3", features = ["serde"] }
16
scc = "2"
17
ahash = { version = "0.8", features = ["serde"] }
18
-
serde = { version = "1", features = ["derive"] }
19
-
serde_json = "1"
20
-
hypertext = { version = "0.12", features = ["axum", "htmx"] }
21
22
[target.'cfg(not(target_env = "msvc"))'.dependencies]
23
tikv-jemallocator = "0.6"
···
1
+
cargo-features = ["codegen-backend"]
2
+
3
[package]
4
name = "sightline"
5
version = "0.1.0"
···
17
smol_str = { version = "0.3", features = ["serde"] }
18
scc = "2"
19
ahash = { version = "0.8", features = ["serde"] }
20
+
fun-html = { git = "https://github.com/90-008/fun-html.git", features = ["axum"] }
21
22
[target.'cfg(not(target_env = "msvc"))'.dependencies]
23
tikv-jemallocator = "0.6"
24
+
25
+
[profile.dev]
26
+
debug = 0
27
+
strip = "debuginfo"
+45
-2
src/main.rs
+45
-2
src/main.rs
···
1
+
use std::{net::SocketAddr, sync::Arc};
2
+
3
+
use tracing::Level;
4
+
use tracing_subscriber::EnvFilter;
5
+
6
+
use crate::state::AppState;
7
+
8
+
pub mod router;
9
+
pub mod state;
10
+
pub mod templates;
11
+
12
+
#[tokio::main]
13
+
async fn main() {
14
+
tracing_subscriber::fmt::fmt()
15
+
.with_env_filter(
16
+
EnvFilter::builder()
17
+
.with_default_directive(Level::INFO.into())
18
+
.from_env_lossy(),
19
+
)
20
+
.compact()
21
+
.init();
22
+
23
+
let addr = SocketAddr::from((
24
+
[0, 0, 0, 0],
25
+
std::env::var("PORT")
26
+
.ok()
27
+
.and_then(|s| s.parse::<u16>().ok())
28
+
.unwrap_or(3713),
29
+
));
30
+
let listener = tokio::net::TcpListener::bind(addr).await.unwrap();
31
+
32
+
let state = Arc::new(AppState::new());
33
+
let app = router::build(state);
34
+
35
+
tracing::info!("hi! serving on {addr}... (^_^)");
36
+
tokio::select! {
37
+
res = axum::serve(listener, app) => {
38
+
if let Err(e) = res {
39
+
tracing::error!("oops: serve failed: {e}! (@,@)");
40
+
}
41
+
}
42
+
_ = tokio::signal::ctrl_c() => {
43
+
tracing::info!("received ctrl-c! bye bye... (T.T)/");
44
+
}
45
+
}
46
}
+13
src/router/index.rs
+13
src/router/index.rs
···
···
1
+
use std::sync::Arc;
2
+
3
+
use axum::{
4
+
extract::State,
5
+
response::{Html, IntoResponse},
6
+
};
7
+
use fun_html::elt::text;
8
+
9
+
use crate::{state::AppState, templates::document};
10
+
11
+
pub async fn handle(state: State<Arc<AppState>>) -> impl IntoResponse {
12
+
Html(document::tmpl(text("meow")))
13
+
}
+13
src/router/mod.rs
+13
src/router/mod.rs
+11
src/state.rs
+11
src/state.rs
+23
src/templates/document.rs
+23
src/templates/document.rs
···
···
1
+
use fun_html::{Document, Element, attr::*, conv::*, html};
2
+
3
+
const HTMX_SRC: &str = "https://unpkg.com/htmx.org@2";
4
+
const MATCHA_SRC: &str = "https://matcha.mizu.sh/matcha.lite.css";
5
+
6
+
pub fn tmpl(children: Element) -> Document {
7
+
html(
8
+
[lang("en")],
9
+
[
10
+
head([
11
+
title("sightline"),
12
+
meta(charset_utf8()),
13
+
meta([
14
+
name("viewport"),
15
+
content("width=device-width, initial-scale=1.0"),
16
+
]),
17
+
script(HTMX_SRC),
18
+
link_stylesheet(MATCHA_SRC),
19
+
]),
20
+
body(children),
21
+
],
22
+
)
23
+
}
+1
src/templates/mod.rs
+1
src/templates/mod.rs
···
···
1
+
pub mod document;