|
|
@ -2,7 +2,7 @@
|
|
|
|
extern crate rocket;
|
|
|
|
extern crate rocket;
|
|
|
|
|
|
|
|
|
|
|
|
use poise::serenity_prelude::Http;
|
|
|
|
use poise::serenity_prelude::Http;
|
|
|
|
use rocket::fs::{relative, FileServer};
|
|
|
|
use rocket::{fs::{relative, FileServer}};
|
|
|
|
use rocket_dyn_templates::{tera, Template};
|
|
|
|
use rocket_dyn_templates::{tera, Template};
|
|
|
|
use sass_rocket_fairing::SassFairing;
|
|
|
|
use sass_rocket_fairing::SassFairing;
|
|
|
|
use std::{collections::HashMap, env};
|
|
|
|
use std::{collections::HashMap, env};
|
|
|
@ -20,6 +20,8 @@ use routes::*;
|
|
|
|
mod i18n;
|
|
|
|
mod i18n;
|
|
|
|
use i18n::{i18n_filter, load_catalogs};
|
|
|
|
use i18n::{i18n_filter, load_catalogs};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use crate::i18n::langs_filter;
|
|
|
|
|
|
|
|
|
|
|
|
mod prelude;
|
|
|
|
mod prelude;
|
|
|
|
|
|
|
|
|
|
|
|
#[launch]
|
|
|
|
#[launch]
|
|
|
@ -43,14 +45,20 @@ async fn rocket() -> _ {
|
|
|
|
routes![get_challenge, login, post_login, success, logout, testing],
|
|
|
|
routes![get_challenge, login, post_login, success, logout, testing],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.mount("/css", FileServer::from(relative!("styles/css")))
|
|
|
|
.mount("/css", FileServer::from(relative!("styles/css")))
|
|
|
|
.attach(Template::custom(|engines| {
|
|
|
|
.attach(Template::custom(move |engines| {
|
|
|
|
use tera::Value;
|
|
|
|
use tera::Value;
|
|
|
|
let catalogs = load_catalogs().unwrap();
|
|
|
|
let (catalogs, langs) = load_catalogs().unwrap();
|
|
|
|
engines.tera.register_filter(
|
|
|
|
engines.tera.register_filter(
|
|
|
|
"i18n",
|
|
|
|
"i18n",
|
|
|
|
move |value: &Value, args: &HashMap<String, Value>| {
|
|
|
|
move |value: &Value, args: &HashMap<String, Value>| {
|
|
|
|
i18n_filter(value, args, &catalogs)
|
|
|
|
i18n_filter(value, args, &catalogs)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
engines.tera.register_filter(
|
|
|
|
|
|
|
|
"langs",
|
|
|
|
|
|
|
|
move |value: &Value, args: &HashMap<String, Value>| {
|
|
|
|
|
|
|
|
langs_filter(value, args, &langs)
|
|
|
|
|
|
|
|
}
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}))
|
|
|
|
}))
|
|
|
|
.attach(SassFairing::default())
|
|
|
|
.attach(SassFairing::default())
|
|
|
|