forked from MIrrors/bin
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
22f5e257a9 | ||
|
|
f675f75b3b | ||
|
|
cd3d911ca0 | ||
|
|
4c9f1af0ab | ||
|
|
1fe4db7420 |
34
Cargo.lock
generated
34
Cargo.lock
generated
@@ -41,8 +41,8 @@ dependencies = [
|
||||
"askama_escape 0.2.0 (git+https://github.com/djc/askama?rev=fc5addc4)",
|
||||
"humansize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
@@ -70,7 +70,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "bin"
|
||||
version = "1.0.0"
|
||||
version = "1.0.1"
|
||||
dependencies = [
|
||||
"askama 0.8.0 (git+https://github.com/djc/askama?rev=fc5addc4)",
|
||||
"askama_escape 0.2.0 (git+https://github.com/djc/askama?rev=fc5addc4)",
|
||||
@@ -80,7 +80,7 @@ dependencies = [
|
||||
"linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rocket 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syntect 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
@@ -91,7 +91,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -225,7 +225,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"ndarray 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
@@ -408,7 +408,7 @@ dependencies = [
|
||||
"matrixmultiply 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-complex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -527,7 +527,7 @@ dependencies = [
|
||||
"base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"xml-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
@@ -799,15 +799,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.87"
|
||||
version = "1.0.88"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.87"
|
||||
version = "1.0.88"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -822,7 +822,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -867,8 +867,8 @@ dependencies = [
|
||||
"onig 4.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"plist 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"yaml-rust 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -889,7 +889,7 @@ name = "toml"
|
||||
version = "0.4.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1127,8 +1127,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267"
|
||||
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
||||
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
||||
"checksum serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)" = "2e20fde37801e83c891a2dc4ebd3b81f0da4d1fb67a9e0a2a3b921e2536a58ee"
|
||||
"checksum serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)" = "633e97856567e518b59ffb2ad7c7a4fd4c5d91d9c7f32dd38a27b2bf7e8114ea"
|
||||
"checksum serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)" = "9f301d728f2b94c9a7691c90f07b0b4e8a4517181d9461be94c04bddeb4bd850"
|
||||
"checksum serde_derive 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)" = "beed18e6f5175aef3ba670e57c60ef3b1b74d250d962a26604bff4c80e970dd4"
|
||||
"checksum serde_json 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)" = "27dce848e7467aa0e2fcaf0a413641499c0b745452aaca1194d24dedde9e13c9"
|
||||
"checksum smallvec 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "88aea073965ab29f6edb5493faf96ad662fb18aa9eeb186a3b7057951605ed15"
|
||||
"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "bin"
|
||||
version = "1.0.0"
|
||||
version = "1.0.1"
|
||||
authors = ["Jordan Doyle <jordan@doyle.la>"]
|
||||
edition = "2018"
|
||||
|
||||
|
||||
50
README.md
50
README.md
@@ -1,13 +1,39 @@
|
||||
# bin.
|
||||
a pastebin.
|
||||
# bin
|
||||
a paste bin.
|
||||
|
||||
A paste bin that's actually minimalist. No database requirement, no commenting functionality, no self-destructing or time bomb messages and no social media integration—just an application to quickly send snippits of text to people.
|
||||
|
||||
[bin](https://bin.doyle.la/) is written in Rust in around 100 lines of code. It's fast, it's simple, there's code highlighting and you can ⌘+A without going to the 'plain' page. It's revolutionary in the paste bin industry, disrupting markets and pushing boundaries never seen before.
|
||||
|
||||
There's no good open source pastebin solutions. I'm sorry to everyone who has one on GitHub but I have to say it. We try to cram as many little features as humanly possible into them and still try and call them minimalist. I don't want to run Redis, I don't want commenting functionality, I don't want self-destructing or time bomb messages and I especially don't want social media integration—I don't know about you but normally I just need to send a quick little snippit of code to someone, it doesn't need a title and I don't *really* mind when it disappears as long as its around long enough for them to see. Honestly, [I'm guilty of it myself](https://github.com/w4/hidden-note), we've all made a pastebin at one point or another but when it comes to making one to release to the public we create abominations.
|
||||
##### so how do you get bin?
|
||||
|
||||
[bin.](https://bin.doyle.la/) is written in Rust in around 100 lines of code. It's fast, it's simple, there's code highlighting and you can ⌘+A without going to the 'plain' page. Revolutionary in the pastebin industry, disrupting markets and pushing boundaries never seen before.
|
||||
Download the latest version from the [releases](https://github.com/w4/bin/releases) page, extract it and run the `./bin` executable. You can also compile it from source using Cargo if you swing that way:
|
||||
|
||||
##### curl support?
|
||||
```bash
|
||||
# nix-shell provides an environment with rust/cargo installed
|
||||
$ nix-shell
|
||||
|
||||
[nix-shell:~/Code/bin]$ cargo build --release
|
||||
Compiling bin v1.0.0 (/Users/jordanjd/Code/bin)
|
||||
Finished release [optimized] target(s) in 3.61s
|
||||
|
||||
[nix-shell:~/Code/bin]$ ./target/release/bin
|
||||
...
|
||||
```
|
||||
|
||||
##### how do you run it?
|
||||
|
||||
```bash
|
||||
$ ./bin
|
||||
```
|
||||
|
||||
##### funny, what settings are there?
|
||||
|
||||
bin uses [rocket](https://rocket.rs) so you can add a [rocket config file](https://api.rocket.rs/v0.3/rocket/config/) if you like. You can set `ROCKET_PORT` in your environment if you want to change the default port (8820).
|
||||
|
||||
bin's only configuration value is `BIN_BUFFER_SIZE` which defaults to 2000. Change this value if you want your bin to hold more pastes.
|
||||
|
||||
##### is there curl support?
|
||||
|
||||
```bash
|
||||
$ curl -X PUT --data 'hello world' bin.doyle.la
|
||||
@@ -16,18 +42,6 @@ $ curl https://bin.doyle.la/cateettary
|
||||
hello world
|
||||
```
|
||||
|
||||
##### how do you run bin?
|
||||
|
||||
```bash
|
||||
$ ./bin
|
||||
```
|
||||
|
||||
##### good one, what settings are there?
|
||||
|
||||
bin. uses [rocket](https://rocket.rs) so you can add a [rocket config file](https://api.rocket.rs/v0.3/rocket/config/) if you like. You can set `ROCKET_PORT` in your environment if you want to change the default port (8820).
|
||||
|
||||
bin's only configuration value is `BIN_BUFFER_SIZE` which defaults to 2000. Change this value if you want your bin to hold more pastes.
|
||||
|
||||
##### how does syntax highlighting work?
|
||||
|
||||
To get syntax highlighting you need to add the file extension at the end of your paste URL.
|
||||
To get syntax highlighting you need to add the file extension at the end of your paste URL.
|
||||
|
||||
24
src/main.rs
24
src/main.rs
@@ -55,7 +55,7 @@ struct IndexForm {
|
||||
fn submit(input: Form<IndexForm>) -> Redirect {
|
||||
let id = generate_id();
|
||||
store_paste(id.clone(), input.into_inner().val);
|
||||
Redirect::to(uri!(render: id))
|
||||
Redirect::to(uri!(show_paste: id))
|
||||
}
|
||||
|
||||
#[put("/", data = "<input>")]
|
||||
@@ -67,7 +67,7 @@ fn submit_raw(input: Data, host: HostHeader) -> std::io::Result<String> {
|
||||
store_paste(id.clone(), data);
|
||||
|
||||
match *host {
|
||||
Some(host) => Ok(format!("https://{}/{}", host, id)),
|
||||
Some(host) => Ok(format!("https://{}{}", host, uri!(show_paste: id))),
|
||||
None => Ok(id),
|
||||
}
|
||||
}
|
||||
@@ -78,12 +78,12 @@ fn submit_raw(input: Data, host: HostHeader) -> std::io::Result<String> {
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "paste.html")]
|
||||
struct Render {
|
||||
struct ShowPaste {
|
||||
content: MarkupDisplay<Html, String>,
|
||||
}
|
||||
|
||||
#[get("/<key>")]
|
||||
fn render(key: String, plaintext: IsPlaintextRequest) -> Result<Content<String>, Status> {
|
||||
fn show_paste(key: String, plaintext: IsPlaintextRequest) -> Result<Content<String>, Status> {
|
||||
let mut splitter = key.splitn(2, '.');
|
||||
let key = splitter.next().ok_or_else(|| Status::NotFound)?;
|
||||
let ext = splitter.next();
|
||||
@@ -95,16 +95,14 @@ fn render(key: String, plaintext: IsPlaintextRequest) -> Result<Content<String>,
|
||||
if *plaintext {
|
||||
Ok(Content(ContentType::Plain, entry))
|
||||
} else {
|
||||
let template = Render {
|
||||
content: match ext {
|
||||
None => MarkupDisplay::new_unsafe(entry, Html),
|
||||
Some(extension) => highlight(&entry, extension)
|
||||
.map(|h| MarkupDisplay::new_safe(h, Html))
|
||||
.ok_or_else(|| Status::NotFound)?,
|
||||
},
|
||||
let content = match ext {
|
||||
None => MarkupDisplay::new_unsafe(entry, Html),
|
||||
Some(extension) => highlight(&entry, extension)
|
||||
.map(|h| MarkupDisplay::new_safe(h, Html))
|
||||
.ok_or_else(|| Status::NotFound)?,
|
||||
};
|
||||
|
||||
template
|
||||
ShowPaste { content }
|
||||
.render()
|
||||
.map(|html| Content(ContentType::HTML, html))
|
||||
.map_err(|_| Status::InternalServerError)
|
||||
@@ -113,6 +111,6 @@ fn render(key: String, plaintext: IsPlaintextRequest) -> Result<Content<String>,
|
||||
|
||||
fn main() {
|
||||
rocket::ignite()
|
||||
.mount("/", routes![index, submit, submit_raw, render])
|
||||
.mount("/", routes![index, submit, submit_raw, show_paste])
|
||||
.launch();
|
||||
}
|
||||
|
||||
@@ -6,10 +6,14 @@
|
||||
textarea {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
|
||||
background: none;
|
||||
border: none;
|
||||
color: inherit;
|
||||
|
||||
resize: none;
|
||||
overflow: auto;
|
||||
|
||||
color: inherit;
|
||||
font-family: inherit;
|
||||
font-size: 1rem;
|
||||
line-height: inherit;
|
||||
@@ -24,7 +28,6 @@
|
||||
width: 3rem;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
|
||||
background: #2196F3;
|
||||
|
||||
color: white;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
overflow: scroll;
|
||||
overflow: auto;
|
||||
font-family: inherit;
|
||||
font-size: 1rem;
|
||||
line-height: inherit;
|
||||
|
||||
Reference in New Issue
Block a user