From fbab0b9441ec9a26c8d40946975e73cadbbd239c Mon Sep 17 00:00:00 2001
From: Joscha
Date: Sat, 1 Mar 2025 22:23:30 +0100
Subject: [PATCH] Remove /typst endpoint
---
showbits-thermal-printer/src/drawer.rs | 3 +--
showbits-thermal-printer/src/drawer/typst.rs | 25 --------------------
showbits-thermal-printer/src/server.rs | 17 +------------
showbits-thermal-printer/static/index.html | 1 -
showbits-thermal-printer/static/typst.html | 21 ----------------
5 files changed, 2 insertions(+), 65 deletions(-)
delete mode 100644 showbits-thermal-printer/src/drawer/typst.rs
delete mode 100644 showbits-thermal-printer/static/typst.html
diff --git a/showbits-thermal-printer/src/drawer.rs b/showbits-thermal-printer/src/drawer.rs
index 057fe2e..9cbce78 100644
--- a/showbits-thermal-printer/src/drawer.rs
+++ b/showbits-thermal-printer/src/drawer.rs
@@ -3,7 +3,6 @@ mod chat_message;
mod new_typst;
mod photo;
mod tictactoe;
-mod typst;
use showbits_common::widgets::{FontStuff, HasFontStuff};
use tokio::sync::mpsc;
@@ -12,7 +11,7 @@ use crate::persistent_printer::PersistentPrinter;
pub use self::{
backlog::BacklogDrawing, chat_message::ChatMessageDrawing, new_typst::NewTypstDrawing,
- photo::PhotoDrawing, tictactoe::TicTacToeDrawing, typst::TypstDrawing,
+ photo::PhotoDrawing, tictactoe::TicTacToeDrawing,
};
pub const FEED: f32 = 96.0;
diff --git a/showbits-thermal-printer/src/drawer/typst.rs b/showbits-thermal-printer/src/drawer/typst.rs
deleted file mode 100644
index ea12a26..0000000
--- a/showbits-thermal-printer/src/drawer/typst.rs
+++ /dev/null
@@ -1,25 +0,0 @@
-use showbits_common::{Node, Tree, WidgetExt, color::WHITE, widgets::Typst};
-use taffy::{prelude::length, style_helpers::percent};
-
-use crate::persistent_printer::PersistentPrinter;
-
-use super::{Context, Drawing, FEED};
-
-pub struct TypstDrawing(pub String);
-
-impl Drawing for TypstDrawing {
- fn draw(&self, printer: &mut PersistentPrinter, ctx: &mut Context) -> anyhow::Result<()> {
- let mut tree = Tree::::new(WHITE);
-
- let typst = Typst::new(self.0.clone()).node().register(&mut tree)?;
-
- let root = Node::empty()
- .with_size_width(percent(1.0))
- .with_padding_bottom(length(FEED))
- .and_child(typst)
- .register(&mut tree)?;
-
- printer.print_tree(&mut tree, ctx, root)?;
- Ok(())
- }
-}
diff --git a/showbits-thermal-printer/src/server.rs b/showbits-thermal-printer/src/server.rs
index a159e55..9f301c2 100644
--- a/showbits-thermal-printer/src/server.rs
+++ b/showbits-thermal-printer/src/server.rs
@@ -14,7 +14,7 @@ use tokio::{net::TcpListener, sync::mpsc};
use crate::{
documents,
- drawer::{ChatMessageDrawing, Command, PhotoDrawing, TicTacToeDrawing, TypstDrawing},
+ drawer::{ChatMessageDrawing, Command, PhotoDrawing, TicTacToeDrawing},
};
use self::{r#static::get_static_file, statuscode::status_code};
@@ -46,7 +46,6 @@ pub async fn run(tx: mpsc::Sender, addr: String) -> anyhow::Result<()>
post(documents::text::post).fallback(get_static_file),
)
.route("/tictactoe", post(post_tictactoe))
- .route("/typst", post(post_typst).fallback(get_static_file))
.fallback(get(get_static_file))
.layer(DefaultBodyLimit::max(32 * 1024 * 1024)) // 32 MiB
.with_state(Server { tx });
@@ -114,17 +113,3 @@ async fn post_photo(server: State, mut multipart: Multipart) -> somehow:
async fn post_tictactoe(server: State) {
let _ = server.tx.send(Command::draw(TicTacToeDrawing)).await;
}
-
-// /typst
-
-#[derive(Deserialize)]
-struct PostTypstForm {
- source: String,
-}
-
-async fn post_typst(server: State, request: Form) {
- let _ = server
- .tx
- .send(Command::draw(TypstDrawing(request.0.source)))
- .await;
-}
diff --git a/showbits-thermal-printer/static/index.html b/showbits-thermal-printer/static/index.html
index 00dcfc7..97c3a21 100644
--- a/showbits-thermal-printer/static/index.html
+++ b/showbits-thermal-printer/static/index.html
@@ -10,7 +10,6 @@
- Print typst code
-
-
diff --git a/showbits-thermal-printer/static/typst.html b/showbits-thermal-printer/static/typst.html
deleted file mode 100644
index 0b4e08e..0000000
--- a/showbits-thermal-printer/static/typst.html
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-