Simplify drawing logic

Now that only typst is left, things become a lot simpler.
This commit is contained in:
Joscha 2025-03-01 23:35:10 +01:00
parent a55109c677
commit 7d74a56559
12 changed files with 41 additions and 109 deletions

View file

@ -2,10 +2,7 @@ use axum::{Form, extract::State};
use jiff::Zoned;
use serde::{Deserialize, Serialize};
use crate::{
drawer::{Command, NewTypstDrawing},
server::{Server, somehow},
};
use crate::server::{Server, somehow};
#[derive(Serialize)]
struct Data {
@ -34,10 +31,6 @@ pub async fn post(server: State<Server>, Form(form): Form<FormData>) -> somehow:
.with_json("/data.json", &data)
.with_main_file(include_str!("main.typ"));
let _ = server
.tx
.send(Command::draw(NewTypstDrawing::new(typst)))
.await;
server.print_typst(typst).await;
Ok(())
}

View file

@ -6,7 +6,6 @@ use image::{ImageFormat, Rgba, RgbaImage, imageops};
use serde::{Deserialize, Serialize};
use crate::{
drawer::{Command, NewTypstDrawing},
printer::Printer,
server::{Server, somehow},
};
@ -101,10 +100,6 @@ pub async fn post(server: State<Server>, Form(form): Form<FormData>) -> somehow:
.with_file("/image.png", bytes)
.with_main_file(include_str!("main.typ"));
let _ = server
.tx
.send(Command::draw(NewTypstDrawing::new(typst)))
.await;
server.print_typst(typst).await;
Ok(())
}

View file

@ -1,10 +1,7 @@
use axum::{Form, extract::State};
use serde::{Deserialize, Serialize};
use crate::{
drawer::{Command, NewTypstDrawing},
server::Server,
};
use crate::server::Server;
#[derive(Serialize)]
struct Data {
@ -31,8 +28,5 @@ pub async fn post(server: State<Server>, Form(form): Form<FormData>) {
.with_json("/data.json", &data)
.with_main_file(include_str!("main.typ"));
let _ = server
.tx
.send(Command::draw(NewTypstDrawing::new(typst)))
.await;
server.print_typst(typst).await;
}

View file

@ -1,10 +1,7 @@
use axum::{Form, extract::State};
use serde::{Deserialize, Serialize};
use crate::{
drawer::{Command, NewTypstDrawing},
server::Server,
};
use crate::server::Server;
#[derive(Serialize)]
struct Data {
@ -57,8 +54,5 @@ pub async fn post(server: State<Server>, Form(form): Form<FormData>) {
typst.add_file(format!("/egg_bad/pattern_{i:02}.png"), *pattern);
}
let _ = server
.tx
.send(Command::draw(NewTypstDrawing::new(typst)))
.await;
server.print_typst(typst).await;
}

View file

@ -9,10 +9,7 @@ use axum::{
use image::ImageFormat;
use serde::Serialize;
use crate::{
drawer::{Command, NewTypstDrawing},
server::{Server, somehow, statuscode::status_code},
};
use crate::server::{Server, somehow, statuscode::status_code};
#[derive(Serialize)]
struct Data {
@ -79,10 +76,6 @@ pub async fn post(server: State<Server>, mut multipart: Multipart) -> somehow::R
.with_file("/image.png", bytes)
.with_main_file(include_str!("main.typ"));
let _ = server
.tx
.send(Command::draw(NewTypstDrawing::new(typst)))
.await;
server.print_typst(typst).await;
Ok(Redirect::to("image").into_response())
}

View file

@ -1,10 +1,7 @@
use axum::{Form, extract::State};
use serde::{Deserialize, Serialize};
use crate::{
drawer::{Command, NewTypstDrawing},
server::Server,
};
use crate::server::Server;
#[derive(Serialize)]
struct Data {
@ -31,8 +28,5 @@ pub async fn post(server: State<Server>, Form(form): Form<FormData>) {
.with_json("/data.json", &data)
.with_main_file(include_str!("main.typ"));
let _ = server
.tx
.send(Command::draw(NewTypstDrawing::new(typst)))
.await;
server.print_typst(typst).await;
}

View file

@ -1,10 +1,7 @@
use axum::{Form, extract::State};
use serde::{Deserialize, Serialize};
use crate::{
drawer::{Command, NewTypstDrawing},
server::{Server, somehow},
};
use crate::server::{Server, somehow};
#[derive(Serialize)]
struct Data {
@ -25,10 +22,6 @@ pub async fn post(server: State<Server>, Form(form): Form<FormData>) -> somehow:
.with_json("/data.json", &data)
.with_main_file(include_str!("main.typ"));
let _ = server
.tx
.send(Command::draw(NewTypstDrawing::new(typst)))
.await;
server.print_typst(typst).await;
Ok(())
}