This commit is contained in:
Robin Appelman 2026-08-13 01:50:53 +02:00
commit db71d66600
5 changed files with 48 additions and 46 deletions

View file

@ -2,17 +2,17 @@
Thanks for taking the time ! 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 - [ ] Cargo Format
- Run `cargo fmt` on the project. - Run `cargo fmt` on the project.
- [ ] Clippy lints - [ ] Clippy lints
- Run `cargo clippy -- -Dwarnings` on the project to check for suggestions - 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 --fix` to let clippy apply the suggestions itself, if any.
This can be tiresome for frequent contributors, so it might would be better if 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). 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 The [Build CI](.github/workflow/buildci.yaml) will also check whether the
cross-compiled to arm64 without any errors. project can be compiled and cross-compiled to arm64 without any errors.

View file

@ -14,24 +14,23 @@ jobs:
- name: Clippy - name: Clippy
run: cargo clippy -- -Dwarnings run: cargo clippy -- -Dwarnings
build: build:
needs: pre-build-checks needs: pre-build-checks
strategy: strategy:
matrix: matrix:
arch: [amd64, arm64] arch: [amd64, arm64]
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout project - name: Checkout project
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup cross compiling - name: Setup cross compiling
run: | run: |
source ./.github/buildci.sh source ./.github/buildci.sh
setup_cross_compiling ${{ matrix.arch }} setup_cross_compiling ${{ matrix.arch }}
- name: Build - name: Build
run: | run: |
[ $GITHUB_REF_TYPE = "branch" ] && \ [ $GITHUB_REF_TYPE = "branch" ] && \
export __REF=${GITHUB_SHA::7} || \ export __REF=${GITHUB_SHA::7} || \

View file

@ -9,15 +9,15 @@ edition = "2021"
build = "build.rs" build = "build.rs"
[dependencies] [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"] } clap = { version = "4.6.1", features = ["derive", "env"] }
once_cell = "1" once_cell = "1"
rand = "0.10.1"
rocket = "0.5.1"
rust-embed = "8.11.0"
sha256 = "1" sha256 = "1"
syntect = "5.3.0"
time = { version = "0.3", features = ["formatting"] } time = { version = "0.3", features = ["formatting"] }
tree_magic = "0.2.3"
[dependencies.rocket_dyn_templates] [dependencies.rocket_dyn_templates]
version = "0.2.0" version = "0.2.0"

View file

@ -1,4 +1,4 @@
version: '3.3' version: "3.3"
services: services:
pastebin: pastebin:
image: wantguns/bin image: wantguns/bin
@ -9,4 +9,4 @@ services:
- BIN_PORT=6163 # Defaults to 6162 - BIN_PORT=6163 # Defaults to 6162
- BIN_LIMITS={form="16 MiB"} - BIN_LIMITS={form="16 MiB"}
volumes: volumes:
- ./upload:/upload # upload folder will have your pastes - ./upload:/upload # upload folder will have your pastes

View file

@ -1,4 +1,5 @@
# Bin # Bin
A minimal pastebin which also accepts binary files like Images, PDFs and ships A minimal pastebin which also accepts binary files like Images, PDFs and ships
multiple clients. multiple clients.
@ -14,10 +15,10 @@ You can paste
- Normal Text - Normal Text
- Paste Images from clipboard: - Paste Images from clipboard:
![clipboard-paste](.github/files/image_clipboard.gif) ![clipboard-paste](.github/files/image_clipboard.gif)
- Files by drag and drop: - Files by drag and drop:
![drag_n_drop](.github/files/drag_n_drop.gif) ![drag_n_drop](.github/files/drag_n_drop.gif)
### CLI ### CLI
@ -25,7 +26,8 @@ You can paste
#### Installation #### 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 ```bash
curl -o pst https://bin.noracodes.dev/r/client && chmod +x pst curl -o pst https://bin.noracodes.dev/r/client && chmod +x pst
@ -51,10 +53,9 @@ PASTELINK="$URL$RESPONSE"
echo "$PASTELINK.$EXTENSION" echo "$PASTELINK.$EXTENSION"
``` ```
You have the option to remove the `/client` description / help in the You have the option to remove the `/client` description / help in the landing
landing page. To show the `/client` description, run the `bin` binary page. To show the `/client` description, run the `bin` binary with either
with either `BIN_CLIENT_DESC` env variable or a `-c` flag. More on `BIN_CLIENT_DESC` env variable or a `-c` flag. More on arguments later
arguments later
#### Usage #### Usage
@ -75,23 +76,27 @@ $ cat someimage.png | pst
```vim ```vim
nnoremap <leader>p :!pst %<CR> nnoremap <leader>p :!pst %<CR>
``` ```
#### Usage #### Usage
Use `<leader> + p` paste. Use `<leader> + p` paste.
## Server Deployment ## 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 ### Manual
- Build on your own: - Build on your own:
```bash ```bash
# A statically linked build # A statically linked build
$ cargo build --release $ cargo build --release
``` ```
- Execute the binary as is, no extra shenanigans needed: - Execute the binary as is, no extra shenanigans needed:
```bash ```bash
$ ./bin $ ./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 the essential arguments, you can also use environment variables, which have the
highest preference in order. highest preference in order.
Everything from the [official Rocket Everything from the
doc](https://rocket.rs/v0.5-rc/guide/configuration/#overview) is supported, [official Rocket doc](https://rocket.rs/v0.5-rc/guide/configuration/#overview)
just that you have to prefix the env variable with "BIN_": is supported, just that you have to prefix the env variable with "BIN\_":
```txt ```txt
BIN_PORT=6163 BIN_PORT=6163
BIN_ADDRESS=0.0.0.0 BIN_ADDRESS=0.0.0.0
@ -145,24 +151,21 @@ BIN_IDENT=false
## API ## API
`GET /r/<id>[.<ext>]` `GET /r/<id>[.<ext>]` Get raw pastes
Get raw pastes
`GET /p/<id>` `GET /p/<id>`
Get pastes with a pretty UI Get pastes with a pretty UI
`GET /p/<id>.<ext> ` `GET /p/<id>.<ext> `
Get syntax highlighted pastes in the pretty UI. Get syntax highlighted pastes in the pretty UI. E.g.
E.g. https://bin.nora.codes/p/foobaz.cpp should return a C++ syntax https://bin.nora.codes/p/foobaz.cpp should return a C++ syntax highlighted paste
highlighted paste
`POST /` `POST /` Post binary data, get object ID
Post binary data, get object ID
## Design Decisions ## Design Decisions
This pastebin: This pastebin:
- does not use a database. It lacks non-essential features like - does not use a database. It lacks non-essential features like
password-protection / automatic deletion as a result of which, it can do password-protection / automatic deletion as a result of which, it can do
@ -170,13 +173,13 @@ This pastebin:
deploying it easier. deploying it easier.
- uses server sided highlighting, which ensures that everything stays light and - uses server sided highlighting, which ensures that everything stays light and
snappy at the client side. snappy at the client side.
- uses very minimal frontend because a pastebin does not need it. It focuses - uses very minimal frontend because a pastebin does not need it. It focuses (or
(or atleast tries to) on getting things done in minimum amount of clicks. atleast tries to) on getting things done in minimum amount of clicks.
## Hacking ## Hacking
- If you want to ensure your pushed refs will pass CI, add the prepush script - If you want to ensure your pushed refs will pass CI, add the prepush script to
to your Git hooks: your Git hooks:
```bash ```bash
$ cp -a tools/prepush .git/hooks/pre-push $ cp -a tools/prepush .git/hooks/pre-push