🥳 0.2.0

This commit is contained in:
Kainoa Kanter 2022-03-13 16:33:00 -07:00
parent fbaf091aee
commit 39edd22776
11 changed files with 259 additions and 267 deletions

8
.gitignore vendored
View File

@ -2,10 +2,6 @@
**/node_modules/
**/dist/
**/.parcel-cache/
**/config.json
config.json
**/url.txt
**/yarn.lock
**/package-lock.json
**/yarn-error.log
node_modules
.yarn-integrity
**/package-lock.json

View File

@ -34,7 +34,7 @@ Submit your public instance [here](https://github.com/Domterion/zer0bin/issues/n
| Website | Country | Expiration | Max paste size | Version |
| ---------------------------------------------- | ------- | ---------- | -------------- | ------- |
| zer0b.in (not up yet) | ? | 7 days | 40,000 chars | vx.x.x |
| [stepbro.voring.me](https://stepbro.voring.me) | 🇺🇸 US | 365 days | 100,000 chars | v0.1.0 |
| [stepbro.voring.me](https://stepbro.voring.me) | 🇺🇸 US | 365 days | 69,000 chars | v0.2.0 |
# Technologies used
@ -46,27 +46,25 @@ Backend: <a href="https://actix.rs/"><img src="https://pool.jortage.com/voringme
### Requirements
- Rust >= 1.58.0
- Postgresql >= 12.0
- NodeJS >= 16.0
- Nginx
- Domain with SSL
- \*nix OS
- Rust >= 1.58.0
- Postgresql >= 12.0
- NodeJS >= 16.0
- Nginx
- Domain with SSL
- \*nix OS
### Steps
1. `git clone https://github.com/Domterion/zer0bin && cd zer0bin`
2. `cp example.nginx /etc/nginx/sites-avaliable/yoursite.tld`, edit as appropriate, `sudo ln -s /etc/nginx/sites-avaliable/yoursite.tld /etc/nginx/sites-enabled/yoursite.tld && systemctl nginx restart`
3. `psql -d postgres`
4. `CREATE DATABASE zer0bin;` and `\c zer0bin`
5. Paste contents of `schema.sql` and `\q`
6. `cd frontend`
7. `cp config.example.json config.json` and edit as appropriate
8. `npm i && npm run build`
9. `cd ../backend`
10. `cp config.example.json config.json` and edit as appropriate
11. `cargo build --release`
12. `./target/release/backend` (preferably in a tmux session)
2. `cp example.nginx /etc/nginx/sites-avaliable/yoursite.tld`, edit as appropriate, `sudo cp /etc/nginx/sites-avaliable/yoursite.tld /etc/nginx/sites-enabled/yoursite.tld && systemctl nginx restart`
3. `psql -f example.sql -U <username> zer0bin`
5. `cd frontend`
6. `cp config.example.json config.json` and edit as appropriate
7. `npm i && npm run build`
8. `cd ../backend`
9. `cp config.example.json config.json` and edit as appropriate
10. `cargo build --release`
11. `./target/release/backend` (preferably in a tmux session or as a service)
### Configuration

View File

@ -1,18 +1,18 @@
{
"server": {
"backend_host": "127.0.0.1",
"backend_port": 8000
},
"pastes": {
"character_limit": 40000,
"days_til_expiration": 7,
"id_length": 10
},
"ratelimits": {
"seconds_in_between_pastes": 2,
"allowed_pastes_before_ratelimit": 5
},
"databases": {
"postgres_uri": "postgres://postgres:postgres@localhost:5432/zer0bin"
}
}
"server": {
"backend_host": "127.0.0.1",
"backend_port": 8000
},
"pastes": {
"character_limit": 40000,
"days_til_expiration": 7,
"id_length": 10
},
"ratelimits": {
"seconds_in_between_pastes": 2,
"allowed_pastes_before_ratelimit": 5
},
"databases": {
"postgres_uri": "postgres://postgres:postgres@localhost:5432/zer0bin"
}
}

View File

@ -37,7 +37,7 @@ pub struct GetPasteResponse {
#[derive(Serialize)]
pub struct GetStatsResponse {
pub count: i64
pub count: i64,
}
#[derive(Serialize)]

View File

@ -1,3 +1,3 @@
{
"api_url": "http://example.tld/api"
"api_url": "http://example.tld/api"
}

View File

@ -1,167 +1,167 @@
body,
html {
height: 100%;
height: 100%;
}
body {
background-color: #191724;
margin: 0;
background-color: #191724;
margin: 0;
}
pre {
margin: 0;
margin: 0;
}
.wrapper {
display: flex;
padding: 1rem 0.5rem;
font-size: 1rem;
height: calc(100% - 2rem);
display: flex;
padding: 1rem 0.5rem;
font-size: 1rem;
height: calc(100% - 2rem);
}
.line-numbers {
color: #908caa;
font-family: monospace;
text-align: end;
user-select: none;
font-size: 15px;
padding-right: 8px;
color: #908caa;
font-family: monospace;
text-align: end;
user-select: none;
font-size: 15px;
padding-right: 8px;
}
#code-view-pre {
padding-top: 0;
padding-bottom: 0;
font-size: 15px;
-webkit-text-size-adjust: none;
padding-top: 0;
padding-bottom: 0;
font-size: 15px;
-webkit-text-size-adjust: none;
}
#code-view {
padding-top: 0;
padding-bottom: 0;
padding-top: 0;
padding-bottom: 0;
}
code {
color: #e0def4;
color: #e0def4;
}
textarea {
background-color: transparent;
resize: none;
width: 100%;
height: 100%;
padding: 0;
padding-left: 1rem;
margin: 0;
border: none;
outline: 0;
color: #e0def4;
font-size: 15px;
background-color: transparent;
resize: none;
width: 100%;
height: 100%;
padding: 0;
padding-left: 1rem;
margin: 0;
border: none;
outline: 0;
color: #e0def4;
font-size: 15px;
}
.button-wrapper {
position: absolute;
top: 0;
right: 0;
padding: 1rem;
background-color: #1f1d2e;
z-index: 10;
position: absolute;
top: 0;
right: 0;
padding: 1rem;
background-color: #1f1d2e;
z-index: 10;
}
.buttons {
display: flex;
display: flex;
}
.buttons > * + * {
margin-left: 0.25rem;
margin-left: 0.25rem;
}
a {
color: #31748f;
color: #31748f;
}
a:visited {
color: #c4a7e7;
color: #c4a7e7;
}
a:hover :not(.logo) {
color: #9ccfd8;
color: #9ccfd8;
}
.btn {
cursor: pointer;
background: 0 0;
color: #9ccfd8;
padding-left: 0;
font-size: 1rem;
border: none;
transition: background-color 0.2s ease-in-out;
display: inline-block;
text-decoration: none;
cursor: pointer;
background: 0 0;
color: #9ccfd8;
padding-left: 0;
font-size: 1rem;
border: none;
transition: background-color 0.2s ease-in-out;
display: inline-block;
text-decoration: none;
}
.btn:hover {
color: #e0def4;
color: #e0def4;
}
.btn:disabled,
.btn[disabled] {
color: #6e6a86;
color: #6e6a86;
}
.logo {
font-size: 1.8rem;
font-weight: 700;
text-align: center;
text-decoration: none;
color: #8fbcc8;
width: 100%;
font-family: monospace;
display: inline-block;
background: linear-gradient(
to right,
#eb6f92,
#c9b065,
#ebbcba,
#31748f,
#9ccfd8,
#c4a7e7
);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
animation: rainbow 120s linear infinite;
background-size: 400% 100%;
font-size: 1.8rem;
font-weight: 700;
text-align: center;
text-decoration: none;
color: #8fbcc8;
width: 100%;
font-family: monospace;
display: inline-block;
background: linear-gradient(
to right,
#eb6f92,
#c9b065,
#ebbcba,
#31748f,
#9ccfd8,
#c4a7e7
);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
animation: rainbow 120s linear infinite;
background-size: 400% 100%;
}
.logo:hover {
animation: rainbow 3s ease infinite !important;
animation: rainbow 3s ease infinite !important;
}
#messages {
position: absolute;
top: 0;
right: 168px;
z-index: 1000;
padding: 0;
margin: 0;
list-style: none;
width: 400px;
position: absolute;
top: 0;
right: 168px;
z-index: 1000;
padding: 0;
margin: 0;
list-style: none;
width: 400px;
}
#messages li {
background-color: rgba(31, 29, 46, 0.8);
font-family: monospace;
color: #e0def4;
padding: 7px;
background-color: rgba(31, 29, 46, 0.8);
font-family: monospace;
color: #e0def4;
padding: 7px;
}
@keyframes rainbow {
0%,
100% {
background-position: 0 0;
}
0%,
100% {
background-position: 0 0;
}
50% {
background-position: 100% 0;
}
50% {
background-position: 100% 0;
}
}

