mirror of
https://github.com/dani-garcia/vaultwarden
synced 2024-12-14 01:23:55 +01:00
Default to $data_folder/templates and remove dev option (use TEMPLATES_FOLDER=src/static/templates
instead)
This commit is contained in:
parent
19b6bb0fd6
commit
bcd750695f
1 changed files with 9 additions and 11 deletions
20
src/main.rs
20
src/main.rs
|
@ -328,21 +328,19 @@ pub struct Config {
|
||||||
templates: Handlebars,
|
templates: Handlebars,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_templates(path: Option<String>) -> Handlebars {
|
fn load_templates(path: String) -> Handlebars {
|
||||||
let mut hb = Handlebars::new();
|
let mut hb = Handlebars::new();
|
||||||
|
|
||||||
// First register default templates here (use include_str?)
|
// First register default templates here (use include_str?)
|
||||||
hb.register_template_string("tpl_1", "Good afternoon, {{name}}").unwrap();
|
hb.register_template_string("tpl_1", "Good afternoon, {{name}}")
|
||||||
|
.unwrap();
|
||||||
// TODO: Development-only. Remove this before release
|
|
||||||
hb.register_templates_directory(".hbs", "src/static/templates").unwrap();
|
|
||||||
|
|
||||||
// And then load user templates to overwrite the defaults
|
// And then load user templates to overwrite the defaults
|
||||||
if let Some(path) = path {
|
// Use .hbs extension for the files
|
||||||
// Use .hbs extension for the files
|
// Templates get registered with their relative name
|
||||||
// Templates get registered with their relative name
|
hb.register_templates_directory(".hbs", path).unwrap();
|
||||||
hb.register_templates_directory(".hbs", path).unwrap();
|
|
||||||
}
|
// println!("{}", hb.render("tpl_1", &json!({"name": "Dani"})).unwrap());
|
||||||
|
|
||||||
hb
|
hb
|
||||||
}
|
}
|
||||||
|
@ -364,6 +362,7 @@ impl Config {
|
||||||
database_url: get_env_or("DATABASE_URL", format!("{}/{}", &df, "db.sqlite3")),
|
database_url: get_env_or("DATABASE_URL", format!("{}/{}", &df, "db.sqlite3")),
|
||||||
icon_cache_folder: get_env_or("ICON_CACHE_FOLDER", format!("{}/{}", &df, "icon_cache")),
|
icon_cache_folder: get_env_or("ICON_CACHE_FOLDER", format!("{}/{}", &df, "icon_cache")),
|
||||||
attachments_folder: get_env_or("ATTACHMENTS_FOLDER", format!("{}/{}", &df, "attachments")),
|
attachments_folder: get_env_or("ATTACHMENTS_FOLDER", format!("{}/{}", &df, "attachments")),
|
||||||
|
templates: load_templates(get_env_or("TEMPLATES_FOLDER", format!("{}/{}", &df, "templates"))),
|
||||||
|
|
||||||
// icon_cache_ttl defaults to 30 days (30 * 24 * 60 * 60 seconds)
|
// icon_cache_ttl defaults to 30 days (30 * 24 * 60 * 60 seconds)
|
||||||
icon_cache_ttl: get_env_or("ICON_CACHE_TTL", 2_592_000),
|
icon_cache_ttl: get_env_or("ICON_CACHE_TTL", 2_592_000),
|
||||||
|
@ -403,7 +402,6 @@ impl Config {
|
||||||
yubico_server: get_env("YUBICO_SERVER"),
|
yubico_server: get_env("YUBICO_SERVER"),
|
||||||
|
|
||||||
mail: MailConfig::load(),
|
mail: MailConfig::load(),
|
||||||
templates: load_templates(get_env("TEMPLATES_FOLDER")),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue