1
Fork 0
mirror of https://github.com/RGBCube/Site synced 2025-08-01 13:37:49 +00:00

Fix path issues

This commit is contained in:
RGBCube 2024-01-08 23:16:05 +03:00
parent 499bd01a63
commit acffe1993c
No known key found for this signature in database
4 changed files with 7 additions and 28 deletions

17
Cargo.lock generated
View file

@ -317,9 +317,9 @@ dependencies = [
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.4.13" version = "4.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52bdc885e4cacc7f7c9eedc1ef6da641603180c783c41a15c264944deeaab642" checksum = "33e92c5c1a78c62968ec57dbc2440366a2d6e5a23faf829970ff1585dc6b18e2"
dependencies = [ dependencies = [
"clap_builder", "clap_builder",
"clap_derive", "clap_derive",
@ -327,9 +327,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_builder" name = "clap_builder"
version = "4.4.12" version = "4.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb7fb5e4e979aec3be7791562fcba452f94ad85e954da024396433e0e25a79e9" checksum = "f4323769dc8a61e2c39ad7dc26f6f2800524691a44d74fe3d1071a5c24db6370"
dependencies = [ dependencies = [
"anstream", "anstream",
"anstyle", "anstyle",
@ -930,14 +930,6 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "proc-file"
version = "1.0.0"
source = "git+https://github.com/RGBCube/proc-file#88d6d829891e56bd89827f0bf5e0eca5aa2c047c"
dependencies = [
"proc-macro2",
]
[[package]] [[package]]
name = "proc-macro-error" name = "proc-macro-error"
version = "1.0.4" version = "1.0.4"
@ -1230,7 +1222,6 @@ dependencies = [
"maud", "maud",
"mime_guess", "mime_guess",
"minify-js", "minify-js",
"proc-file",
"pulldown-cmark", "pulldown-cmark",
"serde", "serde",
"serde_yaml", "serde_yaml",

View file

@ -24,7 +24,6 @@ log = { version = "0.4.20", features = [ "serde" ] }
maud = { git = "https://github.com/lambda-fairy/maud", features = [ "axum" ] } maud = { git = "https://github.com/lambda-fairy/maud", features = [ "axum" ] }
mime_guess = "2.0.4" mime_guess = "2.0.4"
minify-js = "0.6.0" minify-js = "0.6.0"
proc-file = { git = "https://github.com/RGBCube/proc-file" }
pulldown-cmark = "0.9.3" pulldown-cmark = "0.9.3"
serde = { version = "1.0.195", features = [ "derive" ] } serde = { version = "1.0.195", features = [ "derive" ] }
serde_yaml = "0.9.30" serde_yaml = "0.9.30"

View file

@ -74,7 +74,7 @@ async fn redirect_http(args: Cli) {
match make_https(host, uri) { match make_https(host, uri) {
Ok(uri) => Ok(Redirect::permanent(&uri.to_string())), Ok(uri) => Ok(Redirect::permanent(&uri.to_string())),
Err(error) => { Err(error) => {
log::warn!("Failed to convert URI to HTTPS: {}", error); log::warn!("Failed to convert URI to HTTPS: {error}");
Err(StatusCode::BAD_REQUEST) Err(StatusCode::BAD_REQUEST)
}, },
} }

View file

@ -1,6 +1,5 @@
use std::{ use std::{
collections::HashMap, collections::HashMap,
path,
sync::LazyLock, sync::LazyLock,
}; };
@ -26,18 +25,8 @@ pub struct Metadata {
} }
pub static PAGES: LazyLock<HashMap<String, (Metadata, Markup)>> = LazyLock::new(|| { pub static PAGES: LazyLock<HashMap<String, (Metadata, Markup)>> = LazyLock::new(|| {
let routes_path = dbg!(path::Path::new(proc_file::file!())
.parent()
.unwrap()
.canonicalize()
.unwrap());
HashMap::from_iter(embed::dir!(".").flatten().iter().filter_map(|file| { HashMap::from_iter(embed::dir!(".").flatten().iter().filter_map(|file| {
let path = dbg!(path::Path::new(file.path().as_ref())) let path = file.path().as_ref().split_once("routes/").unwrap().1;
.strip_prefix(&routes_path)
.unwrap()
.to_str()
.unwrap();
if !path.ends_with(".md") { if !path.ends_with(".md") {
return None; return None;
@ -52,7 +41,7 @@ pub static PAGES: LazyLock<HashMap<String, (Metadata, Markup)>> = LazyLock::new(
log::info!("Adding page {path}"); log::info!("Adding page {path}");
Some(( Some((
path.to_string().strip_suffix(".md").unwrap().to_string(), path.strip_suffix(".md").unwrap().to_string(),
(metadata, markdown::parse(content)), (metadata, markdown::parse(content)),
)) ))
})) }))