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
|
||||
|
||||
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
|
||||
|
||||
@@ -13,20 +15,17 @@ Sharpbin is a pastebin-style website built with ASP.NET Core and SvelteKit.
|
||||
- Server-side paste compression to save storage.
|
||||
- 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
|
||||
|
||||
The easiest way to run SharpbinV3 is using Docker Compose.
|
||||
|
||||
1. Ensure Docker and Docker Compose are installed.
|
||||
2. Clone the repository.
|
||||
|
||||
```bash
|
||||
git clone https://github.com/whoswhip/Sharpbin.git
|
||||
```
|
||||
|
||||
3. Run the following command in the root directory:
|
||||
|
||||
```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.
|
||||
|
||||
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",
|
||||
"version": "0.0.1",
|
||||
"version": "3.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "sharpbinv3.client",
|
||||
"version": "0.0.1",
|
||||
"version": "3.0.0",
|
||||
"dependencies": {
|
||||
"@lucide/svelte": "^0.562.0",
|
||||
"@sveltejs/adapter-node": "^5.4.0",
|
||||
@@ -15,6 +15,7 @@
|
||||
"highlight.js": "^11.8.0",
|
||||
"jsdom": "^27.4.0",
|
||||
"marked": "^17.0.1",
|
||||
"papaparse": "^5.5.3",
|
||||
"qrcode": "^1.5.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -26,6 +27,7 @@
|
||||
"@tailwindcss/vite": "^4.1.17",
|
||||
"@types/jsdom": "^27.0.0",
|
||||
"@types/node": "^22",
|
||||
"@types/papaparse": "^5.5.2",
|
||||
"@types/qrcode": "^1.5.6",
|
||||
"eslint": "^9.39.1",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
@@ -34,8 +36,9 @@
|
||||
"prettier": "^3.7.4",
|
||||
"prettier-plugin-svelte": "^3.4.0",
|
||||
"prettier-plugin-tailwindcss": "^0.7.2",
|
||||
"svelte": "^5.45.6",
|
||||
"svelte": "^5.48.3",
|
||||
"svelte-check": "^4.3.4",
|
||||
"tailwind-scrollbar": "^4.0.2",
|
||||
"tailwindcss": "^4.1.17",
|
||||
"typescript": "^5.9.3",
|
||||
"typescript-eslint": "^8.48.1",
|
||||
@@ -1824,6 +1827,23 @@
|
||||
"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": {
|
||||
"version": "1.5.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/qrcode/-/qrcode-1.5.6.tgz",
|
||||
@@ -3724,6 +3744,12 @@
|
||||
"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": {
|
||||
"version": "1.0.1",
|
||||
"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": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
|
||||
@@ -4079,6 +4119,17 @@
|
||||
"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": {
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz",
|
||||
@@ -4348,9 +4399,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/svelte": {
|
||||
"version": "5.46.1",
|
||||
"resolved": "https://registry.npmjs.org/svelte/-/svelte-5.46.1.tgz",
|
||||
"integrity": "sha512-ynjfCHD3nP2el70kN5Pmg37sSi0EjOm9FgHYQdC4giWG/hzO3AatzXXJJgP305uIhGQxSufJLuYWtkY8uK/8RA==",
|
||||
"version": "5.48.3",
|
||||
"resolved": "https://registry.npmjs.org/svelte/-/svelte-5.48.3.tgz",
|
||||
"integrity": "sha512-w7QZ398cdNherTdiQ/v3SYLLGOO4948Jgjh04PYqtTYVohmBvbmFwLmo7pp8gp4/1tceRWfSTjHgjtfpCVNJmQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jridgewell/remapping": "^2.3.4",
|
||||
@@ -4361,7 +4412,7 @@
|
||||
"aria-query": "^5.3.1",
|
||||
"axobject-query": "^4.1.0",
|
||||
"clsx": "^2.1.1",
|
||||
"devalue": "^5.5.0",
|
||||
"devalue": "^5.6.2",
|
||||
"esm-env": "^1.2.1",
|
||||
"esrap": "^2.2.1",
|
||||
"is-reference": "^3.0.3",
|
||||
@@ -4433,6 +4484,22 @@
|
||||
"integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==",
|
||||
"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": {
|
||||
"version": "4.1.18",
|
||||
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.1.18.tgz",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "sharpbinv3.client",
|
||||
"private": true,
|
||||
"version": "3.0.0",
|
||||
"version": "3.0.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
@@ -22,6 +22,7 @@
|
||||
"@tailwindcss/vite": "^4.1.17",
|
||||
"@types/jsdom": "^27.0.0",
|
||||
"@types/node": "^22",
|
||||
"@types/papaparse": "^5.5.2",
|
||||
"@types/qrcode": "^1.5.6",
|
||||
"eslint": "^9.39.1",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
@@ -30,8 +31,9 @@
|
||||
"prettier": "^3.7.4",
|
||||
"prettier-plugin-svelte": "^3.4.0",
|
||||
"prettier-plugin-tailwindcss": "^0.7.2",
|
||||
"svelte": "^5.45.6",
|
||||
"svelte": "^5.48.3",
|
||||
"svelte-check": "^4.3.4",
|
||||
"tailwind-scrollbar": "^4.0.2",
|
||||
"tailwindcss": "^4.1.17",
|
||||
"typescript": "^5.9.3",
|
||||
"typescript-eslint": "^8.48.1",
|
||||
@@ -45,6 +47,7 @@
|
||||
"highlight.js": "^11.8.0",
|
||||
"jsdom": "^27.4.0",
|
||||
"marked": "^17.0.1",
|
||||
"papaparse": "^5.5.3",
|
||||
"qrcode": "^1.5.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
let isOpen = false;
|
||||
let searchQuery = '';
|
||||
let dropdownElement: HTMLDivElement;
|
||||
let dropdownListElement: HTMLDivElement;
|
||||
let dropdownMaxHeight = '12rem';
|
||||
|
||||
$: filteredOptions = searchable
|
||||
? options.filter(
|
||||
@@ -39,10 +41,18 @@
|
||||
|
||||
function toggleDropdown() {
|
||||
isOpen = !isOpen;
|
||||
if (isOpen && searchable) {
|
||||
if (isOpen) {
|
||||
setTimeout(() => {
|
||||
const input = dropdownElement?.querySelector('input[type="text"]') as HTMLInputElement;
|
||||
input?.focus();
|
||||
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;
|
||||
input?.focus();
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
@@ -70,19 +80,22 @@
|
||||
<div
|
||||
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'}
|
||||
bind:this={dropdownListElement}
|
||||
style="max-height: {dropdownMaxHeight}; width: 100%;"
|
||||
>
|
||||
{#if searchable}
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search..."
|
||||
class="w-full border-b border-neutral-700 bg-neutral-800 p-2 outline-none"
|
||||
class:dropdown-sm-input={variant === 'sm'}
|
||||
bind:value={searchQuery}
|
||||
on:keydown={handleKeyDown}
|
||||
/>
|
||||
<div style="position: sticky; top: 0; z-index: 1; background: inherit;">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search..."
|
||||
class="w-full border-b border-neutral-700 bg-neutral-800 p-2 outline-none"
|
||||
class:dropdown-sm-input={variant === 'sm'}
|
||||
bind:value={searchQuery}
|
||||
on:keydown={handleKeyDown}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="max-h-48 overflow-y-auto">
|
||||
<div class="scrollbar-thin scrollbar-thumb-neutral-600 scrollbar-track-neutral-700" style="overflow-y: auto; max-height: calc({dropdownMaxHeight} - 3rem);">
|
||||
{#each filteredOptions as option (option.value)}
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -230,7 +230,9 @@
|
||||
}
|
||||
turnstileWidgetId = window.turnstile.render(turnstileEl, {
|
||||
sitekey: reportSiteKey,
|
||||
theme: 'dark'
|
||||
theme: 'dark',
|
||||
size: 'flexible',
|
||||
appearence: 'interaction-only'
|
||||
});
|
||||
};
|
||||
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"
|
||||
></textarea>
|
||||
{#if reportSiteKey}
|
||||
<div class="flex justify-center">
|
||||
<div class="cf-turnstile" bind:this={turnstileEl}></div>
|
||||
</div>
|
||||
<div class="cf-turnstile w-full" bind:this={turnstileEl}></div>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import type { PageData } from '../../routes/$types';
|
||||
import { slide } from 'svelte/transition';
|
||||
import { Menu, X } from '@lucide/svelte';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
function logout() {
|
||||
clearTokens();
|
||||
@@ -23,9 +24,24 @@
|
||||
currentPath !== '/' && !currentPath.startsWith('/login') && !currentPath.startsWith('/register')
|
||||
? `?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>
|
||||
|
||||
<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>
|
||||
<a href={resolve('/')} class="text-xl font-bold text-white hover:text-neutral-300">Sharpbin</a
|
||||
@@ -80,15 +96,16 @@
|
||||
aria-expanded={menuOpen}
|
||||
>
|
||||
{#if menuOpen}
|
||||
<X class="h-6 w-6 text-white" />
|
||||
<X class="pointer-events-none h-6 w-6 text-white" />
|
||||
{:else}
|
||||
<Menu class="h-6 w-6 text-white" />
|
||||
<Menu class="pointer-events-none h-6 w-6 text-white" />
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
{#if menuOpen}
|
||||
<div
|
||||
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 }}
|
||||
out:slide={{ duration: 180 }}
|
||||
style="z-index:1000;position:relative;"
|
||||
|
||||
@@ -7,89 +7,177 @@
|
||||
formatBytes
|
||||
} from '$lib/utils/misc';
|
||||
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 type { Paste } from '$lib/types/paste';
|
||||
|
||||
export let paste: Paste;
|
||||
export let now: Date;
|
||||
export let showUser: boolean = true;
|
||||
export let compact: boolean = false;
|
||||
|
||||
const createdAt = extractDateFromUUIDv7(paste.uuid);
|
||||
const syntax = syntaxes[paste.syntax] ?? syntaxes['plaintext'];
|
||||
</script>
|
||||
|
||||
<a
|
||||
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"
|
||||
>
|
||||
<span
|
||||
class="w-fit max-w-full truncate text-lg font-semibold text-neutral-100 hover:text-white"
|
||||
use:tooltip={paste.title || 'Untitled Paste'}
|
||||
{#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"
|
||||
>
|
||||
{paste.title || 'Untitled Paste'}
|
||||
</span>
|
||||
<div class="flex flex-row justify-between">
|
||||
<div>
|
||||
<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" />
|
||||
<span>
|
||||
{#if createdAt}
|
||||
{#if createdAt.getTime() > Date.now() - 86_400_000}
|
||||
Created {dateToRelativeString(createdAt, true, false, now)}
|
||||
{:else}
|
||||
Created on {createdAt.toLocaleDateString()}
|
||||
{/if}
|
||||
{#if createdAt}
|
||||
{#if createdAt.getTime() > Date.now() - 86_400_000}
|
||||
Created {dateToRelativeString(createdAt, true, false, now)}
|
||||
{:else}
|
||||
Creation date unknown
|
||||
Created on {createdAt.toLocaleDateString()}
|
||||
{/if}
|
||||
</span>
|
||||
{:else}
|
||||
Creation date unknown
|
||||
{/if}
|
||||
</div>
|
||||
{#if paste.expiresAt > 0}
|
||||
</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="mt-1 flex items-center gap-2 text-sm text-neutral-400"
|
||||
use:tooltip={new Date(paste.expiresAt).toLocaleString()}
|
||||
class="flex items-center gap-2"
|
||||
use:tooltip={paste.isCompressed ? `Compressed Size: ${formatBytes(paste.size)}` : ''}
|
||||
>
|
||||
<Timer class="h-4 w-4" />
|
||||
<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}`)}
|
||||
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
|
||||
class="w-fit max-w-full truncate text-lg font-semibold text-neutral-100 hover:text-white"
|
||||
use:tooltip={paste.title || 'Untitled Paste'}
|
||||
>
|
||||
{paste.title || 'Untitled Paste'}
|
||||
</span>
|
||||
<div class="flex flex-row justify-between">
|
||||
<div>
|
||||
<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" />
|
||||
<span>
|
||||
{paste.expiresAt > 0 && paste.expiresAt < Date.now()
|
||||
? `Expired ${dateToRelativeString(new Date(paste.expiresAt), true, false, now)}`
|
||||
: `Expires in ${dateToRelativeString(new Date(paste.expiresAt), true, false, now)}`}
|
||||
{#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}
|
||||
</span>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="mt-1 flex items-center gap-2 text-sm text-neutral-400">
|
||||
<User class="h-4 w-4" />
|
||||
<span>{paste.author?.username ?? 'Anonymous'}</span>
|
||||
{#if paste.expiresAt > 0}
|
||||
<div
|
||||
class="mt-1 flex items-center gap-2 text-sm text-neutral-400"
|
||||
use:tooltip={new Date(paste.expiresAt).toLocaleString()}
|
||||
>
|
||||
<Timer class="h-4 w-4" />
|
||||
<span>
|
||||
{paste.expiresAt > 0 && paste.expiresAt < Date.now()
|
||||
? `Expired ${dateToRelativeString(new Date(paste.expiresAt), true, false, now)}`
|
||||
: `Expires in ${dateToRelativeString(new Date(paste.expiresAt), true, false, now)}`}
|
||||
</span>
|
||||
</div>
|
||||
{/if}
|
||||
{#if showUser}
|
||||
<div class="mt-1 flex items-center gap-2 text-sm text-neutral-400">
|
||||
<User class="h-4 w-4" />
|
||||
<span>{paste.author?.username ?? 'Anonymous'}</span>
|
||||
</div>
|
||||
{/if}
|
||||
{#if paste.editedAt}
|
||||
<div
|
||||
class="mt-1 flex items-center gap-2 text-sm text-neutral-400"
|
||||
use:tooltip={new Date(paste.editedAt).toLocaleString()}
|
||||
>
|
||||
<History class="h-4 w-4" />
|
||||
<span>Edited {dateToRelativeString(new Date(paste.editedAt), true, false, now)}</span>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{#if paste.editedAt}
|
||||
<div>
|
||||
<div class="flex items-center gap-2 text-sm text-neutral-400">
|
||||
<Eye class="h-4 w-4" />
|
||||
<span>{formatNumber(paste.views)} View{paste.views !== 1 ? 's' : ''}</span>
|
||||
</div>
|
||||
<div
|
||||
class="mt-1 flex items-center gap-2 text-sm text-neutral-400"
|
||||
use:tooltip={new Date(paste.editedAt).toLocaleString()}
|
||||
use:tooltip={paste.isCompressed ? `Compressed Size: ${formatBytes(paste.size)}` : ''}
|
||||
>
|
||||
<History class="h-4 w-4" />
|
||||
<span>Edited {dateToRelativeString(new Date(paste.editedAt), true, false, now)}</span>
|
||||
<FileBox class="h-4 w-4" />
|
||||
<span>{formatBytes(paste.trueSize)}</span>
|
||||
</div>
|
||||
<div class="mt-1 flex items-center gap-2 text-sm text-neutral-400">
|
||||
<Code class="h-4 w-4" />
|
||||
<span>{syntax.name}</span>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div>
|
||||
<div class="flex items-center gap-2 text-sm text-neutral-400">
|
||||
<Eye class="h-4 w-4" />
|
||||
<span>{formatNumber(paste.views)} View{paste.views !== 1 ? 's' : ''}</span>
|
||||
</div>
|
||||
<div
|
||||
class="mt-1 flex items-center gap-2 text-sm text-neutral-400"
|
||||
use:tooltip={paste.isCompressed ? `Compressed Size: ${formatBytes(paste.size)}` : ''}
|
||||
>
|
||||
<FileBox class="h-4 w-4" />
|
||||
<span>{formatBytes(paste.trueSize)}</span>
|
||||
</div>
|
||||
<div class="mt-1 flex items-center gap-2 text-sm text-neutral-400">
|
||||
<Code class="h-4 w-4" />
|
||||
<span>{syntax.name}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</a>
|
||||
{/if}
|
||||
|
||||
@@ -34,6 +34,7 @@ export const syntaxes: Record<string, Syntax> = {
|
||||
crystal: { name: 'Crystal', extension: '.cr' },
|
||||
csharp: { name: 'C#', extension: '.cs' },
|
||||
css: { name: 'CSS', extension: '.css' },
|
||||
csv: { name: 'CSV', extension: '.csv' },
|
||||
cue: { name: 'CUE', extension: '.cue' },
|
||||
d: { name: 'D', extension: '.d' },
|
||||
dart: { name: 'Dart', extension: '.dart' },
|
||||
@@ -156,6 +157,26 @@ export const syntaxes: Record<string, Syntax> = {
|
||||
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 = {
|
||||
0: 'User',
|
||||
1: 'Moderator',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import type { PageData } from './$types';
|
||||
import { syntaxes } from '$lib/consts';
|
||||
import { syntaxes, expiresOptions } from '$lib/consts';
|
||||
import { user } from '$lib/stores/user';
|
||||
import { getToken } from '$lib/utils/auth';
|
||||
import { onMount } from 'svelte';
|
||||
@@ -21,6 +21,7 @@
|
||||
export let data: PageData;
|
||||
|
||||
let textArea: HTMLTextAreaElement;
|
||||
let markdownConatiner: HTMLDivElement;
|
||||
|
||||
let error = '';
|
||||
let title = '';
|
||||
@@ -54,25 +55,34 @@
|
||||
renderedMarkdown = await parseMarkdown(content, false);
|
||||
}
|
||||
previewMode = toPreview;
|
||||
if (!toPreview) {
|
||||
requestAnimationFrame(resize);
|
||||
}
|
||||
requestAnimationFrame(() => resize(previewMode));
|
||||
}
|
||||
|
||||
function resize() {
|
||||
if (!textArea) return;
|
||||
function resize(markdown: boolean = false) {
|
||||
if ((!markdown && !textArea) || (markdown && !markdownConatiner)) return;
|
||||
|
||||
textArea.style.height = 'auto';
|
||||
let h: number;
|
||||
let max: number;
|
||||
let element = markdown ? markdownConatiner : textArea;
|
||||
|
||||
const h = textArea.scrollHeight;
|
||||
const max = MAX_HEIGHT();
|
||||
if (!markdown) {
|
||||
textArea.style.height = 'auto';
|
||||
|
||||
h = textArea.scrollHeight;
|
||||
max = MAX_HEIGHT();
|
||||
} else {
|
||||
markdownConatiner.style.height = 'auto';
|
||||
|
||||
h = markdownConatiner.scrollHeight;
|
||||
max = MAX_HEIGHT();
|
||||
}
|
||||
|
||||
if (h > max) {
|
||||
textArea.style.height = max + 'px';
|
||||
textArea.style.overflowY = 'auto';
|
||||
element.style.height = max + 'px';
|
||||
element.style.overflowY = 'auto';
|
||||
} else {
|
||||
textArea.style.height = h + 'px';
|
||||
textArea.style.overflowY = 'hidden';
|
||||
element.style.height = h + 'px';
|
||||
element.style.overflowY = 'hidden';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +96,9 @@
|
||||
) {
|
||||
window.turnstile.render('.cf-turnstile', {
|
||||
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)
|
||||
})) ?? [];
|
||||
|
||||
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 =
|
||||
data.options?.visibilities?.map((visibility: { value: number; displayName: string }) => ({
|
||||
value: visibility.value,
|
||||
@@ -256,7 +252,9 @@
|
||||
<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"
|
||||
style="height: {previewHeight}"
|
||||
bind:this={markdownConatiner}
|
||||
>
|
||||
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
||||
{@html renderedMarkdown}
|
||||
</div>
|
||||
{:else}
|
||||
@@ -268,9 +266,9 @@
|
||||
minlength="1"
|
||||
bind:this={textArea}
|
||||
bind:value={content}
|
||||
on:input={resize}
|
||||
on:change={resize}
|
||||
on:focus={resize}
|
||||
on:input={() => resize()}
|
||||
on:change={() => resize()}
|
||||
on:focus={() => resize()}
|
||||
on:beforeinput={(e) => {
|
||||
if (!data.options?.maxPasteSize) return;
|
||||
|
||||
@@ -299,7 +297,7 @@
|
||||
isDragging = false;
|
||||
}}
|
||||
on:drop={(e) => {
|
||||
requestAnimationFrame(resize);
|
||||
requestAnimationFrame(() => resize());
|
||||
e.preventDefault();
|
||||
isDragging = false;
|
||||
|
||||
@@ -363,7 +361,7 @@
|
||||
<div class="mt-1 flex">
|
||||
{#if selectedSyntax === 'markdown'}
|
||||
<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
|
||||
type="button"
|
||||
@@ -386,10 +384,10 @@
|
||||
</div>
|
||||
{/if}
|
||||
<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'
|
||||
? '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">
|
||||
<span>
|
||||
@@ -430,7 +428,7 @@
|
||||
/>
|
||||
</div>
|
||||
{#if selectedVisibility === 2}
|
||||
<div class="flex w-full mb-2">
|
||||
<div class="mb-2 flex w-full">
|
||||
<input
|
||||
type={passwordVisible ? 'text' : 'password'}
|
||||
placeholder="Password for private paste"
|
||||
@@ -479,11 +477,7 @@
|
||||
</label>
|
||||
{/if}
|
||||
{#if data.options?.requiresVerification && 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>
|
||||
<div class="cf-turnstile mb-1 w-full" data-sitekey={data.auth.cf_turnstile_site_key}></div>
|
||||
{/if}
|
||||
<button
|
||||
type="submit"
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
<script lang="ts">
|
||||
import hljs from 'highlight.js';
|
||||
import Papa from 'papaparse';
|
||||
import { onMount } from 'svelte';
|
||||
import type { PageData } from './$types';
|
||||
import {
|
||||
File,
|
||||
FileBox,
|
||||
Eye,
|
||||
EyeClosed,
|
||||
Globe,
|
||||
Lock,
|
||||
EyeOff,
|
||||
User,
|
||||
CalendarDays,
|
||||
@@ -32,7 +34,7 @@
|
||||
isBinaryData
|
||||
} from '$lib/utils/misc';
|
||||
import { parseMarkdown } from '$lib/utils/markdown';
|
||||
import { syntaxes } from '$lib/consts';
|
||||
import { syntaxes, expiresOptions } from '$lib/consts';
|
||||
import { resolve } from '$app/paths';
|
||||
import { decryptAES, encryptAES } from '$lib/utils/encryption';
|
||||
import { fade } from 'svelte/transition';
|
||||
@@ -73,21 +75,7 @@
|
||||
value: lang,
|
||||
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 =
|
||||
data.options?.visibilities?.map((visibility: { value: number; displayName: string }) => ({
|
||||
value: visibility.value,
|
||||
@@ -147,6 +135,11 @@
|
||||
return;
|
||||
}
|
||||
|
||||
if (lang === 'csv') {
|
||||
await renderCsv(code);
|
||||
return;
|
||||
}
|
||||
|
||||
let highlighted = '';
|
||||
try {
|
||||
if (lang === 'plaintext') {
|
||||
@@ -173,6 +166,52 @@
|
||||
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) {
|
||||
editError = '';
|
||||
editLoading = true;
|
||||
@@ -429,7 +468,7 @@
|
||||
<meta property="og:title" content={data.paste.title || 'Untitled Paste'} />
|
||||
<meta
|
||||
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'
|
||||
}, created on ${
|
||||
extractDateFromUUIDv7(data.paste.uuid)?.toLocaleDateString() ?? 'Unknown Date'
|
||||
@@ -494,9 +533,13 @@
|
||||
<div class="relative flex shrink-0 items-center">
|
||||
<div
|
||||
class="flex"
|
||||
use:tooltip={data.paste.isCompressed
|
||||
? `Compressed Size: ${formatBytes(data.paste.size)}`
|
||||
: `This paste is not compressed.`}
|
||||
use:tooltip={`${
|
||||
data.paste.isCompressed ? `Compressed Size: ${formatBytes(data.paste.size)}` : ''
|
||||
}${
|
||||
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" />
|
||||
<span class="text-neutral-400">{formatBytes(data.paste.trueSize)}</span>
|
||||
@@ -594,13 +637,13 @@
|
||||
<div>
|
||||
<div class="flex shrink-0 items-center">
|
||||
{#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>
|
||||
{: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>
|
||||
{: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>
|
||||
{/if}
|
||||
{#if editing && editMetadata}
|
||||
@@ -855,12 +898,13 @@
|
||||
<div
|
||||
class={data.paste.syntax === 'markdown'
|
||||
? 'markdown rounded-b-md bg-neutral-800 p-4'
|
||||
: 'codeblock-with-lines overflow-x-auto overflow-y-auto'}
|
||||
: 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'}
|
||||
class:hidden={!contentRendered}
|
||||
on:click={handleMarkdownClick}
|
||||
role="presentation"
|
||||
>
|
||||
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
||||
{@html pasteContent}
|
||||
</div>
|
||||
{/if}
|
||||
@@ -925,5 +969,50 @@
|
||||
padding-left: 0.25em;
|
||||
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>
|
||||
</main>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
@import 'tailwindcss';
|
||||
@import 'highlight.js/styles/github-dark.css';
|
||||
@plugin 'tailwind-scrollbar';
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
if (window.turnstile && data.options?.cf_turnstile_site_key) {
|
||||
window.turnstile.render('.cf-turnstile', {
|
||||
sitekey: data.options.cf_turnstile_site_key,
|
||||
theme: 'dark'
|
||||
theme: 'dark',
|
||||
size: 'flexible',
|
||||
appearence: 'interaction-only'
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -130,9 +132,7 @@
|
||||
/>
|
||||
{/if}
|
||||
{#if data.options?.cf_turnstile_site_key}
|
||||
<div class="flex w-full justify-center">
|
||||
<div class="cf-turnstile"></div>
|
||||
</div>
|
||||
<div class="cf-turnstile w-full"></div>
|
||||
{/if}
|
||||
<button
|
||||
type="submit"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { goto } from '$app/navigation';
|
||||
import { setTokens, startTokenRefreshInterval } from '$lib/utils/auth';
|
||||
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 { resolve } from '$app/paths';
|
||||
import { onMount } from 'svelte';
|
||||
@@ -16,8 +16,11 @@
|
||||
let error = '';
|
||||
|
||||
let passwordFocused = false;
|
||||
let showPassword = false;
|
||||
1;
|
||||
let passwordChecks = {
|
||||
length: false,
|
||||
minLength: false,
|
||||
maxLength: false,
|
||||
upper: false,
|
||||
lower: false,
|
||||
number: false
|
||||
@@ -36,7 +39,9 @@
|
||||
) {
|
||||
window.turnstile.render('.cf-turnstile', {
|
||||
sitekey: data.options.cf_turnstile_site_key,
|
||||
theme: 'dark'
|
||||
theme: 'dark',
|
||||
size: 'flexible',
|
||||
appearence: 'interaction-only'
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -53,12 +58,14 @@
|
||||
});
|
||||
|
||||
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.lower = /[a-z]/.test(pw);
|
||||
passwordChecks.number = /[0-9]/.test(pw);
|
||||
passwordValid =
|
||||
passwordChecks.length &&
|
||||
passwordChecks.minLength &&
|
||||
passwordChecks.maxLength &&
|
||||
passwordChecks.upper &&
|
||||
passwordChecks.lower &&
|
||||
passwordChecks.number;
|
||||
@@ -166,34 +173,61 @@
|
||||
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>
|
||||
<input
|
||||
type="password"
|
||||
placeholder="Password"
|
||||
bind:value={password}
|
||||
required
|
||||
on:focus={() => (passwordFocused = true)}
|
||||
on:blur={() => (passwordFocused = false)}
|
||||
autocomplete="new-password"
|
||||
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"
|
||||
/>
|
||||
<div class="flex w-full">
|
||||
<input
|
||||
type={showPassword ? 'text' : 'password'}
|
||||
placeholder="Password"
|
||||
bind:value={password}
|
||||
required
|
||||
on:focus={() => (passwordFocused = true)}
|
||||
on:blur={() => (passwordFocused = false)}
|
||||
autocomplete="new-password"
|
||||
disabled={loading || !data.options?.registration_enabled}
|
||||
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}
|
||||
<ul
|
||||
transition:slide
|
||||
class="space-y-2 rounded border border-neutral-700 bg-neutral-800 p-3 text-sm"
|
||||
>
|
||||
<li
|
||||
class="flex items-center gap-2 {passwordChecks.length
|
||||
class="flex items-center gap-2 {passwordChecks.minLength
|
||||
? 'text-green-400'
|
||||
: 'text-red-400'}"
|
||||
>
|
||||
{#if passwordChecks.length}
|
||||
{#if passwordChecks.minLength}
|
||||
<Check class="h-4 w-4" />
|
||||
{:else}
|
||||
<X class="h-4 w-4" />
|
||||
{/if}
|
||||
At least 8 characters
|
||||
</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
|
||||
class="flex items-center gap-2 {passwordChecks.upper
|
||||
? 'text-green-400'
|
||||
@@ -241,6 +275,7 @@
|
||||
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"
|
||||
/>
|
||||
|
||||
{#if confirmPassword && password !== confirmPassword}
|
||||
<div
|
||||
transition:fade
|
||||
@@ -250,9 +285,7 @@
|
||||
</div>
|
||||
{/if}
|
||||
{#if data.options?.cf_turnstile_site_key && data.options?.registration_enabled}
|
||||
<div class="flex w-full justify-center">
|
||||
<div class="cf-turnstile"></div>
|
||||
</div>
|
||||
<div class="cf-turnstile w-full"></div>
|
||||
{/if}
|
||||
<button
|
||||
type="submit"
|
||||
|
||||
@@ -413,7 +413,7 @@
|
||||
<div class="mt-6 max-h-[60vh] space-y-4 overflow-y-auto">
|
||||
{#if pastes && pastes.length > 0}
|
||||
{#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}
|
||||
{:else}
|
||||
<p class="text-center text-neutral-400">
|
||||
@@ -423,150 +423,142 @@
|
||||
</div>
|
||||
{#if reportsSubmitted || reportsTarget}
|
||||
<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">
|
||||
<h2 class="mb-3 text-xl font-semibold text-neutral-200">Submitted Reports</h2>
|
||||
{#if reportsSubmitted.reports.length > 0}
|
||||
<div class="space-y-3">
|
||||
{#each reportsSubmitted.reports as report (report.reportID)}
|
||||
<div
|
||||
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"
|
||||
tabindex="0"
|
||||
on:click={() => goto(resolve(`/report/${report.reportID}`))}
|
||||
on:keydown={(e) => {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
e.preventDefault();
|
||||
goto(resolve(`/report/${report.reportID}`));
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div class="flex flex-wrap items-center justify-between gap-2">
|
||||
<span class="text-lg font-semibold text-neutral-100">
|
||||
Report #{report.reportID}
|
||||
</span>
|
||||
<span class="text-sm text-neutral-300">
|
||||
{reportTypeLabels[report.type] ?? 'Other'}
|
||||
· {reportStatusLabels[report.status] ?? 'Open'}
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-3 text-sm text-neutral-400">
|
||||
<span>{reportTargetLabels[report.targetType] ?? 'Unknown'}</span>
|
||||
{#if report.pasteId}
|
||||
<a
|
||||
href={resolve(`/${report.pasteId}`)}
|
||||
class="text-neutral-300 hover:text-white"
|
||||
on:click|stopPropagation
|
||||
>
|
||||
{report.pasteTitle !== '' ? report.pasteTitle : report.pasteId}
|
||||
</a>
|
||||
{/if}
|
||||
{#if report.userUUID}
|
||||
{#if report.targetUsername}
|
||||
<a
|
||||
href={resolve(`/user/${report.targetUsername}`)}
|
||||
class="text-neutral-300 hover:text-white"
|
||||
use:tooltip={report.userUUID}
|
||||
on:click|stopPropagation
|
||||
>
|
||||
{report.targetDisplayName || report.targetUsername}
|
||||
</a>
|
||||
{:else}
|
||||
<span>{report.userUUID}</span>
|
||||
{/if}
|
||||
{/if}
|
||||
<span>
|
||||
Created {new Date(report.createdAt * 1000).toLocaleString()}
|
||||
</span>
|
||||
</div>
|
||||
{#if report.description}
|
||||
<p class="text-sm text-neutral-300">{report.description}</p>
|
||||
{/if}
|
||||
<div class="space-y-3">
|
||||
{#each reportsSubmitted.reports as report (report.reportID)}
|
||||
<div
|
||||
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"
|
||||
tabindex="0"
|
||||
on:click={() => goto(resolve(`/report/${report.reportID}`))}
|
||||
on:keydown={(e) => {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
e.preventDefault();
|
||||
goto(resolve(`/report/${report.reportID}`));
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div class="flex flex-wrap items-center justify-between gap-2">
|
||||
<span class="text-lg font-semibold text-neutral-100">
|
||||
Report #{report.reportID}
|
||||
</span>
|
||||
<span class="text-sm text-neutral-300">
|
||||
{reportTypeLabels[report.type] ?? 'Other'}
|
||||
· {reportStatusLabels[report.status] ?? 'Open'}
|
||||
</span>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{:else}
|
||||
<p class="text-center text-neutral-400">No submitted reports to show.</p>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{#if reportsTarget}
|
||||
<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>
|
||||
{#if reportsTarget.reports.length > 0}
|
||||
<div class="space-y-3">
|
||||
{#each reportsTarget.reports as report (report.reportID)}
|
||||
<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"
|
||||
role="link"
|
||||
tabindex="0"
|
||||
on:click={() => goto(resolve(`/report/${report.reportID}`))}
|
||||
on:keydown={(e) => {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
e.preventDefault();
|
||||
goto(resolve(`/report/${report.reportID}`));
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div class="flex flex-wrap items-center justify-between gap-2">
|
||||
<span class="text-lg font-semibold text-neutral-100">
|
||||
Report #{report.reportID}
|
||||
</span>
|
||||
<span class="text-sm text-neutral-300">
|
||||
{reportTypeLabels[report.type] ?? 'Other'}
|
||||
· {reportStatusLabels[report.status] ?? 'Open'}
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-3 text-sm text-neutral-400">
|
||||
<span>{reportTargetLabels[report.targetType] ?? 'Unknown'}</span>
|
||||
{#if report.reporterUsername}
|
||||
<div class="flex flex-wrap items-center gap-3 text-sm text-neutral-400">
|
||||
<span>{reportTargetLabels[report.targetType] ?? 'Unknown'}</span>
|
||||
{#if report.pasteId}
|
||||
<a
|
||||
href={resolve(`/${report.pasteId}`)}
|
||||
class="text-neutral-300 hover:text-white"
|
||||
on:click|stopPropagation
|
||||
>
|
||||
{report.pasteTitle !== '' ? report.pasteTitle : report.pasteId}
|
||||
</a>
|
||||
{/if}
|
||||
{#if report.userUUID}
|
||||
{#if report.targetUsername}
|
||||
<a
|
||||
href={resolve(`/user/${report.reporterUsername}`)}
|
||||
href={resolve(`/user/${report.targetUsername}`)}
|
||||
class="text-neutral-300 hover:text-white"
|
||||
use:tooltip={report.reporterUUID}
|
||||
use:tooltip={report.userUUID}
|
||||
on:click|stopPropagation
|
||||
>
|
||||
{report.reporterDisplayName || report.reporterUsername}
|
||||
{report.targetDisplayName || report.targetUsername}
|
||||
</a>
|
||||
{:else}
|
||||
<span>{report.reporterUUID}</span>
|
||||
<span>{report.userUUID}</span>
|
||||
{/if}
|
||||
{#if report.pastePID}
|
||||
{/if}
|
||||
<span>
|
||||
Created {new Date(report.createdAt * 1000).toLocaleString()}
|
||||
</span>
|
||||
</div>
|
||||
{#if report.description}
|
||||
<p class="text-sm text-neutral-300">{report.description}</p>
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{#if reportsTarget && reportsTarget.reports.length > 0}
|
||||
<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>
|
||||
<div class="space-y-3">
|
||||
{#each reportsTarget.reports as report (report.reportID)}
|
||||
<div
|
||||
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"
|
||||
tabindex="0"
|
||||
on:click={() => goto(resolve(`/report/${report.reportID}`))}
|
||||
on:keydown={(e) => {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
e.preventDefault();
|
||||
goto(resolve(`/report/${report.reportID}`));
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div class="flex flex-wrap items-center justify-between gap-2">
|
||||
<span class="text-lg font-semibold text-neutral-100">
|
||||
Report #{report.reportID}
|
||||
</span>
|
||||
<span class="text-sm text-neutral-300">
|
||||
{reportTypeLabels[report.type] ?? 'Other'}
|
||||
· {reportStatusLabels[report.status] ?? 'Open'}
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-3 text-sm text-neutral-400">
|
||||
<span>{reportTargetLabels[report.targetType] ?? 'Unknown'}</span>
|
||||
{#if report.reporterUsername}
|
||||
<a
|
||||
href={resolve(`/user/${report.reporterUsername}`)}
|
||||
class="text-neutral-300 hover:text-white"
|
||||
use:tooltip={report.reporterUUID}
|
||||
on:click|stopPropagation
|
||||
>
|
||||
{report.reporterDisplayName || report.reporterUsername}
|
||||
</a>
|
||||
{:else}
|
||||
<span>{report.reporterUUID}</span>
|
||||
{/if}
|
||||
{#if report.pastePID}
|
||||
<a
|
||||
href={resolve(`/${report.pasteId ?? report.pastePID}`)}
|
||||
class="text-neutral-300 hover:text-white"
|
||||
on:click|stopPropagation
|
||||
>
|
||||
{report.pasteTitle ? report.pasteTitle : `Paste #${report.pastePID}`}
|
||||
</a>
|
||||
{/if}
|
||||
{#if report.userUUID}
|
||||
{#if report.targetUsername}
|
||||
<a
|
||||
href={resolve(`/${report.pasteId ?? report.pastePID}`)}
|
||||
href={resolve(`/user/${report.targetUsername}`)}
|
||||
class="text-neutral-300 hover:text-white"
|
||||
use:tooltip={report.userUUID}
|
||||
on:click|stopPropagation
|
||||
>
|
||||
{report.pasteTitle ? report.pasteTitle : `Paste #${report.pastePID}`}
|
||||
{report.targetDisplayName || report.targetUsername}
|
||||
</a>
|
||||
{:else}
|
||||
<span>{report.userUUID}</span>
|
||||
{/if}
|
||||
{#if report.userUUID}
|
||||
{#if report.targetUsername}
|
||||
<a
|
||||
href={resolve(`/user/${report.targetUsername}`)}
|
||||
class="text-neutral-300 hover:text-white"
|
||||
use:tooltip={report.userUUID}
|
||||
on:click|stopPropagation
|
||||
>
|
||||
{report.targetDisplayName || report.targetUsername}
|
||||
</a>
|
||||
{:else}
|
||||
<span>{report.userUUID}</span>
|
||||
{/if}
|
||||
{/if}
|
||||
<span>
|
||||
Created {new Date(report.createdAt * 1000).toLocaleString()}
|
||||
</span>
|
||||
</div>
|
||||
{#if report.description}
|
||||
<p class="text-sm text-neutral-300">{report.description}</p>
|
||||
{/if}
|
||||
<span>
|
||||
Created {new Date(report.createdAt * 1000).toLocaleString()}
|
||||
</span>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{:else}
|
||||
<p class="text-center text-neutral-400">No reports to show.</p>
|
||||
{/if}
|
||||
{#if report.description}
|
||||
<p class="text-sm text-neutral-300">{report.description}</p>
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -394,7 +394,16 @@ namespace SharpbinV3.Server.Controllers
|
||||
Syntax = p.Syntax,
|
||||
Visibility = p.Visibility,
|
||||
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
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -53,13 +53,13 @@ namespace SharpbinV3.Server.Services
|
||||
|
||||
var totpEnabled = await _db.UserTotps.AnyAsync(t => t.UserUUID == user.UUID);
|
||||
var claims = new List<Claim>
|
||||
{
|
||||
new("uuid", user.UUID.ToString()),
|
||||
new("username", user.Username),
|
||||
new("displayname", user.DisplayName ?? ""),
|
||||
new("totp_enabled", totpEnabled.ToString()),
|
||||
new(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString())
|
||||
};
|
||||
{
|
||||
new("uuid", user.UUID.ToString()),
|
||||
new("username", user.Username),
|
||||
new("displayname", user.DisplayName ?? ""),
|
||||
new("totp_enabled", totpEnabled.ToString()),
|
||||
new(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString())
|
||||
};
|
||||
|
||||
if (user.Roles != null)
|
||||
{
|
||||
|
||||
@@ -126,6 +126,7 @@ namespace SharpbinV3.Server.Services
|
||||
.OrderByDescending(p => p.PID)
|
||||
.Skip(offset)
|
||||
.Take(count)
|
||||
.Include(p => p.User)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
"crystal",
|
||||
"csharp",
|
||||
"css",
|
||||
"csv",
|
||||
"cue",
|
||||
"d",
|
||||
"dart",
|
||||
|
||||
Reference in New Issue
Block a user