mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
New page, decreased default maxfilesizem, add max title length.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Paste Archives - Sharpbin</title>
|
||||
<link rel="preload" href="css/style.css" as="style">
|
||||
<link rel="preload" href="css/archive.css" as="style">
|
||||
<link rel="preload" href="js/archive.js" as="script">
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
<link rel="stylesheet" href="css/archive.css">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Noto+Sans+Mono:wght@100..900&display=swap"
|
||||
rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div class="main-container">
|
||||
<h1 id="archive-header">Paste Archives</h1>
|
||||
<div class="archive-information">
|
||||
<p id="archive-title">Title</p>
|
||||
<p id="archive-date">Date</p>
|
||||
<p id="archive-syntax">Syntax</p>
|
||||
</div>
|
||||
<ol class="archive-list" id="archives">
|
||||
<!-- <li>
|
||||
<a href="paste.html?id=1">
|
||||
<p id="archive-title">Title</p>
|
||||
<p id="archive-date">Date</p>
|
||||
<p id="archive-syntax">Syntax</p>
|
||||
</a>
|
||||
</li> -->
|
||||
</ol>
|
||||
<div class="paste-actions">
|
||||
<button id="previous-button" onclick="previousPage()"><</button>
|
||||
<p id="paste-pages">0/0</p>
|
||||
<button id="next-button" onclick="nextPage()">></button>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script src="js/archive.js"></script>
|
||||
<script src="js/navbar.js"></script>
|
||||
</html>
|
||||
@@ -0,0 +1,62 @@
|
||||
.archive-list {
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
max-height: 100%;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
.archive-list li {
|
||||
margin: 5px 0 5px 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
}
|
||||
.archive-list li a {
|
||||
display: block;
|
||||
padding: 1rem;
|
||||
background-color: var(--neutral-800);
|
||||
color: var(--neutral-50);
|
||||
text-decoration: none;
|
||||
transition: background-color 0.3s;
|
||||
border-radius: 5px;
|
||||
border: 1px solid var(--neutral-700);
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
#archive-title {
|
||||
min-width: 50%;
|
||||
max-width: 50%;
|
||||
}
|
||||
.archive-information {
|
||||
padding: 0 2px 0 2px;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.main-container {
|
||||
max-height: 80% !important;
|
||||
}
|
||||
.paste-actions {
|
||||
width: 100%;
|
||||
margin-top: 5px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
button {
|
||||
padding: 10px 40px 10px 40px;
|
||||
margin: 5px 0;
|
||||
border-radius: 5px;
|
||||
border: 1px solid var(--neutral-800);
|
||||
background-color: var(--neutral-800);
|
||||
color: var(--neutral-50);
|
||||
cursor: pointer;
|
||||
transition: background-color 0.3s;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: var(--neutral-700);
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
pages = 0;
|
||||
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
var queries = new URLSearchParams(window.location.search);
|
||||
var page = queries.get("page");
|
||||
var limit = queries.get("limit");
|
||||
|
||||
if (parseInt(page).isNaN) {
|
||||
page = 0;
|
||||
}
|
||||
|
||||
var archiveList = document.getElementById("archives");
|
||||
var archiveListHTML = "";
|
||||
var pagesElement = document.getElementById("paste-pages");
|
||||
|
||||
if (page == null || page < 0) {
|
||||
page = 0;
|
||||
}
|
||||
if (limit == null || limit < 1 || limit > 25) {
|
||||
limit = 25;
|
||||
}
|
||||
|
||||
var archiveData = await getPastes(page, limit);
|
||||
|
||||
var pastes = archiveData.pastes;
|
||||
pages = archiveData.pages;
|
||||
pagesElement.innerText = `${parseInt(page) + 1}/${pages + 1}`;
|
||||
|
||||
|
||||
pastes.forEach(paste => {
|
||||
var title = paste.title.length > 30 ? paste.title.substring(0, 30) + '...' : paste.title;
|
||||
archiveListHTML += `
|
||||
<li>
|
||||
<a href="/${paste.id}">
|
||||
<p id="archive-title" title="${paste.title}">${title}</p>
|
||||
<p id="archive-date">${formatDate(paste.created)}</p>
|
||||
<p id="archive-syntax">${paste.syntax}</p>
|
||||
</a>
|
||||
</li>
|
||||
`;
|
||||
});
|
||||
|
||||
archiveList.innerHTML = archiveListHTML;
|
||||
});
|
||||
|
||||
async function getPastes(page, limit) {
|
||||
const response = await fetch(`/api/pastes/archive?page=${page}&limit=${limit}`);
|
||||
const data = await response.json();
|
||||
return data;
|
||||
}
|
||||
|
||||
function formatDate(unix) {
|
||||
if (typeof unix !== 'number' || isNaN(unix)) {
|
||||
return 'Invalid date';
|
||||
}
|
||||
var nowunix = Math.floor(Date.now() / 1000);
|
||||
var diff = nowunix - unix;
|
||||
|
||||
if (diff < 60) {
|
||||
return `${diff} second${diff !== 1 ? 's' : ''} ago`;
|
||||
} else if (diff < 3600) {
|
||||
const minutes = Math.floor(diff / 60);
|
||||
return `${minutes} minute${minutes !== 1 ? 's' : ''} ago`;
|
||||
} else if (diff < 86400) {
|
||||
const hours = Math.floor(diff / 3600);
|
||||
return `${hours} hour${hours !== 1 ? 's' : ''} ago`;
|
||||
} else {
|
||||
const days = Math.floor(diff / 86400);
|
||||
return `${days} day${days !== 1 ? 's' : ''} ago`;
|
||||
}
|
||||
}
|
||||
|
||||
function nextPage() {
|
||||
var queries = new URLSearchParams(window.location.search);
|
||||
var page = queries.get("page");
|
||||
var limit = queries.get("limit");
|
||||
|
||||
if (page == null || page < 0) {
|
||||
page = 0;
|
||||
}
|
||||
if (limit == null || limit < 1 || limit > 25) {
|
||||
limit = 25;
|
||||
}
|
||||
|
||||
if (page + 1 > pages) {
|
||||
return;
|
||||
}
|
||||
|
||||
page++;
|
||||
window.location.href = `/archive?page=${page}&limit=${limit}`;
|
||||
}
|
||||
|
||||
function previousPage() {
|
||||
var queries = new URLSearchParams(window.location.search);
|
||||
var page = queries.get("page");
|
||||
var limit = queries.get("limit");
|
||||
|
||||
if (page == null || page < 0) {
|
||||
page = 0;
|
||||
}
|
||||
if (limit == null || limit < 1 || limit > 25) {
|
||||
limit = 25;
|
||||
}
|
||||
|
||||
if (page < pages) {
|
||||
return;
|
||||
}
|
||||
|
||||
page--;
|
||||
window.location.href = `/archive?page=${page}&limit=${limit}`;
|
||||
}
|
||||
@@ -15,7 +15,6 @@ document.getElementById("create-form").addEventListener("submit", async function
|
||||
|
||||
if (visibility === "2" && password !== "" && password.length >= 6) {
|
||||
content = await encryptAES(content, password);
|
||||
console.log(content);
|
||||
}
|
||||
else if (visibility === "2") {
|
||||
alert("Password must be at least 6 characters long");
|
||||
|
||||
@@ -2,8 +2,8 @@ const navbarHTML = `
|
||||
<div class="nav-bar">
|
||||
<button class="hamburger" onclick="toggleMenu()">☰</button>
|
||||
<div class="nav-links">
|
||||
<a href="index.html" class="nav-link">Home</a>
|
||||
<a href="archive.html" class="nav-link">Paste Archive</a>
|
||||
<a href="/" class="nav-link">Home</a>
|
||||
<a href="/archive" class="nav-link">Paste Archive</a>
|
||||
</div>
|
||||
<style>
|
||||
.nav-bar {display: flex;justify-content: space-between;align-items: center;padding: 1rem 2rem;background-color: var(--neutral-900);color: #fff;position: fixed;width: 100%;top: 0;left: 0;right: 0;}.nav-link {color: #fff;text-decoration: none;font-size: 1.2rem;transition: color 0.3s;}.nav-link:hover {color: var(--neutral-300);}.nav-links .nav-link {width: auto;padding: 0 1rem;border-bottom: none;}.nav-links .nav-link:last-child {border-bottom: none;}.hamburger {display: none;background: none;border: none;font-size: 2rem;cursor: pointer;margin: 0 auto;}.nav-links {display: flex;flex-direction: row;position: static;background-color: transparent;padding: 0;max-height: none;transition: none;}.nav-links.show {display: flex;flex-direction: column;position: absolute;top: 100%;left: 0;right: 0;background-color: var(--neutral-900);padding: 1rem 2rem;max-height: 500px;transition: max-height 0.3s ease-out;overflow: hidden;}@media (max-width: 800px) {.nav-links {display: none;flex-direction: column;width: 100%;position: absolute;top: 100%;left: 0;right: 0;border-top: 1px solid var(--neutral-800);background-color: var(--neutral-900);padding: 1rem 2rem;max-height: 0;transition: max-height 0.3s ease-out;overflow: hidden;}.nav-link{width: 100% !important;padding: 1rem 0 !important;text-align: center;border-bottom: 1px solid var(--neutral-800) !important;}.nav-links.show {display: flex;max-height: 500px;flex-direction: column;align-items: center;}.hamburger {display: block;margin: 0 auto;}.nav-bar {justify-content: center;}}
|
||||
|
||||
Reference in New Issue
Block a user