View File

@ -1,69 +1,65 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>zer0bin</title>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
<meta name="theme-color" content="#90BDC9" />
<meta
name="keywords"
content="zerobin, zer0bin, paste, paste bin, pastebin, pastebin alternative, foss pastebin, open source pastebin, free pastebin, ghostbin, hastebin, pastebin.com, free pastebin online, paste online, github paste, github gist, github gist paste"
/>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>zer0bin</title>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
<meta name="theme-color" content="#90BDC9" />
<meta
name="keywords"
content="zerobin, zer0bin, paste, paste bin, pastebin, pastebin alternative, foss pastebin, open source pastebin, free pastebin, ghostbin, hastebin, pastebin.com, free pastebin online, paste online, github paste, github gist, github gist paste"
/>
<link href="css/style.css" rel="stylesheet" />
<link href="css/rosepine.min.css" rel="stylesheet" />
<link href="css/style.css" rel="stylesheet" />
<link href="css/rosepine.min.css" rel="stylesheet" />
<meta name="title" content="zer0bin" />
<meta name="description" content="🖊 Just a place to paste" />
<meta name="title" content="zer0bin" />
<meta name="description" content="🖊 Just a place to paste" />
<meta property="og:type" content="website" />
<meta property="og:title" content="zer0bin" />
<meta property="og:description" content="🖊 Just a place to paste" />
<meta
property="og:image"
content="https://raw.githubusercontent.com/Domterion/zer0bin/main/zero.png"
/>
<meta property="twitter:title" content="zer0bin" />
<meta
property="twitter:description"
content="🖊 Just a place to paste"
/>
<meta
property="twitter:image"
content="https://raw.githubusercontent.com/Domterion/zer0bin/main/zero.png"
/>
<meta property="og:type" content="website" />
<meta property="og:title" content="zer0bin" />
<meta property="og:description" content="🖊 Just a place to paste" />
<meta
property="og:image"
content="https://raw.githubusercontent.com/Domterion/zer0bin/main/zero.png"
/>
<meta property="twitter:title" content="zer0bin" />
<meta property="twitter:description" content="🖊 Just a place to paste" />
<meta
property="twitter:image"
content="https://raw.githubusercontent.com/Domterion/zer0bin/main/zero.png"
/>
<!-- We cant move this, we can split the on document stuff into here but yeah -->
<script defer type="module" src="src/index.js"></script>
</head>
<script defer type="module" src="src/index.js"></script>
</head>
<body>
<ul id="messages"></ul>
<body>
<ul id="messages"></ul>
<div class="button-wrapper">
<a href="/" class="logo">zer0bin</a>
<div class="buttons">
<button id="save-button" class="btn"></button>
<button id="new-button" class="btn"></button>
<a href="https://github.com/Domterion/zer0bin">
<button class="btn" id="github-button"></button>
</a>
</div>
</div>
<div class="wrapper">
<div class="line-numbers"></div>
<pre
id="code-view-pre"
style="display: none"
><code id="code-view"></code></pre>
<textarea
spellcheck="false"
autofocus
name="value"
id="text-area"
style="display: none"
></textarea>
</div>
</body>
<div class="button-wrapper">
<a href="/" class="logo">zer0bin</a>
<div class="buttons">
<button id="save-button" class="btn"></button>
<button id="new-button" class="btn"></button>
<a href="https://github.com/Domterion/zer0bin">
<button class="btn" id="github-button"></button>
</a>
</div>
</div>
<div class="wrapper">
<div class="line-numbers"></div>
<pre
id="code-view-pre"
style="display: none"
><code id="code-view"></code></pre>
<textarea
spellcheck="false"
autofocus
name="value"
id="text-area"
style="display: none"
></textarea>
</div>
</body>
</html>

