Remove /typst endpoint
This commit is contained in:
parent
5f2dcf81d3
commit
fbab0b9441
5 changed files with 2 additions and 65 deletions
|
|
@ -3,7 +3,6 @@ mod chat_message;
|
||||||
mod new_typst;
|
mod new_typst;
|
||||||
mod photo;
|
mod photo;
|
||||||
mod tictactoe;
|
mod tictactoe;
|
||||||
mod typst;
|
|
||||||
|
|
||||||
use showbits_common::widgets::{FontStuff, HasFontStuff};
|
use showbits_common::widgets::{FontStuff, HasFontStuff};
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
@ -12,7 +11,7 @@ use crate::persistent_printer::PersistentPrinter;
|
||||||
|
|
||||||
pub use self::{
|
pub use self::{
|
||||||
backlog::BacklogDrawing, chat_message::ChatMessageDrawing, new_typst::NewTypstDrawing,
|
backlog::BacklogDrawing, chat_message::ChatMessageDrawing, new_typst::NewTypstDrawing,
|
||||||
photo::PhotoDrawing, tictactoe::TicTacToeDrawing, typst::TypstDrawing,
|
photo::PhotoDrawing, tictactoe::TicTacToeDrawing,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const FEED: f32 = 96.0;
|
pub const FEED: f32 = 96.0;
|
||||||
|
|
|
||||||
|
|
@ -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::<Context>::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(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -14,7 +14,7 @@ use tokio::{net::TcpListener, sync::mpsc};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
documents,
|
documents,
|
||||||
drawer::{ChatMessageDrawing, Command, PhotoDrawing, TicTacToeDrawing, TypstDrawing},
|
drawer::{ChatMessageDrawing, Command, PhotoDrawing, TicTacToeDrawing},
|
||||||
};
|
};
|
||||||
|
|
||||||
use self::{r#static::get_static_file, statuscode::status_code};
|
use self::{r#static::get_static_file, statuscode::status_code};
|
||||||
|
|
@ -46,7 +46,6 @@ pub async fn run(tx: mpsc::Sender<Command>, addr: String) -> anyhow::Result<()>
|
||||||
post(documents::text::post).fallback(get_static_file),
|
post(documents::text::post).fallback(get_static_file),
|
||||||
)
|
)
|
||||||
.route("/tictactoe", post(post_tictactoe))
|
.route("/tictactoe", post(post_tictactoe))
|
||||||
.route("/typst", post(post_typst).fallback(get_static_file))
|
|
||||||
.fallback(get(get_static_file))
|
.fallback(get(get_static_file))
|
||||||
.layer(DefaultBodyLimit::max(32 * 1024 * 1024)) // 32 MiB
|
.layer(DefaultBodyLimit::max(32 * 1024 * 1024)) // 32 MiB
|
||||||
.with_state(Server { tx });
|
.with_state(Server { tx });
|
||||||
|
|
@ -114,17 +113,3 @@ async fn post_photo(server: State<Server>, mut multipart: Multipart) -> somehow:
|
||||||
async fn post_tictactoe(server: State<Server>) {
|
async fn post_tictactoe(server: State<Server>) {
|
||||||
let _ = server.tx.send(Command::draw(TicTacToeDrawing)).await;
|
let _ = server.tx.send(Command::draw(TicTacToeDrawing)).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /typst
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
|
||||||
struct PostTypstForm {
|
|
||||||
source: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn post_typst(server: State<Server>, request: Form<PostTypstForm>) {
|
|
||||||
let _ = server
|
|
||||||
.tx
|
|
||||||
.send(Command::draw(TypstDrawing(request.0.source)))
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="image">Upload an image</a></li>
|
<li><a href="image">Upload an image</a></li>
|
||||||
<li><a href="photo">Take a photo</a></li>
|
<li><a href="photo">Take a photo</a></li>
|
||||||
<li><a href="typst">Print typst</a></li>
|
|
||||||
<li><a href="egg">Osterei</a></li>
|
<li><a href="egg">Osterei</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
||||||
<title>TP: Typst</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Print typst code</h1>
|
|
||||||
<form method="post">
|
|
||||||
<textarea name="source" rows="24" cols="100">
|
|
||||||
Hi from Typst!
|
|
||||||
$
|
|
||||||
sum_(i=1)^n i = integral_(i=0)^n i + n/2
|
|
||||||
$</textarea
|
|
||||||
>
|
|
||||||
<br />
|
|
||||||
<button>Print!</button>
|
|
||||||
</form>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue