add crate for future frontend

This commit is contained in:
Lennart
2024-08-03 16:32:24 +02:00
parent 076f140923
commit 3869dad772
6 changed files with 170 additions and 4 deletions

View 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/" }

View 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>)));
}

View 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>