mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
add crate for future frontend
This commit is contained in:
108
Cargo.lock
generated
108
Cargo.lock
generated
@@ -342,6 +342,61 @@ dependencies = [
|
||||
"password-hash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "askama"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b79091df18a97caea757e28cd2d5fda49c6cd4bd01ddffd7ff01ace0c0ad2c28"
|
||||
dependencies = [
|
||||
"askama_derive",
|
||||
"askama_escape",
|
||||
"humansize",
|
||||
"num-traits",
|
||||
"percent-encoding",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "askama_actix"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e4b0dd17cfe203b00ba3853a89fba459ecf24c759b738b244133330607c78e55"
|
||||
dependencies = [
|
||||
"actix-web",
|
||||
"askama",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "askama_derive"
|
||||
version = "0.12.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19fe8d6cb13c4714962c072ea496f3392015f0989b1a2847bb4b2d9effd71d83"
|
||||
dependencies = [
|
||||
"askama_parser",
|
||||
"basic-toml",
|
||||
"mime",
|
||||
"mime_guess",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"serde",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "askama_escape"
|
||||
version = "0.10.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "619743e34b5ba4e9703bba34deac3427c72507c7159f5fd030aea8cac0cfe341"
|
||||
|
||||
[[package]]
|
||||
name = "askama_parser"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "acb1161c6b64d1c3d83108213c2a2533a342ac225aabd0bda218278c2ddb00c0"
|
||||
dependencies = [
|
||||
"nom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-trait"
|
||||
version = "0.1.81"
|
||||
@@ -395,6 +450,15 @@ version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
|
||||
|
||||
[[package]]
|
||||
name = "basic-toml"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "823388e228f614e9558c6804262db37960ec8821856535f5c3f59913140558f8"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
@@ -1068,6 +1132,15 @@ version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
|
||||
|
||||
[[package]]
|
||||
name = "humansize"
|
||||
version = "2.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6cb51c9a029ddc91b07a787f1d86b53ccfa49b0e86688c946ebe8d3555685dd7"
|
||||
dependencies = [
|
||||
"libm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "2.1.0"
|
||||
@@ -1265,6 +1338,16 @@ version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
|
||||
|
||||
[[package]]
|
||||
name = "mime_guess"
|
||||
version = "2.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e"
|
||||
dependencies = [
|
||||
"mime",
|
||||
"unicase",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
version = "0.2.1"
|
||||
@@ -1526,9 +1609,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "quick-xml"
|
||||
version = "0.35.0"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "86e446ed58cef1bbfe847bc2fda0e2e4ea9f0e57b90c507d4781292590d72a4e"
|
||||
checksum = "96a05e2e8efddfa51a84ca47cec303fac86c8541b686d37cac5efc0e094417bc"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"serde",
|
||||
@@ -1726,6 +1809,7 @@ dependencies = [
|
||||
"rustical_auth",
|
||||
"rustical_caldav",
|
||||
"rustical_carddav",
|
||||
"rustical_frontend",
|
||||
"rustical_store",
|
||||
"serde",
|
||||
"sqlx",
|
||||
@@ -1811,6 +1895,17 @@ dependencies = [
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustical_frontend"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"actix-web",
|
||||
"askama",
|
||||
"askama_actix",
|
||||
"rustical_store",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustical_store"
|
||||
version = "0.1.0"
|
||||
@@ -2491,6 +2586,15 @@ version = "1.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
|
||||
|
||||
[[package]]
|
||||
name = "unicase"
|
||||
version = "2.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89"
|
||||
dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-bidi"
|
||||
version = "0.3.15"
|
||||
|
||||
@@ -12,6 +12,7 @@ rustical_store = { path = "./crates/store/" }
|
||||
rustical_auth = { path = "./crates/auth/" }
|
||||
rustical_caldav = { path = "./crates/caldav/" }
|
||||
rustical_carddav = { path = "./crates/carddav/" }
|
||||
rustical_frontend = { path = "./crates/frontend/" }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
tokio = { version = "1.39", features = [
|
||||
"net",
|
||||
|
||||
11
crates/frontend/Cargo.toml
Normal file
11
crates/frontend/Cargo.toml
Normal file
@@ -0,0 +1,11 @@
|
||||
[package]
|
||||
name = "rustical_frontend"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "4.8"
|
||||
askama = { version = "0.12", features = ["serde", "with-actix-web"] }
|
||||
askama_actix = "0.14"
|
||||
tokio = { version = "1.39", features = ["sync", "full"] }
|
||||
rustical_store = { path = "../store/" }
|
||||
31
crates/frontend/src/lib.rs
Normal file
31
crates/frontend/src/lib.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
use actix_web::{
|
||||
get,
|
||||
http::Method,
|
||||
web::{self, Data},
|
||||
};
|
||||
use askama::Template;
|
||||
use rustical_store::CalendarStore;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "index.html")]
|
||||
struct IndexTemplate {}
|
||||
|
||||
#[get("")]
|
||||
async fn route_index() -> IndexTemplate {
|
||||
IndexTemplate {}
|
||||
}
|
||||
|
||||
async fn route_user<C: CalendarStore + ?Sized>(store: Data<RwLock<C>>) -> IndexTemplate {
|
||||
IndexTemplate {}
|
||||
}
|
||||
|
||||
pub fn configure_frontend<C: CalendarStore + ?Sized>(
|
||||
cfg: &mut web::ServiceConfig,
|
||||
store: Arc<RwLock<C>>,
|
||||
) {
|
||||
cfg.app_data(Data::from(store.clone()))
|
||||
.service(route_index)
|
||||
.service(web::resource("/user/{user}").route(web::method(Method::GET).to(route_user::<C>)));
|
||||
}
|
||||
15
crates/frontend/templates/index.html
Normal file
15
crates/frontend/templates/index.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Test</title>
|
||||
<link href="css/style.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Test</h1>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,11 +1,11 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use actix_web::body::MessageBody;
|
||||
use actix_web::dev::{ServiceFactory, ServiceRequest, ServiceResponse};
|
||||
use actix_web::middleware::{Logger, NormalizePath};
|
||||
use actix_web::{web, App};
|
||||
use rustical_auth::CheckAuthentication;
|
||||
use rustical_frontend::configure_frontend;
|
||||
use rustical_store::CalendarStore;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
pub fn make_app<CS: CalendarStore + ?Sized, A: CheckAuthentication>(
|
||||
@@ -40,4 +40,8 @@ pub fn make_app<CS: CalendarStore + ?Sized, A: CheckAuthentication>(
|
||||
// rustical_carddav::configure_well_known(cfg, "/carddav".to_string())
|
||||
// }),
|
||||
)
|
||||
.service(
|
||||
web::scope("/frontend").configure(|cfg| configure_frontend(cfg, cal_store.clone())),
|
||||
)
|
||||
.service(web::redirect("/", "/frontend").permanent())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user