From 4a4301ee72c4f1e8b2287befd05d90e4fc5140fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Sun, 14 May 2023 01:54:58 +0300 Subject: [PATCH] style(server): make the default landing page fancier --- config.toml | 19 +++++++++++++------ src/server.rs | 4 +++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/config.toml b/config.toml index 19fad3a..ac7be17 100644 --- a/config.toml +++ b/config.toml @@ -8,9 +8,14 @@ max_content_length = "10MB" upload_path = "./upload" timeout = "30s" expose_version = false -landing_page = """Submit files via HTTP POST here: - curl -F 'file=@example.txt' " -This will return the finished URL. +landing_page = """ +┬─┐┬ ┬┌─┐┌┬┐┬ ┬┌─┐┌─┐┌─┐┌┬┐┌─┐ +├┬┘│ │└─┐ │ └┬┘├─┘├─┤└─┐ │ ├┤ +┴└─└─┘└─┘ ┴ ┴ ┴ ┴ ┴└─┘ ┴ └─┘ + +Submit files via HTTP POST here: + curl -F 'file=@example.txt' +This will return the URL of the uploaded file. The server administrator might remove any pastes that they do not personally want to host. @@ -19,10 +24,12 @@ If you are the server administrator and want to change this page, just go into your config file and change it! If you change the expiry time, it is recommended that you do. -Check out the GitHub repository at https://github.com/orhun/rustypaste - By default, pastes expire every hour. The server admin may or may not have -changed this.""" +changed this. + +Check out the GitHub repository at https://github.com/orhun/rustypaste +Command line tool is available at https://github.com/orhun/rustypaste-cli +""" [paste] random_url = { enabled = true, type = "petname", words = 2, separator = "-" } diff --git a/src/server.rs b/src/server.rs index 317c3b4..6d2f0b7 100644 --- a/src/server.rs +++ b/src/server.rs @@ -25,7 +25,9 @@ async fn index(config: web::Data>) -> Result .read() .map_err(|_| error::ErrorInternalServerError("cannot acquire config"))?; match &config.server.landing_page { - Some(page) => Ok(HttpResponse::Ok().body(page.clone())), + Some(page) => Ok(HttpResponse::Ok() + .content_type("text/plain; charset=\"UTF-8\"") + .body(page.clone())), None => Ok(HttpResponse::Found() .append_header(("Location", env!("CARGO_PKG_HOMEPAGE"))) .finish()),