forked from MIrrors/bin
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b095d2464c | ||
|
|
3c76d4fd1a | ||
|
|
06b90b8271 | ||
|
|
21b04b88ae | ||
|
|
53d97709fa | ||
|
|
ff3d193734 | ||
|
|
2b53d0a34c | ||
|
|
2502cc7f5c | ||
|
|
4bd924b423 | ||
|
|
be88df22f7 | ||
|
|
275ace8356 | ||
|
|
41900eaeee | ||
|
|
1115bbc937 |
1
.dockerignore
Normal file
1
.dockerignore
Normal file
@@ -0,0 +1 @@
|
||||
target
|
||||
@@ -25,7 +25,7 @@ matrix:
|
||||
os: osx
|
||||
|
||||
# *BSD
|
||||
- env: TARGET=x86_64-unknown-freebsd DISABLE_TESTS=1
|
||||
# - env: TARGET=x86_64-unknown-freebsd DISABLE_TESTS=1
|
||||
- env: TARGET=x86_64-unknown-netbsd DISABLE_TESTS=1
|
||||
|
||||
# Windows
|
||||
@@ -33,6 +33,7 @@ matrix:
|
||||
|
||||
before_install:
|
||||
- set -e
|
||||
- command -v apt-get && sudo apt-get install -y libclang-dev
|
||||
- rustup self update
|
||||
|
||||
install:
|
||||
@@ -53,7 +54,7 @@ deploy:
|
||||
# - Encrypt it: `travis encrypt 0123456789012345678901234567890123456789
|
||||
# - Paste the output down here
|
||||
api_key:
|
||||
secure: "VRWAaqZi3ttaVfvgaSK0hQAIYDFUvPdOhhHxQESNO5qoexjc9wioDe7qfi2PcIKEMcEnXgVlmqKEyd0K4Cur9gWKDCfVPUEDTlph+Xdx+p5ViB+9Bz1z9qFSJchZtqqPGqfaq4Fk5HjBr6V31JFV0pjDfy2dHJzjQke+CGG8Zk/1n4H0dYqxZ4EyxcmuIxAnplyUDNdOrbwkuRKEGXLg94Ayk/OmLqHwvCJGYsa3jSgS2ySDT3nRaM9CG5WxKaEQMW4uEWJLbgmqFaxCWh1sOYt+brDWXc9aIJIFsR4b8wdHdHVL0C34dW/0xjxSQPN3PK3jKZYduiu49XgHtpKF9fvsFQSeQwM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|
||||
on:
|
||||
|
||||
1022
Cargo.lock
generated
1022
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
12
Cargo.toml
12
Cargo.toml
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "bin"
|
||||
version = "1.0.2"
|
||||
version = "1.0.3"
|
||||
description = "a paste bin."
|
||||
repository = "https://github.com/w4/bin"
|
||||
license = "WTFPL OR 0BSD"
|
||||
@@ -10,12 +10,12 @@ edition = "2018"
|
||||
[dependencies]
|
||||
owning_ref = "0.4"
|
||||
linked-hash-map = "0.5"
|
||||
rocket = { version = "0.4", default-features = false }
|
||||
askama = "0.8"
|
||||
lazy_static = "1.2"
|
||||
rand = { version = "0.6", features = ["nightly"] }
|
||||
rocket = { version = "0.4.4", default-features = false }
|
||||
askama = "0.9"
|
||||
lazy_static = "1.4"
|
||||
rand = { version = "0.7", features = ["nightly"] }
|
||||
gpw = "0.1"
|
||||
syntect = "3.0"
|
||||
syntect = "4.1"
|
||||
serde_derive = "1.0"
|
||||
|
||||
[profile.release]
|
||||
|
||||
15
Dockerfile
Normal file
15
Dockerfile
Normal file
@@ -0,0 +1,15 @@
|
||||
FROM rust:1.34.2-slim-stretch AS builder
|
||||
RUN rustup install nightly-x86_64-unknown-linux-gnu
|
||||
|
||||
COPY . /sources
|
||||
WORKDIR /sources
|
||||
RUN cargo +nightly build --release
|
||||
RUN chown nobody:nogroup /sources/target/release/bin
|
||||
|
||||
|
||||
FROM debian:stretch-slim
|
||||
COPY --from=builder /sources/target/release/bin /pastebin
|
||||
|
||||
USER nobody
|
||||
EXPOSE 8000
|
||||
ENTRYPOINT ["/pastebin"]
|
||||
10
README.md
10
README.md
@@ -1,9 +1,9 @@
|
||||
# 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.
|
||||
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 snippets 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.
|
||||
[bin](https://bin.gy/) is written in Rust in around 200 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.
|
||||
|
||||
##### so how do you get bin?
|
||||
|
||||
@@ -36,9 +36,9 @@ bin's only configuration value is `BIN_BUFFER_SIZE` which defaults to 2000. Chan
|
||||
##### is there curl support?
|
||||
|
||||
```bash
|
||||
$ curl -X PUT --data 'hello world' bin.doyle.la
|
||||
https://bin.doyle.la/cateettary
|
||||
$ curl https://bin.doyle.la/cateettary
|
||||
$ curl -X PUT --data 'hello world' https://bin.gy
|
||||
https://bin.gy/cateettary
|
||||
$ curl https://bin.gy/cateettary
|
||||
hello world
|
||||
```
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ main() {
|
||||
|
||||
cross rustc --bin bin --target $TARGET --release -- -C lto
|
||||
|
||||
strip target/$TARGET/release/bin
|
||||
cp target/$TARGET/release/bin $stage/
|
||||
[ "$TARGET" = "arm-unknown-linux-gnueabi" ] || [ "$TARGET" = "x86_64-pc-windows-gnu" ] || strip target/$TARGET/release/bin
|
||||
cp target/$TARGET/release/* $stage/
|
||||
|
||||
cd $stage
|
||||
tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz *
|
||||
|
||||
@@ -4,7 +4,7 @@ set -ex
|
||||
|
||||
# TODO This is the "test phase", tweak it as you see fit
|
||||
main() {
|
||||
cross build --target $TARGET
|
||||
cross check
|
||||
cross build --target $TARGET --release
|
||||
|
||||
if [ ! -z $DISABLE_TESTS ]; then
|
||||
@@ -12,7 +12,6 @@ main() {
|
||||
fi
|
||||
|
||||
cross test --target $TARGET
|
||||
cross test --target $TARGET --release
|
||||
}
|
||||
|
||||
# we don't run the "test phase" when doing deploys
|
||||
|
||||
@@ -2,8 +2,8 @@ with import <nixpkgs> {};
|
||||
let src = fetchFromGitHub {
|
||||
owner = "mozilla";
|
||||
repo = "nixpkgs-mozilla";
|
||||
# commited 12/2/2019
|
||||
rev = "37f7f33ae3ddd70506cd179d9718621b5686c48d";
|
||||
# commited 19/2/2020
|
||||
rev = "e912ed483e980dfb4666ae0ed17845c4220e5e7c";
|
||||
sha256 = "0cmvc9fnr38j3n0m4yf0k6s2x589w1rdby1qry1vh435v79gp95j";
|
||||
};
|
||||
in
|
||||
@@ -14,6 +14,9 @@ stdenv.mkDerivation {
|
||||
buildInputs = [
|
||||
latest.rustChannels.nightly.cargo
|
||||
latest.rustChannels.nightly.rust
|
||||
stdenv.cc.libc
|
||||
] ++
|
||||
pkgs.lib.optional pkgs.stdenv.isDarwin pkgs.darwin.apple_sdk.frameworks.Security;
|
||||
|
||||
LIBCLANG_PATH="${llvmPackages.libclang}/lib";
|
||||
}
|
||||
|
||||
17
src/main.rs
17
src/main.rs
@@ -1,5 +1,4 @@
|
||||
#![feature(proc_macro_hygiene, decl_macro)]
|
||||
#![feature(type_alias_enum_variants)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
@@ -19,7 +18,7 @@ use params::{HostHeader, IsPlaintextRequest};
|
||||
|
||||
use askama::{Html as AskamaHtml, MarkupDisplay, Template};
|
||||
|
||||
use rocket::http::{ContentType, Status};
|
||||
use rocket::http::{ContentType, RawStr, Status};
|
||||
use rocket::request::Form;
|
||||
use rocket::response::content::{Content, Html};
|
||||
use rocket::response::Redirect;
|
||||
@@ -100,14 +99,22 @@ fn show_paste(key: String, plaintext: IsPlaintextRequest) -> Result<Content<Stri
|
||||
if *plaintext {
|
||||
Ok(Content(ContentType::Plain, entry.to_string()))
|
||||
} else {
|
||||
let content = match ext {
|
||||
let code_highlighted = match ext {
|
||||
Some(extension) => match highlight(&entry, extension) {
|
||||
Some(html) => MarkupDisplay::new_safe(Cow::Owned(html), AskamaHtml),
|
||||
Some(html) => html,
|
||||
None => return Err(Status::NotFound),
|
||||
},
|
||||
None => MarkupDisplay::new_unsafe(Cow::Borrowed(entry), AskamaHtml),
|
||||
None => String::from(RawStr::from_str(entry).html_escape()),
|
||||
};
|
||||
|
||||
// Add <code> tags to enable line numbering with CSS
|
||||
let html = format!(
|
||||
"<code>{}</code>",
|
||||
code_highlighted.replace("\n", "</code><code>")
|
||||
);
|
||||
|
||||
let content = MarkupDisplay::new_safe(Cow::Borrowed(&html), AskamaHtml);
|
||||
|
||||
let template = ShowPaste { content };
|
||||
match template.render() {
|
||||
Ok(html) => Ok(Content(ContentType::HTML, html)),
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
<meta charset="UTF-8">
|
||||
<title>bin.</title>
|
||||
|
||||
<link rel="help" href="https://github.com/w4/bin">
|
||||
|
||||
<style>
|
||||
* { box-sizing: border-box; }
|
||||
|
||||
|
||||
@@ -9,7 +9,23 @@
|
||||
font-family: inherit;
|
||||
font-size: 1rem;
|
||||
line-height: inherit;
|
||||
counter-reset: line;
|
||||
}
|
||||
code {
|
||||
counter-increment: line;
|
||||
}
|
||||
|
||||
code::before {
|
||||
content: counter(line);
|
||||
display: inline-block;
|
||||
width: 2em; /* Fixed width */
|
||||
padding: 0 1em 0.3em 0;
|
||||
margin-right: .5em;
|
||||
color: #888;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
|
||||
|
||||
{% endblock styles %}
|
||||
|
||||
{% block content %}<pre><code>{{ content|safe }}</code></pre>{% endblock content %}
|
||||
{% block content %}<pre>{{ content|safe }}</pre>{% endblock content %}
|
||||
Reference in New Issue
Block a user