1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-07-31 09:24:31 +03:00

Fix embedded templates loading

This commit is contained in:
Quentin Gliech
2021-12-13 17:56:35 +01:00
parent ac211a5aa0
commit daf5542e6d
5 changed files with 28 additions and 41 deletions

36
Cargo.lock generated
View File

@ -435,9 +435,9 @@ dependencies = [
[[package]]
name = "clap"
version = "3.0.0-rc.1"
version = "3.0.0-rc.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c068998524e6d40ea78c8d2a4b00398f0a8b818c2d484bcb3cbeb2cff2c105ae"
checksum = "967965e82fc46fee1a88147a7a977a66d615ed5f83eb95b18577b342c08f90ff"
dependencies = [
"atty",
"bitflags",
@ -452,9 +452,9 @@ dependencies = [
[[package]]
name = "clap_derive"
version = "3.0.0-rc.1"
version = "3.0.0-rc.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0152ba3ee01fa5a9133d4e15a1d9659c75d2270365768dd5a880cc7e68871874"
checksum = "85946d4034625800196413478a1c6d3a57c12785e1f3970e590e0137dfa07342"
dependencies = [
"heck",
"proc-macro-error",
@ -743,12 +743,6 @@ version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
[[package]]
name = "dtoa"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0"
[[package]]
name = "dyn-clone"
version = "1.0.4"
@ -1138,9 +1132,9 @@ dependencies = [
[[package]]
name = "hermit-abi"
version = "0.1.20"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7a30908dbce072eca83216eab939d2290080e00ca71611b96a09e5cdce5f3fa"
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [
"libc",
]
@ -1433,9 +1427,9 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.109"
version = "0.2.111"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f98a04dce437184842841303488f70d0188c5f51437d2a834dc097eafa909a01"
checksum = "8e167738f1866a7ec625567bae89ca0d44477232a4f7c52b1c7f2adc2c98804f"
[[package]]
name = "libm"
@ -2155,9 +2149,9 @@ dependencies = [
[[package]]
name = "phf"
version = "0.10.0"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9fc3db1018c4b59d7d582a739436478b6035138b6aecbce989fc91c3e98409f"
checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259"
dependencies = [
"phf_shared",
]
@ -2653,9 +2647,9 @@ checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f"
[[package]]
name = "ryu"
version = "1.0.6"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c9613b5a66ab9ba26415184cfc41156594925a9cf3a2057e57f31ff145f6568"
checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f"
[[package]]
name = "safemem"
@ -2883,12 +2877,12 @@ dependencies = [
[[package]]
name = "serde_yaml"
version = "0.8.21"
version = "0.8.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8c608a35705a5d3cdc9fbe403147647ff34b921f8e833e49306df898f9b20af"
checksum = "a4a521f2940385c165a24ee286aa8599633d162077a54bdcae2a6fd5a7bfa7a0"
dependencies = [
"dtoa",
"indexmap",
"ryu",
"serde",
"yaml-rust",
]

View File

@ -9,7 +9,7 @@ license = "Apache-2.0"
tokio = { version = "1.14.0", features = ["full"] }
futures = "0.3.18"
anyhow = "1.0.51"
clap = { version = "3.0.0-rc.1", features = ["derive"] }
clap = { version = "3.0.0-rc.4", features = ["derive"] }
dotenv = "0.15.0"
schemars = { version = "0.8.8", features = ["url", "chrono"] }
tower = { version = "0.4.11", features = ["full"] }

View File

@ -10,7 +10,7 @@ dev = []
[dependencies]
tracing = "0.1.29"
tokio = "1.14.0"
tokio = { version = "1.14.0", features = ["macros"] }
anyhow = "1.0.51"
thiserror = "1.0.30"

View File

@ -115,17 +115,12 @@ impl Templates {
let mut tera = Tera::default();
info!("Loading builtin templates");
for (name, source) in EXTRA_TEMPLATES {
if let Some(source) = source {
tera.add_raw_template(name, source)?;
}
}
for (name, source) in TEMPLATES {
if let Some(source) = source {
tera.add_raw_template(name, source)?;
}
}
tera.add_raw_templates(
EXTRA_TEMPLATES
.into_iter()
.chain(TEMPLATES)
.filter_map(|(name, content)| content.map(|c| (name, c))),
)?;
Ok(tera)
}
@ -183,9 +178,7 @@ impl Templates {
self::functions::register(&mut tera);
let loaded: HashSet<_> = tera.get_template_names().collect();
let needed: HashSet<_> = std::array::IntoIter::new(TEMPLATES)
.map(|(name, _)| name)
.collect();
let needed: HashSet<_> = TEMPLATES.into_iter().map(|(name, _)| name).collect();
debug!(?loaded, ?needed, "Templates loaded");
let missing: HashSet<_> = needed.difference(&loaded).collect();
@ -219,7 +212,7 @@ impl Templates {
.await
.context("could not create destination folder")?;
let templates = std::array::IntoIter::new(TEMPLATES).chain(EXTRA_TEMPLATES);
let templates = TEMPLATES.into_iter().chain(EXTRA_TEMPLATES);
let mut options = OpenOptions::new();
if overwrite {
@ -285,9 +278,9 @@ impl warp::reject::Reject for TemplateError {}
register_templates! {
extra = {
"base.html",
"components/button.html",
"components/field.html"
"components/field.html",
"base.html",
};
/// Render the login page

View File

@ -29,7 +29,7 @@ macro_rules! count {
macro_rules! register_templates {
{
$(
extra = { $( $extra_template:expr ),* };
extra = { $( $extra_template:expr ),* $(,)? };
)?
$(