mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae3b96d7e0 | ||
|
|
6e95ae595a | ||
|
|
517a82d058 | ||
|
|
46615aba5b | ||
|
|
59c609e7c1 | ||
|
|
ada51d5c56 | ||
|
|
c158cde86d | ||
|
|
38d25d785e | ||
|
|
410172f922 | ||
|
|
b872de29d2 | ||
|
|
c90bd84ad7 | ||
|
|
eb542342c9 |
+331
-226
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,4 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
|
||||
namespace Sharpbin
|
||||
|
||||
@@ -153,7 +153,7 @@
|
||||
|
||||
}).then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
const result = obj;
|
||||
if (result.message != null) {
|
||||
createNotification(`${result.message} for ${reason}`);
|
||||
} else {
|
||||
@@ -174,7 +174,7 @@
|
||||
|
||||
}).then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
const result = obj;
|
||||
if (result.message != null) {
|
||||
createNotification(`${result.message} for ${reason}`);
|
||||
} else {
|
||||
@@ -199,7 +199,7 @@
|
||||
|
||||
}).then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
const result = obj;
|
||||
if (result.message != null) {
|
||||
createNotification(`${result.message} to ${result.password}`);
|
||||
navigator.clipboard.writeText(result.password);
|
||||
|
||||
@@ -13,10 +13,13 @@
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
<a href="login" id="login-signup-btn" style="display: none;" >login</a>
|
||||
<a href="sign-up" id="login-signup-btn" style="display: none;">sign up</a>
|
||||
<a href="dash" id="dash-btn" style="display: none;">dashboard</a>
|
||||
</div>
|
||||
<div class="nav-hamburger-menu">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" fill="currentColor" class="bi bi-list" viewBox="0 0 16 16" id="hamburger-button" style="cursor: pointer;">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" fill="currentColor" class="bi bi-list"
|
||||
viewBox="0 0 16 16" id="hamburger-button" style="cursor: pointer;">
|
||||
<path fill-rule="evenodd"
|
||||
d="M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5" />
|
||||
</svg>
|
||||
@@ -24,7 +27,9 @@
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
<a href="login" id="login-signup-btn" style="display: none;" >login</a>
|
||||
<a href="sign-up" id="login-signup-btn" style="display: none;">sign up</a>
|
||||
<a href="dash" id="dash-btn" style="display: none;">dashboard</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-wrapper">
|
||||
@@ -32,18 +37,73 @@
|
||||
<h1>paste archive</h1>
|
||||
<input type="text" placeholder="search" class="text-input" oninput="search()">
|
||||
<div class="pastes-wrapper">
|
||||
{pastes}
|
||||
Loading...
|
||||
</div>
|
||||
<div class="buttons-wrapper">
|
||||
<a class="arrow-button" href="/archive?page={backpagenum}"><</a>
|
||||
<p>{currentpagenum}/{totalpages}</p>
|
||||
<a class="arrow-button" href="/archive?page={pagenum}">></a>
|
||||
<a class="arrow-button" id="back-page"><</a>
|
||||
<p id="page-count"></p>
|
||||
<a class="arrow-button" id="next-page">></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
let searchTimeout;
|
||||
let pagenum = 1;
|
||||
|
||||
function authenticate() {
|
||||
fetch('/api/accounts/authenticate')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.message == "Authenticated") {
|
||||
document.querySelectorAll("#login-signup-btn").forEach(element => {
|
||||
element.style.display = 'none';
|
||||
});
|
||||
document.getElementById('dash-btn').style.display = 'block';
|
||||
}else{
|
||||
document.querySelectorAll("#login-signup-btn").forEach(element => {
|
||||
element.style.display = 'block';
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getPastes() {
|
||||
fetch(`/api/pastes/get`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
page: pagenum
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const pastesWrapper = document.querySelector('.pastes-wrapper');
|
||||
const pageCount = document.getElementById('page-count');
|
||||
pastesWrapper.innerHTML = '';
|
||||
pageCount.innerHTML = `${pagenum}/${data.pages}`;
|
||||
if (data.pastes.length === 0) {
|
||||
pastesWrapper.innerHTML = '<h1>no pastes found</h1>';
|
||||
return;
|
||||
}
|
||||
data.pastes.forEach(paste => {
|
||||
title = paste.title.length > 30 ? paste.title.substring(0, 30) + '...' : paste.title;
|
||||
pastesWrapper.innerHTML += `<a href="/${paste.id}" title="${paste.title}"><li>${title} ${paste.date} ${paste.size}</li></a>`;
|
||||
});
|
||||
});
|
||||
}
|
||||
document.getElementById('back-page').addEventListener('click', function () {
|
||||
if (pagenum > 1) {
|
||||
pagenum--;
|
||||
getPastes();
|
||||
}
|
||||
});
|
||||
document.getElementById('next-page').addEventListener('click', function () {
|
||||
pagenum++;
|
||||
getPastes();
|
||||
});
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
var mobile = window.mobileCheck();
|
||||
@@ -51,6 +111,8 @@
|
||||
document.querySelector('.nav-div').style.display = 'none';
|
||||
document.querySelector('.nav-hamburger-menu').style.display = 'flex';
|
||||
}
|
||||
authenticate();
|
||||
getPastes();
|
||||
});
|
||||
|
||||
document.getElementById("hamburger-button").addEventListener("click", function () {
|
||||
|
||||
@@ -84,11 +84,10 @@
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
if (result.pasteId != null) {
|
||||
window.location.href = `/${result.pasteId}`;
|
||||
} else if (result.error != null) {
|
||||
notification(result.error);
|
||||
if (obj.pasteId != null) {
|
||||
window.location.href = `/${obj.pasteId}`;
|
||||
} else if (obj.error != null) {
|
||||
notification(obj.error);
|
||||
}
|
||||
})
|
||||
});
|
||||
@@ -309,6 +308,8 @@
|
||||
border: #2a2a2a00 2px solid;
|
||||
cursor: pointer;
|
||||
font-size: 1.2em;
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
@@ -319,7 +320,7 @@
|
||||
|
||||
.nav-div {
|
||||
top: 0;
|
||||
margin-top: 10px;
|
||||
margin-top: 1.5px;
|
||||
position: absolute;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
.then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
const result = obj;
|
||||
isLoggingIn = true;
|
||||
if (result.message != null) {
|
||||
window.location.href = "/";
|
||||
|
||||
@@ -67,8 +67,8 @@
|
||||
const date = new Date(unixTimestamp * 1000);
|
||||
return date.toLocaleString();
|
||||
}
|
||||
function authenticated() {
|
||||
fetch('/api/accounts/authenticated')
|
||||
function authenticate() {
|
||||
fetch('/api/accounts/authenticate')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.message == "Authenticated") {
|
||||
@@ -92,11 +92,12 @@
|
||||
.then(response => response.json())
|
||||
.then(json => {
|
||||
info = json;
|
||||
title = json.title.length > 40 ? json.title.substring(0, 40) + '...' : json.title;
|
||||
document.getElementById('uploader-username').innerText = json.uploader || 'Anonymous';
|
||||
document.getElementById('creationdate').innerText = localizeDateTime(json.date);
|
||||
document.getElementById('paste-size').innerText = json.size;
|
||||
document.getElementById('paste-size').title = `Compressed Size: ${json.compressedSize}`;
|
||||
document.getElementById('paste-title').innerText = json.title;
|
||||
document.getElementById('paste-title').innerText = title;
|
||||
document.getElementById('paste-title').title = json.title;
|
||||
if (json.title == "") {
|
||||
document.getElementById('paste-title').innerText = `Untitled ${json.uid}`;
|
||||
@@ -126,7 +127,7 @@
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
fetchInfo();
|
||||
authenticated();
|
||||
authenticate();
|
||||
const creationdateElement = document.getElementById('creationdate');
|
||||
const creationdateText = creationdateElement.innerText.trim();
|
||||
const textElement = document.getElementById('text');
|
||||
@@ -197,7 +198,7 @@
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
const result = obj;
|
||||
if (result.message != null) {
|
||||
createNotification(`Success: ${result.message}`);
|
||||
setTimeout(() => {
|
||||
@@ -265,7 +266,7 @@
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
const result = obj;
|
||||
if (result.message != null) {
|
||||
const inputWrapper = document.getElementById('input-wrapper');
|
||||
inputWrapper.style.display = 'none';
|
||||
@@ -313,7 +314,7 @@
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
color: white;
|
||||
backdrop-filter: blur(2.5px);
|
||||
backdrop-filter: blur(5px);
|
||||
}
|
||||
.input-wrapper-container{
|
||||
z-index: 101;
|
||||
@@ -325,6 +326,7 @@
|
||||
border-radius: 5px;
|
||||
padding: 20px;
|
||||
background-color: #181818;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
body {
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
</div>
|
||||
<div class="container-wrapper">
|
||||
<div class="paste-container">
|
||||
<h1 id="paste-title" title="{pastetitleattribute}">{pastetitle}</h1>
|
||||
<h1 id="paste-title"></h1>
|
||||
<h3 class="uploader-text"><a id="uploader-username" class="user-a"></a> <a id="creationdate"></a> <a id="paste-size"></a>
|
||||
</h3>
|
||||
<div class="paste-wrapper">
|
||||
@@ -74,8 +74,8 @@
|
||||
<script>
|
||||
info = "";
|
||||
editing = false;
|
||||
function authenticated() {
|
||||
fetch('/api/accounts/authenticated')
|
||||
function authenticate() {
|
||||
fetch('/api/accounts/authenticate')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.message == "Authenticated") {
|
||||
@@ -97,8 +97,7 @@
|
||||
function fetchInfo() {
|
||||
fetch('/api/pastes/info?id={pasteid}')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const json = JSON.parse(data);
|
||||
.then(json => {
|
||||
info = json;
|
||||
document.getElementById('uploader-username').innerText = json.uploader;
|
||||
document.getElementById('creationdate').innerText = localizeDateTime(json.date);
|
||||
@@ -144,8 +143,7 @@
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
.then(result => {
|
||||
if (result.content != null) {
|
||||
const textElement = document.getElementById('text');
|
||||
textElement.innerText = result.content;
|
||||
@@ -166,10 +164,6 @@
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
fetchInfo();
|
||||
authenticated();
|
||||
|
||||
const creationdateElement = document.getElementById('creationdate');
|
||||
const creationdateText = creationdateElement.innerText.trim();
|
||||
creationdateElement.innerText = localizeDateTime(parseInt(creationdateText));
|
||||
var mobile = window.mobileCheck();
|
||||
if (mobile) {
|
||||
document.querySelector('.nav-div').style.display = 'none';
|
||||
@@ -218,8 +212,7 @@
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
.then(result => {
|
||||
if (result.message != null) {
|
||||
createNotification(`Success: ${result.message}`);
|
||||
setTimeout(() => {
|
||||
@@ -244,8 +237,7 @@
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
.then(result => {
|
||||
if (result.message != null) {
|
||||
createNotification(`Success: ${result.message}`);
|
||||
document.getElementById('text').innerText = text;
|
||||
@@ -313,7 +305,7 @@
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
color: white;
|
||||
backdrop-filter: blur(2.5px);
|
||||
backdrop-filter: blur(5px);
|
||||
}
|
||||
|
||||
.input-wrapper-container {
|
||||
@@ -326,6 +318,7 @@
|
||||
border-radius: 5px;
|
||||
padding: 20px;
|
||||
background-color: #181818;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.container-wrapper {
|
||||
@@ -474,7 +467,7 @@
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.user-a {
|
||||
.user-a:any-link {
|
||||
color: rgb(190, 190, 190);
|
||||
text-decoration: none;
|
||||
text-decoration: underline;
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
const result = obj;
|
||||
if (result.message != null) {
|
||||
window.location.href = "/";
|
||||
isLoggingIn = false;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# Sharpbin is currently being re-written.
|
||||
Quite frankly the current code base is quite messy, I also am just bored and would like to improve this since it's a pretty fun thing to make.
|
||||
# Sharpbin
|
||||
Sharpbin is a Pastebin type website completely in C#, except for the frontend, being pure HTML & CSS.
|
||||
Sharpbin can be used for sharing large amounts of text.
|
||||
@@ -13,8 +15,13 @@ Sharpbin can be used for sharing large amounts of text.
|
||||
- Private encrypted pastes, sadly the encryption is server side, although client side may be soon!
|
||||
- Mobile Support
|
||||
- Captchas for logins and sign ups
|
||||
- Editable pastes
|
||||
... And more to come!
|
||||
|
||||
# TODO
|
||||
- ~~Fix css on the confirmations~~
|
||||
- ~~Update file size when an edit is made in the database~~
|
||||
|
||||
# Demo Website & Screenshots
|
||||
You can find the test website at https://bin.whoswhip.top , there is no removed functionality and is the exact same code in this repo.
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user