diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index f84a00e..2ed3100 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -2,17 +2,17 @@ Thanks for taking the time ! -Please ensure that some basic checks are passed before creating this Pull Request: +Please ensure that some basic checks are passed before creating this Pull +Request: - [ ] Cargo Format - - Run `cargo fmt` on the project. - + - Run `cargo fmt` on the project. - [ ] Clippy lints - - Run `cargo clippy -- -Dwarnings` on the project to check for suggestions - - Run `cargo clippy --fix` to let clippy apply the suggestions itself, if any. + - Run `cargo clippy -- -Dwarnings` on the project to check for suggestions + - Run `cargo clippy --fix` to let clippy apply the suggestions itself, if any. This can be tiresome for frequent contributors, so it might would be better if you used a git pre-push hook as mentioned in the [readme](readme.md#hacking). -The [Build CI](.github/workflow/buildci.yaml) will also check whether the project can be compiled and -cross-compiled to arm64 without any errors. +The [Build CI](.github/workflow/buildci.yaml) will also check whether the +project can be compiled and cross-compiled to arm64 without any errors. diff --git a/.github/workflows/buildci.yml b/.github/workflows/buildci.yml index ec7c19b..7a117f4 100644 --- a/.github/workflows/buildci.yml +++ b/.github/workflows/buildci.yml @@ -14,24 +14,23 @@ jobs: - name: Clippy run: cargo clippy -- -Dwarnings - - + build: needs: pre-build-checks strategy: - matrix: + matrix: arch: [amd64, arm64] runs-on: ubuntu-latest steps: - name: Checkout project uses: actions/checkout@v2 - + - name: Setup cross compiling run: | source ./.github/buildci.sh setup_cross_compiling ${{ matrix.arch }} - - - name: Build + + - name: Build run: | [ $GITHUB_REF_TYPE = "branch" ] && \ export __REF=${GITHUB_SHA::7} || \ diff --git a/Cargo.toml b/Cargo.toml index 181c604..b0f4175 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,15 +9,15 @@ edition = "2021" build = "build.rs" [dependencies] -rand ="0.10.1" -rocket = "0.5.1" -tree_magic = "0.2.3" -syntect = "5.3.0" -rust-embed="8.11.0" clap = { version = "4.6.1", features = ["derive", "env"] } once_cell = "1" +rand = "0.10.1" +rocket = "0.5.1" +rust-embed = "8.11.0" sha256 = "1" +syntect = "5.3.0" time = { version = "0.3", features = ["formatting"] } +tree_magic = "0.2.3" [dependencies.rocket_dyn_templates] version = "0.2.0" diff --git a/docker-compose.yml b/docker-compose.yml index 8887331..a031687 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3.3' +version: "3.3" services: pastebin: image: wantguns/bin @@ -9,4 +9,4 @@ services: - BIN_PORT=6163 # Defaults to 6162 - BIN_LIMITS={form="16 MiB"} volumes: - - ./upload:/upload # upload folder will have your pastes + - ./upload:/upload # upload folder will have your pastes diff --git a/readme.md b/readme.md index b8f648e..c2850db 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,5 @@ -# Bin +# Bin + A minimal pastebin which also accepts binary files like Images, PDFs and ships multiple clients. @@ -14,10 +15,10 @@ You can paste - Normal Text - Paste Images from clipboard: -![clipboard-paste](.github/files/image_clipboard.gif) + ![clipboard-paste](.github/files/image_clipboard.gif) - Files by drag and drop: -![drag_n_drop](.github/files/drag_n_drop.gif) + ![drag_n_drop](.github/files/drag_n_drop.gif) ### CLI @@ -25,7 +26,8 @@ You can paste #### Installation -Get the client from [this repository](contrib/cli/client) or from my deployed paste: +Get the client from [this repository](contrib/cli/client) or from my deployed +paste: ```bash curl -o pst https://bin.noracodes.dev/r/client && chmod +x pst @@ -51,10 +53,9 @@ PASTELINK="$URL$RESPONSE" echo "$PASTELINK.$EXTENSION" ``` -You have the option to remove the `/client` description / help in the -landing page. To show the `/client` description, run the `bin` binary -with either `BIN_CLIENT_DESC` env variable or a `-c` flag. More on -arguments later +You have the option to remove the `/client` description / help in the landing +page. To show the `/client` description, run the `bin` binary with either +`BIN_CLIENT_DESC` env variable or a `-c` flag. More on arguments later #### Usage @@ -75,23 +76,27 @@ $ cat someimage.png | pst ```vim nnoremap p :!pst % ``` + #### Usage Use ` + p` paste. ## Server Deployment -The [main fork](https://github.com/wantguns/bin) ships Docker and binary releases. +The [main fork](https://github.com/wantguns/bin) ships Docker and binary +releases. ### Manual - Build on your own: + ```bash # A statically linked build $ cargo build --release ``` - Execute the binary as is, no extra shenanigans needed: + ```bash $ ./bin ``` @@ -131,9 +136,10 @@ This pastebin utilizes a custom configuration provider from Rocket. Apart from the essential arguments, you can also use environment variables, which have the highest preference in order. -Everything from the [official Rocket -doc](https://rocket.rs/v0.5-rc/guide/configuration/#overview) is supported, -just that you have to prefix the env variable with "BIN_": +Everything from the +[official Rocket doc](https://rocket.rs/v0.5-rc/guide/configuration/#overview) +is supported, just that you have to prefix the env variable with "BIN\_": + ```txt BIN_PORT=6163 BIN_ADDRESS=0.0.0.0 @@ -145,24 +151,21 @@ BIN_IDENT=false ## API -`GET /r/[.]` - Get raw pastes +`GET /r/[.]` Get raw pastes `GET /p/` - Get pastes with a pretty UI + Get pastes with a pretty UI -`GET /p/. ` +`GET /p/. ` - Get syntax highlighted pastes in the pretty UI. - E.g. https://bin.nora.codes/p/foobaz.cpp should return a C++ syntax - highlighted paste +Get syntax highlighted pastes in the pretty UI. E.g. +https://bin.nora.codes/p/foobaz.cpp should return a C++ syntax highlighted paste -`POST /` - Post binary data, get object ID +`POST /` Post binary data, get object ID ## Design Decisions -This pastebin: +This pastebin: - does not use a database. It lacks non-essential features like password-protection / automatic deletion as a result of which, it can do @@ -170,13 +173,13 @@ This pastebin: deploying it easier. - uses server sided highlighting, which ensures that everything stays light and snappy at the client side. -- uses very minimal frontend because a pastebin does not need it. It focuses - (or atleast tries to) on getting things done in minimum amount of clicks. +- uses very minimal frontend because a pastebin does not need it. It focuses (or + atleast tries to) on getting things done in minimum amount of clicks. ## Hacking -- If you want to ensure your pushed refs will pass CI, add the prepush script - to your Git hooks: +- If you want to ensure your pushed refs will pass CI, add the prepush script to + your Git hooks: ```bash $ cp -a tools/prepush .git/hooks/pre-push