Use local deps

This commit is contained in:
Mo 2022-11-02 20:50:23 +01:00
parent ba01105058
commit 6b5bd9f113
11 changed files with 40 additions and 7 deletions

2
.gitignore vendored
View file

@ -1,2 +1,4 @@
*.json *.json
/node_modules/
/target/ /target/
logs

View file

@ -15,6 +15,7 @@ axum = { version = "0.5", default-features = false, features = [
"query", "query",
"form", "form",
] } ] }
axum-extra = { version = "0.3", features = ["spa"] }
captcha = "0.0.9" captcha = "0.0.9"
lettre = "0.10" lettre = "0.10"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }

View file

@ -12,6 +12,7 @@ use axum::extract::Extension;
use axum::routing::{get, post}; use axum::routing::{get, post};
use axum::{error_handling::HandleErrorLayer, http::StatusCode, BoxError}; use axum::{error_handling::HandleErrorLayer, http::StatusCode, BoxError};
use axum::{Router, Server}; use axum::{Router, Server};
use axum_extra::routing::SpaRouter;
use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::process; use std::process;
use std::sync::Arc; use std::sync::Arc;
@ -41,10 +42,16 @@ async fn init() -> Result<WorkerGuard> {
let config = Arc::new(config); let config = Arc::new(config);
let captcha_solutions = Arc::new(captcha_solutions::SharedCaptchaSolutions::new()); let captcha_solutions = Arc::new(captcha_solutions::SharedCaptchaSolutions::new());
let spa = SpaRouter::new(&format!("{}/static", &path_prefix), "static");
let routes = Router::new() let routes = Router::new()
.route("/", get(routes::index)) .route("/", get(routes::index))
.route("/submit", post(routes::submit)) .route("/submit", post(routes::submit))
.route("/success", get(routes::success)) .route("/success", get(routes::success));
let app = Router::new()
.nest(&path_prefix, routes)
.merge(spa)
.layer(TraceLayer::new_for_http().on_response(DefaultOnResponse::new().level(Level::INFO))) .layer(TraceLayer::new_for_http().on_response(DefaultOnResponse::new().level(Level::INFO)))
.layer( .layer(
ServiceBuilder::new() ServiceBuilder::new()
@ -61,8 +68,6 @@ async fn init() -> Result<WorkerGuard> {
.layer(Extension(mailer)) .layer(Extension(mailer))
.layer(Extension(captcha_solutions)); .layer(Extension(captcha_solutions));
let app = Router::new().nest(&path_prefix, routes);
Server::bind(&socket_address) Server::bind(&socket_address)
.serve(app.into_make_service()) .serve(app.into_make_service())
.await .await

View file

@ -79,11 +79,12 @@ pub async fn submit(
} }
} }
success().await success(config).await
} }
pub async fn success() -> Result<Response, errors::AppError> { pub async fn success(config: Extension<Arc<config::Config>>) -> Result<Response, errors::AppError> {
let template = templates::Success { let template = templates::Success {
path_prefix: &config.path_prefix,
message: message:
"Ihre Anfrage wurde erfolgreich übermittelt! Wir melden uns bald bei Ihnen zurück.", "Ihre Anfrage wurde erfolgreich übermittelt! Wir melden uns bald bei Ihnen zurück.",
}; };

View file

@ -16,5 +16,6 @@ pub struct ContactForm<'a> {
#[derive(Template)] #[derive(Template)]
#[template(path = "success.askama.html")] #[template(path = "success.askama.html")]
pub struct Success<'a> { pub struct Success<'a> {
pub path_prefix: &'a str,
pub message: &'a str, pub message: &'a str,
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

7
static/bootstrap/bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -8,13 +8,13 @@
{% block styles %}{% endblock %} {% block styles %}{% endblock %}
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous"> <link href="{{ path_prefix }}/static/bootstrap/bootstrap.min.css" rel="stylesheet"/>
</head> </head>
<body> <body>
{% block body %}{% endblock %} {% block body %}{% endblock %}
{% block scripts %}{% endblock %} {% block scripts %}{% endblock %}
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous"></script> <script src="{{ path_prefix }}/static/bootstrap/bootstrap.bundle.min.js"></script>
</body> </body>
</html> </html>

7
update_deps.sh Executable file
View file

@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -e
npm update
cp -v node_modules/bootstrap/dist/{css/bootstrap.min.css{,.map},js/bootstrap.bundle.min.js{,.map}} static/bootstrap