mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 10:32:19 +00:00
add crate for future frontend
This commit is contained in:
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>
|
||||
Reference in New Issue
Block a user