Templates!

This commit is contained in:
Daniel Flanagan 2024-05-07 21:23:36 -05:00
parent 8dd1ffbdf5
commit 888359fead
5 changed files with 27 additions and 5 deletions

14
Cargo.lock generated
View file

@ -788,6 +788,12 @@ version = "2.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
[[package]]
name = "memo-map"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "374c335b2df19e62d4cb323103473cbc6510980253119180de862d89184f6a83"
[[package]] [[package]]
name = "mime" name = "mime"
version = "0.3.17" version = "0.3.17"
@ -810,6 +816,8 @@ version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7165d0e94806d52ad5295e4b54a95176d831814840bc067298ca647e1c956338" checksum = "7165d0e94806d52ad5295e4b54a95176d831814840bc067298ca647e1c956338"
dependencies = [ dependencies = [
"memo-map",
"self_cell",
"serde", "serde",
] ]
@ -1216,6 +1224,12 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "self_cell"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d369a96f978623eb3dc28807c4852d6cc617fed53da5d3c400feff1ef34a714a"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.200" version = "1.0.200"

View file

@ -10,7 +10,7 @@ axum = { version = "0.7.5", features = ["macros", "tokio"] }
color-eyre = "0.6.3" color-eyre = "0.6.3"
config = "0.14.0" config = "0.14.0"
futures = "0.3.30" futures = "0.3.30"
minijinja = "2.0.1" minijinja = { version = "2.0.1", features = ["loader"] }
notify = "6.1.1" notify = "6.1.1"
redact = { version = "0.1.9", features = ["serde"] } redact = { version = "0.1.9", features = ["serde"] }
sled = "0.34.7" sled = "0.34.7"

7
pages/index.html.jinja Normal file
View file

@ -0,0 +1,7 @@
{% extends "page.html.jinja" %}
{% block body %}
<h1>Index</h1>
<p class="important">
Welcome to my awesome homepage.
</p>
{% endblock %}

View file

@ -54,11 +54,11 @@ async fn main() -> Besult<()> {
info!("Tailwind spawned. {tw:#?}"); info!("Tailwind spawned. {tw:#?}");
}); });
let mut templates = Arc::new(Mutex::new(Environment::new())); let templates = Arc::new(Mutex::new(Environment::new()));
while let Some(d) = tokio::fs::read_dir("templates").await?.next_entry().await? { while let Some(d) = tokio::fs::read_dir("templates").await?.next_entry().await? {
templates.clone().lock().await.add_template( templates.clone().lock().await.add_template_owned(
d.path().to_string_lossy().as_ref(), d.file_name().into_string().unwrap(),
&std::fs::read_to_string(d.path())?, std::fs::read_to_string(d.path())?,
)?; )?;
} }

View file

@ -7,6 +7,7 @@
</head> </head>
<body class="bg-base text-text"> <body class="bg-base text-text">
{% block body %}{% endblock %}
</body> </body>
</html> </html>