From e17b26994f56b251057ede5ed483fe70489eaaae Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Fri, 30 Sep 2022 22:10:43 -0800 Subject: [PATCH 1/4] add cli args to disable file upload --- src/args.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/args.rs b/src/args.rs index 577fa0f..1472391 100644 --- a/src/args.rs +++ b/src/args.rs @@ -59,4 +59,7 @@ pub struct Args { #[clap(long, env="MICROBIN_WIDE")] pub wide: bool, + + #[clap(short, long, env="MICROBIN_NO_FILE_UPLOAD")] + pub no_file_upload: bool, } \ No newline at end of file From fc3998243bdd3fa0725ed3a854ebe39034b3c15b Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Fri, 30 Sep 2022 22:11:03 -0800 Subject: [PATCH 2/4] ignore file processing if no_file_upload is true --- src/endpoints/create.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/endpoints/create.rs b/src/endpoints/create.rs index 8c8b1a3..40efa41 100644 --- a/src/endpoints/create.rs +++ b/src/endpoints/create.rs @@ -106,6 +106,10 @@ pub async fn create( continue; } "file" => { + if ARGS.no_file_upload { + continue; + } + let path = field.content_disposition().get_filename(); let path = match path { From 82c30ce6cd16843a0d1e75f25664245a6635f7a2 Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Fri, 30 Sep 2022 22:11:25 -0800 Subject: [PATCH 3/4] conditionally render file upload --- templates/index.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/index.html b/templates/index.html index e1c4ef7..943de85 100644 --- a/templates/index.html +++ b/templates/index.html @@ -59,11 +59,13 @@ {%- endif %} + {% if !args.no_file_upload %}

+ {% endif %}
From 0b5dea5dd1510cff4d1652be29f575c4bd70e948 Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Fri, 30 Sep 2022 22:12:24 -0800 Subject: [PATCH 4/4] add flag to docs --- README.MD | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/README.MD b/README.MD index 18006f6..b64e4c4 100644 --- a/README.MD +++ b/README.MD @@ -11,8 +11,8 @@ MicroBin is a super tiny, feature rich, configurable, self-contained and self-hosted paste bin web application. It is very easy to set up and use, and will only require a few megabytes of memory and disk storage. It takes only a couple minutes to set it up, why not give it a try now? [![Deploy to Render](https://render.com/images/deploy-to-render-button.svg)](https://render.com/deploy?repo=https://github.com/szabodanika/microbin) - -Or install from Cargo: + +Or install from Cargo: `cargo install microbin` @@ -37,7 +37,7 @@ And run with your custom configuration: - Automatic dark mode (follows system preferences) - Very little CSS and absolutely no JS (see [water.css](https://github.com/kognise/water.css)) - Most of the above can be toggled on and off! - + ## 1 Usage ### What is a "pasta" anyway? @@ -222,7 +222,7 @@ server { listen 443 ssl; # managed by Certbot server_name microbin.myserver.com; - + location / { # Make sure to change the port if you are not running MicroBin at 8080! proxy_pass http://127.0.0.1:8080$request_uri; @@ -234,7 +234,7 @@ server { # Limit content size - I have 1GB because my MicroBin server is private, no one else will use it. client_max_body_size 1024M; - + ssl_certificate /etc/letsencrypt/live/microbin.myserver.com/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/microbin.myserver.com/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot @@ -329,3 +329,7 @@ Displays your MicroBin's version information. ### --wide Changes the maximum width of the UI from 720 pixels to 1080 pixels. + +### --no-file-upload + +Disables and hides the file upload option in the UI. \ No newline at end of file