feat: restructure project, implement askama templating #26

Merged
theo merged 21 commits from restructure-project into main 2024-07-26 14:42:03 +02:00
35 changed files with 31 additions and 48 deletions
Showing only changes of commit 86a6d2b9d3 - Show all commits

24
Cargo.lock generated
View File

@ -1487,25 +1487,6 @@ dependencies = [
"unicode-normalization", "unicode-normalization",
] ]
[[package]]
name = "include_dir"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "923d117408f1e49d914f1a379a309cffe4f18c05cf4e3d12e613a15fc81bd0dd"
dependencies = [
"include_dir_macros",
]
[[package]]
name = "include_dir_macros"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cab85a7ed0bd5f0e76d93846e0147172bed2e2d3f859bcc33a8d9699cad1a75"
dependencies = [
"proc-macro2",
"quote",
]
[[package]] [[package]]
name = "indexmap" name = "indexmap"
version = "1.9.3" version = "1.9.3"
@ -2101,9 +2082,9 @@ dependencies = [
[[package]] [[package]]
name = "object" name = "object"
version = "0.36.1" version = "0.36.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "081b846d1d56ddfc18fdf1a922e4f6e07a11768ea1b92dec44e42b72712ccfce" checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]
@ -3270,7 +3251,6 @@ version = "0.1.0"
dependencies = [ dependencies = [
"axum", "axum",
"clego", "clego",
"include_dir",
"tauri", "tauri",
"tauri-build", "tauri-build",
"tokio", "tokio",

View File

@ -1,6 +1,6 @@
[workspace] [workspace]
resolver = "2" resolver = "2"
members = [ members = [
florian_briand marked this conversation as resolved
Review

Packages :

  • tauri/src devient crates/app -> Interfaces et code métier via Axum + Askama + HTMx
  • tauri/src-tauri devient crates/desktop
  • clego devient crates/sesam-vitale
Packages : - `tauri/src` devient `crates/app` -> Interfaces et code métier via Axum + Askama + HTMx - `tauri/src-tauri` devient `crates/desktop` - `clego` devient `crates/sesam-vitale`
"clego", "crates/clego",
"tauri" "crates/tauri"
] ]

View File

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

After

Width:  |  Height:  |  Size: 974 B

View File

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

After

Width:  |  Height:  |  Size: 7.6 KiB

View File

After

Width:  |  Height:  |  Size: 903 B

View File

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

After

Width:  |  Height:  |  Size: 85 KiB

View File

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -5,10 +5,37 @@ use tauri::{path::BaseDirectory, Manager};
use tokio::sync::Mutex; use tokio::sync::Mutex;
use tower::{Service, ServiceExt}; use tower::{Service, ServiceExt};
async fn process_tauri_request(request: tauri::http::Request<>, router: axum:Router ){
let (parts, body) = request.into_parts();
let body = axum::body::Body::from(body);
let request = axum::extract::Request::from_parts(parts, body);
let response = match router.as_service().ready().await {
Ok(ready_service) => ready_service.call(request).await,
Err(_error) => panic!("Failed to get ready service"),
};
let response = match response {
Ok(response) => response,
Err(_error) => panic!("Problem getting response from request."),
};
let (parts, body) = response.into_parts();
let body = match axum::body::to_bytes(body, usize::MAX).await {
Ok(bytes) => bytes.to_vec(),
Err(_error) => panic!("Problem converting response body to bytes."),
};
let response = tauri::http::Response::from_parts(parts, body);
}
#[cfg_attr(mobile, tauri::mobile_entry_point)] #[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() { pub fn run() {
tauri::Builder::default() tauri::Builder::default()
.setup(|app| { .setup(|app| {
// Create a router and adds it the the app state
let resource_path_buf = app let resource_path_buf = app
.path() .path()
.resolve("assets", BaseDirectory::Resource) .resolve("assets", BaseDirectory::Resource)
@ -27,30 +54,6 @@ pub fn run() {
tauri::async_runtime::spawn(async move { tauri::async_runtime::spawn(async move {
let mut router = router.lock().await; let mut router = router.lock().await;
let (parts, body) = request.into_parts();
let body = axum::body::Body::from(body);
let request = axum::extract::Request::from_parts(parts, body);
let response = match router.as_service().ready().await {
Ok(ready_service) => ready_service.call(request).await,
Err(_error) => panic!("Failed to get ready service"),
};
let response = match response {
Ok(response) => response,
Err(_error) => panic!("Problem getting response from request."),
};
let (parts, body) = response.into_parts();
let body = match axum::body::to_bytes(body, usize::MAX).await {
Ok(bytes) => bytes.to_vec(),
Err(_error) => panic!("Problem converting response body to bytes."),
};
let response = tauri::http::Response::from_parts(parts, body);
responder.respond(response); responder.respond(response);
}); });
}) })