View File

@ -1,22 +1,22 @@
{
"name": "zer0bin",
"source": "index.html",
"version": "0.1.0",
"browserslist": "> 0.5%, last 2 versions, not dead",
"license": "MIT",
"scripts": {
"start": "parcel",
"build": "parcel build"
},
"devDependencies": {
"parcel": "^2.3.2"
},
"description": "just a place to paste",
"repository": "https://github.com/Domterion/zer0bin",
"author": "Domterion, ThatOneCalculator",
"dependencies": {
"@ant-design/icons-svg": "^4.2.1",
"highlight.js": "^11.4.0",
"jquery": "^3.6.0"
}
"name": "zer0bin",
"source": "index.html",
"version": "0.2.0",
"browserslist": "> 0.5%, last 2 versions, not dead",
"license": "MIT",
"scripts": {
"start": "parcel",
"build": "parcel build"
},
"devDependencies": {
"parcel": "^2.3.2"
},
"description": "just a place to paste",
"repository": "https://github.com/Domterion/zer0bin",
"author": "Domterion, ThatOneCalculator",
"dependencies": {
"@ant-design/icons-svg": "^4.2.1",
"highlight.js": "^11.4.0",
"jquery": "^3.6.0"
}
}

View File

@ -1,10 +1,6 @@
// import { $ } from "jquery"
const $ = require("jquery");
const config = require("../config.json");
const apiUrl = config.api_url;
const hljs = require("highlight.js");
import { hljs } from "highlight.js"
import {
SaveOutlined,
FileAddOutlined,
@ -12,6 +8,9 @@ import {
} from "@ant-design/icons-svg";
import { renderIconDefinitionToSVGElement } from "@ant-design/icons-svg/es/helpers";
const config = require("../config.json");
const apiUrl = config.api_url;
const svgSave = renderIconDefinitionToSVGElement(SaveOutlined, {
extraSVGAttrs: {
width: "1em",
@ -68,7 +67,7 @@ function postPaste(content, callback) {
callback(
JSON.parse(
xhr.responseText ||
`{"data": { "message": "An unkown error occured!" } }`
`{"data": { "message": "An unkown error occured!" } }`
)
);
},
@ -88,7 +87,7 @@ function getPaste(id, callback) {
callback(
JSON.parse(
xhr.responseText ||
`{"data": { "message": "Unknown error occurred.." } }`
`{"data": { "message": "Unknown error occurred.." } }`
)
);
},

View File

@ -5,13 +5,14 @@ CREATE TABLE IF NOT EXISTS pastes (
"expires_at" TIMESTAMP WITHOUT TIME ZONE,
"created_at" TIMESTAMP WITHOUT TIME ZONE DEFAULT(NOW() AT TIME ZONE 'utc')
);
CREATE OR REPLACE FUNCTION deleteExpiredPastes() RETURNS trigger AS $pastes_expire$
BEGIN
DELETE FROM pastes WHERE "expires_at" IS NOT NULL AND "expires_at" < now() AT TIME ZONE 'utc';
RETURN NEW;
END;
CREATE OR REPLACE FUNCTION deleteExpiredPastes() RETURNS trigger AS $pastes_expire$ BEGIN
DELETE FROM pastes
WHERE "expires_at" IS NOT NULL
AND "expires_at" < now() AT TIME ZONE 'utc';
RETURN NEW;
END;
$pastes_expire$ LANGUAGE plpgsql;
CREATE TRIGGER checkPastes BEFORE INSERT OR UPDATE ON pastes
FOR STATEMENT EXECUTE PROCEDURE deleteExpiredPastes();
CREATE TRIGGER checkPastes BEFORE
INSERT
OR
UPDATE ON pastes FOR STATEMENT EXECUTE PROCEDURE deleteExpiredPastes();

View File

@ -2,37 +2,39 @@
<foreignObject width="100%" height="100%">
<div xmlns="http://www.w3.org/1999/xhtml">
<style>
h1 {
background: linear-gradient(
to right,
#eb6f92,
#c9b065,
#ebbcba,
#31748f,
#9ccfd8,
#c4a7e7
);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
animation: rainbow 5s ease infinite;
background-size: 400% 100%;
font-family: "Cartograph CF", monospace;
font-weight: 600;
text-align: center;
}
@keyframes rainbow {
0%, 100% {
background-position: 0 0;
}
50% {
background-position: 100% 0;
}
}
</style>
<h1> zer0bin </h1>
<style>
h1 {
background: linear-gradient(to right,
#eb6f92,
#c9b065,
#ebbcba,
#31748f,
#9ccfd8,
#c4a7e7);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
animation: rainbow 5s ease infinite;
background-size: 400% 100%;
font-family: "Cartograph CF", monospace;
font-weight: 600;
text-align: center;
}
@keyframes rainbow {
0%,
100% {
background-position: 0 0;
}
50% {
background-position: 100% 0;
}
}
</style>
<h1> zer0bin </h1>
</div>
</foreignObject>
</svg>
</svg>

Before

Width:  |  Height:  |  Size: 710 B

After

Width:  |  Height:  |  Size: 827 B