mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
44e6b3e423
|
||
|
|
a7481b5852
|
||
|
|
ca79582693
|
||
|
|
16f5bff317
|
||
|
|
b0a774afbb | ||
|
|
78c94e9195 | ||
|
|
4d0352b4e4
|
||
|
|
c940fc5207
|
||
|
|
7082fc4534
|
||
|
|
bfad18bb05
|
||
|
|
147e43cd8a
|
||
|
|
95316f5a84
|
||
|
|
091c6d895e
|
||
|
|
43f9a25915
|
||
|
|
6e59fbe627
|
||
|
|
ec62e3be75
|
||
|
|
3681f586dc
|
||
|
|
a06021f0cd
|
||
|
|
5ecb6a9714
|
||
|
|
75010d3034
|
||
|
|
71fb5b1616
|
||
|
|
6c8cdccbbf
|
||
|
|
4db986715c
|
||
|
|
c9aa0d9a16
|
||
|
|
51449abe6e
|
||
|
|
9c49c21e62
|
||
|
|
c1784f626a
|
||
|
|
c95b2fe0c3
|
||
|
|
9d0bf7e5af
|
||
|
|
3f4201b12c
|
||
|
|
33dce1ef17
|
||
|
|
2d01e726a9
|
||
|
|
a6b98a97f8
|
||
|
|
01efa399cf
|
||
|
|
590f0c3da9
|
||
|
|
1937307ae7
|
@@ -1,6 +1,8 @@
|
|||||||
# SharpbinV3
|
# SharpbinV3
|
||||||
|
|
||||||
Sharpbin is a pastebin-style website built with ASP.NET Core and SvelteKit.
|
Sharpbin is a [pastebin](https://en.wikipedia.org/wiki/Pastebin)-style website built with ASP.NET Core and SvelteKit.
|
||||||
|
|
||||||
|
A live instance is available at [sharpbin.cc](https://sharpbin.cc).
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
@@ -13,20 +15,17 @@ Sharpbin is a pastebin-style website built with ASP.NET Core and SvelteKit.
|
|||||||
- Server-side paste compression to save storage.
|
- Server-side paste compression to save storage.
|
||||||
- Captcha support via Cloudflare Turnstile.
|
- Captcha support via Cloudflare Turnstile.
|
||||||
|
|
||||||
## Project Structure
|
|
||||||
|
|
||||||
- **[SharpbinV3.Server](SharpbinV3.Server/README.md)**: Backend API built with C# and ASP.NET Core. Refer to its README for server-side development and configuration.
|
|
||||||
- **[SharpbinV3.Client](SharpbinV3.Client/README.md)**: Frontend application built with SvelteKit and TypeScript. Refer to its README for client-side development and setup.
|
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
The easiest way to run SharpbinV3 is using Docker Compose.
|
The easiest way to run SharpbinV3 is using Docker Compose.
|
||||||
|
|
||||||
1. Ensure Docker and Docker Compose are installed.
|
1. Ensure Docker and Docker Compose are installed.
|
||||||
2. Clone the repository.
|
2. Clone the repository.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/whoswhip/Sharpbin.git
|
git clone https://github.com/whoswhip/Sharpbin.git
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Run the following command in the root directory:
|
3. Run the following command in the root directory:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -61,3 +60,8 @@ You can configure the application using environment variables. When using Docker
|
|||||||
- `VIEW_INTERNAL_API_KEY`: Enforces views to be counted/recorded only by the frontend, if set it needs to be the same for both backend and frontend.
|
- `VIEW_INTERNAL_API_KEY`: Enforces views to be counted/recorded only by the frontend, if set it needs to be the same for both backend and frontend.
|
||||||
|
|
||||||
The frontend will be accessible at http://localhost:5173.
|
The frontend will be accessible at http://localhost:5173.
|
||||||
|
|
||||||
|
## Project Structure
|
||||||
|
|
||||||
|
- **[SharpbinV3.Server](SharpbinV3.Server/README.md)**: Backend API built with C# and ASP.NET Core. Refer to its README for server-side development and configuration.
|
||||||
|
- **[SharpbinV3.Client](SharpbinV3.Client/README.md)**: Frontend application built with SvelteKit and TypeScript. Refer to its README for client-side development and setup.
|
||||||
|
|||||||
Generated
+74
-7
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "sharpbinv3.client",
|
"name": "sharpbinv3.client",
|
||||||
"version": "0.0.1",
|
"version": "3.0.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "sharpbinv3.client",
|
"name": "sharpbinv3.client",
|
||||||
"version": "0.0.1",
|
"version": "3.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@lucide/svelte": "^0.562.0",
|
"@lucide/svelte": "^0.562.0",
|
||||||
"@sveltejs/adapter-node": "^5.4.0",
|
"@sveltejs/adapter-node": "^5.4.0",
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
"highlight.js": "^11.8.0",
|
"highlight.js": "^11.8.0",
|
||||||
"jsdom": "^27.4.0",
|
"jsdom": "^27.4.0",
|
||||||
"marked": "^17.0.1",
|
"marked": "^17.0.1",
|
||||||
|
"papaparse": "^5.5.3",
|
||||||
"qrcode": "^1.5.4"
|
"qrcode": "^1.5.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -26,6 +27,7 @@
|
|||||||
"@tailwindcss/vite": "^4.1.17",
|
"@tailwindcss/vite": "^4.1.17",
|
||||||
"@types/jsdom": "^27.0.0",
|
"@types/jsdom": "^27.0.0",
|
||||||
"@types/node": "^22",
|
"@types/node": "^22",
|
||||||
|
"@types/papaparse": "^5.5.2",
|
||||||
"@types/qrcode": "^1.5.6",
|
"@types/qrcode": "^1.5.6",
|
||||||
"eslint": "^9.39.1",
|
"eslint": "^9.39.1",
|
||||||
"eslint-config-prettier": "^10.1.8",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
@@ -34,8 +36,9 @@
|
|||||||
"prettier": "^3.7.4",
|
"prettier": "^3.7.4",
|
||||||
"prettier-plugin-svelte": "^3.4.0",
|
"prettier-plugin-svelte": "^3.4.0",
|
||||||
"prettier-plugin-tailwindcss": "^0.7.2",
|
"prettier-plugin-tailwindcss": "^0.7.2",
|
||||||
"svelte": "^5.45.6",
|
"svelte": "^5.48.3",
|
||||||
"svelte-check": "^4.3.4",
|
"svelte-check": "^4.3.4",
|
||||||
|
"tailwind-scrollbar": "^4.0.2",
|
||||||
"tailwindcss": "^4.1.17",
|
"tailwindcss": "^4.1.17",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^5.9.3",
|
||||||
"typescript-eslint": "^8.48.1",
|
"typescript-eslint": "^8.48.1",
|
||||||
@@ -1824,6 +1827,23 @@
|
|||||||
"undici-types": "~6.21.0"
|
"undici-types": "~6.21.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/papaparse": {
|
||||||
|
"version": "5.5.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/papaparse/-/papaparse-5.5.2.tgz",
|
||||||
|
"integrity": "sha512-gFnFp/JMzLHCwRf7tQHrNnfhN4eYBVYYI897CGX4MY1tzY9l2aLkVyx2IlKZ/SAqDbB3I1AOZW5gTMGGsqWliA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/prismjs": {
|
||||||
|
"version": "1.26.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/prismjs/-/prismjs-1.26.5.tgz",
|
||||||
|
"integrity": "sha512-AUZTa7hQ2KY5L7AmtSiqxlhWxb4ina0yd8hNbl4TWuqnv/pFP0nDMb3YrfSBf4hJVGLh2YEIBfKaBW/9UEl6IQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/@types/qrcode": {
|
"node_modules/@types/qrcode": {
|
||||||
"version": "1.5.6",
|
"version": "1.5.6",
|
||||||
"resolved": "https://registry.npmjs.org/@types/qrcode/-/qrcode-1.5.6.tgz",
|
"resolved": "https://registry.npmjs.org/@types/qrcode/-/qrcode-1.5.6.tgz",
|
||||||
@@ -3724,6 +3744,12 @@
|
|||||||
"node": ">=6"
|
"node": ">=6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/papaparse": {
|
||||||
|
"version": "5.5.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/papaparse/-/papaparse-5.5.3.tgz",
|
||||||
|
"integrity": "sha512-5QvjGxYVjxO59MGU2lHVYpRWBBtKHnlIAcSe1uNFCkkptUh63NFRj0FJQm7nR67puEruUci/ZkjmEFrjCAyP4A==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/parent-module": {
|
"node_modules/parent-module": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
|
||||||
@@ -4053,6 +4079,20 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/prism-react-renderer": {
|
||||||
|
"version": "2.4.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/prism-react-renderer/-/prism-react-renderer-2.4.1.tgz",
|
||||||
|
"integrity": "sha512-ey8Ls/+Di31eqzUxC46h8MksNuGx/n0AAC8uKpwFau4RPDYLuE3EXTp8N8G2vX2N7UC/+IXeNUnlWBGGcAG+Ig==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/prismjs": "^1.26.0",
|
||||||
|
"clsx": "^2.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": ">=16.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/punycode": {
|
"node_modules/punycode": {
|
||||||
"version": "2.3.1",
|
"version": "2.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
|
||||||
@@ -4079,6 +4119,17 @@
|
|||||||
"node": ">=10.13.0"
|
"node": ">=10.13.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/react": {
|
||||||
|
"version": "19.2.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/react/-/react-19.2.3.tgz",
|
||||||
|
"integrity": "sha512-Ku/hhYbVjOQnXDZFv2+RibmLFGwFdeeKHFcOTlrt7xplBnya5OGn/hIRDsqDiSUcfORsDC7MPxwork8jBwsIWA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/readdirp": {
|
"node_modules/readdirp": {
|
||||||
"version": "4.1.2",
|
"version": "4.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz",
|
||||||
@@ -4348,9 +4399,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/svelte": {
|
"node_modules/svelte": {
|
||||||
"version": "5.46.1",
|
"version": "5.48.3",
|
||||||
"resolved": "https://registry.npmjs.org/svelte/-/svelte-5.46.1.tgz",
|
"resolved": "https://registry.npmjs.org/svelte/-/svelte-5.48.3.tgz",
|
||||||
"integrity": "sha512-ynjfCHD3nP2el70kN5Pmg37sSi0EjOm9FgHYQdC4giWG/hzO3AatzXXJJgP305uIhGQxSufJLuYWtkY8uK/8RA==",
|
"integrity": "sha512-w7QZ398cdNherTdiQ/v3SYLLGOO4948Jgjh04PYqtTYVohmBvbmFwLmo7pp8gp4/1tceRWfSTjHgjtfpCVNJmQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jridgewell/remapping": "^2.3.4",
|
"@jridgewell/remapping": "^2.3.4",
|
||||||
@@ -4361,7 +4412,7 @@
|
|||||||
"aria-query": "^5.3.1",
|
"aria-query": "^5.3.1",
|
||||||
"axobject-query": "^4.1.0",
|
"axobject-query": "^4.1.0",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"devalue": "^5.5.0",
|
"devalue": "^5.6.2",
|
||||||
"esm-env": "^1.2.1",
|
"esm-env": "^1.2.1",
|
||||||
"esrap": "^2.2.1",
|
"esrap": "^2.2.1",
|
||||||
"is-reference": "^3.0.3",
|
"is-reference": "^3.0.3",
|
||||||
@@ -4433,6 +4484,22 @@
|
|||||||
"integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==",
|
"integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/tailwind-scrollbar": {
|
||||||
|
"version": "4.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/tailwind-scrollbar/-/tailwind-scrollbar-4.0.2.tgz",
|
||||||
|
"integrity": "sha512-wAQiIxAPqk0MNTPptVe/xoyWi27y+NRGnTwvn4PQnbvB9kp8QUBiGl/wsfoVBHnQxTmhXJSNt9NHTmcz9EivFA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"prism-react-renderer": "^2.4.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12.13.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"tailwindcss": "4.x"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/tailwindcss": {
|
"node_modules/tailwindcss": {
|
||||||
"version": "4.1.18",
|
"version": "4.1.18",
|
||||||
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.1.18.tgz",
|
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.1.18.tgz",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "sharpbinv3.client",
|
"name": "sharpbinv3.client",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "3.0.0",
|
"version": "3.0.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite dev",
|
"dev": "vite dev",
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
"@tailwindcss/vite": "^4.1.17",
|
"@tailwindcss/vite": "^4.1.17",
|
||||||
"@types/jsdom": "^27.0.0",
|
"@types/jsdom": "^27.0.0",
|
||||||
"@types/node": "^22",
|
"@types/node": "^22",
|
||||||
|
"@types/papaparse": "^5.5.2",
|
||||||
"@types/qrcode": "^1.5.6",
|
"@types/qrcode": "^1.5.6",
|
||||||
"eslint": "^9.39.1",
|
"eslint": "^9.39.1",
|
||||||
"eslint-config-prettier": "^10.1.8",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
@@ -30,8 +31,9 @@
|
|||||||
"prettier": "^3.7.4",
|
"prettier": "^3.7.4",
|
||||||
"prettier-plugin-svelte": "^3.4.0",
|
"prettier-plugin-svelte": "^3.4.0",
|
||||||
"prettier-plugin-tailwindcss": "^0.7.2",
|
"prettier-plugin-tailwindcss": "^0.7.2",
|
||||||
"svelte": "^5.45.6",
|
"svelte": "^5.48.3",
|
||||||
"svelte-check": "^4.3.4",
|
"svelte-check": "^4.3.4",
|
||||||
|
"tailwind-scrollbar": "^4.0.2",
|
||||||
"tailwindcss": "^4.1.17",
|
"tailwindcss": "^4.1.17",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^5.9.3",
|
||||||
"typescript-eslint": "^8.48.1",
|
"typescript-eslint": "^8.48.1",
|
||||||
@@ -45,6 +47,7 @@
|
|||||||
"highlight.js": "^11.8.0",
|
"highlight.js": "^11.8.0",
|
||||||
"jsdom": "^27.4.0",
|
"jsdom": "^27.4.0",
|
||||||
"marked": "^17.0.1",
|
"marked": "^17.0.1",
|
||||||
|
"papaparse": "^5.5.3",
|
||||||
"qrcode": "^1.5.4"
|
"qrcode": "^1.5.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
let isOpen = false;
|
let isOpen = false;
|
||||||
let searchQuery = '';
|
let searchQuery = '';
|
||||||
let dropdownElement: HTMLDivElement;
|
let dropdownElement: HTMLDivElement;
|
||||||
|
let dropdownListElement: HTMLDivElement;
|
||||||
|
let dropdownMaxHeight = '12rem';
|
||||||
|
|
||||||
$: filteredOptions = searchable
|
$: filteredOptions = searchable
|
||||||
? options.filter(
|
? options.filter(
|
||||||
@@ -39,10 +41,18 @@
|
|||||||
|
|
||||||
function toggleDropdown() {
|
function toggleDropdown() {
|
||||||
isOpen = !isOpen;
|
isOpen = !isOpen;
|
||||||
if (isOpen && searchable) {
|
if (isOpen) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
if (dropdownElement && dropdownListElement) {
|
||||||
|
const rect = dropdownElement.getBoundingClientRect();
|
||||||
|
const spaceBelow = window.innerHeight - rect.bottom - 8;
|
||||||
|
const maxCap = 416;
|
||||||
|
dropdownMaxHeight = Math.max(120, Math.min(spaceBelow, maxCap)) + 'px';
|
||||||
|
}
|
||||||
|
if (searchable) {
|
||||||
const input = dropdownElement?.querySelector('input[type="text"]') as HTMLInputElement;
|
const input = dropdownElement?.querySelector('input[type="text"]') as HTMLInputElement;
|
||||||
input?.focus();
|
input?.focus();
|
||||||
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,8 +80,11 @@
|
|||||||
<div
|
<div
|
||||||
class="absolute top-full z-50 mt-1 w-full rounded border border-neutral-700 bg-neutral-800 shadow-lg"
|
class="absolute top-full z-50 mt-1 w-full rounded border border-neutral-700 bg-neutral-800 shadow-lg"
|
||||||
class:dropdown-sm-list={variant === 'sm'}
|
class:dropdown-sm-list={variant === 'sm'}
|
||||||
|
bind:this={dropdownListElement}
|
||||||
|
style="max-height: {dropdownMaxHeight}; width: 100%;"
|
||||||
>
|
>
|
||||||
{#if searchable}
|
{#if searchable}
|
||||||
|
<div style="position: sticky; top: 0; z-index: 1; background: inherit;">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Search..."
|
placeholder="Search..."
|
||||||
@@ -80,9 +93,9 @@
|
|||||||
bind:value={searchQuery}
|
bind:value={searchQuery}
|
||||||
on:keydown={handleKeyDown}
|
on:keydown={handleKeyDown}
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
<div class="scrollbar-thin scrollbar-thumb-neutral-600 scrollbar-track-neutral-700" style="overflow-y: auto; max-height: calc({dropdownMaxHeight} - 3rem);">
|
||||||
<div class="max-h-48 overflow-y-auto">
|
|
||||||
{#each filteredOptions as option (option.value)}
|
{#each filteredOptions as option (option.value)}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
@@ -230,7 +230,9 @@
|
|||||||
}
|
}
|
||||||
turnstileWidgetId = window.turnstile.render(turnstileEl, {
|
turnstileWidgetId = window.turnstile.render(turnstileEl, {
|
||||||
sitekey: reportSiteKey,
|
sitekey: reportSiteKey,
|
||||||
theme: 'dark'
|
theme: 'dark',
|
||||||
|
size: 'flexible',
|
||||||
|
appearence: 'interaction-only'
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
if (window.turnstile) {
|
if (window.turnstile) {
|
||||||
@@ -480,9 +482,7 @@
|
|||||||
class="h-28 w-full resize-none rounded border border-neutral-700 bg-neutral-800 p-2 text-white outline-none"
|
class="h-28 w-full resize-none rounded border border-neutral-700 bg-neutral-800 p-2 text-white outline-none"
|
||||||
></textarea>
|
></textarea>
|
||||||
{#if reportSiteKey}
|
{#if reportSiteKey}
|
||||||
<div class="flex justify-center">
|
<div class="cf-turnstile w-full" bind:this={turnstileEl}></div>
|
||||||
<div class="cf-turnstile" bind:this={turnstileEl}></div>
|
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
import type { PageData } from '../../routes/$types';
|
import type { PageData } from '../../routes/$types';
|
||||||
import { slide } from 'svelte/transition';
|
import { slide } from 'svelte/transition';
|
||||||
import { Menu, X } from '@lucide/svelte';
|
import { Menu, X } from '@lucide/svelte';
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
|
||||||
function logout() {
|
function logout() {
|
||||||
clearTokens();
|
clearTokens();
|
||||||
@@ -23,9 +24,24 @@
|
|||||||
currentPath !== '/' && !currentPath.startsWith('/login') && !currentPath.startsWith('/register')
|
currentPath !== '/' && !currentPath.startsWith('/login') && !currentPath.startsWith('/register')
|
||||||
? `?return=${encodeURIComponent(page.url.pathname + page.url.search)}`
|
? `?return=${encodeURIComponent(page.url.pathname + page.url.search)}`
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
|
function handleClickOutside(event: MouseEvent) {
|
||||||
|
const navbar = document.getElementById('navbar');
|
||||||
|
const mobileMenu = document.getElementById('mobile-menu');
|
||||||
|
if (menuOpen && mobileMenu && navbar && !navbar.contains(event.target as Node)) {
|
||||||
|
menuOpen = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
document.addEventListener('click', handleClickOutside);
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener('click', handleClickOutside);
|
||||||
|
};
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="top-0 left-0 z-100 h-15 w-full bg-neutral-900">
|
<div class="top-0 left-0 z-100 h-15 w-full bg-neutral-900" id="navbar">
|
||||||
<div class="mx-auto hidden h-15 w-[95%] max-w-7xl items-center py-2 md:flex">
|
<div class="mx-auto hidden h-15 w-[95%] max-w-7xl items-center py-2 md:flex">
|
||||||
<div>
|
<div>
|
||||||
<a href={resolve('/')} class="text-xl font-bold text-white hover:text-neutral-300">Sharpbin</a
|
<a href={resolve('/')} class="text-xl font-bold text-white hover:text-neutral-300">Sharpbin</a
|
||||||
@@ -80,15 +96,16 @@
|
|||||||
aria-expanded={menuOpen}
|
aria-expanded={menuOpen}
|
||||||
>
|
>
|
||||||
{#if menuOpen}
|
{#if menuOpen}
|
||||||
<X class="h-6 w-6 text-white" />
|
<X class="pointer-events-none h-6 w-6 text-white" />
|
||||||
{:else}
|
{:else}
|
||||||
<Menu class="h-6 w-6 text-white" />
|
<Menu class="pointer-events-none h-6 w-6 text-white" />
|
||||||
{/if}
|
{/if}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{#if menuOpen}
|
{#if menuOpen}
|
||||||
<div
|
<div
|
||||||
class="mx-auto mb-2 w-full rounded-b border-b border-neutral-800 bg-neutral-900 px-2 py-3 md:hidden"
|
class="mx-auto mb-2 w-full rounded-b border-b border-neutral-800 bg-neutral-900 px-2 py-3 md:hidden"
|
||||||
|
id="mobile-menu"
|
||||||
in:slide={{ duration: 180 }}
|
in:slide={{ duration: 180 }}
|
||||||
out:slide={{ duration: 180 }}
|
out:slide={{ duration: 180 }}
|
||||||
style="z-index:1000;position:relative;"
|
style="z-index:1000;position:relative;"
|
||||||
|
|||||||
@@ -7,21 +7,106 @@
|
|||||||
formatBytes
|
formatBytes
|
||||||
} from '$lib/utils/misc';
|
} from '$lib/utils/misc';
|
||||||
import { resolve } from '$app/paths';
|
import { resolve } from '$app/paths';
|
||||||
import { Eye, FileBox, Code, User, History, Calendar, Timer } from '@lucide/svelte';
|
import {
|
||||||
|
Eye,
|
||||||
|
FileBox,
|
||||||
|
Code,
|
||||||
|
User,
|
||||||
|
History,
|
||||||
|
Calendar,
|
||||||
|
Timer,
|
||||||
|
Lock,
|
||||||
|
EyeOff,
|
||||||
|
Globe
|
||||||
|
} from '@lucide/svelte';
|
||||||
import { syntaxes } from '$lib/consts';
|
import { syntaxes } from '$lib/consts';
|
||||||
import type { Paste } from '$lib/types/paste';
|
import type { Paste } from '$lib/types/paste';
|
||||||
|
|
||||||
export let paste: Paste;
|
export let paste: Paste;
|
||||||
export let now: Date;
|
export let now: Date;
|
||||||
|
export let showUser: boolean = true;
|
||||||
|
export let compact: boolean = false;
|
||||||
|
|
||||||
const createdAt = extractDateFromUUIDv7(paste.uuid);
|
const createdAt = extractDateFromUUIDv7(paste.uuid);
|
||||||
const syntax = syntaxes[paste.syntax] ?? syntaxes['plaintext'];
|
const syntax = syntaxes[paste.syntax] ?? syntaxes['plaintext'];
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<a
|
{#if compact}
|
||||||
|
<a
|
||||||
|
href={resolve(`/${paste.id}`)}
|
||||||
|
class="flex flex-col gap-1 rounded border border-neutral-700 bg-neutral-800 px-4 py-3 transition-colors duration-200 hover:bg-neutral-700 focus:ring-2 focus:ring-neutral-600 focus:outline-none"
|
||||||
|
>
|
||||||
|
<div class="flex w-full flex-row justify-between">
|
||||||
|
<span
|
||||||
|
class="text-md w-fit max-w-full truncate font-semibold text-neutral-100 hover:text-white"
|
||||||
|
use:tooltip={paste.title || 'Untitled Paste'}
|
||||||
|
>
|
||||||
|
{paste.title || 'Untitled Paste'}
|
||||||
|
</span>
|
||||||
|
<div
|
||||||
|
class="flex items-center gap-2 text-sm text-neutral-400"
|
||||||
|
use:tooltip={`${createdAt?.toLocaleString()} • ${dateToRelativeString(createdAt ?? new Date(), true, false, now)}`}
|
||||||
|
>
|
||||||
|
<Calendar class="h-4 w-4" />
|
||||||
|
{#if createdAt}
|
||||||
|
{#if createdAt.getTime() > Date.now() - 86_400_000}
|
||||||
|
Created {dateToRelativeString(createdAt, true, false, now)}
|
||||||
|
{:else}
|
||||||
|
Created on {createdAt.toLocaleDateString()}
|
||||||
|
{/if}
|
||||||
|
{:else}
|
||||||
|
Creation date unknown
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex flex-row justify-between text-sm text-neutral-400">
|
||||||
|
<div>
|
||||||
|
{#if showUser}
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<User class="h-4 w-4" />
|
||||||
|
{paste.author?.username ?? 'Anonymous'}
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
{#if paste.visibility === 0}
|
||||||
|
<Globe class="h-4 w-4" />
|
||||||
|
Public
|
||||||
|
{:else if paste.visibility === 1}
|
||||||
|
<EyeOff class="h-4 w-4" />
|
||||||
|
Unlisted
|
||||||
|
{:else}
|
||||||
|
<Lock class="h-4 w-4" />
|
||||||
|
Private
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<Eye class="h-4 w-4" />
|
||||||
|
|
||||||
|
{formatNumber(paste.views)} View{paste.views !== 1 ? 's' : ''}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
class="flex items-center gap-2"
|
||||||
|
use:tooltip={paste.isCompressed ? `Compressed Size: ${formatBytes(paste.size)}` : ''}
|
||||||
|
>
|
||||||
|
<FileBox class="h-4 w-4" />
|
||||||
|
{formatBytes(paste.trueSize)}
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<Code class="h-4 w-4" />
|
||||||
|
{syntax.name}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
{:else}
|
||||||
|
<a
|
||||||
href={resolve(`/${paste.id}`)}
|
href={resolve(`/${paste.id}`)}
|
||||||
class="flex flex-col gap-2 rounded border border-neutral-700 bg-neutral-800 px-5 py-4 transition-colors duration-200 hover:bg-neutral-700 focus:ring-2 focus:ring-neutral-600 focus:outline-none"
|
class="flex flex-col gap-2 rounded border border-neutral-700 bg-neutral-800 px-5 py-4 transition-colors duration-200 hover:bg-neutral-700 focus:ring-2 focus:ring-neutral-600 focus:outline-none"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
class="w-fit max-w-full truncate text-lg font-semibold text-neutral-100 hover:text-white"
|
class="w-fit max-w-full truncate text-lg font-semibold text-neutral-100 hover:text-white"
|
||||||
use:tooltip={paste.title || 'Untitled Paste'}
|
use:tooltip={paste.title || 'Untitled Paste'}
|
||||||
@@ -60,10 +145,12 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if showUser}
|
||||||
<div class="mt-1 flex items-center gap-2 text-sm text-neutral-400">
|
<div class="mt-1 flex items-center gap-2 text-sm text-neutral-400">
|
||||||
<User class="h-4 w-4" />
|
<User class="h-4 w-4" />
|
||||||
<span>{paste.author?.username ?? 'Anonymous'}</span>
|
<span>{paste.author?.username ?? 'Anonymous'}</span>
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
{#if paste.editedAt}
|
{#if paste.editedAt}
|
||||||
<div
|
<div
|
||||||
class="mt-1 flex items-center gap-2 text-sm text-neutral-400"
|
class="mt-1 flex items-center gap-2 text-sm text-neutral-400"
|
||||||
@@ -92,4 +179,5 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
{/if}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ export const syntaxes: Record<string, Syntax> = {
|
|||||||
crystal: { name: 'Crystal', extension: '.cr' },
|
crystal: { name: 'Crystal', extension: '.cr' },
|
||||||
csharp: { name: 'C#', extension: '.cs' },
|
csharp: { name: 'C#', extension: '.cs' },
|
||||||
css: { name: 'CSS', extension: '.css' },
|
css: { name: 'CSS', extension: '.css' },
|
||||||
|
csv: { name: 'CSV', extension: '.csv' },
|
||||||
cue: { name: 'CUE', extension: '.cue' },
|
cue: { name: 'CUE', extension: '.cue' },
|
||||||
d: { name: 'D', extension: '.d' },
|
d: { name: 'D', extension: '.d' },
|
||||||
dart: { name: 'Dart', extension: '.dart' },
|
dart: { name: 'Dart', extension: '.dart' },
|
||||||
@@ -156,6 +157,26 @@ export const syntaxes: Record<string, Syntax> = {
|
|||||||
zenscript: { name: 'ZenScript', extension: '.zs' }
|
zenscript: { name: 'ZenScript', extension: '.zs' }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const expiresOptions = [
|
||||||
|
{ value: 0, label: 'Never Expire' },
|
||||||
|
{ value: 30000, label: 'Expire in 5 Minutes' },
|
||||||
|
{ value: 600000, label: 'Expire in 10 Minutes' },
|
||||||
|
{ value: 1800000, label: 'Expire in 30 Minutes' },
|
||||||
|
{ value: 3600000, label: 'Expire in 1 Hour' },
|
||||||
|
{ value: 21600000, label: 'Expire in 6 Hours' },
|
||||||
|
{ value: 43200000, label: 'Expire in 12 Hours' },
|
||||||
|
{ value: 86400000, label: 'Expire in 1 Day' },
|
||||||
|
{ value: 604800000, label: 'Expire in 1 Week' },
|
||||||
|
{ value: 1209600000, label: 'Expire in 2 Weeks' },
|
||||||
|
{ value: 2592000000, label: 'Expire in 1 Month' },
|
||||||
|
{ value: 7776000000, label: 'Expire in 3 Months' },
|
||||||
|
{ value: 15552000000, label: 'Expire in 6 Months' },
|
||||||
|
{ value: 31536000000, label: 'Expire in 1 Year' },
|
||||||
|
{ value: 63072000000, label: 'Expire in 2 Years' },
|
||||||
|
{ value: 157680000000, label: 'Expire in 5 Years' },
|
||||||
|
{ value: 315360000000, label: 'Expire in 10 Years' }
|
||||||
|
];
|
||||||
|
|
||||||
export const roles = {
|
export const roles = {
|
||||||
0: 'User',
|
0: 'User',
|
||||||
1: 'Moderator',
|
1: 'Moderator',
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { PageData } from './$types';
|
import type { PageData } from './$types';
|
||||||
import { syntaxes } from '$lib/consts';
|
import { syntaxes, expiresOptions } from '$lib/consts';
|
||||||
import { user } from '$lib/stores/user';
|
import { user } from '$lib/stores/user';
|
||||||
import { getToken } from '$lib/utils/auth';
|
import { getToken } from '$lib/utils/auth';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
|
|
||||||
let textArea: HTMLTextAreaElement;
|
let textArea: HTMLTextAreaElement;
|
||||||
|
let markdownConatiner: HTMLDivElement;
|
||||||
|
|
||||||
let error = '';
|
let error = '';
|
||||||
let title = '';
|
let title = '';
|
||||||
@@ -54,25 +55,34 @@
|
|||||||
renderedMarkdown = await parseMarkdown(content, false);
|
renderedMarkdown = await parseMarkdown(content, false);
|
||||||
}
|
}
|
||||||
previewMode = toPreview;
|
previewMode = toPreview;
|
||||||
if (!toPreview) {
|
requestAnimationFrame(() => resize(previewMode));
|
||||||
requestAnimationFrame(resize);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function resize() {
|
function resize(markdown: boolean = false) {
|
||||||
if (!textArea) return;
|
if ((!markdown && !textArea) || (markdown && !markdownConatiner)) return;
|
||||||
|
|
||||||
|
let h: number;
|
||||||
|
let max: number;
|
||||||
|
let element = markdown ? markdownConatiner : textArea;
|
||||||
|
|
||||||
|
if (!markdown) {
|
||||||
textArea.style.height = 'auto';
|
textArea.style.height = 'auto';
|
||||||
|
|
||||||
const h = textArea.scrollHeight;
|
h = textArea.scrollHeight;
|
||||||
const max = MAX_HEIGHT();
|
max = MAX_HEIGHT();
|
||||||
|
} else {
|
||||||
|
markdownConatiner.style.height = 'auto';
|
||||||
|
|
||||||
|
h = markdownConatiner.scrollHeight;
|
||||||
|
max = MAX_HEIGHT();
|
||||||
|
}
|
||||||
|
|
||||||
if (h > max) {
|
if (h > max) {
|
||||||
textArea.style.height = max + 'px';
|
element.style.height = max + 'px';
|
||||||
textArea.style.overflowY = 'auto';
|
element.style.overflowY = 'auto';
|
||||||
} else {
|
} else {
|
||||||
textArea.style.height = h + 'px';
|
element.style.height = h + 'px';
|
||||||
textArea.style.overflowY = 'hidden';
|
element.style.overflowY = 'hidden';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +96,9 @@
|
|||||||
) {
|
) {
|
||||||
window.turnstile.render('.cf-turnstile', {
|
window.turnstile.render('.cf-turnstile', {
|
||||||
sitekey: data.auth.cf_turnstile_site_key,
|
sitekey: data.auth.cf_turnstile_site_key,
|
||||||
theme: 'dark'
|
theme: 'dark',
|
||||||
|
size: 'flexible',
|
||||||
|
appearence: 'interaction-only'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -108,22 +120,6 @@
|
|||||||
label: syntaxes[lang]?.name ?? lang.charAt(0).toUpperCase() + lang.slice(1)
|
label: syntaxes[lang]?.name ?? lang.charAt(0).toUpperCase() + lang.slice(1)
|
||||||
})) ?? [];
|
})) ?? [];
|
||||||
|
|
||||||
const expiresOptions = [
|
|
||||||
{ value: 0, label: 'Never Expire' },
|
|
||||||
{ value: 600000, label: 'Expire in 10 Minutes' },
|
|
||||||
{ value: 3600000, label: 'Expire in 1 Hour' },
|
|
||||||
{ value: 86400000, label: 'Expire in 1 Day' },
|
|
||||||
{ value: 604800000, label: 'Expire in 1 Week' },
|
|
||||||
{ value: 1209600000, label: 'Expire in 2 Weeks' },
|
|
||||||
{ value: 2592000000, label: 'Expire in 1 Month' },
|
|
||||||
{ value: 7776000000, label: 'Expire in 3 Months' },
|
|
||||||
{ value: 15552000000, label: 'Expire in 6 Months' },
|
|
||||||
{ value: 31536000000, label: 'Expire in 1 Year' },
|
|
||||||
{ value: 63072000000, label: 'Expire in 2 Years' },
|
|
||||||
{ value: 157680000000, label: 'Expire in 5 Years' },
|
|
||||||
{ value: 315360000000, label: 'Expire in 10 Years' }
|
|
||||||
];
|
|
||||||
|
|
||||||
const visibilityOptions =
|
const visibilityOptions =
|
||||||
data.options?.visibilities?.map((visibility: { value: number; displayName: string }) => ({
|
data.options?.visibilities?.map((visibility: { value: number; displayName: string }) => ({
|
||||||
value: visibility.value,
|
value: visibility.value,
|
||||||
@@ -256,7 +252,9 @@
|
|||||||
<div
|
<div
|
||||||
class="markdown min-h-20 w-full overflow-y-auto rounded rounded-b-none border border-neutral-700 bg-neutral-800 p-2 transition-colors duration-200"
|
class="markdown min-h-20 w-full overflow-y-auto rounded rounded-b-none border border-neutral-700 bg-neutral-800 p-2 transition-colors duration-200"
|
||||||
style="height: {previewHeight}"
|
style="height: {previewHeight}"
|
||||||
|
bind:this={markdownConatiner}
|
||||||
>
|
>
|
||||||
|
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
||||||
{@html renderedMarkdown}
|
{@html renderedMarkdown}
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
@@ -268,9 +266,9 @@
|
|||||||
minlength="1"
|
minlength="1"
|
||||||
bind:this={textArea}
|
bind:this={textArea}
|
||||||
bind:value={content}
|
bind:value={content}
|
||||||
on:input={resize}
|
on:input={() => resize()}
|
||||||
on:change={resize}
|
on:change={() => resize()}
|
||||||
on:focus={resize}
|
on:focus={() => resize()}
|
||||||
on:beforeinput={(e) => {
|
on:beforeinput={(e) => {
|
||||||
if (!data.options?.maxPasteSize) return;
|
if (!data.options?.maxPasteSize) return;
|
||||||
|
|
||||||
@@ -299,7 +297,7 @@
|
|||||||
isDragging = false;
|
isDragging = false;
|
||||||
}}
|
}}
|
||||||
on:drop={(e) => {
|
on:drop={(e) => {
|
||||||
requestAnimationFrame(resize);
|
requestAnimationFrame(() => resize());
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
isDragging = false;
|
isDragging = false;
|
||||||
|
|
||||||
@@ -363,7 +361,7 @@
|
|||||||
<div class="mt-1 flex">
|
<div class="mt-1 flex">
|
||||||
{#if selectedSyntax === 'markdown'}
|
{#if selectedSyntax === 'markdown'}
|
||||||
<div
|
<div
|
||||||
class="monospace mb-2 flex h-12 w-36 items-center justify-between gap-1 rounded-bl border border-neutral-700 bg-neutral-800 p-1 text-sm text-neutral-400 md:h-8"
|
class="monospace mb-2 flex min-h-full w-36 items-center justify-between gap-1 rounded-bl border border-neutral-700 bg-neutral-800 p-1 text-sm text-neutral-400 md:h-8"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
@@ -386,10 +384,10 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div
|
<div
|
||||||
class="monospace mb-2 flex h-12 items-center justify-between {selectedSyntax ===
|
class="monospace mb-2 flex h-fit min-h-12 items-center justify-between {selectedSyntax ===
|
||||||
'markdown'
|
'markdown'
|
||||||
? 'ml-auto w-[calc(100%-150px)] rounded-br'
|
? 'ml-auto w-[calc(100%-150px)] rounded-br'
|
||||||
: 'w-full rounded-b'} border border-neutral-700 bg-neutral-800 p-1 pr-2 pl-2 text-sm text-neutral-400 md:h-8"
|
: 'w-full rounded-b'} border border-neutral-700 bg-neutral-800 p-1 pr-2 pl-2 text-sm text-neutral-400 md:h-8 md:min-h-8"
|
||||||
>
|
>
|
||||||
<div class="flex flex-col md:flex-row md:gap-2">
|
<div class="flex flex-col md:flex-row md:gap-2">
|
||||||
<span>
|
<span>
|
||||||
@@ -430,7 +428,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{#if selectedVisibility === 2}
|
{#if selectedVisibility === 2}
|
||||||
<div class="flex w-full mb-2">
|
<div class="mb-2 flex w-full">
|
||||||
<input
|
<input
|
||||||
type={passwordVisible ? 'text' : 'password'}
|
type={passwordVisible ? 'text' : 'password'}
|
||||||
placeholder="Password for private paste"
|
placeholder="Password for private paste"
|
||||||
@@ -479,11 +477,7 @@
|
|||||||
</label>
|
</label>
|
||||||
{/if}
|
{/if}
|
||||||
{#if data.options?.requiresVerification && data.auth?.cf_turnstile_site_key}
|
{#if data.options?.requiresVerification && data.auth?.cf_turnstile_site_key}
|
||||||
<div
|
<div class="cf-turnstile mb-1 w-full" data-sitekey={data.auth.cf_turnstile_site_key}></div>
|
||||||
class="mb-2 flex min-h-16.25 w-auto items-center justify-center rounded border border-neutral-700 bg-neutral-800 p-2 pb-1"
|
|
||||||
>
|
|
||||||
<div class="cf-turnstile" data-sitekey={data.auth.cf_turnstile_site_key}></div>
|
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import hljs from 'highlight.js';
|
import hljs from 'highlight.js';
|
||||||
|
import Papa from 'papaparse';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import type { PageData } from './$types';
|
import type { PageData } from './$types';
|
||||||
import {
|
import {
|
||||||
File,
|
File,
|
||||||
FileBox,
|
FileBox,
|
||||||
Eye,
|
Eye,
|
||||||
EyeClosed,
|
Globe,
|
||||||
|
Lock,
|
||||||
EyeOff,
|
EyeOff,
|
||||||
User,
|
User,
|
||||||
CalendarDays,
|
CalendarDays,
|
||||||
@@ -32,7 +34,7 @@
|
|||||||
isBinaryData
|
isBinaryData
|
||||||
} from '$lib/utils/misc';
|
} from '$lib/utils/misc';
|
||||||
import { parseMarkdown } from '$lib/utils/markdown';
|
import { parseMarkdown } from '$lib/utils/markdown';
|
||||||
import { syntaxes } from '$lib/consts';
|
import { syntaxes, expiresOptions } from '$lib/consts';
|
||||||
import { resolve } from '$app/paths';
|
import { resolve } from '$app/paths';
|
||||||
import { decryptAES, encryptAES } from '$lib/utils/encryption';
|
import { decryptAES, encryptAES } from '$lib/utils/encryption';
|
||||||
import { fade } from 'svelte/transition';
|
import { fade } from 'svelte/transition';
|
||||||
@@ -73,21 +75,7 @@
|
|||||||
value: lang,
|
value: lang,
|
||||||
label: syntaxes[lang]?.name ?? lang.charAt(0).toUpperCase() + lang.slice(1)
|
label: syntaxes[lang]?.name ?? lang.charAt(0).toUpperCase() + lang.slice(1)
|
||||||
})) ?? [];
|
})) ?? [];
|
||||||
const expiresOptions = [
|
|
||||||
{ value: 0, label: 'Never Expire' },
|
|
||||||
{ value: 600000, label: 'Expire in 10 Minutes' },
|
|
||||||
{ value: 3600000, label: 'Expire in 1 Hour' },
|
|
||||||
{ value: 86400000, label: 'Expire in 1 Day' },
|
|
||||||
{ value: 604800000, label: 'Expire in 1 Week' },
|
|
||||||
{ value: 1209600000, label: 'Expire in 2 Weeks' },
|
|
||||||
{ value: 2592000000, label: 'Expire in 1 Month' },
|
|
||||||
{ value: 7776000000, label: 'Expire in 3 Months' },
|
|
||||||
{ value: 15552000000, label: 'Expire in 6 Months' },
|
|
||||||
{ value: 31536000000, label: 'Expire in 1 Year' },
|
|
||||||
{ value: 63072000000, label: 'Expire in 2 Years' },
|
|
||||||
{ value: 157680000000, label: 'Expire in 5 Years' },
|
|
||||||
{ value: 315360000000, label: 'Expire in 10 Years' }
|
|
||||||
];
|
|
||||||
const visibilityOptions =
|
const visibilityOptions =
|
||||||
data.options?.visibilities?.map((visibility: { value: number; displayName: string }) => ({
|
data.options?.visibilities?.map((visibility: { value: number; displayName: string }) => ({
|
||||||
value: visibility.value,
|
value: visibility.value,
|
||||||
@@ -147,6 +135,11 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lang === 'csv') {
|
||||||
|
await renderCsv(code);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let highlighted = '';
|
let highlighted = '';
|
||||||
try {
|
try {
|
||||||
if (lang === 'plaintext') {
|
if (lang === 'plaintext') {
|
||||||
@@ -173,6 +166,52 @@
|
|||||||
decryptStatus = '';
|
decryptStatus = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function renderCsv(content: string) {
|
||||||
|
try {
|
||||||
|
const results = Papa.parse(content, {
|
||||||
|
header: false,
|
||||||
|
skipEmptyLines: true,
|
||||||
|
dynamicTyping: false
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!results.data || results.data.length === 0) {
|
||||||
|
pasteContent = '<div class="p-4 text-neutral-400">No data in CSV</div>';
|
||||||
|
contentRendered = true;
|
||||||
|
decryptStatus = '';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const rows = results.data as string[][];
|
||||||
|
const [header, ...body] = rows;
|
||||||
|
|
||||||
|
const escape = (v: string) =>
|
||||||
|
v.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
||||||
|
|
||||||
|
const tableHtml = `
|
||||||
|
<table class="csv-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
${header.map((c) => `<th>${c ? escape(c) : ''}</th>`).join('')}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
${body
|
||||||
|
.map((row) => `<tr>${row.map((c) => `<td>${c ? escape(c) : ''}</td>`).join('')}</tr>`)
|
||||||
|
.join('')}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
`;
|
||||||
|
|
||||||
|
pasteContent = tableHtml;
|
||||||
|
contentRendered = true;
|
||||||
|
decryptStatus = '';
|
||||||
|
} catch {
|
||||||
|
pasteContent = '<div class="p-4 text-red-400">Failed to parse CSV</div>';
|
||||||
|
contentRendered = true;
|
||||||
|
decryptStatus = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function updatePaste(content: string | null, metadata: Paste | null) {
|
async function updatePaste(content: string | null, metadata: Paste | null) {
|
||||||
editError = '';
|
editError = '';
|
||||||
editLoading = true;
|
editLoading = true;
|
||||||
@@ -429,7 +468,7 @@
|
|||||||
<meta property="og:title" content={data.paste.title || 'Untitled Paste'} />
|
<meta property="og:title" content={data.paste.title || 'Untitled Paste'} />
|
||||||
<meta
|
<meta
|
||||||
property="og:description"
|
property="og:description"
|
||||||
content={`A ${data.paste.syntax} paste on Sharpbin created by ${
|
content={`A ${syntaxes[data.paste.syntax].name} paste on Sharpbin created by ${
|
||||||
data.paste.author ? data.paste.author.username : 'Anonymous'
|
data.paste.author ? data.paste.author.username : 'Anonymous'
|
||||||
}, created on ${
|
}, created on ${
|
||||||
extractDateFromUUIDv7(data.paste.uuid)?.toLocaleDateString() ?? 'Unknown Date'
|
extractDateFromUUIDv7(data.paste.uuid)?.toLocaleDateString() ?? 'Unknown Date'
|
||||||
@@ -494,9 +533,13 @@
|
|||||||
<div class="relative flex shrink-0 items-center">
|
<div class="relative flex shrink-0 items-center">
|
||||||
<div
|
<div
|
||||||
class="flex"
|
class="flex"
|
||||||
use:tooltip={data.paste.isCompressed
|
use:tooltip={`${
|
||||||
? `Compressed Size: ${formatBytes(data.paste.size)}`
|
data.paste.isCompressed ? `Compressed Size: ${formatBytes(data.paste.size)}` : ''
|
||||||
: `This paste is not compressed.`}
|
}${
|
||||||
|
data.paste.visibility === 2
|
||||||
|
? ` • Decrypted Size: ${formatBytes(decryptedContent ? new TextEncoder().encode(decryptedContent).length : 0)}`
|
||||||
|
: ''
|
||||||
|
}`}
|
||||||
>
|
>
|
||||||
<FileBox class="mr-2 h-6 w-6 text-neutral-400" />
|
<FileBox class="mr-2 h-6 w-6 text-neutral-400" />
|
||||||
<span class="text-neutral-400">{formatBytes(data.paste.trueSize)}</span>
|
<span class="text-neutral-400">{formatBytes(data.paste.trueSize)}</span>
|
||||||
@@ -594,13 +637,13 @@
|
|||||||
<div>
|
<div>
|
||||||
<div class="flex shrink-0 items-center">
|
<div class="flex shrink-0 items-center">
|
||||||
{#if data.paste.visibility === 0}
|
{#if data.paste.visibility === 0}
|
||||||
<Eye class="mr-2 h-6 w-6 text-neutral-400" />
|
<Globe class="mr-2 h-6 w-6 text-neutral-400" />
|
||||||
<span class="text-neutral-400">{editing ? '' : 'Public'}</span>
|
<span class="text-neutral-400">{editing ? '' : 'Public'}</span>
|
||||||
{:else if data.paste.visibility === 1}
|
{:else if data.paste.visibility === 1}
|
||||||
<EyeClosed class="mr-2 h-6 w-6 text-neutral-400" />
|
<EyeOff class="mr-2 h-6 w-6 text-neutral-400" />
|
||||||
<span class="text-neutral-400">{editing ? '' : 'Unlisted'}</span>
|
<span class="text-neutral-400">{editing ? '' : 'Unlisted'}</span>
|
||||||
{:else if data.paste.visibility === 2}
|
{:else if data.paste.visibility === 2}
|
||||||
<EyeOff class="mr-2 h-6 w-6 text-neutral-400" />
|
<Lock class="mr-2 h-6 w-6 text-neutral-400" />
|
||||||
<span class="text-neutral-400">{editing ? '' : 'Private'}</span>
|
<span class="text-neutral-400">{editing ? '' : 'Private'}</span>
|
||||||
{/if}
|
{/if}
|
||||||
{#if editing && editMetadata}
|
{#if editing && editMetadata}
|
||||||
@@ -855,12 +898,13 @@
|
|||||||
<div
|
<div
|
||||||
class={data.paste.syntax === 'markdown'
|
class={data.paste.syntax === 'markdown'
|
||||||
? 'markdown rounded-b-md bg-neutral-800 p-4'
|
? 'markdown rounded-b-md bg-neutral-800 p-4'
|
||||||
|
: data.paste.syntax === 'csv'
|
||||||
|
? 'csv-container scrollbar overflow-x-auto overflow-y-auto scrollbar-thumb-neutral-600 scrollbar-track-neutral-800'
|
||||||
: 'codeblock-with-lines overflow-x-auto overflow-y-auto'}
|
: 'codeblock-with-lines overflow-x-auto overflow-y-auto'}
|
||||||
class:hidden={!contentRendered}
|
class:hidden={!contentRendered}
|
||||||
on:click={handleMarkdownClick}
|
on:click={handleMarkdownClick}
|
||||||
role="presentation"
|
role="presentation"
|
||||||
>
|
>
|
||||||
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
|
||||||
{@html pasteContent}
|
{@html pasteContent}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -925,5 +969,50 @@
|
|||||||
padding-left: 0.25em;
|
padding-left: 0.25em;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.csv-table {
|
||||||
|
border-collapse: separate;
|
||||||
|
border-spacing: 0;
|
||||||
|
background-color: var(--color-neutral-800);
|
||||||
|
border-bottom-left-radius: 0.25rem;
|
||||||
|
border-bottom-right-radius: 0.25rem;
|
||||||
|
min-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.csv-table thead th {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
background-color: var(--color-neutral-800);
|
||||||
|
border-bottom: 2px solid var(--color-neutral-700);
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.csv-table tbody tr,
|
||||||
|
.csv-table thead th {
|
||||||
|
border-bottom: 1px solid var(--color-neutral-700);
|
||||||
|
}
|
||||||
|
|
||||||
|
.csv-table tbody tr:hover,
|
||||||
|
.csv-table thead tr:hover {
|
||||||
|
background-color: rgba(255, 255, 255, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.csv-table tbody td,
|
||||||
|
.csv-table thead th {
|
||||||
|
padding: 0.75rem 1rem;
|
||||||
|
text-align: left;
|
||||||
|
color: var(--color-neutral-300);
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.csv-table tbody tr:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.csv-container {
|
||||||
|
max-height: 60vh;
|
||||||
|
border-bottom-left-radius: 0.25rem;
|
||||||
|
border-bottom-right-radius: 0.25rem;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
@import 'tailwindcss';
|
@import 'tailwindcss';
|
||||||
@import 'highlight.js/styles/github-dark.css';
|
@import 'highlight.js/styles/github-dark.css';
|
||||||
|
@plugin 'tailwind-scrollbar';
|
||||||
|
|
||||||
* {
|
* {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|||||||
@@ -17,7 +17,9 @@
|
|||||||
if (window.turnstile && data.options?.cf_turnstile_site_key) {
|
if (window.turnstile && data.options?.cf_turnstile_site_key) {
|
||||||
window.turnstile.render('.cf-turnstile', {
|
window.turnstile.render('.cf-turnstile', {
|
||||||
sitekey: data.options.cf_turnstile_site_key,
|
sitekey: data.options.cf_turnstile_site_key,
|
||||||
theme: 'dark'
|
theme: 'dark',
|
||||||
|
size: 'flexible',
|
||||||
|
appearence: 'interaction-only'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -130,9 +132,7 @@
|
|||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{#if data.options?.cf_turnstile_site_key}
|
{#if data.options?.cf_turnstile_site_key}
|
||||||
<div class="flex w-full justify-center">
|
<div class="cf-turnstile w-full"></div>
|
||||||
<div class="cf-turnstile"></div>
|
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import { setTokens, startTokenRefreshInterval } from '$lib/utils/auth';
|
import { setTokens, startTokenRefreshInterval } from '$lib/utils/auth';
|
||||||
import { extractError } from '$lib/utils/misc';
|
import { extractError } from '$lib/utils/misc';
|
||||||
import { Check, X } from '@lucide/svelte';
|
import { Check, X, Eye, EyeClosed } from '@lucide/svelte';
|
||||||
import { slide, fade } from 'svelte/transition';
|
import { slide, fade } from 'svelte/transition';
|
||||||
import { resolve } from '$app/paths';
|
import { resolve } from '$app/paths';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
@@ -16,8 +16,11 @@
|
|||||||
let error = '';
|
let error = '';
|
||||||
|
|
||||||
let passwordFocused = false;
|
let passwordFocused = false;
|
||||||
|
let showPassword = false;
|
||||||
|
1;
|
||||||
let passwordChecks = {
|
let passwordChecks = {
|
||||||
length: false,
|
minLength: false,
|
||||||
|
maxLength: false,
|
||||||
upper: false,
|
upper: false,
|
||||||
lower: false,
|
lower: false,
|
||||||
number: false
|
number: false
|
||||||
@@ -36,7 +39,9 @@
|
|||||||
) {
|
) {
|
||||||
window.turnstile.render('.cf-turnstile', {
|
window.turnstile.render('.cf-turnstile', {
|
||||||
sitekey: data.options.cf_turnstile_site_key,
|
sitekey: data.options.cf_turnstile_site_key,
|
||||||
theme: 'dark'
|
theme: 'dark',
|
||||||
|
size: 'flexible',
|
||||||
|
appearence: 'interaction-only'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -53,12 +58,14 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
function validatePassword(pw: string) {
|
function validatePassword(pw: string) {
|
||||||
passwordChecks.length = pw.length >= 8;
|
passwordChecks.minLength = pw.length >= 8;
|
||||||
|
passwordChecks.maxLength = pw.length <= 128;
|
||||||
passwordChecks.upper = /[A-Z]/.test(pw);
|
passwordChecks.upper = /[A-Z]/.test(pw);
|
||||||
passwordChecks.lower = /[a-z]/.test(pw);
|
passwordChecks.lower = /[a-z]/.test(pw);
|
||||||
passwordChecks.number = /[0-9]/.test(pw);
|
passwordChecks.number = /[0-9]/.test(pw);
|
||||||
passwordValid =
|
passwordValid =
|
||||||
passwordChecks.length &&
|
passwordChecks.minLength &&
|
||||||
|
passwordChecks.maxLength &&
|
||||||
passwordChecks.upper &&
|
passwordChecks.upper &&
|
||||||
passwordChecks.lower &&
|
passwordChecks.lower &&
|
||||||
passwordChecks.number;
|
passwordChecks.number;
|
||||||
@@ -166,8 +173,9 @@
|
|||||||
class="focus:bg-neutral-750 w-full rounded border border-neutral-700 bg-neutral-800 p-2 placeholder-neutral-500 transition-colors duration-200 focus:border-neutral-600"
|
class="focus:bg-neutral-750 w-full rounded border border-neutral-700 bg-neutral-800 p-2 placeholder-neutral-500 transition-colors duration-200 focus:border-neutral-600"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex w-full">
|
||||||
<input
|
<input
|
||||||
type="password"
|
type={showPassword ? 'text' : 'password'}
|
||||||
placeholder="Password"
|
placeholder="Password"
|
||||||
bind:value={password}
|
bind:value={password}
|
||||||
required
|
required
|
||||||
@@ -175,25 +183,51 @@
|
|||||||
on:blur={() => (passwordFocused = false)}
|
on:blur={() => (passwordFocused = false)}
|
||||||
autocomplete="new-password"
|
autocomplete="new-password"
|
||||||
disabled={loading || !data.options?.registration_enabled}
|
disabled={loading || !data.options?.registration_enabled}
|
||||||
class="focus:bg-neutral-750 w-full rounded border border-neutral-700 bg-neutral-800 p-2 placeholder-neutral-500 transition-colors duration-200 focus:border-neutral-600"
|
class="focus:bg-neutral-750 w-[calc(100%-40px)] rounded-l border border-neutral-700 bg-neutral-800 p-2 placeholder-neutral-500 transition-colors duration-200 focus:border-neutral-600"
|
||||||
/>
|
/>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
on:click={() => (showPassword = !showPassword)}
|
||||||
|
disabled={loading || !data.options?.registration_enabled}
|
||||||
|
class="ml-2 flex w-10 items-center rounded-r border border-neutral-700 bg-neutral-800 p-2 transition-colors duration-200 hover:bg-neutral-700 focus:outline-none"
|
||||||
|
>
|
||||||
|
{#if showPassword}
|
||||||
|
<EyeClosed class="h-5 w-5 text-neutral-400" />
|
||||||
|
{:else}
|
||||||
|
<Eye class="h-5 w-5 text-neutral-400" />
|
||||||
|
{/if}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
{#if passwordFocused}
|
{#if passwordFocused}
|
||||||
<ul
|
<ul
|
||||||
transition:slide
|
transition:slide
|
||||||
class="space-y-2 rounded border border-neutral-700 bg-neutral-800 p-3 text-sm"
|
class="space-y-2 rounded border border-neutral-700 bg-neutral-800 p-3 text-sm"
|
||||||
>
|
>
|
||||||
<li
|
<li
|
||||||
class="flex items-center gap-2 {passwordChecks.length
|
class="flex items-center gap-2 {passwordChecks.minLength
|
||||||
? 'text-green-400'
|
? 'text-green-400'
|
||||||
: 'text-red-400'}"
|
: 'text-red-400'}"
|
||||||
>
|
>
|
||||||
{#if passwordChecks.length}
|
{#if passwordChecks.minLength}
|
||||||
<Check class="h-4 w-4" />
|
<Check class="h-4 w-4" />
|
||||||
{:else}
|
{:else}
|
||||||
<X class="h-4 w-4" />
|
<X class="h-4 w-4" />
|
||||||
{/if}
|
{/if}
|
||||||
At least 8 characters
|
At least 8 characters
|
||||||
</li>
|
</li>
|
||||||
|
<li
|
||||||
|
class="flex items-center gap-2 {passwordChecks.maxLength
|
||||||
|
? 'text-green-400'
|
||||||
|
: 'text-red-400'}"
|
||||||
|
>
|
||||||
|
{#if passwordChecks.maxLength}
|
||||||
|
<Check class="h-4 w-4" />
|
||||||
|
{:else}
|
||||||
|
<X class="h-4 w-4" />
|
||||||
|
{/if}
|
||||||
|
No more than 128 characters
|
||||||
|
</li>
|
||||||
<li
|
<li
|
||||||
class="flex items-center gap-2 {passwordChecks.upper
|
class="flex items-center gap-2 {passwordChecks.upper
|
||||||
? 'text-green-400'
|
? 'text-green-400'
|
||||||
@@ -241,6 +275,7 @@
|
|||||||
disabled={loading || !data.options?.registration_enabled}
|
disabled={loading || !data.options?.registration_enabled}
|
||||||
class="focus:bg-neutral-750 w-full rounded border border-neutral-700 bg-neutral-800 p-2 placeholder-neutral-500 transition-colors duration-200 focus:border-neutral-600"
|
class="focus:bg-neutral-750 w-full rounded border border-neutral-700 bg-neutral-800 p-2 placeholder-neutral-500 transition-colors duration-200 focus:border-neutral-600"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{#if confirmPassword && password !== confirmPassword}
|
{#if confirmPassword && password !== confirmPassword}
|
||||||
<div
|
<div
|
||||||
transition:fade
|
transition:fade
|
||||||
@@ -250,9 +285,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{#if data.options?.cf_turnstile_site_key && data.options?.registration_enabled}
|
{#if data.options?.cf_turnstile_site_key && data.options?.registration_enabled}
|
||||||
<div class="flex w-full justify-center">
|
<div class="cf-turnstile w-full"></div>
|
||||||
<div class="cf-turnstile"></div>
|
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
|
|||||||
@@ -413,7 +413,7 @@
|
|||||||
<div class="mt-6 max-h-[60vh] space-y-4 overflow-y-auto">
|
<div class="mt-6 max-h-[60vh] space-y-4 overflow-y-auto">
|
||||||
{#if pastes && pastes.length > 0}
|
{#if pastes && pastes.length > 0}
|
||||||
{#each pastes.slice().sort((a, b) => b.uuid.localeCompare(a.uuid)) as paste (paste.uuid)}
|
{#each pastes.slice().sort((a, b) => b.uuid.localeCompare(a.uuid)) as paste (paste.uuid)}
|
||||||
<Paste {paste} {now} />
|
<Paste {paste} {now} showUser={false} compact={true} />
|
||||||
{/each}
|
{/each}
|
||||||
{:else}
|
{:else}
|
||||||
<p class="text-center text-neutral-400">
|
<p class="text-center text-neutral-400">
|
||||||
@@ -423,10 +423,9 @@
|
|||||||
</div>
|
</div>
|
||||||
{#if reportsSubmitted || reportsTarget}
|
{#if reportsSubmitted || reportsTarget}
|
||||||
<div class="mt-6 space-y-6">
|
<div class="mt-6 space-y-6">
|
||||||
{#if reportsSubmitted}
|
{#if reportsSubmitted && reportsSubmitted.reports.length > 0}
|
||||||
<div class="rounded border border-neutral-800 bg-neutral-900/60 p-4">
|
<div class="rounded border border-neutral-800 bg-neutral-900/60 p-4">
|
||||||
<h2 class="mb-3 text-xl font-semibold text-neutral-200">Submitted Reports</h2>
|
<h2 class="mb-3 text-xl font-semibold text-neutral-200">Submitted Reports</h2>
|
||||||
{#if reportsSubmitted.reports.length > 0}
|
|
||||||
<div class="space-y-3">
|
<div class="space-y-3">
|
||||||
{#each reportsSubmitted.reports as report (report.reportID)}
|
{#each reportsSubmitted.reports as report (report.reportID)}
|
||||||
<div
|
<div
|
||||||
@@ -485,19 +484,15 @@
|
|||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
|
||||||
<p class="text-center text-neutral-400">No submitted reports to show.</p>
|
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{#if reportsTarget}
|
{#if reportsTarget && reportsTarget.reports.length > 0}
|
||||||
<div class="rounded border border-neutral-800 bg-neutral-900/60 p-4">
|
<div class="rounded border border-neutral-800 bg-neutral-900/60 p-4">
|
||||||
<h2 class="mb-3 text-xl font-semibold text-neutral-200">Reports About This User</h2>
|
<h2 class="mb-3 text-xl font-semibold text-neutral-200">Reports About This User</h2>
|
||||||
{#if reportsTarget.reports.length > 0}
|
|
||||||
<div class="space-y-3">
|
<div class="space-y-3">
|
||||||
{#each reportsTarget.reports as report (report.reportID)}
|
{#each reportsTarget.reports as report (report.reportID)}
|
||||||
<div
|
<div
|
||||||
class="flex flex-col gap-2 rounded border border-neutral-700 bg-neutral-800 px-5 py-4 transition-colors duration-200 hover:bg-neutral-700 focus:ring-2 focus:ring-neutral-600 focus:outline-none"
|
class="flex cursor-pointer flex-col gap-2 rounded border border-neutral-700 bg-neutral-800 px-5 py-4 transition-colors duration-200 hover:bg-neutral-700 focus:ring-2 focus:ring-neutral-600 focus:outline-none"
|
||||||
role="link"
|
role="link"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
on:click={() => goto(resolve(`/report/${report.reportID}`))}
|
on:click={() => goto(resolve(`/report/${report.reportID}`))}
|
||||||
@@ -564,9 +559,6 @@
|
|||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
|
||||||
<p class="text-center text-neutral-400">No reports to show.</p>
|
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -394,7 +394,16 @@ namespace SharpbinV3.Server.Controllers
|
|||||||
Syntax = p.Syntax,
|
Syntax = p.Syntax,
|
||||||
Visibility = p.Visibility,
|
Visibility = p.Visibility,
|
||||||
ExpiresAt = p.ExpiresAt,
|
ExpiresAt = p.ExpiresAt,
|
||||||
EditedAt = p.EditedAt
|
EditedAt = p.EditedAt,
|
||||||
|
Author = p.User != null && p.User.Visibility == 0 ? new UserSimpleDto
|
||||||
|
{
|
||||||
|
UID = p.User.UID,
|
||||||
|
UUID = p.User.UUID,
|
||||||
|
Username = p.User.Username,
|
||||||
|
DisplayName = p.User.DisplayName,
|
||||||
|
Visibility = p.User.Visibility,
|
||||||
|
Roles = p.User.Roles
|
||||||
|
} : null
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ namespace SharpbinV3.Server.Services
|
|||||||
.OrderByDescending(p => p.PID)
|
.OrderByDescending(p => p.PID)
|
||||||
.Skip(offset)
|
.Skip(offset)
|
||||||
.Take(count)
|
.Take(count)
|
||||||
|
.Include(p => p.User)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
"crystal",
|
"crystal",
|
||||||
"csharp",
|
"csharp",
|
||||||
"css",
|
"css",
|
||||||
|
"csv",
|
||||||
"cue",
|
"cue",
|
||||||
"d",
|
"d",
|
||||||
"dart",
|
"dart",
|
||||||
|
|||||||
Reference in New Issue
Block a user