From af328d70095e54dcefd01955276da9bd3f190fac Mon Sep 17 00:00:00 2001 From: itsjunetime Date: Wed, 21 Aug 2024 17:47:12 -0600 Subject: [PATCH] A few minor optimizations for loading and such --- Cargo.lock | 140 +++++++++++++++++++++------------- backend/src/fonts.rs | 20 +++-- fonts/catppuccin_syntax | 2 +- fonts/maple-mono | 2 +- shared_data/src/lib.rs | 7 +- shared_data/src/md_to_html.rs | 2 +- 6 files changed, 110 insertions(+), 63 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2ba4231..fee62bc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + [[package]] name = "ahash" version = "0.8.11" @@ -111,7 +117,7 @@ dependencies = [ [[package]] name = "any_spawner" version = "0.1.1" -source = "git+https://github.com/leptos-rs/leptos.git#ba40560ad78ee46a9a388f507d35351731b1e90d" +source = "git+https://github.com/leptos-rs/leptos.git#c5dea52e69fd1c1c83c0c089d1c73692ed2b4fea" dependencies = [ "futures", "thiserror", @@ -350,7 +356,7 @@ dependencies = [ "cc", "cfg-if", "libc", - "miniz_oxide", + "miniz_oxide 0.7.4", "object", "rustc-demangle", ] @@ -720,7 +726,7 @@ dependencies = [ [[package]] name = "const_str_slice_concat" version = "0.1.0" -source = "git+https://github.com/leptos-rs/leptos.git#ba40560ad78ee46a9a388f507d35351731b1e90d" +source = "git+https://github.com/leptos-rs/leptos.git#c5dea52e69fd1c1c83c0c089d1c73692ed2b4fea" [[package]] name = "convert_case" @@ -1015,7 +1021,7 @@ dependencies = [ [[package]] name = "either_of" version = "0.1.0" -source = "git+https://github.com/leptos-rs/leptos.git#ba40560ad78ee46a9a388f507d35351731b1e90d" +source = "git+https://github.com/leptos-rs/leptos.git#c5dea52e69fd1c1c83c0c089d1c73692ed2b4fea" dependencies = [ "pin-project-lite", ] @@ -1095,12 +1101,12 @@ checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "flate2" -version = "1.0.31" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f211bbe8e69bbd0cfdea405084f128ae8b4aaa6b0b522fc8f2b009084797920" +checksum = "9c0596c1eac1f9e04ed902702e9878208b336edc9d6fddc8a48387349bab3666" dependencies = [ "crc32fast", - "miniz_oxide", + "miniz_oxide 0.8.0", ] [[package]] @@ -1680,9 +1686,9 @@ checksum = "493913a18c0d7bebb75127a26a432162c59edbe06f6cf712001e3e769345e8b5" [[package]] name = "h2" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" +checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" dependencies = [ "atomic-waker", "bytes", @@ -1842,7 +1848,7 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hydration_context" version = "0.2.0-beta2" -source = "git+https://github.com/leptos-rs/leptos.git#ba40560ad78ee46a9a388f507d35351731b1e90d" +source = "git+https://github.com/leptos-rs/leptos.git#c5dea52e69fd1c1c83c0c089d1c73692ed2b4fea" dependencies = [ "futures", "js-sys", @@ -2052,7 +2058,7 @@ dependencies = [ [[package]] name = "leptos" version = "0.7.0-beta2" -source = "git+https://github.com/leptos-rs/leptos.git#ba40560ad78ee46a9a388f507d35351731b1e90d" +source = "git+https://github.com/leptos-rs/leptos.git#c5dea52e69fd1c1c83c0c089d1c73692ed2b4fea" dependencies = [ "any_spawner", "base64 0.22.1", @@ -2090,7 +2096,7 @@ dependencies = [ [[package]] name = "leptos_axum" version = "0.7.0-beta2" -source = "git+https://github.com/leptos-rs/leptos.git#ba40560ad78ee46a9a388f507d35351731b1e90d" +source = "git+https://github.com/leptos-rs/leptos.git#c5dea52e69fd1c1c83c0c089d1c73692ed2b4fea" dependencies = [ "any_spawner", "axum", @@ -2115,7 +2121,7 @@ dependencies = [ [[package]] name = "leptos_config" version = "0.7.0-beta2" -source = "git+https://github.com/leptos-rs/leptos.git#ba40560ad78ee46a9a388f507d35351731b1e90d" +source = "git+https://github.com/leptos-rs/leptos.git#c5dea52e69fd1c1c83c0c089d1c73692ed2b4fea" dependencies = [ "config", "regex", @@ -2127,7 +2133,7 @@ dependencies = [ [[package]] name = "leptos_dom" version = "0.7.0-beta2" -source = "git+https://github.com/leptos-rs/leptos.git#ba40560ad78ee46a9a388f507d35351731b1e90d" +source = "git+https://github.com/leptos-rs/leptos.git#c5dea52e69fd1c1c83c0c089d1c73692ed2b4fea" dependencies = [ "js-sys", "or_poisoned", @@ -2142,7 +2148,7 @@ dependencies = [ [[package]] name = "leptos_hot_reload" version = "0.7.0-beta2" -source = "git+https://github.com/leptos-rs/leptos.git#ba40560ad78ee46a9a388f507d35351731b1e90d" +source = "git+https://github.com/leptos-rs/leptos.git#c5dea52e69fd1c1c83c0c089d1c73692ed2b4fea" dependencies = [ "anyhow", "camino", @@ -2159,7 +2165,7 @@ dependencies = [ [[package]] name = "leptos_integration_utils" version = "0.7.0-beta2" -source = "git+https://github.com/leptos-rs/leptos.git#ba40560ad78ee46a9a388f507d35351731b1e90d" +source = "git+https://github.com/leptos-rs/leptos.git#c5dea52e69fd1c1c83c0c089d1c73692ed2b4fea" dependencies = [ "futures", "hydration_context", @@ -2174,7 +2180,7 @@ dependencies = [ [[package]] name = "leptos_macro" version = "0.7.0-beta2" -source = "git+https://github.com/leptos-rs/leptos.git#ba40560ad78ee46a9a388f507d35351731b1e90d" +source = "git+https://github.com/leptos-rs/leptos.git#c5dea52e69fd1c1c83c0c089d1c73692ed2b4fea" dependencies = [ "attribute-derive", "cfg-if", @@ -2195,8 +2201,8 @@ dependencies = [ [[package]] name = "leptos_meta" -version = "0.7.0-beta2" -source = "git+https://github.com/leptos-rs/leptos.git#ba40560ad78ee46a9a388f507d35351731b1e90d" +version = "0.7.0-beta3" +source = "git+https://github.com/leptos-rs/leptos.git#c5dea52e69fd1c1c83c0c089d1c73692ed2b4fea" dependencies = [ "futures", "indexmap", @@ -2212,7 +2218,7 @@ dependencies = [ [[package]] name = "leptos_router" version = "0.7.0-beta2" -source = "git+https://github.com/leptos-rs/leptos.git#ba40560ad78ee46a9a388f507d35351731b1e90d" +source = "git+https://github.com/leptos-rs/leptos.git#c5dea52e69fd1c1c83c0c089d1c73692ed2b4fea" dependencies = [ "any_spawner", "either_of", @@ -2237,7 +2243,7 @@ dependencies = [ [[package]] name = "leptos_router_macro" version = "0.7.0-beta2" -source = "git+https://github.com/leptos-rs/leptos.git#ba40560ad78ee46a9a388f507d35351731b1e90d" +source = "git+https://github.com/leptos-rs/leptos.git#c5dea52e69fd1c1c83c0c089d1c73692ed2b4fea" dependencies = [ "proc-macro-error", "proc-macro2", @@ -2247,7 +2253,7 @@ dependencies = [ [[package]] name = "leptos_server" version = "0.7.0-beta2" -source = "git+https://github.com/leptos-rs/leptos.git#ba40560ad78ee46a9a388f507d35351731b1e90d" +source = "git+https://github.com/leptos-rs/leptos.git#c5dea52e69fd1c1c83c0c089d1c73692ed2b4fea" dependencies = [ "any_spawner", "base64 0.22.1", @@ -2263,9 +2269,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.157" +version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374af5f94e54fa97cf75e945cce8a6b201e88a1a07e688b47dfd2a59c66dbd86" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "libdeflate-sys" @@ -2431,6 +2437,15 @@ dependencies = [ "adler", ] +[[package]] +name = "miniz_oxide" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +dependencies = [ + "adler2", +] + [[package]] name = "mio" version = "1.0.2" @@ -2463,7 +2478,7 @@ dependencies = [ [[package]] name = "next_tuple" version = "0.1.0-beta2" -source = "git+https://github.com/leptos-rs/leptos.git#ba40560ad78ee46a9a388f507d35351731b1e90d" +source = "git+https://github.com/leptos-rs/leptos.git#c5dea52e69fd1c1c83c0c089d1c73692ed2b4fea" [[package]] name = "nom" @@ -2570,7 +2585,7 @@ dependencies = [ [[package]] name = "oco_ref" version = "0.2.0" -source = "git+https://github.com/leptos-rs/leptos.git#ba40560ad78ee46a9a388f507d35351731b1e90d" +source = "git+https://github.com/leptos-rs/leptos.git#c5dea52e69fd1c1c83c0c089d1c73692ed2b4fea" dependencies = [ "serde", "thiserror", @@ -2585,7 +2600,7 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "or_poisoned" version = "0.1.0" -source = "git+https://github.com/leptos-rs/leptos.git#ba40560ad78ee46a9a388f507d35351731b1e90d" +source = "git+https://github.com/leptos-rs/leptos.git#c5dea52e69fd1c1c83c0c089d1c73692ed2b4fea" [[package]] name = "overload" @@ -3057,7 +3072,7 @@ dependencies = [ [[package]] name = "reactive_graph" version = "0.1.0-beta2" -source = "git+https://github.com/leptos-rs/leptos.git#ba40560ad78ee46a9a388f507d35351731b1e90d" +source = "git+https://github.com/leptos-rs/leptos.git#c5dea52e69fd1c1c83c0c089d1c73692ed2b4fea" dependencies = [ "any_spawner", "async-lock", @@ -3123,9 +3138,9 @@ checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "reqwest" -version = "0.12.5" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" +checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63" dependencies = [ "base64 0.22.1", "bytes", @@ -3163,7 +3178,7 @@ dependencies = [ "wasm-streams", "web-sys", "webpki-roots", - "winreg", + "windows-registry", ] [[package]] @@ -3470,7 +3485,7 @@ dependencies = [ [[package]] name = "server_fn" version = "0.7.0-beta2" -source = "git+https://github.com/leptos-rs/leptos.git#ba40560ad78ee46a9a388f507d35351731b1e90d" +source = "git+https://github.com/leptos-rs/leptos.git#c5dea52e69fd1c1c83c0c089d1c73692ed2b4fea" dependencies = [ "axum", "bytes", @@ -3506,7 +3521,7 @@ dependencies = [ [[package]] name = "server_fn_macro" version = "0.7.0-beta2" -source = "git+https://github.com/leptos-rs/leptos.git#ba40560ad78ee46a9a388f507d35351731b1e90d" +source = "git+https://github.com/leptos-rs/leptos.git#c5dea52e69fd1c1c83c0c089d1c73692ed2b4fea" dependencies = [ "const_format", "convert_case", @@ -3519,7 +3534,7 @@ dependencies = [ [[package]] name = "server_fn_macro_default" version = "0.7.0-beta2" -source = "git+https://github.com/leptos-rs/leptos.git#ba40560ad78ee46a9a388f507d35351731b1e90d" +source = "git+https://github.com/leptos-rs/leptos.git#c5dea52e69fd1c1c83c0c089d1c73692ed2b4fea" dependencies = [ "server_fn_macro", "syn 2.0.75", @@ -3927,6 +3942,9 @@ name = "sync_wrapper" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +dependencies = [ + "futures-core", +] [[package]] name = "syntect" @@ -3951,8 +3969,8 @@ dependencies = [ [[package]] name = "tachys" -version = "0.1.0-beta2" -source = "git+https://github.com/leptos-rs/leptos.git#ba40560ad78ee46a9a388f507d35351731b1e90d" +version = "0.1.0-beta3" +source = "git+https://github.com/leptos-rs/leptos.git#c5dea52e69fd1c1c83c0c089d1c73692ed2b4fea" dependencies = [ "any_spawner", "const_str_slice_concat", @@ -4032,7 +4050,7 @@ dependencies = [ [[package]] name = "throw_error" version = "0.2.0-beta2" -source = "git+https://github.com/leptos-rs/leptos.git#ba40560ad78ee46a9a388f507d35351731b1e90d" +source = "git+https://github.com/leptos-rs/leptos.git#c5dea52e69fd1c1c83c0c089d1c73692ed2b4fea" dependencies = [ "pin-project-lite", ] @@ -4444,9 +4462,9 @@ dependencies = [ [[package]] name = "unicode-properties" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4259d9d4425d9f0661581b804cb85fe66a4c631cadd8f490d1c13a35d5d9291" +checksum = "52ea75f83c0137a9b98608359a5f1af8144876eb67bcb1ce837368e906a9f524" [[package]] name = "unicode-segmentation" @@ -4456,9 +4474,9 @@ checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-xid" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" [[package]] name = "unicode_categories" @@ -4709,6 +4727,36 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-registry" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" +dependencies = [ + "windows-result", + "windows-strings", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result", + "windows-targets 0.52.6", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -4875,16 +4923,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "winreg" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - [[package]] name = "wyz" version = "0.5.1" diff --git a/backend/src/fonts.rs b/backend/src/fonts.rs index 111e3fe..f89ef0b 100644 --- a/backend/src/fonts.rs +++ b/backend/src/fonts.rs @@ -1,4 +1,4 @@ -use axum::{response::Html, extract::Path}; +use axum::{response::Html, extract::Path, http::{HeaderName, header}}; use horrorshow::{html, Raw, helper::doctype, RenderOnce, TemplateBuffer, Template}; use std::sync::OnceLock; use crate::post_list::PostList; @@ -6,13 +6,17 @@ use crate::post_list::PostList; static MAPLE_MONO_LIGHT: &[u8] = include_bytes!("../../fonts/maple-mono/woff2/MapleMono-Light.woff2"); static ISENHEIM_REGULAR: &[u8] = include_bytes!("../../fonts/isenheim/fonts/OpenType-PS/Isenheim_Regulier.otf"); -pub async fn get_font(Path(id): Path) -> &'static [u8] { - // error tolerance babey - if id.contains("maple") { - MAPLE_MONO_LIGHT - } else { - ISENHEIM_REGULAR - } +pub async fn get_font(Path(id): Path) -> ([(HeaderName, &'static str); 1], &'static [u8]) { + ( + // cache for a month + [(header::CACHE_CONTROL, "2592000")], + // error tolerance babey + if id.contains("maple") { + MAPLE_MONO_LIGHT + } else { + ISENHEIM_REGULAR + } + ) } build_info::build_info!(pub fn build); diff --git a/fonts/catppuccin_syntax b/fonts/catppuccin_syntax index ba4d168..d3feec4 160000 --- a/fonts/catppuccin_syntax +++ b/fonts/catppuccin_syntax @@ -1 +1 @@ -Subproject commit ba4d16880d63e656acced2b7d4e034e4a93f74b1 +Subproject commit d3feec47b16a8e99eabb34cdfbaa115541d374fc diff --git a/fonts/maple-mono b/fonts/maple-mono index 375e4f2..217685c 160000 --- a/fonts/maple-mono +++ b/fonts/maple-mono @@ -1 +1 @@ -Subproject commit 375e4f2dc96b2dd2e2e999cd53b57cd93bf4af77 +Subproject commit 217685cef79986f41fe667d6160547a957582383 diff --git a/shared_data/src/lib.rs b/shared_data/src/lib.rs index a01f8e4..9f58fb6 100644 --- a/shared_data/src/lib.rs +++ b/shared_data/src/lib.rs @@ -87,6 +87,11 @@ pub static BASE_STYLE: &str = r#" src: local("Maple Mono"), url("/font/maple-mono"); font-display: swap; } +@font-face { + font-family: "serif fallback"; + src: local("serif"); + size-adjust: 10%; +} * { --body-background: #3f3540; --main-text: #f1f6ff; @@ -96,7 +101,7 @@ pub static BASE_STYLE: &str = r#" --border-color: #ac9fbb; --title-text: #d1bbe4; --code-background: #2b303b; - font-family: Isenheim, Arial; + font-family: Isenheim, "serif fallback"; color: var(--main-text); } body { diff --git a/shared_data/src/md_to_html.rs b/shared_data/src/md_to_html.rs index 2530763..4c8c6cd 100644 --- a/shared_data/src/md_to_html.rs +++ b/shared_data/src/md_to_html.rs @@ -9,7 +9,7 @@ use syntect::{ }; use pulldown_cmark::{CodeBlockKind, CowStr, Event, Tag, TagEnd}; -static FRAPPE_THEME: &[u8] = include_bytes!("../../fonts/catppuccin_syntax/Catppuccin-frappe.tmTheme"); +static FRAPPE_THEME: &[u8] = include_bytes!("../../fonts/catppuccin_syntax/themes/Catppuccin Frappe.tmTheme"); pub fn md_to_html(input: &str) -> String { static THEME: OnceLock = OnceLock::new();