mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
Compare commits
42
Commits
v1.5.1
..
sharpbinV2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
898e4aa9a8
|
||
|
|
f7e493100e
|
||
|
|
219b8c1415 | ||
|
|
7281166aca
|
||
|
|
9bc5d0318d
|
||
|
|
78c26fa2d2
|
||
|
|
57d9a4e3b2
|
||
|
|
f64b617089
|
||
|
|
57f1709032
|
||
|
|
f82edc6b40 | ||
|
|
fbd200b159 | ||
|
|
b95f540ef4
|
||
|
|
bea106ac72
|
||
|
|
fddfeb6525
|
||
|
|
ed98238c40
|
||
|
|
181c401af7
|
||
|
|
3eb7374a07
|
||
|
|
cc0c6a8286
|
||
|
|
73ac667c15
|
||
|
|
89e9673a00
|
||
|
|
63323b1aa7 | ||
|
|
73248e723a
|
||
|
|
e6e6bf9ee6
|
||
|
|
a338b8814a
|
||
|
|
725d8a5732 | ||
|
|
86b90050bd | ||
|
|
357a57a6fb | ||
|
|
7c1e0d77d9 | ||
|
|
45f20772a5 | ||
|
|
1881c8a90d
|
||
|
|
38411ca7c0
|
||
|
|
f8a58740fa | ||
|
|
73743399f1 | ||
|
|
2126c3a078 | ||
|
|
1382fb9f07 | ||
|
|
704d7149fc | ||
|
|
2a25ab1ab8 | ||
|
|
94fb936b32 | ||
|
|
e0a2f20546 | ||
|
|
8f42dd55ae | ||
|
|
01a637f5dd | ||
|
|
d0cf36108f |
@@ -0,0 +1,35 @@
|
||||
**/.classpath
|
||||
**/.dockerignore
|
||||
**/.env
|
||||
**/.git
|
||||
**/.gitignore
|
||||
**/.project
|
||||
**/.settings
|
||||
**/.toolstarget
|
||||
**/.vs
|
||||
**/.vscode
|
||||
**/*.*proj.user
|
||||
**/*.dbmdl
|
||||
**/*.jfm
|
||||
**/azds.yaml
|
||||
**/bin
|
||||
**/charts
|
||||
**/docker-compose*
|
||||
**/Dockerfile*
|
||||
**/node_modules
|
||||
**/npm-debug.log
|
||||
**/obj
|
||||
**/secrets.dev.yaml
|
||||
**/values.dev.yaml
|
||||
LICENSE
|
||||
README.md
|
||||
!**/.gitignore
|
||||
!.git/HEAD
|
||||
!.git/config
|
||||
!.git/packed-refs
|
||||
!.git/refs/heads/**
|
||||
|
||||
SharpbinV2.Server/*.db
|
||||
SharpbinV2.Server/logs
|
||||
SharpbinV2.Server/pastes
|
||||
SharpbinV2.Server/.env
|
||||
@@ -1,63 +0,0 @@
|
||||
###############################################################################
|
||||
# Set default behavior to automatically normalize line endings.
|
||||
###############################################################################
|
||||
* text=auto
|
||||
|
||||
###############################################################################
|
||||
# Set default behavior for command prompt diff.
|
||||
#
|
||||
# This is need for earlier builds of msysgit that does not have it on by
|
||||
# default for csharp files.
|
||||
# Note: This is only used by command line
|
||||
###############################################################################
|
||||
#*.cs diff=csharp
|
||||
|
||||
###############################################################################
|
||||
# Set the merge driver for project and solution files
|
||||
#
|
||||
# Merging from the command prompt will add diff markers to the files if there
|
||||
# are conflicts (Merging from VS is not affected by the settings below, in VS
|
||||
# the diff markers are never inserted). Diff markers may cause the following
|
||||
# file extensions to fail to load in VS. An alternative would be to treat
|
||||
# these files as binary and thus will always conflict and require user
|
||||
# intervention with every merge. To do so, just uncomment the entries below
|
||||
###############################################################################
|
||||
#*.sln merge=binary
|
||||
#*.csproj merge=binary
|
||||
#*.vbproj merge=binary
|
||||
#*.vcxproj merge=binary
|
||||
#*.vcproj merge=binary
|
||||
#*.dbproj merge=binary
|
||||
#*.fsproj merge=binary
|
||||
#*.lsproj merge=binary
|
||||
#*.wixproj merge=binary
|
||||
#*.modelproj merge=binary
|
||||
#*.sqlproj merge=binary
|
||||
#*.wwaproj merge=binary
|
||||
|
||||
###############################################################################
|
||||
# behavior for image files
|
||||
#
|
||||
# image files are treated as binary by default.
|
||||
###############################################################################
|
||||
#*.jpg binary
|
||||
#*.png binary
|
||||
#*.gif binary
|
||||
|
||||
###############################################################################
|
||||
# diff behavior for common document formats
|
||||
#
|
||||
# Convert binary document formats to text before diffing them. This feature
|
||||
# is only available from the command line. Turn it on by uncommenting the
|
||||
# entries below.
|
||||
###############################################################################
|
||||
#*.doc diff=astextplain
|
||||
#*.DOC diff=astextplain
|
||||
#*.docx diff=astextplain
|
||||
#*.DOCX diff=astextplain
|
||||
#*.dot diff=astextplain
|
||||
#*.DOT diff=astextplain
|
||||
#*.pdf diff=astextplain
|
||||
#*.PDF diff=astextplain
|
||||
#*.rtf diff=astextplain
|
||||
#*.RTF diff=astextplain
|
||||
+9
-61
@@ -70,29 +70,7 @@ artifacts/
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
# StyleCop6
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.vspscc
|
||||
@@ -204,22 +182,7 @@ PublishScripts/
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
# Uncomment if necessar6
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
@@ -320,18 +283,7 @@ paket-files/
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
# Cake - Uncomment i6
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
@@ -365,13 +317,9 @@ MigrationBackup/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
/PasteBin/p
|
||||
/PasteBin/privp
|
||||
PasteBin/raw/2d48a001-383d-44fd-8553-4806c9de100d.txt
|
||||
PasteBin/p/2d48a001-383d-44fd-8553-4806c9de100d.html
|
||||
/PasteBin/pastes
|
||||
/PasteBin/pastes.sqlite
|
||||
*.sqlite-journal
|
||||
/PasteBin/logs.txt
|
||||
/PasteBin/config.json
|
||||
/PasteBin/.config
|
||||
|
||||
SharpbinV2.Server/*.db
|
||||
SharpbinV2.Server/logs
|
||||
SharpbinV2.Server/pastes
|
||||
SharpbinV2.Server/.env
|
||||
|
||||
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "C#: SharpbinV2.Server Debug",
|
||||
"type": "dotnet",
|
||||
"request": "launch",
|
||||
"projectPath": "${workspaceFolder}/SharpbinV2.Server/SharpbinV2.Server.csproj"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Sharpbin
|
||||
{
|
||||
public class Encryption
|
||||
{
|
||||
public static string EncryptString(string input, string password)
|
||||
{
|
||||
byte[] encryptedBytes;
|
||||
|
||||
using (Aes aes = Aes.Create())
|
||||
{
|
||||
aes.KeySize = 256;
|
||||
aes.Key = Encoding.UTF8.GetBytes(password.PadRight(32, ' '));
|
||||
aes.IV = new byte[16];
|
||||
|
||||
ICryptoTransform encryptor = aes.CreateEncryptor(aes.Key, aes.IV);
|
||||
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
using (var cs = new CryptoStream(ms, encryptor, CryptoStreamMode.Write))
|
||||
{
|
||||
byte[] inputBytes = Encoding.UTF8.GetBytes(input);
|
||||
cs.Write(inputBytes, 0, inputBytes.Length);
|
||||
}
|
||||
|
||||
encryptedBytes = ms.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
return Convert.ToBase64String(encryptedBytes);
|
||||
}
|
||||
public static string EncryptByteArray(byte[] bytes, string password)
|
||||
{
|
||||
byte[] encryptedBytes;
|
||||
|
||||
using (Aes aes = Aes.Create())
|
||||
{
|
||||
aes.KeySize = 256;
|
||||
aes.Key = Encoding.UTF8.GetBytes(password.PadRight(32, ' '));
|
||||
aes.IV = new byte[16];
|
||||
|
||||
ICryptoTransform encryptor = aes.CreateEncryptor(aes.Key, aes.IV);
|
||||
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
using (var cs = new CryptoStream(ms, encryptor, CryptoStreamMode.Write))
|
||||
{
|
||||
cs.Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
|
||||
encryptedBytes = ms.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
return Convert.ToBase64String(encryptedBytes);
|
||||
}
|
||||
|
||||
public static string DecryptString(string input, string password)
|
||||
{
|
||||
byte[] encryptedBytes = Convert.FromBase64String(input);
|
||||
string decryptedText;
|
||||
|
||||
using (Aes aes = Aes.Create())
|
||||
{
|
||||
aes.KeySize = 256;
|
||||
aes.Key = Encoding.UTF8.GetBytes(password.PadRight(32, ' '));
|
||||
aes.IV = new byte[16];
|
||||
|
||||
ICryptoTransform decryptor = aes.CreateDecryptor(aes.Key, aes.IV);
|
||||
|
||||
using (var ms = new MemoryStream(encryptedBytes))
|
||||
{
|
||||
using (var cs = new CryptoStream(ms, decryptor, CryptoStreamMode.Read))
|
||||
{
|
||||
using (var sr = new StreamReader(cs))
|
||||
{
|
||||
decryptedText = sr.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return decryptedText;
|
||||
}
|
||||
public static byte[] DecryptByteArray(byte[] input, string password)
|
||||
{
|
||||
byte[] decryptedBytes;
|
||||
|
||||
using (Aes aes = Aes.Create())
|
||||
{
|
||||
aes.KeySize = 256;
|
||||
aes.Key = Encoding.UTF8.GetBytes(password.PadRight(32, ' '));
|
||||
aes.IV = new byte[16];
|
||||
|
||||
ICryptoTransform decryptor = aes.CreateDecryptor(aes.Key, aes.IV);
|
||||
|
||||
using (var ms = new MemoryStream(input))
|
||||
{
|
||||
using (var cs = new CryptoStream(ms, decryptor, CryptoStreamMode.Read))
|
||||
{
|
||||
decryptedBytes = new byte[ms.Length];
|
||||
cs.Read(decryptedBytes, 0, decryptedBytes.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return decryptedBytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
using Org.BouncyCastle.Asn1.Cms;
|
||||
|
||||
namespace Sharpbin
|
||||
{
|
||||
public class Logging
|
||||
{
|
||||
public static async Task<Log> LogRequestAsync(HttpContext context)
|
||||
{
|
||||
Log log = new Log();
|
||||
log.Now = DateTime.Now;
|
||||
log.Method = context.Request.Method;
|
||||
log.Path = context.Request.Path;
|
||||
log.UserAgent = context.Request.Headers["User-Agent"];
|
||||
log.Referer = context.Request.Headers["Referer"];
|
||||
log.IP = context.Request.Headers["X-Forwarded-For"].ToString() ?? context.Connection.RemoteIpAddress.ToString();
|
||||
return log;
|
||||
}
|
||||
public static async Task LogError(string message)
|
||||
{
|
||||
Console.BackgroundColor = ConsoleColor.Red;
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
Console.WriteLine($"[ERROR - {DateTime.Now}] {message}");
|
||||
await File.AppendAllTextAsync("logs.log", $"[ERROR - {DateTime.Now}] {message}\n");
|
||||
Console.ResetColor();
|
||||
}
|
||||
public static async Task LogInfo(string message)
|
||||
{
|
||||
Console.WriteLine($"[INFO - {DateTime.Now}] {message}");
|
||||
await File.AppendAllTextAsync("logs.log", $"[INFO - {DateTime.Now}] {message}\n");
|
||||
Console.ResetColor();
|
||||
}
|
||||
public static async Task LogWarning(string message)
|
||||
{
|
||||
Console.BackgroundColor = ConsoleColor.Yellow;
|
||||
Console.ForegroundColor = ConsoleColor.Black;
|
||||
Console.WriteLine($"[WARNING - {DateTime.Now}] {message}");
|
||||
await File.AppendAllTextAsync("logs.log", $"[WARNING - {DateTime.Now}] {message}\n");
|
||||
Console.ResetColor();
|
||||
}
|
||||
|
||||
}
|
||||
public class Log
|
||||
{
|
||||
public DateTime Now { get; set; }
|
||||
public string Method { get; set; }
|
||||
public string Path { get; set; }
|
||||
public string UserAgent { get; set; }
|
||||
public string Referer { get; set; }
|
||||
public string Body { get; set; }
|
||||
public string IP { get; set; }
|
||||
}
|
||||
}
|
||||
-2774
File diff suppressed because it is too large
Load Diff
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:29219",
|
||||
"sslPort": 44358
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://*:5240"
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "https://*:7220;http://*:5240"
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="pastes\**" />
|
||||
<Content Remove="pastes\**" />
|
||||
<EmbeddedResource Remove="pastes\**" />
|
||||
<None Remove="pastes\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="assets\admin.html" />
|
||||
<None Remove="assets\admin\user.html" />
|
||||
<None Remove="assets\archives.html" />
|
||||
<None Remove="assets\banned.html" />
|
||||
<None Remove="assets\dash.html" />
|
||||
<None Remove="assets\error.html" />
|
||||
<None Remove="assets\login.html" />
|
||||
<None Remove="assets\paste.html" />
|
||||
<None Remove="assets\privatepaste.html" />
|
||||
<None Remove="assets\recent_pastes.html" />
|
||||
<None Remove="assets\signup.html" />
|
||||
<None Remove="assets\user.html" />
|
||||
<None Remove="pastes.sqlite" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="assets\admin.html">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="assets\admin\user.html">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="assets\archives.html">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="assets\banned.html">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="assets\index.html">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="assets\privatepaste.html">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="pastes.sqlite">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
|
||||
<PackageReference Include="BouncyCastle.Cryptography" Version="2.4.0" />
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.8" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="wwwroot\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="assets\dash.html">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="assets\error.html">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="assets\login.html">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="assets\paste.html">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="assets\recent_pastes.html">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="assets\signup.html">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="assets\user.html">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Update="config.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,35 +0,0 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
|
||||
namespace Sharpbin
|
||||
{
|
||||
public class Turnstile
|
||||
{
|
||||
public static async Task<bool> VerifyTurnstileToken(string token)
|
||||
{
|
||||
var httpClient = new HttpClient();
|
||||
JObject requestBody = new JObject
|
||||
{
|
||||
["secret"] = Program.cfTurnstileSecret,
|
||||
["response"] = token
|
||||
};
|
||||
var request = new HttpRequestMessage
|
||||
{
|
||||
Method = HttpMethod.Post,
|
||||
RequestUri = new Uri("https://challenges.cloudflare.com/turnstile/v0/siteverify"),
|
||||
Content = new StringContent(requestBody.ToString(), Encoding.UTF8, "application/json")
|
||||
};
|
||||
using (var response = await httpClient.SendAsync(request))
|
||||
{
|
||||
var jsonresponse = JObject.Parse(await response.Content.ReadAsStringAsync());
|
||||
if (jsonresponse["success"]?.ToString().ToLower() == "true")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,488 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@100..900&display=swap" rel="stylesheet">
|
||||
<title>dashboard</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="nav-div">
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
</div>
|
||||
<div class="nav-hamburger-menu">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" fill="currentColor" class="bi bi-list"
|
||||
viewBox="0 0 16 16" id="hamburger-button" style="cursor: pointer;">
|
||||
<path fill-rule="evenodd"
|
||||
d="M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5" />
|
||||
</svg>
|
||||
<div class="nav-buttons">
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-wrapper">
|
||||
<div class="dash-container">
|
||||
<div class="wrapper">
|
||||
<div class="idek-wrapper">
|
||||
<div class="account-info">
|
||||
<span id="username">Username: {username}</span>
|
||||
<span id="uuid">UUID: {uuid}</span>
|
||||
<span id="uid">UID: {uid}</span>
|
||||
<span id="creationdate">{creationdate}</span>
|
||||
<span id="lastlogindate">{lastlogindate}</span>
|
||||
<span id="type">Account Type: {type}</span>
|
||||
<span id="pastescount">Total Pastes: {totalpastes}</span>
|
||||
<span id="pasteSize">Total Pastes Size: {totalsize}</span>
|
||||
</div>
|
||||
<div class="pastes-wrapper">
|
||||
<h3>Your Pastes</h3>
|
||||
<div class="list-container">
|
||||
{pastes}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="idek-wrapper accounts">
|
||||
<div class="accounts-wrapper">
|
||||
<h3>Accounts</h3>
|
||||
<input type="text" placeholder="search" class="text-input" oninput="waitSearch()">
|
||||
<div class="list-container" onscroll="getUsers()">
|
||||
{accounts}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="notifcations-wrapper" id="notifications"></div>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
let searchTimeout;
|
||||
function localizeDateTime(unixTimestamp) {
|
||||
const date = new Date(unixTimestamp * 1000);
|
||||
return date.toLocaleString();
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const creationdateElement = document.getElementById('creationdate');
|
||||
const lastlogindateElement = document.getElementById('lastlogindate');
|
||||
|
||||
const creationdateText = creationdateElement.innerText.trim();
|
||||
const lastlogindateText = lastlogindateElement.innerText.trim();
|
||||
|
||||
creationdateElement.innerText = "Creation Date: " + localizeDateTime(parseInt(creationdateText));
|
||||
lastlogindateElement.innerText = "Last Login Date: " + localizeDateTime(parseInt(lastlogindateText));
|
||||
var mobile = window.mobileCheck();
|
||||
if (mobile) {
|
||||
document.querySelector('.nav-div').style.display = 'none';
|
||||
document.querySelector('.nav-hamburger-menu').style.display = 'flex';
|
||||
}
|
||||
});
|
||||
document.getElementById("hamburger-button").addEventListener("click", function () {
|
||||
const nav = document.querySelector('.nav-buttons');
|
||||
if (nav.style.display == 'none' || nav.style.display == '') {
|
||||
nav.style.display = 'flex';
|
||||
} else {
|
||||
nav.style.display = 'none';
|
||||
}
|
||||
});
|
||||
window.mobileCheck = function () {
|
||||
let check = false;
|
||||
(function (a) { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true; })(navigator.userAgent || navigator.vendor || window.opera);
|
||||
return check;
|
||||
};
|
||||
function createNotification(message) {
|
||||
const notificationWrapper = document.getElementById('notifications');
|
||||
const notificationDiv = document.createElement('div');
|
||||
notificationDiv.classList.add('notification-div');
|
||||
notificationDiv.id = 'notification';
|
||||
|
||||
const notificationText = document.createElement('h2');
|
||||
notificationText.id = 'notification-text';
|
||||
notificationText.innerText = message;
|
||||
|
||||
notificationDiv.appendChild(notificationText);
|
||||
notificationWrapper.appendChild(notificationDiv);
|
||||
|
||||
notificationDiv.style.animation = 'none';
|
||||
notificationDiv.style.display = 'none';
|
||||
notificationDiv.style.display = 'flex';
|
||||
notificationDiv.style.animation = 'hoverup 1s';
|
||||
|
||||
setTimeout(() => {
|
||||
notificationDiv.style.animation = 'hoverdown 1s';
|
||||
}, 4000);
|
||||
|
||||
setTimeout(() => {
|
||||
notificationDiv.remove();
|
||||
}, 4900);
|
||||
}
|
||||
function waitSearch() {
|
||||
clearTimeout(searchTimeout);
|
||||
searchTimeout = setTimeout(search, 200);
|
||||
}
|
||||
function search() {
|
||||
const input = document.querySelector('.text-input').value;
|
||||
const accountWrapper = document.querySelector('.accounts-wrapper');
|
||||
const accounts = accountWrapper.querySelectorAll('.list-a');
|
||||
if (input.length == 0){
|
||||
fetch(`/api/accounts/admin/get?html=true`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
offset: 0,
|
||||
})
|
||||
})
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
const listContainer = accountWrapper.querySelector('.list-container');
|
||||
listContainer.innerHTML = data;
|
||||
})
|
||||
return;
|
||||
}
|
||||
fetch(`/api/accounts/admin/search?html=true`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
search: input
|
||||
})
|
||||
})
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
const listContainer = accountWrapper.querySelector('.list-container');
|
||||
listContainer.innerHTML = data;
|
||||
})
|
||||
}
|
||||
function getUsers() {
|
||||
const accountWrapper = document.querySelector('.accounts-wrapper');
|
||||
const listContainer = accountWrapper.querySelector('.list-container');
|
||||
const accounts = accountWrapper.querySelectorAll('.list-a');
|
||||
const lastAccount = accounts[accounts.length - 1];
|
||||
const lastAccountUsername = lastAccount.querySelector('.list-item').innerText;
|
||||
const lastAccountUUID = lastAccount.querySelector('.list-item').getAttribute('data-uuid');
|
||||
var isScrolledDown = listContainer.scrollTop + listContainer.clientHeight >= listContainer.scrollHeight - 100;
|
||||
if (!isScrolledDown) {
|
||||
return;
|
||||
}
|
||||
fetch(`/api/accounts/admin/get?html=true`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
offset: accounts.length,
|
||||
})
|
||||
})
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
if (data === '') {
|
||||
return;
|
||||
}
|
||||
if (listContainer.innerHTML.includes(data)) {
|
||||
return;
|
||||
}
|
||||
listContainer.innerHTML += data;
|
||||
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
}
|
||||
function isScrolledDown(element){
|
||||
var scrollPosition = element.scrollTop + element.clientHeight;
|
||||
var scrollHeight = element.scrollHeight;
|
||||
return scrollPosition >= scrollHeight;
|
||||
}
|
||||
|
||||
</script>
|
||||
<style>
|
||||
.list-container {
|
||||
max-height: 100%;
|
||||
overflow-y: scroll;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #0d0d0d;
|
||||
}
|
||||
|
||||
.container-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 98.7vh;
|
||||
}
|
||||
|
||||
.dash-container {
|
||||
display: flex;
|
||||
padding: 20px;
|
||||
background-color: #181818;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
width: 80%;
|
||||
max-height: 100%;
|
||||
min-height: 20%;
|
||||
height: fit-content;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.idek-wrapper {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.account-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background-color: #222222;
|
||||
width: 48%;
|
||||
padding: 20px;
|
||||
margin-right: 5px;
|
||||
border-radius: 5px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.pastes-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 48%;
|
||||
margin-left: 5px;
|
||||
border-radius: 5px;
|
||||
padding: 20px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
background-color: #222222;
|
||||
max-height: 30vh;
|
||||
}
|
||||
|
||||
.accounts-wrapper {
|
||||
margin-top: 10px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
border-radius: 5px;
|
||||
padding: 20px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
background-color: #222222;
|
||||
max-height: 40vh;
|
||||
}
|
||||
|
||||
.wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.list-a {
|
||||
transition: 300ms;
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
width: 90%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
background-color: #2a2a2a;
|
||||
margin-top: 5px;
|
||||
margin-bottom: 5px;
|
||||
border: #3a3a3a00 2px solid;
|
||||
}
|
||||
|
||||
.list-a:hover {
|
||||
transition: background-color 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
.list-item {
|
||||
list-style: none;
|
||||
max-width: 100%;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.text-input {
|
||||
transition: border 300ms;
|
||||
width: 90.2%;
|
||||
height: 1.2rem;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
border-radius: 5px;
|
||||
border: #2a2a2a 2px solid;
|
||||
background-color: #2a2a2a;
|
||||
color: white;
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
}
|
||||
|
||||
.text-input:focus {
|
||||
transition: border 300ms;
|
||||
outline: none;
|
||||
border: #333333 2px solid;
|
||||
}
|
||||
|
||||
.nav-div {
|
||||
top: 0;
|
||||
margin-top: 10px;
|
||||
position: absolute;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: fit-content;
|
||||
background-color: #181818;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.nav-hamburger-menu {
|
||||
top: 0;
|
||||
position: absolute;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 99vw;
|
||||
overflow-x: hidden;
|
||||
background-color: #181818;
|
||||
color: white;
|
||||
height: fit-content;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.nav-buttons {
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.nav-buttons a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin: 2px;
|
||||
border-radius: 5px;
|
||||
background-color: #222222;
|
||||
transition: 300ms;
|
||||
border: #2a2a2a00 2px solid;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
|
||||
.nav-buttons a:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
.nav-div a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
border-radius: 5px;
|
||||
background-color: #222222;
|
||||
transition: 300ms;
|
||||
border: #2a2a2a00 2px solid;
|
||||
}
|
||||
|
||||
.nav-div a:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
@media screen and (max-width: 800px) {
|
||||
.nav-div {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-hamburger-menu {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.nav-buttons {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-buttons a {
|
||||
display: block;
|
||||
}
|
||||
.dash-container{
|
||||
height: 80%;
|
||||
margin-top: 6rem;
|
||||
}
|
||||
.container-wrapper {
|
||||
height: 90%;
|
||||
}.wrapper {
|
||||
height: 70%;
|
||||
max-height: 70%;
|
||||
}
|
||||
.idek-wrapper {
|
||||
flex-direction: column;
|
||||
}
|
||||
.accounts{
|
||||
max-height: 20%;
|
||||
}
|
||||
.account-info {
|
||||
width: 90%;
|
||||
margin: 0;
|
||||
}
|
||||
.pastes-wrapper {
|
||||
width: 90%;
|
||||
margin: 0;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.accounts-wrapper {
|
||||
width: 90%;
|
||||
margin: 0;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.list-container {
|
||||
max-height: 100%;
|
||||
overflow-y: scroll;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
</html>
|
||||
@@ -1,687 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@100..900&display=swap" rel="stylesheet">
|
||||
<title>{username}</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="nav-div">
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
</div>
|
||||
<div class="nav-hamburger-menu">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" fill="currentColor" class="bi bi-list" viewBox="0 0 16 16" id="hamburger-button" style="cursor: pointer;">
|
||||
<path fill-rule="evenodd"
|
||||
d="M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5" />
|
||||
</svg>
|
||||
<div class="nav-buttons">
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-wrapper">
|
||||
<div class="account-container">
|
||||
<div class="account-info">
|
||||
<h2>{username}</h2>
|
||||
<h3>UUID: {uuid}</h3>
|
||||
<h3>UID: {uid}</h3>
|
||||
<h3 id="creationdate">{creationdate}</h3>
|
||||
<h3 id="lastlogindate">{lastlogindate}</h3>
|
||||
<h3>Account Type: {type}</h3>
|
||||
<h3>Total Pastes: {totalpastes}</h3>
|
||||
<h3>Total Pastes Size: {totalsize}</h3>
|
||||
</div>
|
||||
<div class="collumn-2">
|
||||
<div class="action-wrapper">
|
||||
<h2 style="text-align: center;">Actions</h2>
|
||||
<div class="button-wrapper">
|
||||
<a onclick="banorunban()" class="button">{typeban}</a>
|
||||
<a onclick="changePassword()" class="button">change password</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pastes-wrapper">
|
||||
<h2 style="text-align: center;">Pastes</h2>
|
||||
<div class="pastes-container">
|
||||
{pastes}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="notifcations-wrapper" id="notifications">
|
||||
|
||||
</div>
|
||||
<div class="input-div" id="ban-div" style="display: none;">
|
||||
<button onclick="banorunban()" class="exit-button">X</button>
|
||||
<input type="date" id="ban-date" placeholder="{typeban} date">
|
||||
<input type="text" id="ban-reason" placeholder="{typeban} reason">
|
||||
<button id="ban-button" onclick="banAccount()">{typeban}</button>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
function localizeDateTime(unixTimestamp) {
|
||||
const date = new Date(unixTimestamp * 1000);
|
||||
return date.toLocaleString();
|
||||
}
|
||||
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const creationdateElement = document.getElementById('creationdate');
|
||||
const lastlogindateElement = document.getElementById('lastlogindate');
|
||||
|
||||
const creationdateText = creationdateElement.innerText.trim();
|
||||
const lastlogindateText = lastlogindateElement.innerText.trim();
|
||||
|
||||
creationdateElement.innerText = "Creation Date: " + localizeDateTime(parseInt(creationdateText));
|
||||
lastlogindateElement.innerText = "Last Login Date: " + localizeDateTime(parseInt(lastlogindateText));
|
||||
if ('{typeban}' == 'unban') {
|
||||
document.getElementById('ban-date').style.display = 'none';
|
||||
}
|
||||
var mobile = window.mobileCheck();
|
||||
if (mobile) {
|
||||
document.querySelector('.nav-div').style.display = 'none';
|
||||
document.querySelector('.nav-hamburger-menu').style.display = 'flex';
|
||||
}
|
||||
});
|
||||
document.getElementById("hamburger-button").addEventListener("click", function () {
|
||||
const nav = document.querySelector('.nav-buttons');
|
||||
if (nav.style.display == 'none' || nav.style.display == '') {
|
||||
nav.style.display = 'flex';
|
||||
} else {
|
||||
nav.style.display = 'none';
|
||||
}
|
||||
});
|
||||
window.mobileCheck = function () {
|
||||
let check = false;
|
||||
(function (a) { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true; })(navigator.userAgent || navigator.vendor || window.opera);
|
||||
return check;
|
||||
};
|
||||
function banorunban() {
|
||||
const banDiv = document.getElementById('ban-div');
|
||||
console.log(banDiv.style.display);
|
||||
if (banDiv.style.display == 'none') {
|
||||
banDiv.style.animation = 'hoverup 1s';
|
||||
banDiv.style.display = 'flex';
|
||||
} else {
|
||||
banDiv.style.animation = 'hoverdown 1s';
|
||||
|
||||
setTimeout(() => {
|
||||
banDiv.style.transition = '200ms';
|
||||
banDiv.style.opacity = 0;
|
||||
|
||||
|
||||
}, 600);
|
||||
setTimeout(() => {
|
||||
banDiv.style.display = 'none';
|
||||
banDiv.style.opacity = 1;
|
||||
}, 1000);
|
||||
|
||||
}
|
||||
console.log(banDiv.style.display);
|
||||
}
|
||||
function banAccount() {
|
||||
let date = document.getElementById('ban-date').value;
|
||||
date = new Date(date).getTime() / 1000;
|
||||
let reason = document.getElementById('ban-reason').value;
|
||||
if (date == null || reason == null) {
|
||||
createNotification('Please fill out all fields');
|
||||
return;
|
||||
}
|
||||
if (date < new Date().getTime() / 1000) {
|
||||
createNotification('Please select a date in the future');
|
||||
return;
|
||||
}
|
||||
if ('{typeban}' == 'unban') {
|
||||
fetch('/api/accounts/admin/{typeban}', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
uuid: '{uuid}',
|
||||
reason: `${reason}`
|
||||
})
|
||||
|
||||
}).then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
if (result.message != null) {
|
||||
createNotification(`${result.message} for ${reason}`);
|
||||
} else {
|
||||
createNotification(`Failed to {typeban} ${result.error}`);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
fetch('/api/accounts/admin/{typeban}', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
uuid: '{uuid}',
|
||||
expiration: `${date}`,
|
||||
reason: `${reason}`
|
||||
})
|
||||
|
||||
}).then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
if (result.message != null) {
|
||||
createNotification(`${result.message} for ${reason}`);
|
||||
} else {
|
||||
createNotification(`Failed to {typeban} ${result.error}`);
|
||||
}
|
||||
})
|
||||
}
|
||||
console.log(date);
|
||||
banorunban();
|
||||
}
|
||||
function changePassword() {
|
||||
let password = prompt('Enter the new password');
|
||||
fetch('/api/accounts/admin/change-password', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
uuid: '{uuid}',
|
||||
password: `${password}`
|
||||
})
|
||||
|
||||
}).then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
if (result.message != null) {
|
||||
createNotification(`${result.message} to ${result.password}`);
|
||||
navigator.clipboard.writeText(result.password);
|
||||
} else {
|
||||
notification(`Failed to change password for ${result.error}`);
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
function createNotification(message) {
|
||||
const notificationWrapper = document.getElementById('notifications');
|
||||
const notificationDiv = document.createElement('div');
|
||||
notificationDiv.classList.add('notification-div');
|
||||
notificationDiv.id = 'notification';
|
||||
|
||||
const notificationText = document.createElement('h2');
|
||||
notificationText.id = 'notification-text';
|
||||
notificationText.innerText = message;
|
||||
|
||||
notificationDiv.appendChild(notificationText);
|
||||
notificationWrapper.appendChild(notificationDiv);
|
||||
|
||||
notificationDiv.style.animation = 'none';
|
||||
notificationDiv.style.display = 'none';
|
||||
notificationDiv.style.display = 'flex';
|
||||
notificationDiv.style.animation = 'hoverup 1s';
|
||||
|
||||
setTimeout(() => {
|
||||
notificationDiv.style.animation = 'hoverdown 1s';
|
||||
}, 4000);
|
||||
|
||||
setTimeout(() => {
|
||||
notificationDiv.remove();
|
||||
}, 4900);
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.notifcations-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
justify-content: flex-end;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.exit-button {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 10px;
|
||||
background-color: #222222;
|
||||
color: white;
|
||||
border: #222222 2px solid;
|
||||
border-radius: 5px;
|
||||
padding: 5px;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
cursor: pointer;
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: bold;
|
||||
width: fit-content;
|
||||
height: fit-content;
|
||||
}
|
||||
|
||||
#ban-div {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.input-div {
|
||||
z-index: 2;
|
||||
position: fixed;
|
||||
background-color: #121212;
|
||||
border-radius: 10px;
|
||||
width: fit-content;
|
||||
max-width: 50%;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: fit-content;
|
||||
padding: 60px;
|
||||
max-height: 50%;
|
||||
border: #181818 3px solid;
|
||||
}
|
||||
|
||||
input {
|
||||
transition: 300ms;
|
||||
width: 80%;
|
||||
max-width: 80%;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
border-radius: 5px;
|
||||
border: #222222 2px solid;
|
||||
background-color: #222222;
|
||||
color: white;
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
}
|
||||
|
||||
input:focus {
|
||||
transition: 300ms;
|
||||
outline: none;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
#ban-button {
|
||||
transition: 300ms;
|
||||
width: 80%;
|
||||
max-width: 80%;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
border-radius: 5px;
|
||||
border: #222222 2px solid;
|
||||
background-color: #222222;
|
||||
color: white;
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
|
||||
#ban-button:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
@keyframes hoverup {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%);
|
||||
}
|
||||
|
||||
25% {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
50% {
|
||||
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes hoverdown {
|
||||
0% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
50% {
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: translateY(200%);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.notification-div {
|
||||
display: flex;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: fit-content;
|
||||
height: fit-content;
|
||||
color: white;
|
||||
background-color: #181818;
|
||||
border-radius: 5px;
|
||||
border: #222222 2px solid;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
margin-right: 10px;
|
||||
margin-bottom: 10px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
h3 {
|
||||
word-break: keep-all;
|
||||
margin-top: -5px;
|
||||
}
|
||||
|
||||
.list-a {
|
||||
transition: background-color 300ms;
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
width: 90%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
background-color: #2a2a2a;
|
||||
margin-top: 5px;
|
||||
margin-bottom: 5px;
|
||||
border: #3a3a3a00 2px solid;
|
||||
}
|
||||
|
||||
.list-a:hover {
|
||||
transition: background-color 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
.list-item {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.collumn-2 {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 48%;
|
||||
max-width: 48%;
|
||||
}
|
||||
|
||||
.pastes-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: fit-content;
|
||||
width: calc(100% - 40px);
|
||||
max-width: 100%;
|
||||
background-color: #222222;
|
||||
border-radius: 5px;
|
||||
padding: 20px;
|
||||
height: fit-content;
|
||||
margin-top: 10px;
|
||||
height: 77.1%;
|
||||
max-height: 77.1%;
|
||||
}
|
||||
|
||||
.pastes-container {
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
height: 100%;
|
||||
max-height: 100%;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #0d0d0d;
|
||||
position: relative;
|
||||
height: calc(100vh - 20px);
|
||||
}
|
||||
|
||||
.container-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.account-container {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
width: 80%;
|
||||
padding: 20px;
|
||||
background-color: #181818;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
margin-top: 6rem;
|
||||
max-height: 100%;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.account-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background-color: #222222;
|
||||
padding: 20px;
|
||||
border-radius: 5px;
|
||||
width: fit-content;
|
||||
width: 48%;
|
||||
max-width: 48%;
|
||||
margin-right: 10px;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.action-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: fit-content;
|
||||
width: calc(100% - 40px);
|
||||
max-width: 100%;
|
||||
background-color: #222222;
|
||||
border-radius: 5px;
|
||||
padding: 20px;
|
||||
height: fit-content;
|
||||
max-height: 20%;
|
||||
padding-bottom: 40px;
|
||||
}
|
||||
|
||||
.button {
|
||||
text-decoration: none;
|
||||
transition: 300ms;
|
||||
width: fit-content;
|
||||
padding: 10px;
|
||||
margin: 10px 0;
|
||||
border-radius: 5px;
|
||||
border: none;
|
||||
background-color: #2a2a2a;
|
||||
margin-left: 10px;
|
||||
margin-right: 10px;
|
||||
color: white;
|
||||
border: #2a2a2a00 2px solid;
|
||||
cursor: pointer;
|
||||
font-size: 1.2em;
|
||||
text-align: center;
|
||||
min-width: 80px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: 2px solid #3a3a3a;
|
||||
}
|
||||
|
||||
|
||||
.nav-div {
|
||||
top: 0;
|
||||
margin-top: 10px;
|
||||
position: absolute;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: fit-content;
|
||||
background-color: #181818;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.nav-hamburger-menu {
|
||||
top: 0;
|
||||
position: absolute;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 99vw;
|
||||
overflow-x: hidden;
|
||||
background-color: #181818;
|
||||
color: white;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.nav-buttons {
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.nav-buttons a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin: 2px;
|
||||
border-radius: 5px;
|
||||
background-color: #222222;
|
||||
transition: 300ms;
|
||||
border: #2a2a2a00 2px solid;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
|
||||
.nav-buttons a:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
.nav-div a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
border-radius: 5px;
|
||||
background-color: #222222;
|
||||
transition: 300ms;
|
||||
border: #2a2a2a00 2px solid;
|
||||
}
|
||||
|
||||
.nav-div a:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
@media screen and (max-width: 800px) {
|
||||
.nav-div {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-hamburger-menu {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.nav-buttons {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-buttons a {
|
||||
display: block;
|
||||
}
|
||||
.container-wrapper{
|
||||
height: 90%;
|
||||
}
|
||||
.account-container {
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
max-height: 100%;
|
||||
}
|
||||
.account-info {
|
||||
margin-right: 0px;
|
||||
width: 90%;
|
||||
max-width: 100%;
|
||||
font-size: smaller !important;
|
||||
}
|
||||
.collumn-2 {
|
||||
margin-top: 10px;
|
||||
width: 90%;
|
||||
max-width: 100%;
|
||||
max-height: 48%;
|
||||
}
|
||||
.action-wrapper {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
max-height: 40%;
|
||||
}
|
||||
.button {
|
||||
width: 90%;
|
||||
max-width: 100%;
|
||||
margin: 0;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.pastes-wrapper {
|
||||
margin-top: 10px;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
max-height: calc(500px * 1.5);
|
||||
}
|
||||
.pastes-container {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
max-height: 20%;
|
||||
overflow-x: hidden;
|
||||
text-align: start;
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
|
||||
</html>
|
||||
@@ -1,376 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@100..900&display=swap" rel="stylesheet">
|
||||
<title>archive</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="nav-div">
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
</div>
|
||||
<div class="nav-hamburger-menu">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" fill="currentColor" class="bi bi-list" viewBox="0 0 16 16" id="hamburger-button" style="cursor: pointer;">
|
||||
<path fill-rule="evenodd"
|
||||
d="M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5" />
|
||||
</svg>
|
||||
<div class="nav-buttons">
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-wrapper">
|
||||
<div class="pastes-container">
|
||||
<h1>paste archive</h1>
|
||||
<input type="text" placeholder="search" class="text-input" oninput="search()">
|
||||
<div class="pastes-wrapper">
|
||||
{pastes}
|
||||
</div>
|
||||
<div class="buttons-wrapper">
|
||||
<a class="arrow-button" href="/archive?page={backpagenum}"><</a>
|
||||
<p>{currentpagenum}/{totalpages}</p>
|
||||
<a class="arrow-button" href="/archive?page={pagenum}">></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
let searchTimeout;
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
var mobile = window.mobileCheck();
|
||||
if (mobile) {
|
||||
document.querySelector('.nav-div').style.display = 'none';
|
||||
document.querySelector('.nav-hamburger-menu').style.display = 'flex';
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById("hamburger-button").addEventListener("click", function () {
|
||||
const nav = document.querySelector('.nav-buttons');
|
||||
if (nav.style.display == 'none' || nav.style.display == '') {
|
||||
nav.style.display = 'flex';
|
||||
} else {
|
||||
nav.style.display = 'none';
|
||||
}
|
||||
});
|
||||
window.mobileCheck = function () {
|
||||
let check = false;
|
||||
(function (a) { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true; })(navigator.userAgent || navigator.vendor || window.opera);
|
||||
return check;
|
||||
};
|
||||
|
||||
function search() {
|
||||
clearTimeout(searchTimeout);
|
||||
searchTimeout = setTimeout(searchPastes, 200);
|
||||
}
|
||||
|
||||
function searchPastes() {
|
||||
const searchInput = document.querySelector('.text-input');
|
||||
if (searchInput.value.length < 3 && searchInput.value.length != 0) {
|
||||
return;
|
||||
}
|
||||
else if (searchInput.value.length == 0) {
|
||||
fetch(`/api/pastes/search?html=true`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
query: ''
|
||||
})
|
||||
})
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
const pastesWrapper = document.querySelector('.pastes-wrapper');
|
||||
if (data === '') {
|
||||
pastesWrapper.innerHTML = '<h1>no pastes found</h1>';
|
||||
return;
|
||||
}
|
||||
try {
|
||||
json = JSON.parse(data);
|
||||
if (json.error != null) {
|
||||
pastesWrapper.innerHTML = `<h1>${json.error}</h1>`;
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch {
|
||||
}
|
||||
|
||||
pastesWrapper.innerHTML = data;
|
||||
});
|
||||
return;
|
||||
}
|
||||
fetch(`/api/pastes/search?html=true`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
query: searchInput.value
|
||||
})
|
||||
})
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
const pastesWrapper = document.querySelector('.pastes-wrapper');
|
||||
if (data === '') {
|
||||
pastesWrapper.innerHTML = '<h1>no pastes found</h1>';
|
||||
return;
|
||||
}
|
||||
try {
|
||||
json = JSON.parse(data);
|
||||
if (json.error != null) {
|
||||
pastesWrapper.innerHTML = `<h1>${json.error}</h1>`;
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch {
|
||||
}
|
||||
pastesWrapper.innerHTML = data;
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
body {
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #0d0d0d;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
|
||||
.container-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.pastes-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 80%;
|
||||
padding: 20px;
|
||||
background-color: #181818;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
max-height: 80vh;
|
||||
min-height: 20%;
|
||||
border: #222222 2px solid;
|
||||
transition: height 300ms;
|
||||
}
|
||||
|
||||
.pastes-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
padding: 20px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
max-height: 70vh;
|
||||
}
|
||||
|
||||
|
||||
|
||||
li {
|
||||
transition: 300ms;
|
||||
list-style: none;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
background-color: #222222;
|
||||
border-radius: 5px;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
border: #22222200 2px solid;
|
||||
}
|
||||
|
||||
li:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
.buttons-wrapper {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.buttons-wrapper a {
|
||||
transition: 300ms;
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
width: fit-content;
|
||||
margin-left: 10px;
|
||||
margin-right: 10px;
|
||||
min-width: 20%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #222222;
|
||||
border-radius: 5px;
|
||||
padding: 10px;
|
||||
border: #22222200 2px solid;
|
||||
}
|
||||
|
||||
.buttons-wrapper a:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: 2px solid #3a3a3a;
|
||||
}
|
||||
|
||||
.pastes-wrapper a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.text-input {
|
||||
transition: border 300ms;
|
||||
width: calc(100% - 44px);
|
||||
height: 1.2rem;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
margin-left: 12px;
|
||||
border-radius: 5px;
|
||||
border: #222222 2px solid;
|
||||
background-color: #222222;
|
||||
color: white;
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
}
|
||||
|
||||
.text-input:focus {
|
||||
transition: border 300ms;
|
||||
outline: none;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
|
||||
.nav-div {
|
||||
top: 0;
|
||||
margin-top: 10px;
|
||||
position: absolute;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: fit-content;
|
||||
background-color: #181818;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.nav-hamburger-menu {
|
||||
top: 0;
|
||||
position: absolute;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 99vw;
|
||||
overflow-x: hidden;
|
||||
background-color: #181818;
|
||||
color: white;
|
||||
height: fit-content;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.nav-buttons {
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.nav-buttons a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin: 2px;
|
||||
border-radius: 5px;
|
||||
background-color: #222222;
|
||||
transition: 300ms;
|
||||
border: #2a2a2a00 2px solid;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
|
||||
.nav-buttons a:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
.nav-div a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
border-radius: 5px;
|
||||
background-color: #222222;
|
||||
transition: 300ms;
|
||||
border: #2a2a2a00 2px solid;
|
||||
}
|
||||
|
||||
.nav-div a:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
@media screen and (max-width: 800px) {
|
||||
.nav-div {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-hamburger-menu {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.nav-buttons {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-buttons a {
|
||||
display: block;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.arrow-button {
|
||||
min-width: fit-content !important;
|
||||
padding-left: 1rem !important;
|
||||
padding-right: 1rem !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
</html>
|
||||
@@ -1,217 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@100..900&display=swap" rel="stylesheet">
|
||||
<title>Error {code}</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="nav-div">
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
</div>
|
||||
<div class="nav-hamburger-menu">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" fill="currentColor" class="bi bi-list"
|
||||
viewBox="0 0 16 16" id="hamburger-button" style="cursor: pointer;">
|
||||
<path fill-rule="evenodd"
|
||||
d="M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5" />
|
||||
</svg>
|
||||
<div class="nav-buttons">
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-wrapper">
|
||||
<div class="error-container">
|
||||
<h1>Error {code}</h1>
|
||||
<h2>{message}</h2>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
function localizeDateTime(unixTimestamp) {
|
||||
const date = new Date(unixTimestamp * 1000);
|
||||
return date.toLocaleString();
|
||||
}
|
||||
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const dateElement = document.getElementById('unix-date');
|
||||
const time = localizeDateTime(parseInt(dateElement.innerText.trim()));
|
||||
dateElement.innerText = time;
|
||||
var mobile = window.mobileCheck();
|
||||
if (mobile) {
|
||||
document.querySelector('.nav-div').style.display = 'none';
|
||||
document.querySelector('.nav-hamburger-menu').style.display = 'flex';
|
||||
}
|
||||
});
|
||||
document.getElementById("hamburger-button").addEventListener("click", function () {
|
||||
const nav = document.querySelector('.nav-buttons');
|
||||
if (nav.style.display == 'none' || nav.style.display == '') {
|
||||
nav.style.display = 'flex';
|
||||
} else {
|
||||
nav.style.display = 'none';
|
||||
}
|
||||
});
|
||||
window.mobileCheck = function () {
|
||||
let check = false;
|
||||
(function (a) { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true; })(navigator.userAgent || navigator.vendor || window.opera);
|
||||
return check;
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
body{
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #0d0d0d;
|
||||
}
|
||||
.container-wrapper{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 98.7vh;
|
||||
}
|
||||
.error-container{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 80%;
|
||||
padding: 20px;
|
||||
background-color: #181818;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
max-height: 80vh;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
.button{
|
||||
text-decoration: none;
|
||||
transition: 300ms;
|
||||
width: fit-content;
|
||||
padding: 10px;
|
||||
margin: 10px 0;
|
||||
border-radius: 5px;
|
||||
border: none;
|
||||
background-color: #222222;
|
||||
color: white;
|
||||
border: #2a2a2a00 2px solid;
|
||||
cursor: pointer;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
.button:hover{
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: 2px solid #3a3a3a;
|
||||
}
|
||||
.nav-div {
|
||||
top: 0;
|
||||
margin-top: 10px;
|
||||
position: absolute;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: fit-content;
|
||||
background-color: #181818;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.nav-hamburger-menu {
|
||||
top: 0;
|
||||
position: absolute;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 99vw;
|
||||
overflow-x: hidden;
|
||||
background-color: #181818;
|
||||
color: white;
|
||||
height: fit-content;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.nav-buttons {
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.nav-buttons a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin: 2px;
|
||||
border-radius: 5px;
|
||||
background-color: #222222;
|
||||
transition: 300ms;
|
||||
border: #2a2a2a00 2px solid;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
|
||||
.nav-buttons a:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
.nav-div a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
border-radius: 5px;
|
||||
background-color: #222222;
|
||||
transition: 300ms;
|
||||
border: #2a2a2a00 2px solid;
|
||||
}
|
||||
|
||||
.nav-div a:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
@media screen and (max-width: 800px) {
|
||||
.nav-div {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-hamburger-menu {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.nav-buttons {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-buttons a {
|
||||
display: block;
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
</html>
|
||||
@@ -1,349 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@100..900&display=swap" rel="stylesheet">
|
||||
<title>dashboard</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="nav-div">
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
</div>
|
||||
<div class="nav-hamburger-menu">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" fill="currentColor" class="bi bi-list"
|
||||
viewBox="0 0 16 16" id="hamburger-button" style="cursor: pointer;">
|
||||
<path fill-rule="evenodd"
|
||||
d="M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5" />
|
||||
</svg>
|
||||
<div class="nav-buttons">
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-wrapper">
|
||||
<div class="dash-container">
|
||||
<div class="wrapper">
|
||||
<div class="idek-wrapper">
|
||||
<div class="account-info">
|
||||
<span id="username">Username: {username}</span>
|
||||
<span id="uuid">UUID: {uuid}</span>
|
||||
<span id="uid">UID: {uid}</span>
|
||||
<span id="creationdate">{creationdate}</span>
|
||||
<span id="lastlogindate">{lastlogindate}</span>
|
||||
<span id="type">Account Type: {type}</span>
|
||||
<span id="pastescount">Total Pastes: {totalpastes}</span>
|
||||
<span id="pasteSize">Total Pastes Size: {totalsize}</span>
|
||||
</div>
|
||||
<div class="pastes-wrapper">
|
||||
<h3>Your Pastes</h3>
|
||||
{pastes}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="notifcations-wrapper" id="notifications">
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
function localizeDateTime(unixTimestamp) {
|
||||
const date = new Date(unixTimestamp * 1000);
|
||||
return date.toLocaleString();
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const creationdateElement = document.getElementById('creationdate');
|
||||
const lastlogindateElement = document.getElementById('lastlogindate');
|
||||
|
||||
const creationdateText = creationdateElement.innerText.trim();
|
||||
const lastlogindateText = lastlogindateElement.innerText.trim();
|
||||
|
||||
creationdateElement.innerText = "Creation Date: " + localizeDateTime(parseInt(creationdateText));
|
||||
lastlogindateElement.innerText = "Last Login Date: " + localizeDateTime(parseInt(lastlogindateText));
|
||||
var mobile = window.mobileCheck();
|
||||
if (mobile) {
|
||||
document.querySelector('.nav-div').style.display = 'none';
|
||||
document.querySelector('.nav-hamburger-menu').style.display = 'flex';
|
||||
}
|
||||
});
|
||||
document.getElementById("hamburger-button").addEventListener("click", function () {
|
||||
const nav = document.querySelector('.nav-buttons');
|
||||
if (nav.style.display == 'none' || nav.style.display == '') {
|
||||
nav.style.display = 'flex';
|
||||
} else {
|
||||
nav.style.display = 'none';
|
||||
}
|
||||
});
|
||||
window.mobileCheck = function () {
|
||||
let check = false;
|
||||
(function (a) { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true; })(navigator.userAgent || navigator.vendor || window.opera);
|
||||
return check;
|
||||
};
|
||||
function createNotification(message) {
|
||||
const notificationWrapper = document.getElementById('notifications');
|
||||
const notificationDiv = document.createElement('div');
|
||||
notificationDiv.classList.add('notification-div');
|
||||
notificationDiv.id = 'notification';
|
||||
|
||||
const notificationText = document.createElement('h2');
|
||||
notificationText.id = 'notification-text';
|
||||
notificationText.innerText = message;
|
||||
|
||||
notificationDiv.appendChild(notificationText);
|
||||
notificationWrapper.appendChild(notificationDiv);
|
||||
|
||||
notificationDiv.style.animation = 'none';
|
||||
notificationDiv.style.display = 'none';
|
||||
notificationDiv.style.display = 'flex';
|
||||
notificationDiv.style.animation = 'hoverup 1s';
|
||||
|
||||
setTimeout(() => {
|
||||
notificationDiv.style.animation = 'hoverdown 1s';
|
||||
}, 4000);
|
||||
|
||||
setTimeout(() => {
|
||||
notificationDiv.remove();
|
||||
}, 4900);
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
body {
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #0d0d0d;
|
||||
}
|
||||
|
||||
.container-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 98.7vh;
|
||||
}
|
||||
|
||||
.dash-container {
|
||||
display: flex;
|
||||
padding: 20px;
|
||||
background-color: #181818;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
width: 80%;
|
||||
max-height: 80vh;
|
||||
height: 50%;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.idek-wrapper {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.account-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background-color: #222222;
|
||||
width: 48%;
|
||||
height: calc(100% - 40px);
|
||||
padding: 20px;
|
||||
margin-right: 5px;
|
||||
border-radius: 5px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.pastes-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 48%;
|
||||
height: calc(100% - 40px);
|
||||
margin-left: 5px;
|
||||
border-radius: 5px;
|
||||
padding: 20px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
background-color: #222222;
|
||||
max-height: 70vh;
|
||||
}
|
||||
|
||||
.wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.list-a {
|
||||
transition: background-color 300ms;
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
background-color: #2a2a2a;
|
||||
margin-top: 5px;
|
||||
margin-bottom: 5px;
|
||||
border: #3a3a3a00 2px solid;
|
||||
}
|
||||
|
||||
.list-a:hover {
|
||||
transition: background-color 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
.list-item {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.nav-div {
|
||||
top: 0;
|
||||
margin-top: 10px;
|
||||
position: absolute;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: fit-content;
|
||||
background-color: #181818;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.nav-hamburger-menu {
|
||||
top: 0;
|
||||
position: absolute;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 99vw;
|
||||
overflow-x: hidden;
|
||||
background-color: #181818;
|
||||
color: white;
|
||||
height: fit-content;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.nav-buttons {
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.nav-buttons a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin: 2px;
|
||||
border-radius: 5px;
|
||||
background-color: #222222;
|
||||
transition: 300ms;
|
||||
border: #2a2a2a00 2px solid;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
|
||||
.nav-buttons a:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
.nav-div a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
border-radius: 5px;
|
||||
background-color: #222222;
|
||||
transition: 300ms;
|
||||
border: #2a2a2a00 2px solid;
|
||||
}
|
||||
|
||||
.nav-div a:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 800px) {
|
||||
.nav-div {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-hamburger-menu {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.nav-buttons {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-buttons a {
|
||||
display: block;
|
||||
}
|
||||
.dash-container{
|
||||
height: 80%;
|
||||
margin-top: 6rem;
|
||||
}
|
||||
.container-wrapper {
|
||||
height: 90%;
|
||||
}.wrapper {
|
||||
height: 70%;
|
||||
max-height: 70%;
|
||||
}
|
||||
.idek-wrapper {
|
||||
flex-direction: column;
|
||||
}
|
||||
.accounts{
|
||||
max-height: 20%;
|
||||
}
|
||||
.account-info {
|
||||
width: 90%;
|
||||
margin: 0;
|
||||
}
|
||||
.pastes-wrapper {
|
||||
width: 90%;
|
||||
margin: 0;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.list-container {
|
||||
max-height: 100%;
|
||||
overflow-y: scroll;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
</html>
|
||||
@@ -1,209 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@100..900&display=swap" rel="stylesheet">
|
||||
<title>Error {code}</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="nav-div">
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
</div>
|
||||
<div class="nav-hamburger-menu">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" fill="currentColor" class="bi bi-list"
|
||||
viewBox="0 0 16 16" id="hamburger-button" style="cursor: pointer;">
|
||||
<path fill-rule="evenodd"
|
||||
d="M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5" />
|
||||
</svg>
|
||||
<div class="nav-buttons">
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-wrapper">
|
||||
<div class="error-container">
|
||||
<h1>Error {code}</h1>
|
||||
<h2>{message}</h2>
|
||||
<a href="/" class="button">home page</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
var mobile = window.mobileCheck();
|
||||
if (mobile) {
|
||||
document.querySelector('.nav-div').style.display = 'none';
|
||||
document.querySelector('.nav-hamburger-menu').style.display = 'flex';
|
||||
}
|
||||
});
|
||||
document.getElementById("hamburger-button").addEventListener("click", function () {
|
||||
const nav = document.querySelector('.nav-buttons');
|
||||
if (nav.style.display == 'none' || nav.style.display == '') {
|
||||
nav.style.display = 'flex';
|
||||
} else {
|
||||
nav.style.display = 'none';
|
||||
}
|
||||
});
|
||||
window.mobileCheck = function () {
|
||||
let check = false;
|
||||
(function (a) { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true; })(navigator.userAgent || navigator.vendor || window.opera);
|
||||
return check;
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
body{
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #0d0d0d;
|
||||
}
|
||||
.container-wrapper{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 98.7vh;
|
||||
}
|
||||
.error-container{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 80%;
|
||||
padding: 20px;
|
||||
background-color: #181818;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
max-height: 80vh;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
.button{
|
||||
text-decoration: none;
|
||||
transition: 300ms;
|
||||
width: fit-content;
|
||||
padding: 10px;
|
||||
margin: 10px 0;
|
||||
border-radius: 5px;
|
||||
border: none;
|
||||
background-color: #222222;
|
||||
color: white;
|
||||
border: #2a2a2a00 2px solid;
|
||||
cursor: pointer;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
.button:hover{
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: 2px solid #3a3a3a;
|
||||
}
|
||||
.nav-div {
|
||||
top: 0;
|
||||
margin-top: 10px;
|
||||
position: absolute;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: fit-content;
|
||||
background-color: #181818;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.nav-hamburger-menu {
|
||||
top: 0;
|
||||
position: absolute;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 99vw;
|
||||
overflow-x: hidden;
|
||||
background-color: #181818;
|
||||
color: white;
|
||||
height: fit-content;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.nav-buttons {
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.nav-buttons a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin: 2px;
|
||||
border-radius: 5px;
|
||||
background-color: #222222;
|
||||
transition: 300ms;
|
||||
border: #2a2a2a00 2px solid;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
|
||||
.nav-buttons a:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
.nav-div a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
border-radius: 5px;
|
||||
background-color: #222222;
|
||||
transition: 300ms;
|
||||
border: #2a2a2a00 2px solid;
|
||||
}
|
||||
|
||||
.nav-div a:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
@media screen and (max-width: 800px) {
|
||||
.nav-div {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-hamburger-menu {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.nav-buttons {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-buttons a {
|
||||
display: block;
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
</html>
|
||||
@@ -1,419 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@100..900&display=swap" rel="stylesheet">
|
||||
<title>create paste</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="nav-div">
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
</div>
|
||||
<div class="nav-hamburger-menu">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" fill="currentColor" class="bi bi-list" viewBox="0 0 16 16" id="hamburger-button" style="cursor: pointer;">
|
||||
<path fill-rule="evenodd"
|
||||
d="M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5" />
|
||||
</svg>
|
||||
<div class="nav-buttons">
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-wrapper">
|
||||
<div class="creation-container">
|
||||
<h1>create paste</h1>
|
||||
<form id="createForm">
|
||||
<label for="pasteTitle" class="label">Title</label>
|
||||
<input type="text" id="pasteTitle" class="textinput" name="pasteTitle" maxlength="500">
|
||||
<label for="pasteContent" class="label">Content</label>
|
||||
<textarea id="pasteContent" class="textarea" name="pasteContent" required maxlength="500000"></textarea>
|
||||
<select for="pasteVisibility" id="pasteVisibility" class="textinput" name="pasteVisibility" required>
|
||||
<option value="Public">Public</option>
|
||||
<option value="Unlisted">Unlisted</option>
|
||||
<option value="Private">Private</option>
|
||||
</select>
|
||||
<label for="pastePassword" class="label" id="pastePasswordLabel">Paste Password</label>
|
||||
<input type="password" id="pastePassword" class="textinput" name="pastePassword" maxlength="500">
|
||||
<button type="submit" class="button">Create</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="notification-div" id="notification">
|
||||
<h2 id="notification-text"></h2>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
document.getElementById("pasteVisibility").value = "Public";
|
||||
var mobile = window.mobileCheck();
|
||||
if (mobile) {
|
||||
document.querySelector('.nav-div').style.display = 'none';
|
||||
document.querySelector('.nav-hamburger-menu').style.display = 'flex';
|
||||
}
|
||||
});
|
||||
document.getElementById("createForm").addEventListener("submit", function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var textAreaContent = document.getElementById("pasteContent").value;
|
||||
var textTitleContent = document.getElementById("pasteTitle").value;
|
||||
var textVisibilityContent = document.getElementById("pasteVisibility").value;
|
||||
|
||||
var requestUrl = "/api/pastes/create";
|
||||
var fetchBody = {
|
||||
title: textTitleContent,
|
||||
content: textAreaContent,
|
||||
visibility: textVisibilityContent
|
||||
};
|
||||
if (textVisibilityContent == "Private") {
|
||||
fetchBody.password = document.getElementById("pastePassword").value;
|
||||
}
|
||||
fetch(requestUrl, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(fetchBody)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
if (result.pasteId != null) {
|
||||
window.location.href = `/${result.pasteId}`;
|
||||
} else if (result.error != null) {
|
||||
notification(result.error);
|
||||
}
|
||||
})
|
||||
});
|
||||
document.getElementById("pasteVisibility").addEventListener("change", function (event) {
|
||||
var visibility = document.getElementById("pasteVisibility").value;
|
||||
if (visibility == "Private") {
|
||||
document.getElementById("pastePassword").style.display = "block";
|
||||
document.getElementById("pastePasswordLabel").style.display = "block";
|
||||
} else {
|
||||
document.getElementById("pastePassword").style.display = "none";
|
||||
document.getElementById("pastePasswordLabel").style.display = "none";
|
||||
}
|
||||
});
|
||||
function notification(message) {
|
||||
const notification = document.getElementById('notification');
|
||||
const notificationText = document.getElementById('notification-text');
|
||||
notificationText.innerText = message;
|
||||
notification.style.animation = 'none';
|
||||
notification.style.display = 'none';
|
||||
notification.style.display = 'flex';
|
||||
notification.style.animation = 'hoverup 1s';
|
||||
setTimeout(() => {
|
||||
|
||||
notification.style.animation = 'hoverdown 1s';
|
||||
}, 4000);
|
||||
setTimeout(() => {
|
||||
notification.style.display = 'none';
|
||||
}, 4900);
|
||||
|
||||
}
|
||||
document.getElementById("hamburger-button").addEventListener("click", function () {
|
||||
const nav = document.querySelector('.nav-buttons');
|
||||
if (nav.style.display == 'none' || nav.style.display == '') {
|
||||
nav.style.display = 'flex';
|
||||
} else {
|
||||
nav.style.display = 'none';
|
||||
}
|
||||
});
|
||||
window.mobileCheck = function () {
|
||||
let check = false;
|
||||
(function (a) { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true; })(navigator.userAgent || navigator.vendor || window.opera);
|
||||
return check;
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
@keyframes hoverup {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%);
|
||||
}
|
||||
|
||||
25% {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
50% {
|
||||
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes hoverdown {
|
||||
0% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
50% {
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: translateY(200%);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#pastePassword {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#pastePasswordLabel {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.notification-div {
|
||||
position: fixed;
|
||||
display: none;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: fit-content;
|
||||
height: fit-content;
|
||||
color: white;
|
||||
background-color: #181818;
|
||||
border-radius: 5px;
|
||||
border: #222222 2px solid;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
margin-right: 10px;
|
||||
margin-bottom: 10px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #0d0d0d;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.container-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 98.7vh;
|
||||
}
|
||||
|
||||
#pasteContent {
|
||||
max-height: 500px;
|
||||
}
|
||||
|
||||
.creation-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 80%;
|
||||
padding: 20px;
|
||||
background-color: #181818;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
max-height: 80vh;
|
||||
min-height: 20%;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
#createForm {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.label {
|
||||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
.textinput {
|
||||
transition: 300ms;
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
margin: 10px 0;
|
||||
border-radius: 5px;
|
||||
border: none;
|
||||
background-color: #282828;
|
||||
color: white;
|
||||
border: #2a2a2a 2px solid;
|
||||
box-sizing: border-box;
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-size: 1.1em;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.textinput:focus {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: 2px solid #3a3a3a;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.textarea {
|
||||
transition: 300ms;
|
||||
width: 100%;
|
||||
min-width: 100%;
|
||||
max-width: 100%;
|
||||
min-height: auto;
|
||||
padding: 10px;
|
||||
margin: 10px 0;
|
||||
border-radius: 5px;
|
||||
border: none;
|
||||
background-color: #282828;
|
||||
color: white;
|
||||
border: #2a2a2a 2px solid;
|
||||
box-sizing: border-box;
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-size: 1.08em;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.textarea:focus {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: 2px solid #3a3a3a;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.button {
|
||||
transition: 300ms;
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
margin: 10px 0;
|
||||
border-radius: 5px;
|
||||
border: none;
|
||||
background-color: #222222;
|
||||
color: white;
|
||||
border: #2a2a2a00 2px solid;
|
||||
cursor: pointer;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: 2px solid #3a3a3a;
|
||||
}
|
||||
|
||||
.nav-div {
|
||||
top: 0;
|
||||
margin-top: 10px;
|
||||
position: absolute;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: fit-content;
|
||||
background-color: #181818;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.nav-hamburger-menu {
|
||||
top: 0;
|
||||
position: absolute;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 99vw;
|
||||
overflow-x: hidden;
|
||||
background-color: #181818;
|
||||
color: white;
|
||||
height: fit-content;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.nav-buttons {
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.nav-buttons a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin: 2px;
|
||||
border-radius: 5px;
|
||||
background-color: #222222;
|
||||
transition: 300ms;
|
||||
border: #2a2a2a00 2px solid;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
|
||||
.nav-buttons a:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
.nav-div a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
border-radius: 5px;
|
||||
background-color: #222222;
|
||||
transition: 300ms;
|
||||
border: #2a2a2a00 2px solid;
|
||||
}
|
||||
|
||||
.nav-div a:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
@media screen and (max-width: 800px) {
|
||||
.nav-div {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-hamburger-menu {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.nav-buttons {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-buttons a {
|
||||
display: block;
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
|
||||
</html>
|
||||
@@ -1,349 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@100..900&display=swap" rel="stylesheet">
|
||||
<script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script>
|
||||
<title>login</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="nav-div">
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
</div>
|
||||
<div class="container-wrapper">
|
||||
<div class="creation-container">
|
||||
<h1>login</h1>
|
||||
<form id="loginForm">
|
||||
<label for="usernameTitle" class="label">Username</label>
|
||||
<input type="text" id="usernameInput" class="textinput" name="pasteTitle" required maxlength="20">
|
||||
<label for="passwordTitle" class="label">Password</label>
|
||||
<input type="password" id="passwordInput" class="textinput" name="pasteTitle" required maxlength="50">
|
||||
<div id="cf-turnstile" class="cf-turnstile" data-sitekey="{sitekey}"></div>
|
||||
<button type="submit" class="button">Login</button>
|
||||
</form>
|
||||
<h3 id="error-message"></h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="notifcations-wrapper" id="notifications">
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
let isLoggingIn = false;
|
||||
document.getElementById("loginForm").addEventListener("submit", function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var usernameContent = document.getElementById("usernameInput").value;
|
||||
var passwordContent = document.getElementById("passwordInput").value;
|
||||
var cf = turnstile.getResponse();
|
||||
|
||||
|
||||
if (isLoggingIn) {
|
||||
createNotification("Please wait for the login to finish.");
|
||||
return;
|
||||
}
|
||||
isLoggingIn = true;
|
||||
var requestUrl = "/api/accounts/login";
|
||||
fetch(requestUrl, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
username: usernameContent,
|
||||
password: passwordContent,
|
||||
cf: cf
|
||||
})
|
||||
})
|
||||
|
||||
.then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
isLoggingIn = true;
|
||||
if (result.message != null) {
|
||||
window.location.href = "/";
|
||||
isLoggingIn = false;
|
||||
}
|
||||
else if (result.error != null) {
|
||||
const errorElement = document.getElementById("error-message");
|
||||
errorElement.innerText = result.error;
|
||||
errorElement.style.opacity = 1;
|
||||
|
||||
setTimeout(() => {
|
||||
errorElement.style.opacity = 0;
|
||||
}, 3000);
|
||||
isLoggingIn = false;
|
||||
turnstile.reset();
|
||||
}
|
||||
})
|
||||
});
|
||||
function createNotification(message) {
|
||||
const notificationWrapper = document.getElementById('notifications');
|
||||
const notificationDiv = document.createElement('div');
|
||||
notificationDiv.classList.add('notification-div');
|
||||
notificationDiv.id = 'notification';
|
||||
|
||||
const notificationText = document.createElement('h2');
|
||||
notificationText.id = 'notification-text';
|
||||
notificationText.innerText = message;
|
||||
|
||||
notificationDiv.appendChild(notificationText);
|
||||
notificationWrapper.appendChild(notificationDiv);
|
||||
|
||||
notificationDiv.style.animation = 'none';
|
||||
notificationDiv.style.display = 'none';
|
||||
notificationDiv.style.display = 'flex';
|
||||
notificationDiv.style.animation = 'hoverup 1s';
|
||||
|
||||
setTimeout(() => {
|
||||
notificationDiv.style.animation = 'hoverdown 1s';
|
||||
}, 4000);
|
||||
|
||||
setTimeout(() => {
|
||||
notificationDiv.remove();
|
||||
}, 4900);
|
||||
}
|
||||
document.getElementById("cf-turnstile").addEventListener("expired-callback", function () {
|
||||
createNotification("Please complete the captcha.");
|
||||
turnstile.reset();
|
||||
});
|
||||
|
||||
</script>
|
||||
<style>
|
||||
body {
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #0d0d0d;
|
||||
}
|
||||
|
||||
.container-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 98.7vh;
|
||||
}
|
||||
|
||||
.creation-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 80%;
|
||||
padding: 20px;
|
||||
background-color: #181818;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
max-height: 80vh;
|
||||
min-height: 20%;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#loginForm {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#error-message {
|
||||
color: red;
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
bottom: -0.1px;
|
||||
margin-bottom: -0.1px;
|
||||
top: 88%;
|
||||
transition: 300ms;
|
||||
|
||||
}
|
||||
|
||||
.label {
|
||||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
.textinput {
|
||||
transition: 300ms;
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
margin: 10px 0;
|
||||
border-radius: 5px;
|
||||
border: none;
|
||||
background-color: #282828;
|
||||
color: white;
|
||||
border: #2a2a2a 2px solid;
|
||||
box-sizing: border-box;
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-size: 1.1em;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.textinput:focus {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: 2px solid #3a3a3a;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.textarea {
|
||||
transition: 300ms;
|
||||
width: 100%;
|
||||
min-width: 100%;
|
||||
max-width: 100%;
|
||||
min-height: auto;
|
||||
padding: 10px;
|
||||
margin: 10px 0;
|
||||
border-radius: 5px;
|
||||
border: none;
|
||||
background-color: #282828;
|
||||
color: white;
|
||||
border: #2a2a2a 2px solid;
|
||||
box-sizing: border-box;
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-size: 1.08em;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.textarea:focus {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: 2px solid #3a3a3a;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.button {
|
||||
transition: 300ms;
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
margin: 10px 0;
|
||||
border-radius: 5px;
|
||||
border: none;
|
||||
background-color: #222222;
|
||||
color: white;
|
||||
border: #2a2a2a00 2px solid;
|
||||
cursor: pointer;
|
||||
font-size: 1.2em;
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: 2px solid #3a3a3a;
|
||||
}
|
||||
|
||||
.nav-div {
|
||||
top: 0;
|
||||
margin-top: 10px;
|
||||
position: absolute;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: fit-content;
|
||||
background-color: #181818;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.nav-div a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
border-radius: 5px;
|
||||
background-color: #222222;
|
||||
transition: 300ms;
|
||||
border: #2a2a2a00 2px solid;
|
||||
}
|
||||
|
||||
.nav-div a:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
@keyframes hoverup {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%);
|
||||
}
|
||||
|
||||
25% {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
50% {
|
||||
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes hoverdown {
|
||||
0% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
50% {
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: translateY(200%);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.notification-div {
|
||||
display: flex;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: fit-content;
|
||||
height: fit-content;
|
||||
color: white;
|
||||
background-color: #181818;
|
||||
border-radius: 5px;
|
||||
border: #222222 2px solid;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
margin-right: 10px;
|
||||
margin-bottom: 10px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.notifcations-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
justify-content: flex-end;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
</html>
|
||||
@@ -1,587 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="nav-div">
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
<a href="login" id="login-signup-btn" style="display: none;" >login</a>
|
||||
<a href="sign-up" id="login-signup-btn" style="display: none;">sign up</a>
|
||||
<a href="dash" id="dash-btn" style="display: none;">dashboard</a>
|
||||
</div>
|
||||
<div class="nav-hamburger-menu">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" fill="currentColor" class="bi bi-list"
|
||||
viewBox="0 0 16 16" id="hamburger-button" style="cursor: pointer;">
|
||||
<path fill-rule="evenodd"
|
||||
d="M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5" />
|
||||
</svg>
|
||||
<div class="nav-buttons">
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
<a href="login" id="login-signup-btn" style="display: none;" >login</a>
|
||||
<a href="sign-up" id="login-signup-btn" style="display: none;">sign up</a>
|
||||
<a href="dash" id="dash-btn" style="display: none;">dashboard</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-wrapper">
|
||||
<div class="paste-container">
|
||||
<h1 id="paste-title"></h1>
|
||||
<h3 class="uploader-text"><a id="uploader-username" class="user-a"></a> <a id="creationdate"></a> <a id="paste-size"></a>
|
||||
</h3>
|
||||
<div class="paste-wrapper">
|
||||
<p id="text"></p>
|
||||
</div>
|
||||
<div class="buttons-wrapper">
|
||||
<a href="/raw/{pasteid}">
|
||||
<button id="view-raw-button" class="button">view raw</button>
|
||||
</a>
|
||||
<button id="copy-button" class="button">copy</button>
|
||||
<button id="download-button" class="button">download</button>
|
||||
<button id="delete-button" class="button" style="display: none;">delete</button>
|
||||
<button id="edit-button" class="button" style="display: none;">edit</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="notifcations-wrapper" id="notifications"></div>
|
||||
<div class="input-wrapper" id="input-wrapper">
|
||||
<div class="input-wrapper-container">
|
||||
<h2 id="input-message"></h2>
|
||||
<div>
|
||||
<button id="yes-button" class="button">Yes</button>
|
||||
<button id="no-button" class="button">No</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
info = "";
|
||||
editing = false;
|
||||
function localizeDateTime(unixTimestamp) {
|
||||
const date = new Date(unixTimestamp * 1000);
|
||||
return date.toLocaleString();
|
||||
}
|
||||
function authenticated() {
|
||||
fetch('/api/accounts/authenticated')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.message == "Authenticated") {
|
||||
if (info.uploader == data.username || data.type == "Admin") {
|
||||
document.getElementById('delete-button').style.display = 'block';
|
||||
document.getElementById('edit-button').style.display = 'block';
|
||||
}
|
||||
document.querySelectorAll("#login-signup-btn").forEach(element => {
|
||||
element.style.display = 'none';
|
||||
});
|
||||
document.getElementById('dash-btn').style.display = 'block';
|
||||
}else{
|
||||
document.querySelectorAll("#login-signup-btn").forEach(element => {
|
||||
element.style.display = 'block';
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
function fetchInfo() {
|
||||
fetch('/api/pastes/info?id={pasteid}')
|
||||
.then(response => response.json())
|
||||
.then(json => {
|
||||
info = json;
|
||||
document.getElementById('uploader-username').innerText = json.uploader || 'Anonymous';
|
||||
document.getElementById('creationdate').innerText = localizeDateTime(json.date);
|
||||
document.getElementById('paste-size').innerText = json.size;
|
||||
document.getElementById('paste-size').title = `Compressed Size: ${json.compressedSize}`;
|
||||
document.getElementById('paste-title').innerText = json.title;
|
||||
document.getElementById('paste-title').title = json.title;
|
||||
if (json.title == "") {
|
||||
document.getElementById('paste-title').innerText = `Untitled ${json.uid}`;
|
||||
document.title = `Untitled ${json.uid}`;
|
||||
}
|
||||
if (json.uploader && json.uploader.startsWith("Anonymous") && json.uploader.length == 46) {
|
||||
document.getElementById('uploader-username').innerText = 'Anonymous';
|
||||
} else if (json.uploader) {
|
||||
document.getElementById('uploader-username').href = `/u/${json.uploader}`;
|
||||
}
|
||||
})
|
||||
.catch(error => console.error('Error fetching paste info:', error));
|
||||
}
|
||||
document.getElementById("edit-button").addEventListener("click", function () {
|
||||
if (editing) {
|
||||
createInput('Are you sure you want to save this edit?');
|
||||
document.getElementById('yes-button').addEventListener("click", finalizeEdit);
|
||||
} else {
|
||||
editing = true;
|
||||
var editButton = document.getElementById('edit-button');
|
||||
editButton.innerText = 'save';
|
||||
var text = document.getElementById('text');
|
||||
var innertext = text.innerText;
|
||||
text.innerHTML = `<textarea class="textarea" id="edit-textarea" style="width: 100%; height: ${text.clientHeight}px;">${innertext}</textarea>`;
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
fetchInfo();
|
||||
authenticated();
|
||||
const creationdateElement = document.getElementById('creationdate');
|
||||
const creationdateText = creationdateElement.innerText.trim();
|
||||
const textElement = document.getElementById('text');
|
||||
creationdateElement.innerText = localizeDateTime(parseInt(creationdateText));
|
||||
textElement.innerText = "Loading...";
|
||||
fetch(`/raw/{pasteid}`)
|
||||
.then(response => response.body)
|
||||
.then(stream => {
|
||||
const reader = stream.getReader();
|
||||
let text = '';
|
||||
|
||||
const read = () => {
|
||||
return reader.read().then(({ done, value }) => {
|
||||
if (done) {
|
||||
textElement.innerText = text;
|
||||
return;
|
||||
}
|
||||
text += new TextDecoder().decode(value);
|
||||
return read();
|
||||
});
|
||||
};
|
||||
|
||||
return read();
|
||||
});
|
||||
var mobile = window.mobileCheck();
|
||||
if (mobile) {
|
||||
document.querySelector('.nav-div').style.display = 'none';
|
||||
document.querySelector('.nav-hamburger-menu').style.display = 'flex';
|
||||
}
|
||||
});
|
||||
document.getElementById("hamburger-button").addEventListener("click", function () {
|
||||
const nav = document.querySelector('.nav-buttons');
|
||||
if (nav.style.display == 'none' || nav.style.display == '') {
|
||||
nav.style.display = 'flex';
|
||||
} else {
|
||||
nav.style.display = 'none';
|
||||
}
|
||||
});
|
||||
window.mobileCheck = function () {
|
||||
let check = false;
|
||||
(function (a) { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true; })(navigator.userAgent || navigator.vendor || window.opera);
|
||||
return check;
|
||||
};
|
||||
|
||||
document.getElementById("copy-button").addEventListener("click", function () {
|
||||
navigator.clipboard.writeText(document.querySelector(".paste-wrapper").innerText);
|
||||
});
|
||||
document.getElementById("download-button").addEventListener("click", function () {
|
||||
var element = document.createElement('a');
|
||||
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(document.querySelector(".paste-wrapper").innerText));
|
||||
element.setAttribute('download', '{pasteid}.txt');
|
||||
element.style.display = 'none';
|
||||
document.body.appendChild(element);
|
||||
element.click();
|
||||
document.body.removeChild(element);
|
||||
});
|
||||
document.getElementById("delete-button").addEventListener("click", function () {
|
||||
createInput('Are you sure you want to delete this paste?');
|
||||
document.getElementById("yes-button").addEventListener("click", function () {
|
||||
fetch(`/api/pastes/delete?id={pasteid}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
id: '{pasteid}'
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
if (result.message != null) {
|
||||
createNotification(`Success: ${result.message}`);
|
||||
setTimeout(() => {
|
||||
const inputWrapper = document.getElementById('input-wrapper');
|
||||
inputWrapper.style.display = 'none';
|
||||
window.location.href = '/';
|
||||
}, 2000);
|
||||
} else {
|
||||
const inputWrapper = document.getElementById('input-wrapper');
|
||||
inputWrapper.style.display = 'none';
|
||||
createNotification(`Error: ${result.error}`);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
document.getElementById("no-button").addEventListener("click", function () {
|
||||
const inputWrapper = document.getElementById('input-wrapper');
|
||||
inputWrapper.style.display = 'none';
|
||||
});
|
||||
function createNotification(message) {
|
||||
const notificationWrapper = document.getElementById('notifications');
|
||||
const notificationDiv = document.createElement('div');
|
||||
notificationDiv.classList.add('notification-div');
|
||||
notificationDiv.id = 'notification';
|
||||
|
||||
const notificationText = document.createElement('h2');
|
||||
notificationText.id = 'notification-text';
|
||||
notificationText.innerText = message;
|
||||
|
||||
notificationDiv.appendChild(notificationText);
|
||||
notificationWrapper.appendChild(notificationDiv);
|
||||
|
||||
notificationDiv.style.animation = 'none';
|
||||
notificationDiv.style.display = 'none';
|
||||
notificationDiv.style.display = 'flex';
|
||||
notificationDiv.style.animation = 'hoverup 1s';
|
||||
|
||||
setTimeout(() => {
|
||||
notificationDiv.style.animation = 'hoverdown 1s';
|
||||
}, 4000);
|
||||
|
||||
setTimeout(() => {
|
||||
notificationDiv.remove();
|
||||
}, 4900);
|
||||
}
|
||||
function createInput(message) {
|
||||
const inputWrapper = document.getElementById('input-wrapper');
|
||||
const inputMessage = document.getElementById('input-message');
|
||||
inputMessage.innerText = message;
|
||||
inputWrapper.style.display = 'flex';
|
||||
}
|
||||
function finalizeEdit() {
|
||||
var textarea = document.getElementById('edit-textarea');
|
||||
var text = textarea.value;
|
||||
fetch(`/api/pastes/edit`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
id: '{pasteid}',
|
||||
text: text
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
if (result.message != null) {
|
||||
const inputWrapper = document.getElementById('input-wrapper');
|
||||
inputWrapper.style.display = 'none';
|
||||
document.getElementById('edit-button').innerText = "edit";
|
||||
createNotification(`Success: ${result.message}`);
|
||||
document.getElementById('text').innerText = text;
|
||||
document.getElementById('edit-textarea').remove();
|
||||
editing = false;
|
||||
} else {
|
||||
const inputWrapper = document.getElementById('input-wrapper');
|
||||
inputWrapper.style.display = 'none';
|
||||
document.getElementById('edit-button').innerText = "edit";
|
||||
createNotification(`Error: ${result.error}`);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
</html>
|
||||
<style>
|
||||
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@100..900&display=swap');
|
||||
|
||||
.textarea{
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: 500;
|
||||
max-width: 100%;
|
||||
min-width: 100%;
|
||||
background-color: #1d1d1d;
|
||||
color: white;
|
||||
border: none;
|
||||
}
|
||||
.textarea:focus{
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.input-wrapper{
|
||||
z-index: 100;
|
||||
display: none;
|
||||
position: absolute;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
color: white;
|
||||
backdrop-filter: blur(2.5px);
|
||||
}
|
||||
.input-wrapper-container{
|
||||
z-index: 101;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 50%;
|
||||
border-radius: 5px;
|
||||
padding: 20px;
|
||||
background-color: #181818;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #0d0d0d;
|
||||
}
|
||||
|
||||
.container-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 98.7vh;
|
||||
}
|
||||
|
||||
.paste-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 80%;
|
||||
padding: 20px;
|
||||
background-color: #181818;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
max-height: 80vh;
|
||||
min-height: 20%;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.paste-wrapper {
|
||||
width: 95%;
|
||||
height: fit-content;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
background-color: #1d1d1d;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
margin-top: 10px;
|
||||
text-wrap: wrap;
|
||||
font-weight: 500;
|
||||
max-height: 80%;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.buttons-wrapper {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: fit-content;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.buttons-wrapper a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.button {
|
||||
transition: 300ms;
|
||||
background-color: #222222;
|
||||
color: white;
|
||||
border: 2px solid #33333300;
|
||||
border-radius: 5px;
|
||||
padding: 5px;
|
||||
margin: 5px;
|
||||
cursor: pointer;
|
||||
font-weight: 500;
|
||||
font-size: 1.05rem;
|
||||
padding: 10px;
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: 625;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: 2px solid #3a3a3a;
|
||||
}
|
||||
|
||||
.uploader-text {
|
||||
margin-top: -1.2rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.user-a:any-link {
|
||||
color: rgb(190, 190, 190);
|
||||
text-decoration: none;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
|
||||
.nav-div {
|
||||
top: 0;
|
||||
margin-top: 10px;
|
||||
position: absolute;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: fit-content;
|
||||
background-color: #181818;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
z-index: 999999;
|
||||
}
|
||||
|
||||
.nav-hamburger-menu {
|
||||
top: 0;
|
||||
position: absolute;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 99vw;
|
||||
overflow-x: hidden;
|
||||
background-color: #181818;
|
||||
color: white;
|
||||
height: fit-content;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.nav-buttons {
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.nav-buttons a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin: 2px;
|
||||
border-radius: 5px;
|
||||
background-color: #222222;
|
||||
transition: 300ms;
|
||||
border: #2a2a2a00 2px solid;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
|
||||
.nav-buttons a:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
.nav-div a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
border-radius: 5px;
|
||||
background-color: #222222;
|
||||
transition: 300ms;
|
||||
border: #2a2a2a00 2px solid;
|
||||
}
|
||||
|
||||
.nav-div a:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 800px) {
|
||||
.nav-div {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-hamburger-menu {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.nav-buttons {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-buttons a {
|
||||
display: block;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@keyframes hoverup {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%);
|
||||
}
|
||||
|
||||
25% {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
50% {
|
||||
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes hoverdown {
|
||||
0% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
50% {
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: translateY(200%);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.notification-div {
|
||||
display: flex;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: fit-content;
|
||||
height: fit-content;
|
||||
color: white;
|
||||
background-color: #181818;
|
||||
border-radius: 5px;
|
||||
border: #222222 2px solid;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
margin-right: 10px;
|
||||
margin-bottom: 10px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 102;
|
||||
position: absolute;
|
||||
}
|
||||
.notifcations-wrapper{
|
||||
z-index: 101;
|
||||
}
|
||||
</style>
|
||||
@@ -1,643 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{pastetitle}</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="nav-div">
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
<a href="login" id="login-signup-btn" style="display: none;" >login</a>
|
||||
<a href="sign-up" id="login-signup-btn" style="display: none;">sign up</a>
|
||||
<a href="dash" id="dash-btn" style="display: none;">dashboard</a>
|
||||
</div>
|
||||
<div class="nav-hamburger-menu">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" fill="currentColor" class="bi bi-list"
|
||||
viewBox="0 0 16 16" id="hamburger-button" style="cursor: pointer;">
|
||||
<path fill-rule="evenodd"
|
||||
d="M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5" />
|
||||
</svg>
|
||||
<div class="nav-buttons">
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
<a href="login" id="login-signup-btn" style="display: none;" >login</a>
|
||||
<a href="sign-up" id="login-signup-btn" style="display: none;">sign up</a>
|
||||
<a href="dash" id="dash-btn" style="display: none;">dashboard</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-wrapper">
|
||||
<div class="paste-container">
|
||||
<h1 id="paste-title" title="{pastetitleattribute}">{pastetitle}</h1>
|
||||
<h3 class="uploader-text"><a id="uploader-username" class="user-a"></a> <a id="creationdate"></a> <a id="paste-size"></a>
|
||||
</h3>
|
||||
<div class="paste-wrapper">
|
||||
<p id="text"></p>
|
||||
</div>
|
||||
<div class="buttons-wrapper">
|
||||
<a href="" id="view-raw-a">
|
||||
<button id="view-raw-button" class="button">view raw</button>
|
||||
</a>
|
||||
<button id="copy-button" class="button">copy</button>
|
||||
<button id="download-button" class="button">download</button>
|
||||
<button id="delete-button" class="button" style="display: none;">delete</button>
|
||||
<button id="edit-button" class="button" style="display: none;">edit</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="passwordDiv">
|
||||
<div class="inputDiv">
|
||||
<h1>This paste is password protected</h1>
|
||||
<input type="password" id="password" class="textinput" name="password" maxlength="500"
|
||||
placeholder="password">
|
||||
<button id="submitPassword" class="button-input">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="notification-div" id="notification">
|
||||
<h2 id="notification-text"></h2>
|
||||
</div>
|
||||
<div class="input-wrapper" id="input-wrapper">
|
||||
<div class="input-wrapper-container">
|
||||
<h2 id="input-message"></h2>
|
||||
<div>
|
||||
<button id="yes-button" class="button">Yes</button>
|
||||
<button id="no-button" class="button">No</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
info = "";
|
||||
editing = false;
|
||||
function authenticated() {
|
||||
fetch('/api/accounts/authenticated')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.message == "Authenticated") {
|
||||
if (info.uploader == data.username || data.type == "Admin") {
|
||||
document.getElementById('delete-button').style.display = 'block';
|
||||
//document.getElementById('edit-button').style.display = 'block';
|
||||
}
|
||||
document.querySelectorAll("#login-signup-btn").forEach(element => {
|
||||
element.style.display = 'none';
|
||||
});
|
||||
document.getElementById('dash-btn').style.display = 'block';
|
||||
}else{
|
||||
document.querySelectorAll("#login-signup-btn").forEach(element => {
|
||||
element.style.display = 'block';
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
function fetchInfo() {
|
||||
fetch('/api/pastes/info?id={pasteid}')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const json = JSON.parse(data);
|
||||
info = json;
|
||||
document.getElementById('uploader-username').innerText = json.uploader;
|
||||
document.getElementById('creationdate').innerText = localizeDateTime(json.date);
|
||||
document.getElementById('paste-size').innerText = json.size;
|
||||
document.getElementById('paste-size').title = `Compressed Size: ${json.compressedSize}`;
|
||||
document.getElementById('paste-title').innerText = json.title;
|
||||
document.getElementById('paste-title').title = json.title;
|
||||
if (json.title == "") {
|
||||
document.getElementById('paste-title').innerText = `Untitled ${json.uid}`;
|
||||
document.title = `Untitled ${json.uid}`;
|
||||
}
|
||||
if (json.uploader.startsWith("Anonymous") && json.uploader.length == 46) {
|
||||
document.getElementById('uploader-username').innerText = 'Anonymous';
|
||||
} else {
|
||||
document.getElementById('uploader-username').href = `/u/${json.uploader}`;
|
||||
}
|
||||
});
|
||||
}
|
||||
document.getElementById("edit-button").addEventListener("click", function () {
|
||||
if (editing) {
|
||||
createInput('Are you sure you want to save this edit?');
|
||||
document.getElementById('yes-button').removeEventListener("click", deletePaste);
|
||||
document.getElementById('yes-button').addEventListener("click", finalizeEdit);
|
||||
document.getElementById('yes-button').removeEventListener("click", finalizeEdit);
|
||||
} else {
|
||||
editing = true;
|
||||
var editButton = document.getElementById('edit-button');
|
||||
editButton.innerText = 'save';
|
||||
var text = document.getElementById('text');
|
||||
var innertext = text.innerText;
|
||||
text.innerHTML = `<textarea class="textarea" id="edit-textarea" style="width: 100%; height: ${text.clientHeight}px;">${innertext}</textarea>`;
|
||||
}
|
||||
});
|
||||
document.getElementById("submitPassword").addEventListener("click", function () {
|
||||
var password = document.getElementById("password").value;
|
||||
fetch(`/api/pastes/password/{pasteid}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
password: password
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
if (result.content != null) {
|
||||
const textElement = document.getElementById('text');
|
||||
textElement.innerText = result.content;
|
||||
document.querySelector(".passwordDiv").style.display = "none";
|
||||
const viewRawButton = document.getElementById('view-raw-a');
|
||||
viewRawButton.href = `/raw/{pasteid}?password=` + password;
|
||||
}
|
||||
else {
|
||||
notification(`Error: ${result.error}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
function localizeDateTime(unixTimestamp) {
|
||||
const date = new Date(unixTimestamp * 1000);
|
||||
return date.toLocaleString();
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
fetchInfo();
|
||||
authenticated();
|
||||
|
||||
const creationdateElement = document.getElementById('creationdate');
|
||||
const creationdateText = creationdateElement.innerText.trim();
|
||||
creationdateElement.innerText = localizeDateTime(parseInt(creationdateText));
|
||||
var mobile = window.mobileCheck();
|
||||
if (mobile) {
|
||||
document.querySelector('.nav-div').style.display = 'none';
|
||||
document.querySelector('.nav-hamburger-menu').style.display = 'flex';
|
||||
}
|
||||
});
|
||||
document.getElementById("hamburger-button").addEventListener("click", function () {
|
||||
const nav = document.querySelector('.nav-buttons');
|
||||
if (nav.style.display == 'none' || nav.style.display == '') {
|
||||
nav.style.display = 'flex';
|
||||
} else {
|
||||
nav.style.display = 'none';
|
||||
}
|
||||
});
|
||||
window.mobileCheck = function () {
|
||||
let check = false;
|
||||
(function (a) { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true; })(navigator.userAgent || navigator.vendor || window.opera);
|
||||
return check;
|
||||
};
|
||||
document.getElementById("copy-button").addEventListener("click", function () {
|
||||
navigator.clipboard.writeText(document.querySelector(".paste-wrapper").innerText);
|
||||
});
|
||||
document.getElementById("download-button").addEventListener("click", function () {
|
||||
var element = document.createElement('a');
|
||||
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(document.querySelector(".paste-wrapper").innerText));
|
||||
element.setAttribute('download', '{pasteid}.txt');
|
||||
element.style.display = 'none';
|
||||
document.body.appendChild(element);
|
||||
element.click();
|
||||
document.body.removeChild(element);
|
||||
});
|
||||
document.getElementById("delete-button").addEventListener("click", function () {
|
||||
createInput('Are you sure you want to delete this paste?');
|
||||
document.getElementById('yes-button').removeEventListener("click", finalizeEdit);
|
||||
document.getElementById('yes-button').addEventListener("click", deletePaste);
|
||||
document.getElementById('yes-button').removeEventListener("click", deletePaste);
|
||||
});
|
||||
function deletePaste() {
|
||||
fetch(`/api/pastes/delete?id={pasteid}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
id: '{pasteid}'
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
if (result.message != null) {
|
||||
createNotification(`Success: ${result.message}`);
|
||||
setTimeout(() => {
|
||||
window.location.href = '/';
|
||||
}, 2000);
|
||||
} else {
|
||||
createNotification(`Error: ${result.error}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
function finalizeEdit() {
|
||||
var textarea = document.getElementById('edit-textarea');
|
||||
var text = textarea.value;
|
||||
fetch(`/api/pastes/edit`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
id: '{pasteid}',
|
||||
text: text
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
if (result.message != null) {
|
||||
createNotification(`Success: ${result.message}`);
|
||||
document.getElementById('text').innerText = text;
|
||||
document.getElementById('edit-textarea').remove();
|
||||
editing = false;
|
||||
} else {
|
||||
createNotification(`Error: ${result.error}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
document.getElementById("no-button").addEventListener("click", function () {
|
||||
const inputWrapper = document.getElementById('input-wrapper');
|
||||
inputWrapper.style.display = 'none';
|
||||
document.getElementById('yes-button').removeEventListener("click", finalizeEdit);
|
||||
document.getElementById('yes-button').removeEventListener("click", deletePaste);
|
||||
|
||||
});
|
||||
function notification(message) {
|
||||
const notification = document.getElementById('notification');
|
||||
const notificationText = document.getElementById('notification-text');
|
||||
notificationText.innerText = message;
|
||||
notification.style.animation = 'none';
|
||||
notification.style.display = 'none';
|
||||
notification.style.display = 'flex';
|
||||
notification.style.animation = 'hoverup 1s';
|
||||
setTimeout(() => {
|
||||
|
||||
notification.style.animation = 'hoverdown 1s';
|
||||
}, 4000);
|
||||
setTimeout(() => {
|
||||
notification.style.display = 'none';
|
||||
}, 4900);
|
||||
|
||||
}
|
||||
function createInput(message) {
|
||||
const inputWrapper = document.getElementById('input-wrapper');
|
||||
const inputMessage = document.getElementById('input-message');
|
||||
inputMessage.innerText = message;
|
||||
inputWrapper.style.display = 'flex';
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
</html>
|
||||
<style>
|
||||
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@100..900&display=swap');
|
||||
|
||||
body {
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #0d0d0d;
|
||||
}
|
||||
|
||||
.input-wrapper {
|
||||
z-index: 100;
|
||||
display: none;
|
||||
position: absolute;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
color: white;
|
||||
backdrop-filter: blur(2.5px);
|
||||
}
|
||||
|
||||
.input-wrapper-container {
|
||||
z-index: 101;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 50%;
|
||||
border-radius: 5px;
|
||||
padding: 20px;
|
||||
background-color: #181818;
|
||||
}
|
||||
|
||||
.container-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 98.7vh;
|
||||
}
|
||||
|
||||
.button-input {
|
||||
transition: 300ms;
|
||||
background-color: #222222;
|
||||
color: white;
|
||||
border: 2px solid #33333300;
|
||||
border-radius: 5px;
|
||||
padding: 5px;
|
||||
margin: 5px;
|
||||
cursor: pointer;
|
||||
font-weight: 500;
|
||||
font-size: 1.05rem;
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: 625;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
|
||||
.button-input:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: 2px solid #3a3a3a;
|
||||
}
|
||||
|
||||
.passwordDiv {
|
||||
z-index: 100;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.4);
|
||||
backdrop-filter: blur(8px);
|
||||
color: white;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.inputDiv {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: fit-content;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.textinput {
|
||||
width: 100%;
|
||||
height: 50px;
|
||||
border-radius: 5px;
|
||||
border: 2px solid #222222;
|
||||
background-color: #181818;
|
||||
padding: 10px;
|
||||
font-size: 1.05rem;
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: 625;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.textinput:focus {
|
||||
outline: none;
|
||||
border: 2px solid #333333;
|
||||
}
|
||||
|
||||
.paste-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 80%;
|
||||
padding: 20px;
|
||||
background-color: #181818;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
max-height: 80vh;
|
||||
min-height: 20%;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.paste-wrapper {
|
||||
width: 95%;
|
||||
height: fit-content;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
background-color: #1d1d1d;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
margin-top: 10px;
|
||||
text-wrap: wrap;
|
||||
font-weight: 500;
|
||||
max-height: 80%;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.buttons-wrapper {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: fit-content;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.buttons-wrapper a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.button {
|
||||
transition: 300ms;
|
||||
background-color: #222222;
|
||||
color: white;
|
||||
border: 2px solid #33333300;
|
||||
border-radius: 5px;
|
||||
padding: 5px;
|
||||
margin: 5px;
|
||||
cursor: pointer;
|
||||
font-weight: 500;
|
||||
font-size: 1.05rem;
|
||||
padding: 10px;
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: 625;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: 2px solid #3a3a3a;
|
||||
}
|
||||
|
||||
.uploader-text {
|
||||
margin-top: -1.2rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.user-a {
|
||||
color: rgb(190, 190, 190);
|
||||
text-decoration: none;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
|
||||
.nav-div {
|
||||
top: 0;
|
||||
margin-top: 10px;
|
||||
position: absolute;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: fit-content;
|
||||
background-color: #181818;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
z-index: 999999;
|
||||
}
|
||||
|
||||
.nav-hamburger-menu {
|
||||
top: 0;
|
||||
position: absolute;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 99vw;
|
||||
overflow-x: hidden;
|
||||
background-color: #181818;
|
||||
color: white;
|
||||
height: fit-content;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.nav-buttons {
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.nav-buttons a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin: 2px;
|
||||
border-radius: 5px;
|
||||
background-color: #222222;
|
||||
transition: 300ms;
|
||||
border: #2a2a2a00 2px solid;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
|
||||
.nav-buttons a:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
.nav-div a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
border-radius: 5px;
|
||||
background-color: #222222;
|
||||
transition: 300ms;
|
||||
border: #2a2a2a00 2px solid;
|
||||
}
|
||||
|
||||
.nav-div a:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 800px) {
|
||||
.nav-div {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-hamburger-menu {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.nav-buttons {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-buttons a {
|
||||
display: block;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@keyframes hoverup {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%);
|
||||
}
|
||||
|
||||
25% {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
50% {
|
||||
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes hoverdown {
|
||||
0% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
50% {
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: translateY(200%);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.notification-div {
|
||||
position: fixed;
|
||||
display: none;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: fit-content;
|
||||
height: fit-content;
|
||||
color: white;
|
||||
background-color: #181818;
|
||||
border-radius: 5px;
|
||||
border: #222222 2px solid;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
margin-right: 10px;
|
||||
margin-bottom: 10px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 102;
|
||||
position: absolute;
|
||||
}
|
||||
.notifcations-wrapper{
|
||||
z-index: 101;
|
||||
}
|
||||
</style>
|
||||
@@ -1,273 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@100..900&display=swap" rel="stylesheet">
|
||||
<title>recent pastes</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="nav-div">
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
</div>
|
||||
<div class="nav-hamburger-menu">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" fill="currentColor" class="bi bi-list"
|
||||
viewBox="0 0 16 16" id="hamburger-button" style="cursor: pointer;">
|
||||
<path fill-rule="evenodd"
|
||||
d="M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5" />
|
||||
</svg>
|
||||
<div class="nav-buttons">
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-wrapper">
|
||||
<div class="pastes-container">
|
||||
<h1>recent pastes</h1>
|
||||
<div class="pastes-wrapper">
|
||||
{pastes}
|
||||
</div>
|
||||
<div class="buttons-wrapper">
|
||||
<a href="/">create paste</a>
|
||||
<a href="/archive">paste archives</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
var mobile = window.mobileCheck();
|
||||
if (mobile) {
|
||||
document.querySelector('.nav-div').style.display = 'none';
|
||||
document.querySelector('.nav-hamburger-menu').style.display = 'flex';
|
||||
}
|
||||
});
|
||||
document.getElementById("hamburger-button").addEventListener("click", function () {
|
||||
const nav = document.querySelector('.nav-buttons');
|
||||
if (nav.style.display == 'none' || nav.style.display == '') {
|
||||
nav.style.display = 'flex';
|
||||
} else {
|
||||
nav.style.display = 'none';
|
||||
}
|
||||
});
|
||||
window.mobileCheck = function () {
|
||||
let check = false;
|
||||
(function (a) { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true; })(navigator.userAgent || navigator.vendor || window.opera);
|
||||
return check;
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
body {
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #0d0d0d;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
|
||||
.container-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 98.7vh;
|
||||
}
|
||||
|
||||
.pastes-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 80%;
|
||||
padding: 20px;
|
||||
background-color: #181818;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
max-height: 80vh;
|
||||
min-height: 20%;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.pastes-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 95%;
|
||||
padding: 20px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
max-height: 70vh;
|
||||
}
|
||||
|
||||
.pastes-wrapper a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
li {
|
||||
transition: 300ms;
|
||||
list-style: none;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
background-color: #222222;
|
||||
border-radius: 5px;
|
||||
width: 90%;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
border: #22222200 2px solid;
|
||||
}
|
||||
|
||||
li:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
.buttons-wrapper {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.buttons-wrapper a {
|
||||
transition: 300ms;
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
width: fit-content;
|
||||
margin-left: 10px;
|
||||
margin-right: 10px;
|
||||
min-width: 20%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #222222;
|
||||
border-radius: 5px;
|
||||
padding: 10px;
|
||||
border: #22222200 2px solid;
|
||||
}
|
||||
|
||||
.buttons-wrapper a:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: 2px solid #3a3a3a;
|
||||
}
|
||||
|
||||
.nav-div {
|
||||
top: 0;
|
||||
margin-top: 10px;
|
||||
position: absolute;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: fit-content;
|
||||
background-color: #181818;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.nav-hamburger-menu {
|
||||
top: 0;
|
||||
position: absolute;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 99vw;
|
||||
overflow-x: hidden;
|
||||
background-color: #181818;
|
||||
color: white;
|
||||
height: fit-content;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.nav-buttons {
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.nav-buttons a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin: 2px;
|
||||
border-radius: 5px;
|
||||
background-color: #222222;
|
||||
transition: 300ms;
|
||||
border: #2a2a2a00 2px solid;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
|
||||
.nav-buttons a:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
.nav-div a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
border-radius: 5px;
|
||||
background-color: #222222;
|
||||
transition: 300ms;
|
||||
border: #2a2a2a00 2px solid;
|
||||
}
|
||||
|
||||
.nav-div a:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 800px) {
|
||||
.nav-div {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-hamburger-menu {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.nav-buttons {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-buttons a {
|
||||
display: block;
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
|
||||
</html>
|
||||
@@ -1,366 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@100..900&display=swap" rel="stylesheet">
|
||||
<script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script>
|
||||
<title>sign-up</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="nav-div">
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
</div>
|
||||
<div class="container-wrapper">
|
||||
<div class="creation-container">
|
||||
<h1>sign-up</h1>
|
||||
<form id="signupForm">
|
||||
<label for="usernameTitle" class="label" onforminput="">Username</label>
|
||||
<input type="text" id="usernameInput" class="textinput" name="pasteTitle" required maxlength="20" minlength="3">
|
||||
<label id="characterCount" for="characterCount" class="ccounter">0/20</label>
|
||||
<label for="passwordTitle" class="label" id="margin-top">Password</label>
|
||||
<input type="password" id="passwordInput" class="textinput" name="pasteTitle" required maxlength="50" minlength="8">
|
||||
<label id="passcharacterCount" for="characterCount" class="ccounter">0/50</label>
|
||||
<div id="cf-turnstile" class="cf-turnstile" data-sitekey="{sitekey}"></div>
|
||||
<button type="submit" class="button" id="button-margin-top">Sign-up</button>
|
||||
</form>
|
||||
<h3 id="error-message"></h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="notifcations-wrapper" id="notifications">
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
let isLoggingIn = false;
|
||||
|
||||
document.getElementById("signupForm").addEventListener("submit", function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var usernameContent = document.getElementById("usernameInput").value;
|
||||
var passwordContent = document.getElementById("passwordInput").value;
|
||||
var cf = turnstile.getResponse();
|
||||
|
||||
if (isLoggingIn) {
|
||||
createNotification("Please wait for the login to finish.");
|
||||
return;
|
||||
}
|
||||
isLoggingIn = true;
|
||||
|
||||
var requestUrl = "/api/accounts/create";
|
||||
fetch(requestUrl, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
username: usernameContent,
|
||||
password: passwordContent,
|
||||
cf: cf
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
if (result.message != null) {
|
||||
window.location.href = "/";
|
||||
isLoggingIn = false;
|
||||
}
|
||||
else if (result.error != null) {
|
||||
const errorElement = document.getElementById("error-message");
|
||||
errorElement.innerText = result.error;
|
||||
errorElement.style.opacity = 1;
|
||||
|
||||
setTimeout(() => {
|
||||
errorElement.style.opacity = 0;
|
||||
}, 3000);
|
||||
isLoggingIn = false;
|
||||
|
||||
}
|
||||
})
|
||||
});
|
||||
document.getElementById("usernameInput").addEventListener("input", function (event) {
|
||||
var usernameContent = document.getElementById("usernameInput").value;
|
||||
var characterCount = usernameContent.length;
|
||||
document.getElementById("characterCount").innerText = `${characterCount}/20`;
|
||||
});
|
||||
document.getElementById("passwordInput").addEventListener("input", function (event) {
|
||||
var passwordContent = document.getElementById("passwordInput").value;
|
||||
var characterCount = passwordContent.length;
|
||||
document.getElementById("passcharacterCount").innerText = `${characterCount}/50`;
|
||||
});
|
||||
function createNotification(message) {
|
||||
const notificationWrapper = document.getElementById('notifications');
|
||||
const notificationDiv = document.createElement('div');
|
||||
notificationDiv.classList.add('notification-div');
|
||||
notificationDiv.id = 'notification';
|
||||
|
||||
const notificationText = document.createElement('h2');
|
||||
notificationText.id = 'notification-text';
|
||||
notificationText.innerText = message;
|
||||
|
||||
notificationDiv.appendChild(notificationText);
|
||||
notificationWrapper.appendChild(notificationDiv);
|
||||
|
||||
notificationDiv.style.animation = 'none';
|
||||
notificationDiv.style.display = 'none';
|
||||
notificationDiv.style.display = 'flex';
|
||||
notificationDiv.style.animation = 'hoverup 1s';
|
||||
|
||||
setTimeout(() => {
|
||||
notificationDiv.style.animation = 'hoverdown 1s';
|
||||
}, 4000);
|
||||
|
||||
setTimeout(() => {
|
||||
notificationDiv.remove();
|
||||
}, 4900);
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
body {
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #0d0d0d;
|
||||
}
|
||||
|
||||
.container-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 98.7vh;
|
||||
}
|
||||
|
||||
.creation-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 80%;
|
||||
padding: 20px;
|
||||
background-color: #181818;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
max-height: 80vh;
|
||||
min-height: 20%;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
#signupForm {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#error-message {
|
||||
color: red;
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
bottom: -0.1px;
|
||||
margin-bottom: -0.1px;
|
||||
top: 61.8%;
|
||||
transition: 300ms;
|
||||
}
|
||||
|
||||
.label {
|
||||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
.textinput {
|
||||
transition: 300ms;
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
margin: 10px 0;
|
||||
border-radius: 5px;
|
||||
border: none;
|
||||
background-color: #282828;
|
||||
color: white;
|
||||
border: #2a2a2a 2px solid;
|
||||
box-sizing: border-box;
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-size: 1.1em;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.textinput:focus {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: 2px solid #3a3a3a;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.textarea {
|
||||
transition: 300ms;
|
||||
width: 100%;
|
||||
min-width: 100%;
|
||||
max-width: 100%;
|
||||
min-height: auto;
|
||||
padding: 10px;
|
||||
margin: 10px 0;
|
||||
border-radius: 5px;
|
||||
border: none;
|
||||
background-color: #282828;
|
||||
color: white;
|
||||
border: #2a2a2a 2px solid;
|
||||
box-sizing: border-box;
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-size: 1.08em;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.textarea:focus {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: 2px solid #3a3a3a;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.button {
|
||||
transition: 300ms;
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
margin: 10px 0;
|
||||
border-radius: 5px;
|
||||
border: none;
|
||||
background-color: #222222;
|
||||
color: white;
|
||||
border: #2a2a2a00 2px solid;
|
||||
cursor: pointer;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: 2px solid #3a3a3a;
|
||||
}
|
||||
|
||||
.nav-div {
|
||||
top: 0;
|
||||
margin-top: 10px;
|
||||
position: absolute;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: fit-content;
|
||||
background-color: #181818;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.nav-div a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
border-radius: 5px;
|
||||
background-color: #222222;
|
||||
transition: 300ms;
|
||||
border: #2a2a2a00 2px solid;
|
||||
}
|
||||
|
||||
.nav-div a:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
.ccounter {
|
||||
align-self: flex-end;
|
||||
text-align: right;
|
||||
margin-top: -2.2rem;
|
||||
margin-right: 10px;
|
||||
font-size: 1.1em;
|
||||
color: #888888;
|
||||
}
|
||||
|
||||
#margin-top {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
#button-margin-top {
|
||||
margin-top: 30px;
|
||||
}
|
||||
@keyframes hoverup {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%);
|
||||
}
|
||||
|
||||
25% {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
50% {
|
||||
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes hoverdown {
|
||||
0% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
50% {
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: translateY(200%);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.notification-div {
|
||||
display: flex;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: fit-content;
|
||||
height: fit-content;
|
||||
color: white;
|
||||
background-color: #181818;
|
||||
border-radius: 5px;
|
||||
border: #222222 2px solid;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
margin-right: 10px;
|
||||
margin-bottom: 10px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.notifcations-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
justify-content: flex-end;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
</html>
|
||||
@@ -1,348 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@100..900&display=swap" rel="stylesheet">
|
||||
<title>{username}</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="nav-div">
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
</div>
|
||||
<div class="nav-hamburger-menu">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" fill="currentColor" class="bi bi-list" viewBox="0 0 16 16" id="hamburger-button" style="cursor: pointer;">
|
||||
<path fill-rule="evenodd"
|
||||
d="M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5" />
|
||||
</svg>
|
||||
<div class="nav-buttons">
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-wrapper">
|
||||
<div class="account-container">
|
||||
<div class="account-info">
|
||||
<h2>{username}</h2>
|
||||
<h3>UID: {uid}</h3>
|
||||
<h3 id="creationdate">{creationdate}</h3>
|
||||
<h3>Account Type: {type}</h3>
|
||||
<h3>Total Pastes: {totalpastes}</h3>
|
||||
<h3>Total Pastes Size: {totalsize}</h3>
|
||||
</div>
|
||||
<div class="collumn-2">
|
||||
<div class="pastes-wrapper">
|
||||
<h2 style="text-align: center;">Pastes</h2>
|
||||
<div class="pastes-container">
|
||||
{pastes}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
function localizeDateTime(unixTimestamp) {
|
||||
const date = new Date(unixTimestamp * 1000);
|
||||
return date.toLocaleString();
|
||||
}
|
||||
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const creationdateElement = document.getElementById('creationdate');
|
||||
|
||||
const creationdateText = creationdateElement.innerText.trim();
|
||||
|
||||
creationdateElement.innerText = "Creation Date: " + localizeDateTime(parseInt(creationdateText));
|
||||
var mobile = window.mobileCheck();
|
||||
if (mobile) {
|
||||
document.querySelector('.nav-div').style.display = 'none';
|
||||
document.querySelector('.nav-hamburger-menu').style.display = 'flex';
|
||||
}
|
||||
});
|
||||
document.getElementById("hamburger-button").addEventListener("click", function () {
|
||||
const nav = document.querySelector('.nav-buttons');
|
||||
if (nav.style.display == 'none' || nav.style.display == '') {
|
||||
nav.style.display = 'flex';
|
||||
} else {
|
||||
nav.style.display = 'none';
|
||||
}
|
||||
});
|
||||
window.mobileCheck = function () {
|
||||
let check = false;
|
||||
(function (a) { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true; })(navigator.userAgent || navigator.vendor || window.opera);
|
||||
return check;
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
body {
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #0d0d0d;
|
||||
height: calc(100vh - 20px);
|
||||
}
|
||||
|
||||
.container-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.account-container {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
width: 80%;
|
||||
padding: 20px;
|
||||
background-color: #181818;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
max-height: 100%;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.account-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background-color: #222222;
|
||||
padding: 20px;
|
||||
border-radius: 5px;
|
||||
width: fit-content;
|
||||
width: 48%;
|
||||
max-width: 48%;
|
||||
margin-right: 10px;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
h3 {
|
||||
word-break: keep-all;
|
||||
margin-top: -5px;
|
||||
}
|
||||
|
||||
.list-a {
|
||||
transition: background-color 300ms;
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
width: 90%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
background-color: #2a2a2a;
|
||||
margin-top: 5px;
|
||||
margin-bottom: 5px;
|
||||
border: #3a3a3a00 2px solid;
|
||||
}
|
||||
|
||||
.list-a:hover {
|
||||
transition: background-color 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
.list-item {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.collumn-2 {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 48%;
|
||||
max-width: 48%;
|
||||
}
|
||||
|
||||
.pastes-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: fit-content;
|
||||
width: calc(100% - 52px);
|
||||
max-width: 100%;
|
||||
background-color: #222222;
|
||||
border-radius: 5px;
|
||||
padding: 26px;
|
||||
height: fit-content;
|
||||
height: 100%;
|
||||
max-height: 100%;
|
||||
}
|
||||
|
||||
.pastes-container {
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
height: 100%;
|
||||
max-height: 100%;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.nav-div {
|
||||
top: 0;
|
||||
margin-top: 10px;
|
||||
position: absolute;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: fit-content;
|
||||
background-color: #181818;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.nav-hamburger-menu {
|
||||
top: 0;
|
||||
position: absolute;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 99vw;
|
||||
overflow-x: hidden;
|
||||
background-color: #181818;
|
||||
color: white;
|
||||
height: fit-content;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.nav-buttons {
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.nav-buttons a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin: 2px;
|
||||
border-radius: 5px;
|
||||
background-color: #222222;
|
||||
transition: 300ms;
|
||||
border: #2a2a2a00 2px solid;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
|
||||
.nav-buttons a:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
.nav-div a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
border-radius: 5px;
|
||||
background-color: #222222;
|
||||
transition: 300ms;
|
||||
border: #2a2a2a00 2px solid;
|
||||
}
|
||||
|
||||
.nav-div a:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
@media screen and (max-width: 800px) {
|
||||
.nav-div {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-hamburger-menu {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.nav-buttons {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-buttons a {
|
||||
display: block;
|
||||
}
|
||||
.container-wrapper{
|
||||
margin-top: calc(90% - 180px);
|
||||
padding-bottom: 50px;
|
||||
height: 90%;
|
||||
}
|
||||
.account-container {
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
max-height: 100%;
|
||||
}
|
||||
.account-info {
|
||||
margin-right: 0px;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
max-width: 100%;
|
||||
font-size: smaller !important;
|
||||
}
|
||||
.collumn-2 {
|
||||
margin-top: 10px;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
max-height: 48%;
|
||||
}
|
||||
.action-wrapper {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
max-height: 40%;
|
||||
}
|
||||
.button {
|
||||
width: 90%;
|
||||
max-width: 100%;
|
||||
margin: 0;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.pastes-wrapper {
|
||||
margin-top: 10px;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
height: 97%;
|
||||
max-width: 100%;
|
||||
max-height: calc(500px * 1.5 - 260px);
|
||||
}
|
||||
.pastes-container {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
max-height: 90%;
|
||||
overflow-x: hidden;
|
||||
text-align: start;
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
|
||||
</html>
|
||||
@@ -1,23 +0,0 @@
|
||||
#!/bin/bash
|
||||
############################################
|
||||
#### Sharpbin Linux installer ####
|
||||
############################################
|
||||
##
|
||||
## This is a semi completed script to install Sharpbin on Linux, however it does not set it as a system daemon/service, cause idk how to do that lol
|
||||
##
|
||||
|
||||
mkdir sharpbin
|
||||
cd sharpbin
|
||||
|
||||
curl -s "https://api.github.com/repos/whoswhip/Sharpbin/releases/latest" | jq -r '.assets[] | select(.name | test("sharpbin-linux-.*\\.tar$")) | .browser_download_url' | xargs -I {} curl -L -o sharpbin-linux.tar {}
|
||||
|
||||
tar -xvf sharpbin-linux.tar
|
||||
chmod +x Sharpbin
|
||||
|
||||
echo "Enter your cloudflare sitekey: "
|
||||
read sitekey
|
||||
echo "Enter your cloudflare secretkey: "
|
||||
read secretkey
|
||||
|
||||
|
||||
echo "{ \"CF_TurnstileSiteKey\": \"$sitekey\", \"CF_TurnstileSecret\": \"$secretkey\" }" > config.json
|
||||
@@ -1,27 +1,21 @@
|
||||
# Sharpbin
|
||||
Sharpbin is a Pastebin type website completely in C#, except for the frontend, being pure HTML & CSS.
|
||||
Sharpbin can be used for sharing large amounts of text.
|
||||
## Features
|
||||
- Account System
|
||||
- Standalone
|
||||
# SharpbinV2
|
||||
SharpbinV2 is a re-write to the original messy code base.
|
||||
|
||||
Instead of using html files and replacing variables(Simple SSR) it is now done with just apis and static html pages served from `wwwroot`.
|
||||
## Current Features
|
||||
- Account Systrem
|
||||
- Syntax Highlighting
|
||||
- Private Pastes with Client Side Encryption
|
||||
- Raw Text Serving
|
||||
- Admin Panel that includes banning users
|
||||
- Search feature for pastes
|
||||
- Recent Pastes and Paste Archives
|
||||
- Pastes can be deleted by an admin or the creator
|
||||
- User profile pages
|
||||
- Private encrypted pastes, sadly the encryption is server side, although client side may be soon!
|
||||
- Mobile Support
|
||||
- Captchas for logins and sign ups
|
||||
... And more to come!
|
||||
|
||||
# Demo Website & Screenshots
|
||||
You can find the test website at https://bin.whoswhip.top , there is no removed functionality and is the exact same code in this repo.
|
||||
<div>
|
||||
<img src="https://github.com/user-attachments/assets/07a28669-3f93-4f79-a3a4-652feab0bbd2" style="width: 250px;">
|
||||
<img src="https://github.com/user-attachments/assets/638d5bab-c967-4856-8ec4-47f4d907aec4" style="width: 250px;">
|
||||
<img src="https://github.com/user-attachments/assets/972b82fa-38ca-41bd-9f65-c8d291bd32e4" style="width: 250px;">
|
||||
<img src="https://github.com/user-attachments/assets/72829045-97da-453b-89c1-ed901c7d840e" style="width: 250px;">
|
||||
|
||||
</div>
|
||||
- Paste Compression at Rest and on Response Transit (Files are only compressed when there is a considerable file size decrease)
|
||||
- Cleaner Code Base
|
||||
- Paste Analytics (Views etc.)
|
||||
|
||||
## TODO
|
||||
- [ ] Password Resets
|
||||
- [x] Switch to Controllers
|
||||
- [ ] Admin Panel
|
||||
- [ ] Paste Editing
|
||||
- [ ] Paste Searching (maybe)
|
||||
- [x] Paste Deletion
|
||||
- [ ] Switch to Razor Pages?
|
||||
|
||||
@@ -0,0 +1,297 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SharpbinV2.Server.Services;
|
||||
using SharpbinV2.Server.Models;
|
||||
using Bcrypt = BCrypt.Net.BCrypt;
|
||||
using Microsoft.AspNetCore.RateLimiting;
|
||||
|
||||
namespace SharpbinV2.Server.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/auth")]
|
||||
public class AuthController : Controller
|
||||
{
|
||||
private readonly DatabaseService _databaseService;
|
||||
private readonly ILogger<AuthController> _logger;
|
||||
|
||||
public AuthController(DatabaseService databaseService, ILogger<AuthController> logger)
|
||||
{
|
||||
_databaseService = databaseService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpPost("login")]
|
||||
[EnableRateLimiting("auth")]
|
||||
public async Task<IActionResult> Login([FromBody] AuthRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var requestDetails = HelperService.GetRequestDetails(HttpContext);
|
||||
if (string.IsNullOrWhiteSpace(request.Username) && string.IsNullOrWhiteSpace(request.Email))
|
||||
return BadRequest(new { success = false, message = "Username or Email is required" });
|
||||
if (request.Password.Length is < 8 or > 128)
|
||||
return BadRequest(new { success = false, message = "Password must be between 8 and 128 characters" });
|
||||
if (!string.IsNullOrWhiteSpace(request.Username) && request.Username.Length > 32)
|
||||
return BadRequest(new { success = false, message = "Username must be 32 characters or less" });
|
||||
if (!string.IsNullOrWhiteSpace(request.Email) && request.Email.Length > 128)
|
||||
return BadRequest(new { success = false, message = "Email must be 128 characters or less" });
|
||||
if (!string.IsNullOrWhiteSpace(request.Username) && !string.IsNullOrWhiteSpace(request.Email))
|
||||
return BadRequest(new { success = false, message = "Please provide either a username or an email, not both" });
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(requestDetails.Token))
|
||||
{
|
||||
var _session = await _databaseService.UserFromToken(requestDetails.Token);
|
||||
if (_session != null)
|
||||
{
|
||||
return BadRequest(new { success = false, message = "You are already logged in" });
|
||||
}
|
||||
}
|
||||
|
||||
User? user = null;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(request.Username))
|
||||
user = await _databaseService.UserFromUsername(request.Username);
|
||||
else if (!string.IsNullOrWhiteSpace(request.Email))
|
||||
user = await _databaseService.UserFromEmail(request.Email);
|
||||
|
||||
if (user == null)
|
||||
return Unauthorized(new { success = false, message = "Invalid username or password" });
|
||||
|
||||
if (!Bcrypt.Verify(request.Password, user.Password))
|
||||
{
|
||||
return Unauthorized(new { success = false, message = "Invalid username or password" });
|
||||
}
|
||||
|
||||
string token = HelperService.GenerateToken();
|
||||
|
||||
var session = await _databaseService.CreateSession(user, requestDetails, token) ?? new Session();
|
||||
if (session.UUID == "0" || session == null)
|
||||
return StatusCode(500, new { success = false, message = "Failed to create session" });
|
||||
|
||||
var cookieOptions = new CookieOptions
|
||||
{
|
||||
HttpOnly = true,
|
||||
#if DEBUG
|
||||
Secure = false,
|
||||
#else
|
||||
Secure = true,
|
||||
#endif
|
||||
SameSite = SameSiteMode.Strict,
|
||||
Expires = DateTimeOffset.UtcNow.AddDays(14)
|
||||
};
|
||||
Response.Cookies.Append("Authorization", token, cookieOptions);
|
||||
return Ok(new
|
||||
{
|
||||
success = true,
|
||||
message = "Login successful",
|
||||
token
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"Error during login attempt for user {request.Username ?? request.Email}");
|
||||
return StatusCode(500, "Internal server error");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("register")]
|
||||
[EnableRateLimiting("auth")]
|
||||
public async Task<IActionResult> Register([FromBody] AuthRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var requestDetails = HelperService.GetRequestDetails(HttpContext);
|
||||
if (string.IsNullOrWhiteSpace(request.Username) && string.IsNullOrWhiteSpace(request.Email))
|
||||
return BadRequest(new { success = false, message = "Username or Email is required" });
|
||||
if (request.Password.Length is < 8 or > 128)
|
||||
return BadRequest(new { success = false, message = "Password must be between 8 and 128 characters" });
|
||||
if (request.Username.Length is < 3 or > 32)
|
||||
return BadRequest(new { success = false, message = "Username must be between 3 and 32 characters" });
|
||||
if (request.Email.Length > 128)
|
||||
return BadRequest(new { success = false, message = "Email must be 128 characters or less" });
|
||||
if (!string.IsNullOrWhiteSpace(request.Email) && !HelperService.IsValidEmail(request.Email))
|
||||
return BadRequest(new { success = false, message = "Invalid email" });
|
||||
if (!string.IsNullOrWhiteSpace(request.Username) && !string.IsNullOrWhiteSpace(request.Email))
|
||||
return BadRequest(new { success = false, message = "Please provide either a username or an email, not both" });
|
||||
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(requestDetails.Token))
|
||||
{
|
||||
var _session = await _databaseService.UserFromToken(requestDetails.Token);
|
||||
if (_session != null)
|
||||
{
|
||||
return BadRequest(new { success = false, message = "You are already logged in" });
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(request.Username))
|
||||
{
|
||||
var existingUser = await _databaseService.UserFromUsername(request.Username);
|
||||
if (existingUser != null)
|
||||
return BadRequest(new { success = false, message = "Username already exists" });
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(request.Email))
|
||||
{
|
||||
var existingUser = await _databaseService.UserFromEmail(request.Email);
|
||||
if (existingUser != null)
|
||||
return BadRequest(new { success = false, message = "Email already exists" });
|
||||
}
|
||||
|
||||
string hashedPassword = Bcrypt.HashPassword(request.Password, Bcrypt.GenerateSalt(12));
|
||||
string token = HelperService.GenerateToken();
|
||||
string uuid = Guid.NewGuid().ToString();
|
||||
|
||||
User? user = await _databaseService.CreateUser(request.Username, request.Email, hashedPassword, uuid);
|
||||
if (user == null)
|
||||
return StatusCode(500, new { success = false, message = "Failed to create user" });
|
||||
|
||||
var session = await _databaseService.CreateSession(user, requestDetails, token) ?? new Session();
|
||||
|
||||
if (session.UUID == "0" || session == null)
|
||||
return StatusCode(500, new { success = false, message = "Failed to create session" });
|
||||
|
||||
var cookieOptions = new CookieOptions
|
||||
{
|
||||
HttpOnly = true,
|
||||
#if DEBUG
|
||||
Secure = false,
|
||||
#else
|
||||
Secure = true,
|
||||
#endif
|
||||
SameSite = SameSiteMode.Strict,
|
||||
Expires = DateTimeOffset.UtcNow.AddDays(14)
|
||||
};
|
||||
|
||||
Response.Cookies.Append("Authorization", token, cookieOptions);
|
||||
return Ok(new
|
||||
{
|
||||
success = true,
|
||||
message = "Registration successful",
|
||||
user = new
|
||||
{
|
||||
user.UID,
|
||||
user.UUID,
|
||||
user.Username,
|
||||
user.Email,
|
||||
user.DisplayName,
|
||||
user.Created
|
||||
},
|
||||
token
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"Error during registration attempt for user {request.Username ?? request.Email}");
|
||||
return StatusCode(500, "Internal server error");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("authenticated")]
|
||||
public async Task<IActionResult> IsAuthenticated()
|
||||
{
|
||||
try
|
||||
{
|
||||
var requestDetails = HelperService.GetRequestDetails(HttpContext);
|
||||
if (string.IsNullOrWhiteSpace(requestDetails.Token))
|
||||
{
|
||||
return Unauthorized(new { success = false, message = "Not authenticated, no token found" });
|
||||
}
|
||||
var user = await _databaseService.UserFromToken(requestDetails.Token);
|
||||
if (user == null)
|
||||
{
|
||||
return Unauthorized(new { success = false, message = "Not authenticated, invalid token" });
|
||||
}
|
||||
var session = await _databaseService.GetSession(requestDetails.Token);
|
||||
long currentTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
|
||||
if (session == null || session.Expirary < currentTime)
|
||||
{
|
||||
Response.Cookies.Delete("Authorization");
|
||||
return Unauthorized(new { success = false, message = "Session expired" });
|
||||
}
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
success = true,
|
||||
message = "Authenticated",
|
||||
expires = session.Expirary,
|
||||
user = new
|
||||
{
|
||||
user.UID,
|
||||
user.UUID,
|
||||
user.Username,
|
||||
user.Email,
|
||||
user.DisplayName,
|
||||
user.Created,
|
||||
user.LastLogin,
|
||||
user.Type
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error checking authentication status");
|
||||
return StatusCode(500, "Internal server error");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("logout")]
|
||||
public async Task<IActionResult> Logout()
|
||||
{
|
||||
try
|
||||
{
|
||||
var requestDetails = HelperService.GetRequestDetails(HttpContext);
|
||||
if (string.IsNullOrWhiteSpace(requestDetails.Token))
|
||||
{
|
||||
return Unauthorized(new { success = false, message = "Not authenticated" });
|
||||
}
|
||||
var user = await _databaseService.UserFromToken(requestDetails.Token);
|
||||
if (user == null)
|
||||
{
|
||||
return Unauthorized(new { success = false, message = "Not authenticated" });
|
||||
}
|
||||
await _databaseService.DeleteSession(requestDetails.Token);
|
||||
Response.Cookies.Delete("Authorization");
|
||||
return Ok(new { success = true, message = "Logged out successfully" });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error during logout attempt");
|
||||
return StatusCode(500, "Internal server error");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpDelete("delete")]
|
||||
public async Task<IActionResult> DeleteAccount()
|
||||
{
|
||||
try
|
||||
{
|
||||
var requestDetails = HelperService.GetRequestDetails(HttpContext);
|
||||
if (string.IsNullOrWhiteSpace(requestDetails.Token))
|
||||
{
|
||||
return Unauthorized(new { success = false, message = "Not authenticated" });
|
||||
}
|
||||
var user = await _databaseService.UserFromToken(requestDetails.Token);
|
||||
if (user == null)
|
||||
{
|
||||
return Unauthorized(new { success = false, message = "Not authenticated" });
|
||||
}
|
||||
await _databaseService.DeleteUser(user);
|
||||
await _databaseService.DeleteSession(requestDetails.Token);
|
||||
Response.Cookies.Delete("Authorization");
|
||||
return Ok(new { success = true, message = "Account deleted successfully" });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error during account deletion attempt");
|
||||
return StatusCode(500, "Internal server error");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public class AuthRequest
|
||||
{
|
||||
public string Username { get; set; } = string.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,527 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.RateLimiting;
|
||||
using SharpbinV2.Server.Services;
|
||||
using SharpbinV2.Server.Models;
|
||||
using System.Text;
|
||||
using IOFile = System.IO.File;
|
||||
using UAParser;
|
||||
|
||||
namespace SharpbinV2.Server.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/pastes")]
|
||||
public class PasteController : Controller
|
||||
{
|
||||
private readonly DatabaseService _databaseService;
|
||||
private readonly ILogger<PasteController> _logger;
|
||||
|
||||
public PasteController(DatabaseService databaseService, ILogger<PasteController> logger)
|
||||
{
|
||||
_databaseService = databaseService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpPost("create")]
|
||||
[EnableRateLimiting("uploads")]
|
||||
[Consumes("text/plain")]
|
||||
public async Task<IActionResult> CreatePaste(string title, string syntax, int visibility)
|
||||
{
|
||||
try
|
||||
{
|
||||
string content = await new StreamReader(HttpContext.Request.Body, Encoding.UTF8).ReadToEndAsync();
|
||||
var requestDetails = HelperService.GetRequestDetails(HttpContext);
|
||||
var queries = HttpContext.Request.Query;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(content))
|
||||
return BadRequest(new { success = false, message = "Content cannot be empty." });
|
||||
|
||||
if (content.Length > Program.MaxFileSize)
|
||||
return BadRequest(new { success = false, message = $"Content exceeds maximum size of {Program.MaxFileSize} bytes." });
|
||||
|
||||
title = !string.IsNullOrWhiteSpace(title) ? title : $"Untitled {await _databaseService.EnumeratePastes()}";
|
||||
syntax = syntax?.ToLower() ?? "none";
|
||||
visibility = visibility < 0 || visibility > 2 ? 0 : visibility;
|
||||
|
||||
if (title.Length > 500)
|
||||
return BadRequest(new { success = false, message = "Title cannot exceed 500 characters." });
|
||||
if (visibility < 0 || visibility > 2)
|
||||
return BadRequest(new { success = false, message = "Invalid visibility option. Must be 0 (public), 1 (unlisted), or 2 (private)." });
|
||||
if (!Program.ValidSyntaxLanguages.Contains(syntax.ToLower()))
|
||||
return BadRequest(new { success = false, message = "Invalid syntax language specified." });
|
||||
if (string.IsNullOrWhiteSpace(title))
|
||||
title = $"Untitled {await _databaseService.EnumeratePastes()}";
|
||||
|
||||
bool shouldCompress = await CompressionService.ShouldCompress(content);
|
||||
byte[] compressedContent = shouldCompress
|
||||
? await CompressionService.CompressString(content)
|
||||
: Encoding.UTF8.GetBytes(content);
|
||||
User? user = await _databaseService.UserFromToken(requestDetails.Token ?? "");
|
||||
string pasteId = HelperService.GenerateRandomString(8);
|
||||
|
||||
Paste paste = new Paste
|
||||
{
|
||||
Created = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
|
||||
Size = compressedContent.Length,
|
||||
TrueSize = content.Length,
|
||||
UUID = Guid.NewGuid().ToString(),
|
||||
ID = pasteId,
|
||||
AuthorUUID = user?.UUID ?? "0", // 0 means the user is anonymous
|
||||
FilePath = shouldCompress ? $"pastes/{pasteId}.txt.gz" : $"pastes/{pasteId}.txt",
|
||||
Visibility = visibility,
|
||||
Title = title,
|
||||
Edited = 0,
|
||||
Views = 0,
|
||||
Syntax = syntax.ToLower()
|
||||
};
|
||||
|
||||
await IOFile.WriteAllBytesAsync(paste.FilePath, compressedContent);
|
||||
bool success = await _databaseService.CreatePaste(paste, _logger);
|
||||
|
||||
if (!success)
|
||||
return StatusCode(500, new { success, message = "An error occurred while creating the paste." });
|
||||
|
||||
_logger.LogInformation($"Paste created successfully: {pasteId}");
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
success = true,
|
||||
paste = new
|
||||
{
|
||||
paste.ID,
|
||||
paste.UUID,
|
||||
paste.Title,
|
||||
paste.Syntax,
|
||||
paste.Visibility,
|
||||
paste.Created,
|
||||
paste.Size,
|
||||
paste.TrueSize,
|
||||
paste.AuthorUUID
|
||||
},
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error creating paste");
|
||||
return StatusCode(500, new { error = "An error occurred while creating the paste." });
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
[EnableRateLimiting("general")]
|
||||
public async Task<IActionResult> GetPaste(string id)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(id))
|
||||
return BadRequest(new { success = false, message = "Invalid paste ID." });
|
||||
Paste? paste = await _databaseService.GetPasteFromID(id);
|
||||
|
||||
if (paste == null || paste.FilePath == null || !IOFile.Exists(paste.FilePath))
|
||||
return NotFound(new { success = false, message = "Paste not found." });
|
||||
|
||||
if (paste.FilePath.EndsWith(".gz"))
|
||||
Response.Headers.Append("Content-Encoding", "gzip");
|
||||
|
||||
Response.Headers.Append("Content-Type", "text/plain; charset=utf-8");
|
||||
Response.Headers.Append("Cache-Control", "public, max-age=3600");
|
||||
|
||||
return PhysicalFile(Path.GetFullPath(paste.FilePath), "text/plain");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error retrieving paste");
|
||||
return StatusCode(500, new { error = "An error occurred while retrieving the paste." });
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("{id}/info")]
|
||||
[EnableRateLimiting("general")]
|
||||
public async Task<IActionResult> GetPasteInfo(string id)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(id))
|
||||
return BadRequest(new { success = false, message = "Invalid paste ID." });
|
||||
Paste? paste = await _databaseService.GetPasteFromID(id);
|
||||
if (paste == null || string.IsNullOrWhiteSpace(paste.UUID))
|
||||
return NotFound(new { success = false, message = "Paste not found." });
|
||||
User? author = null;
|
||||
if (!string.IsNullOrWhiteSpace(paste.AuthorUUID))
|
||||
author = await _databaseService.UserFromUUID(paste.AuthorUUID ?? "");
|
||||
return Ok(new
|
||||
{
|
||||
success = true,
|
||||
paste = new
|
||||
{
|
||||
paste.ID,
|
||||
paste.UUID,
|
||||
paste.Title,
|
||||
paste.Syntax,
|
||||
paste.Views,
|
||||
paste.Visibility,
|
||||
paste.Created,
|
||||
paste.Size,
|
||||
paste.TrueSize,
|
||||
paste.AuthorUUID,
|
||||
username = author?.Username ?? "Anonymous",
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error retrieving paste info");
|
||||
return StatusCode(500, new { error = "An error occurred while retrieving the paste info." });
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("{id}/views")]
|
||||
[EnableRateLimiting("general")]
|
||||
public async Task<IActionResult> GetPasteViews(string id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var requestDetails = HelperService.GetRequestDetails(HttpContext);
|
||||
if (string.IsNullOrWhiteSpace(requestDetails.Token) || await _databaseService.GetSession(requestDetails.Token) == null)
|
||||
return Unauthorized(new { success = false, message = "Invalid or missing authentication token." });
|
||||
if (string.IsNullOrWhiteSpace(id))
|
||||
return BadRequest(new { success = false, message = "Invalid paste ID." });
|
||||
Paste? paste = await _databaseService.GetPasteFromID(id);
|
||||
User? user = await _databaseService.UserFromToken(requestDetails.Token ?? "");
|
||||
if (paste == null)
|
||||
return NotFound(new { success = false, message = "Paste not found." });
|
||||
if (paste.AuthorUUID != user?.UUID)
|
||||
return Unauthorized(new { success = false, message = "You do not have permission to view this paste's views." });
|
||||
|
||||
List<View?>? views = await _databaseService.GetViewsFromPaste(paste.UUID ?? "", _logger);
|
||||
|
||||
if (views == null || views.Count == 0)
|
||||
return BadRequest(new { success = false, message = "No views found for this paste." });
|
||||
|
||||
var details = new List<object>();
|
||||
|
||||
foreach (var view in views)
|
||||
{
|
||||
if (view == null)
|
||||
continue;
|
||||
var uaParser = Parser.GetDefault();
|
||||
ClientInfo clientInfo = uaParser.Parse(view.UserAgent ?? "");
|
||||
details.Add(new
|
||||
{
|
||||
view.PasteUUID,
|
||||
view.Created,
|
||||
UserAgent = new
|
||||
{
|
||||
Browser = clientInfo.UA.Family,
|
||||
Platform = clientInfo.OS.Family,
|
||||
Device = clientInfo.Device.Family
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
success = true,
|
||||
pasteID = paste.ID,
|
||||
pasteUUID = paste.UUID,
|
||||
views = details
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error retrieving paste views");
|
||||
return StatusCode(500, new { error = "An error occurred while retrieving the paste views." });
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("archive")]
|
||||
[EnableRateLimiting("general")]
|
||||
public async Task<IActionResult> GetPastes(int page, int limit)
|
||||
{
|
||||
if (page < 1 || limit < 1 || limit > 25)
|
||||
return BadRequest(new { success = false, message = "Invalid page or limit parameters." });
|
||||
if (page == 1)
|
||||
page = 0;
|
||||
|
||||
try
|
||||
{
|
||||
int pages = await _databaseService.EnumeratePastes() / limit;
|
||||
if (page > pages)
|
||||
return BadRequest(new { success = false, message = "Page number exceeds available pages." });
|
||||
|
||||
List<Paste?>? pastes = await _databaseService.GetPastes(limit, page, _logger);
|
||||
|
||||
if (pastes == null || pastes.Count == 0)
|
||||
return NotFound(new { success = false, message = "No pastes found." });
|
||||
|
||||
var pasteList = new List<object>();
|
||||
foreach (var paste in pastes)
|
||||
{
|
||||
if (paste == null)
|
||||
continue;
|
||||
pasteList.Add(new
|
||||
{
|
||||
paste.ID,
|
||||
paste.UUID,
|
||||
paste.Title,
|
||||
paste.Syntax,
|
||||
paste.Visibility,
|
||||
paste.Created,
|
||||
paste.Size,
|
||||
paste.TrueSize,
|
||||
paste.AuthorUUID
|
||||
});
|
||||
}
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
success = true,
|
||||
pages,
|
||||
pastes = pasteList
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error retrieving pastes archive");
|
||||
return StatusCode(500, new { error = "An error occurred while retrieving the pastes archive." });
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("my")]
|
||||
[EnableRateLimiting("general")]
|
||||
public async Task<IActionResult> GetMyPastes(int page, int limit)
|
||||
{
|
||||
var requestDetails = HelperService.GetRequestDetails(HttpContext);
|
||||
if (string.IsNullOrWhiteSpace(requestDetails.Token) || await _databaseService.GetSession(requestDetails.Token) == null)
|
||||
return Unauthorized(new { success = false, message = "Invalid or missing authentication token." });
|
||||
User? user = await _databaseService.UserFromToken(requestDetails.Token ?? "");
|
||||
if (user == null)
|
||||
return Unauthorized(new { success = false, message = "User not found." });
|
||||
if (page < 1 || limit < 1 || limit > 25)
|
||||
return BadRequest(new { success = false, message = "Invalid page or limit parameters." });
|
||||
if (page == 1)
|
||||
page = 0;
|
||||
|
||||
try
|
||||
{
|
||||
int pages = await _databaseService.EnumerateUserPastes(user) / limit;
|
||||
if (page > pages)
|
||||
return BadRequest(new { success = false, message = "Page number exceeds available pages." });
|
||||
List<Paste?>? pastes = await _databaseService.GetPastesFromUser(user, limit, page, _logger, true);
|
||||
if (pastes == null || pastes.Count == 0)
|
||||
return NotFound(new { success = false, message = "No pastes found." });
|
||||
var pasteList = new List<object>();
|
||||
foreach (var paste in pastes)
|
||||
{
|
||||
if (paste == null)
|
||||
continue;
|
||||
pasteList.Add(new
|
||||
{
|
||||
paste.ID,
|
||||
paste.UUID,
|
||||
paste.Title,
|
||||
paste.Syntax,
|
||||
paste.Visibility,
|
||||
paste.Created,
|
||||
paste.Size,
|
||||
paste.TrueSize,
|
||||
paste.AuthorUUID
|
||||
});
|
||||
}
|
||||
return Ok(new
|
||||
{
|
||||
success = true,
|
||||
pages,
|
||||
pastes = pasteList
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error retrieving user's pastes");
|
||||
return StatusCode(500, new { error = "An error occurred while retrieving the user's pastes." });
|
||||
}
|
||||
}
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
[EnableRateLimiting("general")]
|
||||
public async Task<IActionResult> DeletePaste(string id)
|
||||
{
|
||||
var requestDetails = HelperService.GetRequestDetails(HttpContext);
|
||||
if (string.IsNullOrWhiteSpace(requestDetails.Token) || await _databaseService.GetSession(requestDetails.Token) == null)
|
||||
return Unauthorized(new { success = false, message = "Invalid or missing authentication token." });
|
||||
|
||||
User? user = await _databaseService.UserFromToken(requestDetails.Token ?? "");
|
||||
if (user == null || user.UUID == "0")
|
||||
return Unauthorized(new { success = false, message = "User not found." });
|
||||
|
||||
if (string.IsNullOrWhiteSpace(id))
|
||||
return BadRequest(new { success = false, message = "Invalid paste ID." });
|
||||
try
|
||||
{
|
||||
Paste? paste = await _databaseService.GetPasteFromID(id);
|
||||
if (paste == null)
|
||||
return NotFound(new { success = false, message = "Paste not found." });
|
||||
|
||||
if (paste.AuthorUUID != user.UUID && user.Type != 255)
|
||||
return Unauthorized(new { success = false, message = "You do not have permission to delete this paste." });
|
||||
|
||||
bool success = await _databaseService.DeletePaste(paste, _logger);
|
||||
if (!success)
|
||||
return StatusCode(500, new { success, message = "An error occurred while deleting the paste." });
|
||||
|
||||
if (IOFile.Exists(paste.FilePath))
|
||||
IOFile.Delete(paste.FilePath);
|
||||
|
||||
_logger.LogInformation($"Paste deleted successfully: {id}");
|
||||
return Ok(new { success = true, message = "Paste deleted successfully." });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error deleting paste");
|
||||
return StatusCode(500, new { error = "An error occurred while deleting the paste." });
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("{id}/change-id")]
|
||||
[EnableRateLimiting("general")]
|
||||
public async Task<IActionResult> ChangePasteID(string id, string newId)
|
||||
{
|
||||
var requestDetails = HelperService.GetRequestDetails(HttpContext);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(requestDetails.Token) || await _databaseService.GetSession(requestDetails.Token) == null)
|
||||
return Unauthorized(new { success = false, message = "Invalid or missing authentication token." });
|
||||
User? user = await _databaseService.UserFromToken(requestDetails.Token ?? "");
|
||||
if (user == null || user.UUID == "0")
|
||||
return Unauthorized(new { success = false, message = "User not found." });
|
||||
if (string.IsNullOrWhiteSpace(id) || string.IsNullOrWhiteSpace(newId))
|
||||
return BadRequest(new { success = false, message = "Invalid paste ID." });
|
||||
if (user.Type != 255)
|
||||
return Unauthorized(new { success = false, message = "You do not have permission to change paste ID." });
|
||||
|
||||
try
|
||||
{
|
||||
var paste = await _databaseService.GetPasteFromID(id);
|
||||
if (paste == null)
|
||||
return NotFound(new { success = false, message = "Paste not found." });
|
||||
|
||||
paste.ID = newId;
|
||||
|
||||
var newPaste = await _databaseService.UpdatePaste(paste, _logger);
|
||||
if (newPaste == null)
|
||||
return StatusCode(500, new { success = false, message = "An error occurred while changing the paste ID." });
|
||||
|
||||
if (IOFile.Exists(paste.FilePath) && paste.ID != null)
|
||||
{
|
||||
string newFilePath = paste.FilePath.Replace(paste.ID, newId);
|
||||
IOFile.Move(paste.FilePath, newFilePath);
|
||||
paste.FilePath = newFilePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
return StatusCode(500, new { success = false, message = "Paste file not found or invalid." });
|
||||
}
|
||||
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
success = true,
|
||||
message = "Paste ID changed successfully.",
|
||||
paste = new
|
||||
{
|
||||
newPaste.ID,
|
||||
newPaste.UUID,
|
||||
newPaste.Title,
|
||||
newPaste.Syntax,
|
||||
newPaste.Visibility,
|
||||
newPaste.Created,
|
||||
newPaste.Size,
|
||||
newPaste.TrueSize,
|
||||
newPaste.AuthorUUID
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error changing paste ID");
|
||||
return StatusCode(500, new { error = "An error occurred while changing the paste ID." });
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPatch("{id}")]
|
||||
[EnableRateLimiting("general")]
|
||||
[Consumes("text/plain")]
|
||||
public async Task<IActionResult> EditPaste(string id, string title)
|
||||
{
|
||||
var requestDetails = HelperService.GetRequestDetails(HttpContext);
|
||||
if (string.IsNullOrWhiteSpace(requestDetails.Token) || await _databaseService.GetSession(requestDetails.Token) == null)
|
||||
return Unauthorized(new { success = false, message = "Invalid or missing authentication token." });
|
||||
|
||||
User? user = await _databaseService.UserFromToken(requestDetails.Token ?? "");
|
||||
if (user == null || user.UUID == "0")
|
||||
return Unauthorized(new { success = false, message = "User not found." });
|
||||
if (string.IsNullOrWhiteSpace(id))
|
||||
return BadRequest(new { success = false, message = "Invalid paste ID." });
|
||||
|
||||
var paste = await _databaseService.GetPasteFromID(id);
|
||||
if (paste == null || string.IsNullOrWhiteSpace(paste.FilePath))
|
||||
return NotFound(new { success = false, message = "Paste not found." });
|
||||
|
||||
if (paste.AuthorUUID != user.UUID && user.Type != 255)
|
||||
return Unauthorized(new { success = false, message = "You do not have permission to edit this paste." });
|
||||
|
||||
if (title.Length > 500)
|
||||
return BadRequest(new { success = false, message = "Title cannot exceed 500 characters." });
|
||||
|
||||
try
|
||||
{
|
||||
string content = await new StreamReader(HttpContext.Request.Body, Encoding.UTF8).ReadToEndAsync();
|
||||
if (string.IsNullOrWhiteSpace(content))
|
||||
return BadRequest(new { success = false, message = "Content cannot be empty." });
|
||||
|
||||
if (content.Length > Program.MaxFileSize)
|
||||
return BadRequest(new { success = false, message = $"Content exceeds maximum size of {Program.MaxFileSize} bytes." });
|
||||
|
||||
bool shouldCompress = await CompressionService.ShouldCompress(content);
|
||||
byte[] compressedContent = shouldCompress
|
||||
? await CompressionService.CompressString(content)
|
||||
: Encoding.UTF8.GetBytes(content);
|
||||
|
||||
paste.Edited = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
|
||||
paste.TrueSize = content.Length;
|
||||
paste.Size = compressedContent.Length;
|
||||
paste.FilePath = shouldCompress ? paste.FilePath.Split('.').First() + ".txt.gz" : paste.FilePath.Split('.').First() + ".txt";
|
||||
paste.Title = !string.IsNullOrWhiteSpace(title) ? title : paste.Title;
|
||||
|
||||
await IOFile.WriteAllBytesAsync(paste.FilePath, compressedContent);
|
||||
|
||||
Console.WriteLine($"Wrote {content} to {paste.FilePath}");
|
||||
|
||||
var updatedPaste = await _databaseService.UpdatePaste(paste, _logger);
|
||||
if (updatedPaste == null)
|
||||
return StatusCode(500, new { success = false, message = "An error occurred while editing the paste." });
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
success = true,
|
||||
paste = new
|
||||
{
|
||||
updatedPaste.ID,
|
||||
updatedPaste.UUID,
|
||||
updatedPaste.Title,
|
||||
updatedPaste.Syntax,
|
||||
updatedPaste.Visibility,
|
||||
updatedPaste.Created,
|
||||
updatedPaste.Size,
|
||||
updatedPaste.TrueSize,
|
||||
updatedPaste.AuthorUUID,
|
||||
updatedPaste.Edited
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error editing paste");
|
||||
return StatusCode(500, new { error = "An error occurred while editing the paste." });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.RateLimiting;
|
||||
using SharpbinV2.Server.Services;
|
||||
|
||||
namespace SharpbinV2.Server.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/site")]
|
||||
public class SiteController : Controller
|
||||
{
|
||||
private readonly ILogger<SiteController> _logger;
|
||||
private readonly DatabaseService _databaseService;
|
||||
public SiteController(ILogger<SiteController> logger, DatabaseService databaseService)
|
||||
{
|
||||
_logger = logger;
|
||||
_databaseService = databaseService;
|
||||
}
|
||||
|
||||
[HttpGet("info")]
|
||||
[EnableRateLimiting("general")]
|
||||
public IActionResult GetInfo()
|
||||
{
|
||||
var info = new
|
||||
{
|
||||
Program.MaxFileSize,
|
||||
};
|
||||
return Ok(new { success = true, info });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.RateLimiting;
|
||||
using SharpbinV2.Server.Services;
|
||||
using SharpbinV2.Server.Models;
|
||||
|
||||
namespace SharpbinV2.Server.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("")]
|
||||
public class StaticController : Controller
|
||||
{
|
||||
private readonly ILogger<StaticController> _logger;
|
||||
private readonly DatabaseService _databaseService;
|
||||
private readonly IWebHostEnvironment _environment;
|
||||
|
||||
public StaticController(ILogger<StaticController> logger, DatabaseService databaseService, IWebHostEnvironment environment)
|
||||
{
|
||||
_logger = logger;
|
||||
_databaseService = databaseService;
|
||||
_environment = environment;
|
||||
}
|
||||
|
||||
[HttpGet("")]
|
||||
[EnableRateLimiting("general")]
|
||||
public IActionResult Index()
|
||||
{
|
||||
Response.StatusCode = 200;
|
||||
Response.Headers.Append("Content-Type", "text/html");
|
||||
return PhysicalFile(Path.Combine(_environment.WebRootPath, "index.html"), "text/html");
|
||||
}
|
||||
|
||||
[HttpGet("{pasteid}")]
|
||||
[EnableRateLimiting("general")]
|
||||
public async Task<IActionResult> GetPaste(string pasteid)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(pasteid))
|
||||
{
|
||||
return Redirect("/error?error=400&message=Invalid paste id.");
|
||||
}
|
||||
|
||||
var filePath = Path.Combine(_environment.WebRootPath, pasteid);
|
||||
if (System.IO.File.Exists(filePath))
|
||||
{
|
||||
var contentType = GetContentType(Path.GetExtension(filePath));
|
||||
return PhysicalFile(filePath, contentType);
|
||||
}
|
||||
|
||||
var paste = await _databaseService.GetPasteFromID(pasteid);
|
||||
if (paste == null)
|
||||
{
|
||||
return Redirect("/error?error=400&message=Paste not found.");
|
||||
}
|
||||
|
||||
var requestDetails = HelperService.GetRequestDetails(HttpContext);
|
||||
var user = await _databaseService.UserFromToken(requestDetails.Token ?? "");
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
if (user.UUID != paste.AuthorUUID)
|
||||
{
|
||||
if (!await _databaseService.HasAlreadyViewedFromUserDetails(user))
|
||||
{
|
||||
await _databaseService.AddViewToPaste(user, paste, requestDetails);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!await _databaseService.AlreadyViewed(requestDetails))
|
||||
{
|
||||
await _databaseService.AddViewToPaste(new User { UUID = "0" }, paste, requestDetails);
|
||||
}
|
||||
}
|
||||
|
||||
Response.Headers.Append("Content-Type", "text/html");
|
||||
return PhysicalFile(Path.Combine(_environment.WebRootPath, "paste.html"), "text/html");
|
||||
}
|
||||
|
||||
[HttpGet("error")]
|
||||
public IActionResult Error()
|
||||
{
|
||||
Response.StatusCode = 400;
|
||||
Response.Headers.Append("Content-Type", "text/html");
|
||||
return PhysicalFile(Path.Combine(_environment.WebRootPath, "error.html"), "text/html");
|
||||
}
|
||||
|
||||
[HttpGet("error.html")]
|
||||
public IActionResult ErrorHtml()
|
||||
{
|
||||
return Redirect("/error");
|
||||
}
|
||||
|
||||
[HttpGet("raw/{pasteid}")]
|
||||
[EnableRateLimiting("general")]
|
||||
public async Task<IActionResult> GetRawPaste(string pasteid)
|
||||
{
|
||||
if (string.IsNullOrEmpty(pasteid))
|
||||
{
|
||||
return Redirect("/error?error=400&message=Invalid paste id.");
|
||||
}
|
||||
|
||||
var paste = await _databaseService.GetPasteFromID(pasteid);
|
||||
if (paste == null || paste.FilePath == null)
|
||||
{
|
||||
return Redirect("/error?error=400&message=Paste not found.");
|
||||
}
|
||||
|
||||
Response.Headers.Append("Content-Type", "text/plain");
|
||||
if (paste.FilePath.EndsWith(".gz"))
|
||||
{
|
||||
Response.Headers.Append("Content-Encoding", "gzip");
|
||||
}
|
||||
|
||||
return PhysicalFile(paste.FilePath, "text/plain");
|
||||
}
|
||||
|
||||
[HttpGet("paste.html")]
|
||||
public IActionResult PasteHtml()
|
||||
{
|
||||
return Redirect("/");
|
||||
}
|
||||
|
||||
[HttpGet("archive")]
|
||||
[EnableRateLimiting("general")]
|
||||
public IActionResult Archive()
|
||||
{
|
||||
Response.Headers.Append("Content-Type", "text/html");
|
||||
return PhysicalFile(Path.Combine(_environment.WebRootPath, "archive.html"), "text/html");
|
||||
}
|
||||
|
||||
[HttpGet("dash")]
|
||||
[EnableRateLimiting("general")]
|
||||
public IActionResult Dashboard()
|
||||
{
|
||||
Response.Headers.Append("Content-Type", "text/html");
|
||||
return PhysicalFile(Path.Combine(_environment.WebRootPath, "dash.html"), "text/html");
|
||||
}
|
||||
|
||||
[HttpGet("dash.html")]
|
||||
public IActionResult DashboardHtml()
|
||||
{
|
||||
return Redirect("/dash");
|
||||
}
|
||||
|
||||
[HttpGet("login")]
|
||||
[EnableRateLimiting("general")]
|
||||
public IActionResult Login()
|
||||
{
|
||||
Response.Headers.Append("Content-Type", "text/html");
|
||||
return PhysicalFile(Path.Combine(_environment.WebRootPath, "login.html"), "text/html");
|
||||
}
|
||||
|
||||
[HttpGet("register")]
|
||||
[EnableRateLimiting("general")]
|
||||
public IActionResult Register()
|
||||
{
|
||||
Response.Headers.Append("Content-Type", "text/html");
|
||||
return PhysicalFile(Path.Combine(_environment.WebRootPath, "register.html"), "text/html");
|
||||
}
|
||||
|
||||
[HttpGet("u/{username}")]
|
||||
[EnableRateLimiting("general")]
|
||||
public async Task<IActionResult> UserProfile(string username)
|
||||
{
|
||||
if (string.IsNullOrEmpty(username))
|
||||
{
|
||||
return Redirect("/error?error=400&message=Invalid username.");
|
||||
}
|
||||
|
||||
string html = await System.IO.File.ReadAllTextAsync(Path.Combine(_environment.WebRootPath, "user.html"));
|
||||
|
||||
Response.Headers.Append("Content-Type", "text/html");
|
||||
Response.Headers.Append("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||
Response.Headers.Append("Pragma", "no-cache");
|
||||
Response.Headers.Append("Expires", "0");
|
||||
|
||||
return Content(html, "text/html");
|
||||
}
|
||||
|
||||
[HttpGet("reset-password")]
|
||||
[EnableRateLimiting("general")]
|
||||
public IActionResult ResetPassword()
|
||||
{
|
||||
Response.Headers.Append("Content-Type", "text/html");
|
||||
return PhysicalFile(Path.Combine(_environment.WebRootPath, "reset-password.html"), "text/html");
|
||||
}
|
||||
|
||||
private static string GetContentType(string extension)
|
||||
{
|
||||
return extension.ToLowerInvariant() switch
|
||||
{
|
||||
".html" => "text/html",
|
||||
".css" => "text/css",
|
||||
".js" => "text/javascript",
|
||||
".json" => "application/json",
|
||||
".png" => "image/png",
|
||||
".jpg" or ".jpeg" => "image/jpeg",
|
||||
".ico" => "image/x-icon",
|
||||
_ => "application/octet-stream"
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SharpbinV2.Server.Services;
|
||||
|
||||
namespace SharpbinV2.Server.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/users")]
|
||||
public class UserController : Controller
|
||||
{
|
||||
private readonly ILogger<UserController> _logger;
|
||||
private readonly DatabaseService _databaseService;
|
||||
public UserController(ILogger<UserController> logger, DatabaseService databaseService)
|
||||
{
|
||||
_logger = logger;
|
||||
_databaseService = databaseService;
|
||||
}
|
||||
|
||||
[HttpGet("uuid/{uuid}")]
|
||||
public async Task<IActionResult> GetUserByUuid(string uuid)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(uuid))
|
||||
return BadRequest(new { success = false, message = "UUID cannot be null or empty" });
|
||||
|
||||
var user = await _databaseService.UserFromUUID(uuid);
|
||||
if (user == null)
|
||||
{
|
||||
_logger.LogWarning("User not found for UUID: {Uuid}", uuid);
|
||||
return NotFound(new { success = false, message = "User not found" });
|
||||
}
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
success = true,
|
||||
user = new
|
||||
{
|
||||
user.UID,
|
||||
user.UUID,
|
||||
user.Username,
|
||||
user.DisplayName,
|
||||
user.Created,
|
||||
user.LastLogin,
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error retrieving user by UUID: {Uuid}", uuid);
|
||||
return StatusCode(500, new { success= false, message = "Internal server error" });
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("uid/{uid}")]
|
||||
public async Task<IActionResult> GetUserByUID(int uid)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (uid <= 0)
|
||||
return BadRequest(new { success = false, message = "UID must be a positive integer" });
|
||||
var user = await _databaseService.UserFromUID(uid);
|
||||
if (user == null)
|
||||
{
|
||||
_logger.LogWarning("User not found for UID: {Uid}", uid);
|
||||
return NotFound(new { success = false, message = "User not found" });
|
||||
}
|
||||
return Ok(new
|
||||
{
|
||||
success = true,
|
||||
user = new
|
||||
{
|
||||
user.UID,
|
||||
user.UUID,
|
||||
user.Username,
|
||||
user.DisplayName,
|
||||
user.Created,
|
||||
user.LastLogin,
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error retrieving user by UID: {Uid}", uid);
|
||||
return StatusCode(500, new { success= false, message = "Internal server error" });
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("username/{username}")]
|
||||
public async Task<IActionResult> GetUserByUsername(string username)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(username))
|
||||
return BadRequest(new { success = false, message = "Username cannot be null or empty" });
|
||||
var user = await _databaseService.UserFromUsername(username);
|
||||
if (user == null)
|
||||
{
|
||||
_logger.LogWarning("User not found for username: {Username}", username);
|
||||
return NotFound(new { success = false, message = "User not found" });
|
||||
}
|
||||
return Ok(new
|
||||
{
|
||||
success = true,
|
||||
user = new
|
||||
{
|
||||
user.UID,
|
||||
user.UUID,
|
||||
user.Username,
|
||||
user.DisplayName,
|
||||
user.Created,
|
||||
user.LastLogin,
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error retrieving user by username: {Username}", username);
|
||||
return StatusCode(500, new { success= false, message = "Internal server error" });
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("{uuid}/pastes")]
|
||||
public async Task<IActionResult> GetUserPastes(string uuid, int limit, int page)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(uuid))
|
||||
return BadRequest(new { success = false, message = "UUID cannot be null or empty" });
|
||||
if (limit <= 0 || page < 0)
|
||||
return BadRequest(new { success = false, message = "Invalid pagination parameters" });
|
||||
if (page == 1) page = 0;
|
||||
|
||||
var user = await _databaseService.UserFromUUID(uuid);
|
||||
if (user == null)
|
||||
{
|
||||
_logger.LogWarning("User not found for UUID: {Uuid}", uuid);
|
||||
return NotFound(new { success = false, message = "User not found" });
|
||||
}
|
||||
|
||||
int pages = await _databaseService.EnumerateUserPastes(user) / limit;
|
||||
if (page > pages)
|
||||
return BadRequest(new { success = false, message = "Page number exceeds available pages" });
|
||||
|
||||
var pastes = await _databaseService.GetPastesFromUser(user, limit, page, _logger);
|
||||
if (pastes == null || pastes.Count == 0)
|
||||
return Ok(new { success = false, message = "No pastes found for this user."});
|
||||
|
||||
var pasteList = new List<object>();
|
||||
foreach (var paste in pastes)
|
||||
{
|
||||
if (paste == null)
|
||||
continue;
|
||||
pasteList.Add(new
|
||||
{
|
||||
paste.ID,
|
||||
paste.UUID,
|
||||
paste.Title,
|
||||
paste.Syntax,
|
||||
paste.Visibility,
|
||||
paste.Created,
|
||||
paste.Size,
|
||||
paste.TrueSize,
|
||||
paste.AuthorUUID
|
||||
});
|
||||
}
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
success = true,
|
||||
pastes = pasteList,
|
||||
pages
|
||||
});
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error retrieving pastes for user UUID: {Uuid}", uuid);
|
||||
return StatusCode(500, new { success= false, message = "Internal server error" });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||
USER app
|
||||
WORKDIR /app
|
||||
EXPOSE 8080
|
||||
EXPOSE 8081
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
WORKDIR /src
|
||||
COPY ["SharpbinV2.Server/SharpbinV2.Server.csproj", "SharpbinV2.Server/"]
|
||||
RUN dotnet restore "./SharpbinV2.Server/SharpbinV2.Server.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/SharpbinV2.Server"
|
||||
RUN dotnet build "./SharpbinV2.Server.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
RUN dotnet publish "./SharpbinV2.Server.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "SharpbinV2.Server.dll"]
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace SharpbinV2.Server.Models
|
||||
{
|
||||
public class PasswordReset
|
||||
{
|
||||
public string? UID { get; set; }
|
||||
public string? UUID { get; set; }
|
||||
public string? USERUUID { get; set; }
|
||||
public string? URL { get; set; }
|
||||
public string? Token { get; set; }
|
||||
public long? Created { get; set; }
|
||||
public long? Expirary { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
namespace SharpbinV2.Server.Models
|
||||
{
|
||||
public class Paste
|
||||
{
|
||||
public int UID { get; set; }
|
||||
public string? UUID { get; set; }
|
||||
public string? ID { get; set; }
|
||||
public int? Visibility { get; set; }
|
||||
public string? Title { get; set; }
|
||||
public string? AuthorUUID { get; set; }
|
||||
public string? FilePath { get; set; }
|
||||
public long? Created { get; set; }
|
||||
public long? Edited { get; set; }
|
||||
public int? Size { get; set; }
|
||||
public int? TrueSize { get; set; }
|
||||
public int? Views { get; set; }
|
||||
public string? Syntax { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace SharpbinV2.Server.Models
|
||||
{
|
||||
public class RequestDetails
|
||||
{
|
||||
public string? Ip { get; set; }
|
||||
public string? UserAgent { get; set; }
|
||||
public string? Token { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace SharpbinV2.Server.Models
|
||||
{
|
||||
public class Session
|
||||
{
|
||||
public string? UUID { get; set; }
|
||||
public string? UserUUID { get; set; }
|
||||
public string? Token { get; set; }
|
||||
public long? Created { get; set; }
|
||||
public long? Expirary { get; set; }
|
||||
public string? Ip { get; set; }
|
||||
public string? UserAgent { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace SharpbinV2.Server.Models
|
||||
{
|
||||
public class User
|
||||
{
|
||||
public int? UID { get; set; }
|
||||
public string? UUID { get; set; }
|
||||
public int? Type { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public string? Username { get; set; }
|
||||
public string? DisplayName { get; set; }
|
||||
public string? Password { get; set; }
|
||||
public long? Created { get; set; }
|
||||
public long? LastLogin { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace SharpbinV2.Server.Models
|
||||
{
|
||||
public class View
|
||||
{
|
||||
public string? UUID { get; set; }
|
||||
public string? PasteUUID { get; set; }
|
||||
public string? UserUUID { get; set; }
|
||||
public string? Fingerprint { get; set; }
|
||||
public string? UserAgent { get; set; }
|
||||
public long? Created { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,298 @@
|
||||
using Microsoft.AspNetCore.RateLimiting;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using SharpbinV2.Server.Services;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace SharpbinV2.Server
|
||||
{
|
||||
class Program
|
||||
{
|
||||
public static string MainDatabaseConnection = "Data Source=data.db";
|
||||
public static long MaxFileSize = 1_048_576; // 1MB
|
||||
public static string[] ValidSyntaxLanguages =
|
||||
[
|
||||
"none",
|
||||
"autoHotkey",
|
||||
"autoIt",
|
||||
"bash",
|
||||
"c",
|
||||
"cpp",
|
||||
"csharp",
|
||||
"css",
|
||||
"dart",
|
||||
"html",
|
||||
"java",
|
||||
"javascript",
|
||||
"json",
|
||||
"lua",
|
||||
"markdown",
|
||||
"php",
|
||||
"python",
|
||||
"ruby",
|
||||
"rust",
|
||||
"sql",
|
||||
"swift",
|
||||
"typescript",
|
||||
"toml",
|
||||
"xml"
|
||||
];
|
||||
public static string SHA256Salt = RandomNumberGenerator.GetHexString(32);
|
||||
|
||||
static async Task Main(string[] args)
|
||||
{
|
||||
await Initialize();
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Configuration.AddEnvironmentVariables();
|
||||
|
||||
if (Environment.GetEnvironmentVariable("HTTPS") == "true")
|
||||
{
|
||||
builder.WebHost.UseUrls($"https://*:{Environment.GetEnvironmentVariable("ASPNETCORE_HTTPS_PORTS") ?? "5820"}");
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.WebHost.UseUrls($"http://*:{Environment.GetEnvironmentVariable("ASPNETCORE_HTTP_PORTS") ?? "5810"}");
|
||||
}
|
||||
|
||||
MaxFileSize = Environment.GetEnvironmentVariable("MAX_FILE_SIZE") != null ? Convert.ToInt64(Environment.GetEnvironmentVariable("MAX_FILE_SIZE")) : MaxFileSize;
|
||||
|
||||
if (Environment.GetEnvironmentVariable("SHA256_SALT") != null)
|
||||
{
|
||||
SHA256Salt = Environment.GetEnvironmentVariable("SHA256_SALT") ?? SHA256Salt;
|
||||
}
|
||||
else
|
||||
{
|
||||
SHA256Salt = RandomNumberGenerator.GetHexString(32);
|
||||
Environment.SetEnvironmentVariable("SHA256_SALT", SHA256Salt);
|
||||
|
||||
var dotenv = Path.Combine(Directory.GetCurrentDirectory(), ".env");
|
||||
if (File.Exists(dotenv))
|
||||
{
|
||||
var lines = File.ReadAllLines(dotenv).ToList();
|
||||
var saltLine = $"SHA256_SALT={SHA256Salt}";
|
||||
if (lines.Any(line => line.StartsWith("SHA256_SALT=")))
|
||||
{
|
||||
lines[lines.FindIndex(line => line.StartsWith("SHA256_SALT="))] = saltLine;
|
||||
}
|
||||
else
|
||||
{
|
||||
lines.Add(saltLine);
|
||||
}
|
||||
File.WriteAllLines(dotenv, lines);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
builder.WebHost.ConfigureKestrel(options =>
|
||||
{
|
||||
options.Limits.MaxRequestBodySize = MaxFileSize;
|
||||
});
|
||||
|
||||
builder.Services.AddRateLimiter(options =>
|
||||
{
|
||||
options.AddTokenBucketLimiter("uploads", opt =>
|
||||
{
|
||||
opt.TokenLimit = 10;
|
||||
opt.ReplenishmentPeriod = TimeSpan.FromMinutes(1);
|
||||
opt.TokensPerPeriod = 2;
|
||||
opt.AutoReplenishment = true;
|
||||
});
|
||||
|
||||
options.AddTokenBucketLimiter("auth", opt =>
|
||||
{
|
||||
opt.TokenLimit = 15;
|
||||
opt.ReplenishmentPeriod = TimeSpan.FromMinutes(5);
|
||||
opt.TokensPerPeriod = 10;
|
||||
opt.AutoReplenishment = true;
|
||||
});
|
||||
|
||||
options.AddFixedWindowLimiter("general", opt =>
|
||||
{
|
||||
opt.PermitLimit = 200;
|
||||
opt.Window = TimeSpan.FromMinutes(1);
|
||||
});
|
||||
|
||||
options.OnRejected = async (context, token) =>
|
||||
{
|
||||
context.HttpContext.Response.StatusCode = 429;
|
||||
await context.HttpContext.Response.WriteAsJsonAsync(new
|
||||
{
|
||||
success = false,
|
||||
message = "Rate limit exceeded. Please try again later."
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddCors();
|
||||
builder.Services.AddResponseCaching();
|
||||
builder.Services.AddResponseCompression();
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddScoped<DatabaseService>();
|
||||
//builder.Services.AddEndpointsApiExplorer();
|
||||
//builder.Services.AddSwaggerGen();
|
||||
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseExceptionHandler("/Error");
|
||||
app.UseHsts();
|
||||
|
||||
}
|
||||
|
||||
//if (app.Environment.IsDevelopment())
|
||||
//{
|
||||
// app.UseSwagger();
|
||||
// app.UseSwaggerUI();
|
||||
//}
|
||||
|
||||
|
||||
//app.UseHttpsRedirection();
|
||||
app.UseRouting();
|
||||
app.UseStaticFiles();
|
||||
app.UseRateLimiter();
|
||||
|
||||
app.UseCors(builder =>
|
||||
{
|
||||
builder.AllowAnyOrigin();
|
||||
builder.AllowAnyMethod();
|
||||
builder.AllowAnyHeader();
|
||||
});
|
||||
app.UseResponseCaching();
|
||||
app.UseResponseCompression();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
await app.RunAsync();
|
||||
|
||||
}
|
||||
|
||||
static async Task Initialize()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqliteConnection(MainDatabaseConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = @"CREATE TABLE IF NOT EXISTS users (
|
||||
UID INTEGER UNIQUE,
|
||||
UUID TEXT NOT NULL UNIQUE,
|
||||
Type INTEGER NOT NULL DEFAULT 0,
|
||||
Email TEXT UNIQUE,
|
||||
Username TEXT NOT NULL UNIQUE,
|
||||
DisplayName TEXT,
|
||||
Password TEXT NOT NULL,
|
||||
Created INTEGER NOT NULL,
|
||||
LastLogin INTEGER,
|
||||
PRIMARY KEY(UID AUTOINCREMENT)
|
||||
);";
|
||||
await command.ExecuteNonQueryAsync();
|
||||
command.CommandText = @"CREATE TABLE IF NOT EXISTS pastes (
|
||||
UID INTEGER NOT NULL UNIQUE,
|
||||
UUID TEXT NOT NULL UNIQUE,
|
||||
ID TEXT NOT NULL UNIQUE,
|
||||
Visibility INTEGER,
|
||||
Title TEXT,
|
||||
AuthorUUID TEXT NOT NULL,
|
||||
FilePath TEXT NOT NULL UNIQUE,
|
||||
Created INTEGER NOT NULL,
|
||||
Edited INTEGER,
|
||||
Size INTEGER NOT NULL,
|
||||
TrueSize INTEGER NOT NULL,
|
||||
Views INTEGER NOT NULL DEFAULT 0,
|
||||
Syntax TEXT,
|
||||
PRIMARY KEY(UID AUTOINCREMENT)
|
||||
);";
|
||||
await command.ExecuteNonQueryAsync();
|
||||
command.CommandText = @"CREATE TABLE IF NOT EXISTS sessions (
|
||||
UUID TEXT NOT NULL UNIQUE,
|
||||
UserUUID INTEGER NOT NULL,
|
||||
Token INTEGER NOT NULL UNIQUE,
|
||||
Created INTEGER NOT NULL,
|
||||
Expirary INTEGER NOT NULL,
|
||||
Ip TEXT NOT NULL,
|
||||
UserAgent TEXT NOT NULL
|
||||
);";
|
||||
await command.ExecuteNonQueryAsync();
|
||||
command.CommandText = @"CREATE TABLE IF NOT EXISTS views (
|
||||
UserUUID TEXT NOT NULL,
|
||||
PasteUUID INTEGER NOT NULL,
|
||||
Fingerprint TEXT NOT NULL,
|
||||
UserAgent TEXT,
|
||||
Created INTEGER NOT NULL
|
||||
);";
|
||||
await command.ExecuteNonQueryAsync();
|
||||
command.CommandText = @"CREATE TABLE IF NOT EXISTS punishments (
|
||||
UID INTEGER NOT NULL UNIQUE,
|
||||
UUID TEXT NOT NULL UNIQUE,
|
||||
Type INTEGER NOT NULL DEFAULT 0,
|
||||
Reason TEXT,
|
||||
Created INTEGER NOT NULL,
|
||||
Expirary INTEGER NOT NULL,
|
||||
PRIMARY KEY(UID AUTOINCREMENT)
|
||||
);";
|
||||
await command.ExecuteNonQueryAsync();
|
||||
command.CommandText = @"CREATE TABLE IF NOT EXISTS passwordresets (
|
||||
UID INTEGER NOT NULL UNIQUE,
|
||||
UUID TEXT NOT NULL UNIQUE,
|
||||
USERUUID TEXT NOT NULL UNIQUE,
|
||||
URL TEXT NOT NULL UNIQUE,
|
||||
Token TEXT NOT NULL UNIQUE,
|
||||
Created INTEGER NOT NULL,
|
||||
Expirary INTEGER NOT NULL,
|
||||
PRIMARY KEY(UID AUTOINCREMENT)
|
||||
);";
|
||||
await command.ExecuteNonQueryAsync();
|
||||
await connection.CloseAsync();
|
||||
}
|
||||
}
|
||||
if (!Directory.Exists("pastes"))
|
||||
Directory.CreateDirectory("pastes");
|
||||
if (!Directory.Exists("logs"))
|
||||
Directory.CreateDirectory("logs");
|
||||
var root = Directory.GetCurrentDirectory();
|
||||
var dotenv = Path.Combine(root, ".env");
|
||||
DotEnv.Load(dotenv);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine(ex.Message);
|
||||
Environment.Exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// https://dusted.codes/dotenv-in-dotnet
|
||||
/// </summary>
|
||||
public static class DotEnv
|
||||
{
|
||||
public static void Load(string filePath)
|
||||
{
|
||||
if (!File.Exists(filePath))
|
||||
return;
|
||||
|
||||
foreach (var line in File.ReadAllLines(filePath))
|
||||
{
|
||||
var parts = line.Split(
|
||||
'=',
|
||||
StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if (parts.Length != 2)
|
||||
continue;
|
||||
|
||||
Environment.SetEnvironmentVariable(parts[0], parts[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://localhost:5810"
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "https://localhost:5820;http://localhost:5810"
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"Container (Dockerfile)": {
|
||||
"commandName": "Docker",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_HTTPS_PORTS": "8081",
|
||||
"ASPNETCORE_HTTP_PORTS": "8080"
|
||||
},
|
||||
"publishAllPorts": true,
|
||||
"useSSL": true
|
||||
}
|
||||
},
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:1241",
|
||||
"sslPort": 44317
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
using System.IO.Compression;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
namespace Sharpbin
|
||||
using System.IO.Compression;
|
||||
using System.Text;
|
||||
|
||||
namespace SharpbinV2.Server.Services
|
||||
{
|
||||
public class Compression
|
||||
public class CompressionService
|
||||
{
|
||||
public static async Task<byte[]> CompressString(string text)
|
||||
{
|
||||
@@ -20,7 +21,6 @@ namespace Sharpbin
|
||||
}
|
||||
return compressedBytes;
|
||||
}
|
||||
|
||||
public static async Task<string> DecompressByteArrayToString(byte[] compressedBytes)
|
||||
{
|
||||
string decompressedText;
|
||||
@@ -36,7 +36,6 @@ namespace Sharpbin
|
||||
}
|
||||
return decompressedText;
|
||||
}
|
||||
|
||||
public static async Task<byte[]> DecompressByteArray(byte[] compressedBytes)
|
||||
{
|
||||
byte[] decompressedBytes;
|
||||
@@ -53,7 +52,20 @@ namespace Sharpbin
|
||||
}
|
||||
return decompressedBytes;
|
||||
}
|
||||
public static async Task<bool> ShouldCompress(string text, int sizeThreshold = 512, double ratioThreshold = 0.8)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
return false;
|
||||
|
||||
byte[] inputBytes = Encoding.UTF8.GetBytes(text);
|
||||
if (inputBytes.Length < sizeThreshold)
|
||||
return false;
|
||||
|
||||
byte[] compressedBytes = await CompressString(text).ConfigureAwait(false);
|
||||
double compressionRatio = (double)compressedBytes.Length / inputBytes.Length;
|
||||
|
||||
return compressionRatio < ratioThreshold;
|
||||
}
|
||||
public static bool IsCompressed(byte[] data)
|
||||
{
|
||||
return data.Length >= 2 && data[0] == 0x1F && data[1] == 0x8B;
|
||||
@@ -0,0 +1,775 @@
|
||||
using Microsoft.Data.Sqlite;
|
||||
using SharpbinV2.Server.Models;
|
||||
using Bcrypt = BCrypt.Net.BCrypt;
|
||||
|
||||
namespace SharpbinV2.Server.Services
|
||||
{
|
||||
public class DatabaseService
|
||||
{
|
||||
private readonly string _connectionString;
|
||||
public DatabaseService(IConfiguration configuration)
|
||||
{
|
||||
_connectionString = configuration.GetConnectionString("DefaultConnection") ?? "Data Source=data.db";
|
||||
}
|
||||
|
||||
public async Task<User?> UserFromUsername(string username)
|
||||
{
|
||||
if (string.IsNullOrEmpty(username))
|
||||
return null;
|
||||
using (var connection = new SqliteConnection(_connectionString))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "SELECT * FROM users WHERE Username = @Username;";
|
||||
command.Parameters.AddWithValue("@Username", username);
|
||||
using (var reader = await command.ExecuteReaderAsync())
|
||||
{
|
||||
if (!reader.HasRows)
|
||||
return null;
|
||||
await reader.ReadAsync();
|
||||
return new User
|
||||
{
|
||||
UID = reader.GetInt32(0),
|
||||
UUID = reader.GetString(1),
|
||||
Type = reader.GetInt32(2),
|
||||
Email = reader.IsDBNull(3) ? null : reader.GetString(3),
|
||||
Username = reader.GetString(4),
|
||||
DisplayName = reader.IsDBNull(5) ? null : reader.GetString(5),
|
||||
Password = reader.GetString(6),
|
||||
Created = reader.GetInt64(7),
|
||||
LastLogin = reader.GetInt64(8)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public async Task<User?> UserFromUUID(string uuid)
|
||||
{
|
||||
if (string.IsNullOrEmpty(uuid))
|
||||
return null;
|
||||
using (var connection = new SqliteConnection(_connectionString))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "SELECT * FROM users WHERE UUID = @UUID;";
|
||||
command.Parameters.AddWithValue("@UUID", uuid);
|
||||
using (var reader = await command.ExecuteReaderAsync())
|
||||
{
|
||||
if (!reader.HasRows)
|
||||
return null;
|
||||
await reader.ReadAsync();
|
||||
return new User
|
||||
{
|
||||
UID = reader.GetInt32(0),
|
||||
UUID = reader.GetString(1),
|
||||
Type = reader.GetInt32(2),
|
||||
Email = reader.IsDBNull(3) ? null : reader.GetString(3),
|
||||
Username = reader.GetString(4),
|
||||
DisplayName = reader.IsDBNull(5) ? null : reader.GetString(5),
|
||||
Password = reader.GetString(6),
|
||||
Created = reader.GetInt64(7),
|
||||
LastLogin = reader.GetInt64(8)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public async Task<User?> UserFromEmail(string email)
|
||||
{
|
||||
if (string.IsNullOrEmpty(email))
|
||||
return null;
|
||||
using (var connection = new SqliteConnection(_connectionString))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "SELECT * FROM users WHERE Email = @Email;";
|
||||
command.Parameters.AddWithValue("@Email", email);
|
||||
using (var reader = await command.ExecuteReaderAsync())
|
||||
{
|
||||
if (!reader.HasRows)
|
||||
return null;
|
||||
await reader.ReadAsync();
|
||||
return new User
|
||||
{
|
||||
UID = reader.GetInt32(0),
|
||||
UUID = reader.GetString(1),
|
||||
Type = reader.GetInt32(2),
|
||||
Email = reader.IsDBNull(3) ? null : reader.GetString(3),
|
||||
Username = reader.GetString(4),
|
||||
DisplayName = reader.IsDBNull(5) ? null : reader.GetString(5),
|
||||
Password = reader.GetString(6),
|
||||
Created = reader.GetInt64(7),
|
||||
LastLogin = reader.GetInt64(8)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public async Task<User?> UserFromToken(string token)
|
||||
{
|
||||
if (string.IsNullOrEmpty(token))
|
||||
return null;
|
||||
using (var connection = new SqliteConnection(_connectionString))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "SELECT * FROM sessions WHERE Token = @Token;";
|
||||
command.Parameters.AddWithValue("@Token", token);
|
||||
using (var reader = await command.ExecuteReaderAsync())
|
||||
{
|
||||
if (!reader.HasRows)
|
||||
return null;
|
||||
await reader.ReadAsync();
|
||||
return await UserFromUUID(reader.GetString(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public async Task<User?> UserFromUID(int uid)
|
||||
{
|
||||
if (uid <= 0)
|
||||
return null;
|
||||
using (var connection = new SqliteConnection(_connectionString))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "SELECT * FROM users WHERE UID = @UID;";
|
||||
command.Parameters.AddWithValue("@UID", uid);
|
||||
using (var reader = await command.ExecuteReaderAsync())
|
||||
{
|
||||
if (!reader.HasRows)
|
||||
return null;
|
||||
await reader.ReadAsync();
|
||||
return new User
|
||||
{
|
||||
UID = reader.GetInt32(0),
|
||||
UUID = reader.GetString(1),
|
||||
Type = reader.GetInt32(2),
|
||||
Email = reader.IsDBNull(3) ? null : reader.GetString(3),
|
||||
Username = reader.GetString(4),
|
||||
DisplayName = reader.IsDBNull(5) ? null : reader.GetString(5),
|
||||
Password = reader.GetString(6),
|
||||
Created = reader.GetInt64(7),
|
||||
LastLogin = reader.GetInt64(8)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public async Task<int> EnumeratePastes()
|
||||
{
|
||||
using (var connection = new SqliteConnection(_connectionString))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "SELECT COUNT(*) FROM pastes;";
|
||||
return Convert.ToInt32(await command.ExecuteScalarAsync());
|
||||
}
|
||||
}
|
||||
}
|
||||
public async Task<int> EnumerateUserPastes(User user)
|
||||
{
|
||||
if (user == null)
|
||||
return 0;
|
||||
using (var connection = new SqliteConnection(_connectionString))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "SELECT COUNT(*) FROM pastes WHERE AuthorUUID = @AuthorUUID;";
|
||||
command.Parameters.AddWithValue("@AuthorUUID", user.UUID);
|
||||
return Convert.ToInt32(await command.ExecuteScalarAsync());
|
||||
}
|
||||
}
|
||||
}
|
||||
public async Task<Paste?> GetPasteFromID(string id)
|
||||
{
|
||||
if (string.IsNullOrEmpty(id))
|
||||
return null;
|
||||
using (var connection = new SqliteConnection(_connectionString))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "SELECT * FROM pastes WHERE ID = @ID;";
|
||||
command.Parameters.AddWithValue("@ID", id);
|
||||
using (var reader = await command.ExecuteReaderAsync())
|
||||
{
|
||||
if (!reader.HasRows)
|
||||
return null;
|
||||
await reader.ReadAsync();
|
||||
return new Paste
|
||||
{
|
||||
UUID = reader.GetString(1),
|
||||
ID = reader.GetString(2),
|
||||
Visibility = reader.GetInt32(3),
|
||||
Title = reader.IsDBNull(4) ? null : reader.GetString(4),
|
||||
AuthorUUID = reader.GetString(5),
|
||||
FilePath = reader.GetString(6),
|
||||
Created = reader.GetInt64(7),
|
||||
Edited = reader.GetInt64(8),
|
||||
Size = reader.GetInt32(9),
|
||||
TrueSize = reader.GetInt32(10),
|
||||
Views = reader.GetInt32(11),
|
||||
Syntax = reader.IsDBNull(12) ? null : reader.GetString(12)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public async Task<bool> AlreadyViewed(RequestDetails details)
|
||||
{
|
||||
using (var connection = new SqliteConnection(_connectionString))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "SELECT * FROM views WHERE Fingerprint = @Fingerprint";
|
||||
command.Parameters.AddWithValue("@Fingerprint", HelperService.SHA256Hash(details.Ip + details.UserAgent, Program.SHA256Salt));
|
||||
using (var reader = await command.ExecuteReaderAsync())
|
||||
{
|
||||
return reader.HasRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public async Task<bool> HasAlreadyViewedFromUserDetails(User user)
|
||||
{
|
||||
using (var connection = new SqliteConnection(_connectionString))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "SELECT * FROM views WHERE UserUUID = @UserUUID;";
|
||||
command.Parameters.AddWithValue("@UserUUID", user.UUID);
|
||||
using (var reader = await command.ExecuteReaderAsync())
|
||||
{
|
||||
return reader.HasRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public async Task AddViewToPaste(User user, Paste paste, RequestDetails details)
|
||||
{
|
||||
if (paste == null || details == null)
|
||||
return;
|
||||
var _user = user ?? new User { UUID = "0" };
|
||||
using (var connection = new SqliteConnection(_connectionString))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "INSERT INTO views (UserUUID, PasteUUID, Fingerprint, UserAgent, Created) VALUES (@UserUUID, @PasteUUID, @Fingerprint, @UserAgent, @Created);";
|
||||
command.Parameters.AddWithValue("@UserUUID", _user.UUID);
|
||||
command.Parameters.AddWithValue("@PasteUUID", paste.UUID);
|
||||
command.Parameters.AddWithValue("@Fingerprint", HelperService.SHA256Hash(details.Ip + details.UserAgent, Program.SHA256Salt));
|
||||
command.Parameters.AddWithValue("@UserAgent", details.UserAgent ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@Created", DateTimeOffset.UtcNow.ToUnixTimeSeconds());
|
||||
await command.ExecuteNonQueryAsync();
|
||||
command.CommandText = "UPDATE pastes SET Views = Views + 1 WHERE UUID = @UUID;";
|
||||
command.Parameters.AddWithValue("@UUID", paste.UUID);
|
||||
await command.ExecuteNonQueryAsync();
|
||||
}
|
||||
await connection.CloseAsync();
|
||||
}
|
||||
}
|
||||
public async Task<List<Paste?>?> PastesFromUser(User user)
|
||||
{
|
||||
if (user == null)
|
||||
return null;
|
||||
using (var connection = new SqliteConnection(_connectionString))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "SELECT * FROM pastes WHERE AuthorUUID = @AuthorUUID;";
|
||||
command.Parameters.AddWithValue("@AuthorUUID", user.UUID);
|
||||
using (var reader = await command.ExecuteReaderAsync())
|
||||
{
|
||||
if (!reader.HasRows)
|
||||
return null;
|
||||
var pastes = new List<Paste?>();
|
||||
while (await reader.ReadAsync())
|
||||
{
|
||||
pastes.Add(new Paste
|
||||
{
|
||||
UUID = reader.GetString(1),
|
||||
ID = reader.GetString(2),
|
||||
Visibility = reader.GetInt32(3),
|
||||
Title = reader.IsDBNull(4) ? null : reader.GetString(4),
|
||||
AuthorUUID = reader.GetString(5),
|
||||
FilePath = reader.GetString(6),
|
||||
Created = reader.GetInt64(7),
|
||||
Edited = reader.GetInt64(8),
|
||||
Size = reader.GetInt32(9),
|
||||
TrueSize = reader.GetInt32(10),
|
||||
Views = reader.GetInt32(11),
|
||||
Syntax = reader.IsDBNull(12) ? null : reader.GetString(12)
|
||||
});
|
||||
}
|
||||
return pastes;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public async Task<PasswordReset?> GetPasswordReset(string url, string uuid, string token)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url) || string.IsNullOrEmpty(uuid) || string.IsNullOrEmpty(token))
|
||||
return null;
|
||||
using (var connection = new SqliteConnection(_connectionString))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "SELECT * FROM passwordresets WHERE URL = @URL AND UUID = @UUID AND Token = @Token;";
|
||||
command.Parameters.AddWithValue("@URL", url);
|
||||
command.Parameters.AddWithValue("@UUID", uuid);
|
||||
command.Parameters.AddWithValue("@Token", token);
|
||||
await command.ExecuteNonQueryAsync();
|
||||
using (var reader = await command.ExecuteReaderAsync())
|
||||
{
|
||||
if (!reader.HasRows)
|
||||
return null;
|
||||
await reader.ReadAsync();
|
||||
return new PasswordReset
|
||||
{
|
||||
UID = reader.GetString(0),
|
||||
UUID = reader.GetString(1),
|
||||
USERUUID = reader.GetString(2),
|
||||
URL = reader.GetString(3),
|
||||
Token = reader.GetString(4),
|
||||
Created = reader.GetInt64(5),
|
||||
Expirary = reader.GetInt64(6)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
public async Task<bool> ResetPassword(string uuid, string password_hash)
|
||||
{
|
||||
if (string.IsNullOrEmpty(uuid) || string.IsNullOrEmpty(password_hash))
|
||||
return false;
|
||||
using (var connection = new SqliteConnection(_connectionString))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "UPDATE users SET Password = @Password WHERE UUID = @UUID;";
|
||||
command.Parameters.AddWithValue("@Password", password_hash);
|
||||
command.Parameters.AddWithValue("@UUID", uuid);
|
||||
await command.ExecuteNonQueryAsync();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public async Task<Session?> CreateSession(User user, RequestDetails details, string token)
|
||||
{
|
||||
if (user == null || details == null)
|
||||
return new Session { UUID = "0" };
|
||||
var session = new Session
|
||||
{
|
||||
UUID = Guid.NewGuid().ToString(),
|
||||
UserUUID = user.UUID,
|
||||
Token = token,
|
||||
Created = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
|
||||
Expirary = DateTimeOffset.UtcNow.AddDays(14).ToUnixTimeSeconds(),
|
||||
Ip = Bcrypt.HashPassword(details.Ip, Bcrypt.GenerateSalt(8)),
|
||||
UserAgent = details.UserAgent
|
||||
};
|
||||
using (var connection = new SqliteConnection(_connectionString))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "INSERT INTO sessions (UUID, UserUUID, Token, Created, Expirary, Ip, UserAgent) VALUES (@UUID, @UserUUID, @Token, @Created, @Expirary, @Ip, @UserAgent);";
|
||||
command.Parameters.AddWithValue("@UUID", session.UUID);
|
||||
command.Parameters.AddWithValue("@UserUUID", session.UserUUID);
|
||||
command.Parameters.AddWithValue("@Token", session.Token);
|
||||
command.Parameters.AddWithValue("@Created", session.Created);
|
||||
command.Parameters.AddWithValue("@Expirary", session.Expirary);
|
||||
command.Parameters.AddWithValue("@Ip", session.Ip);
|
||||
command.Parameters.AddWithValue("@UserAgent", session.UserAgent);
|
||||
await command.ExecuteNonQueryAsync();
|
||||
}
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "UPDATE users SET LastLogin = @LastLogin WHERE UUID = @UUID;";
|
||||
command.Parameters.AddWithValue("@LastLogin", session.Created);
|
||||
command.Parameters.AddWithValue("@UUID", user.UUID);
|
||||
await command.ExecuteNonQueryAsync();
|
||||
}
|
||||
}
|
||||
return session;
|
||||
}
|
||||
public async Task<Session?> GetSession(string token)
|
||||
{
|
||||
if (string.IsNullOrEmpty(token))
|
||||
return null;
|
||||
using (var connection = new SqliteConnection(_connectionString))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "SELECT * FROM sessions WHERE Token = @Token;";
|
||||
command.Parameters.AddWithValue("@Token", token);
|
||||
using (var reader = await command.ExecuteReaderAsync())
|
||||
{
|
||||
if (!reader.HasRows)
|
||||
return null;
|
||||
await reader.ReadAsync();
|
||||
return new Session
|
||||
{
|
||||
UUID = reader.GetString(0),
|
||||
UserUUID = reader.GetString(1),
|
||||
Token = reader.GetString(2),
|
||||
Created = reader.GetInt64(3),
|
||||
Expirary = reader.GetInt64(4),
|
||||
Ip = reader.GetString(5),
|
||||
UserAgent = reader.GetString(6)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public async Task<bool> DeleteSession(string token)
|
||||
{
|
||||
if (string.IsNullOrEmpty(token))
|
||||
return false;
|
||||
using (var connection = new SqliteConnection(_connectionString))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "DELETE FROM sessions WHERE Token = @Token;";
|
||||
command.Parameters.AddWithValue("@Token", token);
|
||||
await command.ExecuteNonQueryAsync();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public async Task<User?> CreateUser(string username, string email, string password_hash, string uuid)
|
||||
{
|
||||
if (string.IsNullOrEmpty(username) && string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password_hash))
|
||||
return null;
|
||||
var user = new User
|
||||
{
|
||||
UUID = uuid,
|
||||
Type = 0,
|
||||
Email = email,
|
||||
Username = username,
|
||||
DisplayName = username,
|
||||
Password = password_hash,
|
||||
Created = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
|
||||
LastLogin = DateTimeOffset.UtcNow.ToUnixTimeSeconds()
|
||||
};
|
||||
using (var connection = new SqliteConnection(_connectionString))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "INSERT INTO users (UUID, Type, Email, Username, DisplayName, Password, Created, LastLogin) VALUES (@UUID, @Type, @Email, @Username, @DisplayName, @Password, @Created, @LastLogin);";
|
||||
command.Parameters.AddWithValue("@UUID", user.UUID);
|
||||
command.Parameters.AddWithValue("@Type", user.Type);
|
||||
command.Parameters.AddWithValue("@Email", string.IsNullOrWhiteSpace(user.Email) ? DBNull.Value : user.Email);
|
||||
command.Parameters.AddWithValue("@Username", user.Username);
|
||||
command.Parameters.AddWithValue("@DisplayName", user.DisplayName ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@Password", user.Password);
|
||||
command.Parameters.AddWithValue("@Created", user.Created);
|
||||
command.Parameters.AddWithValue("@LastLogin", user.LastLogin);
|
||||
await command.ExecuteNonQueryAsync();
|
||||
}
|
||||
}
|
||||
return user;
|
||||
}
|
||||
public async Task<bool> DeleteUser(User user)
|
||||
{
|
||||
if (user == null)
|
||||
return false;
|
||||
using (var connection = new SqliteConnection(_connectionString))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "DELETE FROM users WHERE UUID = @UUID;";
|
||||
command.Parameters.AddWithValue("@UUID", user.UUID);
|
||||
await command.ExecuteNonQueryAsync();
|
||||
}
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "DELETE FROM pastes WHERE AuthorUUID = @AuthorUUID;";
|
||||
command.Parameters.AddWithValue("@AuthorUUID", user.UUID);
|
||||
await command.ExecuteNonQueryAsync();
|
||||
}
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "DELETE FROM sessions WHERE UserUUID = @UserUUID;";
|
||||
command.Parameters.AddWithValue("@UserUUID", user.UUID);
|
||||
await command.ExecuteNonQueryAsync();
|
||||
}
|
||||
// anonymize all views by user
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "UPDATE views SET UserUUID = @UserUUID WHERE UserUUID = @OldUserUUID;";
|
||||
command.Parameters.AddWithValue("@UserUUID", "0");
|
||||
command.Parameters.AddWithValue("@OldUserUUID", user.UUID);
|
||||
await command.ExecuteNonQueryAsync();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public async Task<bool> CreatePaste(Paste paste, ILogger logger)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (paste == null || string.IsNullOrEmpty(paste.UUID) || string.IsNullOrEmpty(paste.ID) || paste.AuthorUUID == null)
|
||||
return false;
|
||||
using (var connection = new SqliteConnection(_connectionString))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "INSERT INTO pastes (UUID, ID, Visibility, Title, AuthorUUID, FilePath, Created, Edited, Size, TrueSize, Views, Syntax) VALUES (@UUID, @ID, @Visibility, @Title, @AuthorUUID, @FilePath, @Created, @Edited, @Size, @TrueSize, @Views, @Syntax);";
|
||||
command.Parameters.AddWithValue("@UUID", paste.UUID);
|
||||
command.Parameters.AddWithValue("@ID", paste.ID);
|
||||
command.Parameters.AddWithValue("@Visibility", paste.Visibility ?? 0);
|
||||
command.Parameters.AddWithValue("@Title", paste.Title ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@AuthorUUID", paste.AuthorUUID);
|
||||
command.Parameters.AddWithValue("@FilePath", paste.FilePath ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@Created", paste.Created ?? DateTimeOffset.UtcNow.ToUnixTimeSeconds());
|
||||
command.Parameters.AddWithValue("@Edited", paste.Edited ?? DateTimeOffset.UtcNow.ToUnixTimeSeconds());
|
||||
command.Parameters.AddWithValue("@Size", paste.Size ?? 0);
|
||||
command.Parameters.AddWithValue("@TrueSize", paste.TrueSize ?? 0);
|
||||
command.Parameters.AddWithValue("@Views", paste.Views ?? 0);
|
||||
command.Parameters.AddWithValue("@Syntax", paste.Syntax ?? (object)DBNull.Value);
|
||||
await command.ExecuteNonQueryAsync();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Failed to create paste in database.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public async Task<List<View?>?> GetViewsFromPaste(string uuid, ILogger logger)
|
||||
{
|
||||
if (string.IsNullOrEmpty(uuid))
|
||||
return null;
|
||||
try
|
||||
{
|
||||
using (var connection = new SqliteConnection(_connectionString))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "SELECT * FROM views WHERE PasteUUID = @PasteUUID;";
|
||||
command.Parameters.AddWithValue("@PasteUUID", uuid);
|
||||
using (var reader = await command.ExecuteReaderAsync())
|
||||
{
|
||||
if (!reader.HasRows)
|
||||
return null;
|
||||
var views = new List<View?>();
|
||||
while (await reader.ReadAsync())
|
||||
{
|
||||
views.Add(new View
|
||||
{
|
||||
UserUUID = reader.GetString(0),
|
||||
PasteUUID = reader.GetString(1),
|
||||
Fingerprint = reader.GetString(2),
|
||||
UserAgent = reader.GetString(3),
|
||||
Created = reader.GetInt64(4)
|
||||
});
|
||||
}
|
||||
return views;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Failed to get views from paste in database.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public async Task<List<Paste?>?> GetPastes(int limit, int page, ILogger logger)
|
||||
{
|
||||
if (limit <= 0 || page < 0)
|
||||
return null;
|
||||
try
|
||||
{
|
||||
using (var connection = new SqliteConnection(_connectionString))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "SELECT * FROM pastes WHERE Visibility NOT IN (1,2) ORDER BY Created DESC LIMIT @Limit OFFSET @Offset;";
|
||||
command.Parameters.AddWithValue("@Limit", limit);
|
||||
command.Parameters.AddWithValue("@Offset", limit * page);
|
||||
using (var reader = await command.ExecuteReaderAsync())
|
||||
{
|
||||
if (!reader.HasRows)
|
||||
return null;
|
||||
var pastes = new List<Paste?>();
|
||||
while (await reader.ReadAsync())
|
||||
{
|
||||
pastes.Add(new Paste
|
||||
{
|
||||
UID = reader.GetInt32(0),
|
||||
UUID = reader.GetString(1),
|
||||
ID = reader.GetString(2),
|
||||
Visibility = reader.GetInt32(3),
|
||||
Title = reader.IsDBNull(4) ? null : reader.GetString(4),
|
||||
AuthorUUID = reader.GetString(5),
|
||||
FilePath = reader.GetString(6),
|
||||
Created = reader.GetInt64(7),
|
||||
Edited = reader.GetInt64(8),
|
||||
Size = reader.GetInt32(9),
|
||||
TrueSize = reader.GetInt32(10),
|
||||
Views = reader.GetInt32(11),
|
||||
Syntax = reader.IsDBNull(12) ? null : reader.GetString(12)
|
||||
});
|
||||
}
|
||||
return pastes;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Failed to get pastes from database.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public async Task<List<Paste?>?> GetPastesFromUser(User user, int limit, int page, ILogger logger, bool _private = false)
|
||||
{
|
||||
if (user == null || limit <= 0 || page < 0)
|
||||
return null;
|
||||
try
|
||||
{
|
||||
using (var connection = new SqliteConnection(_connectionString))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
if (_private)
|
||||
command.CommandText = "SELECT * FROM pastes WHERE AuthorUUID = @AuthorUUID ORDER BY Created DESC LIMIT @Limit OFFSET @Offset;";
|
||||
else
|
||||
command.CommandText = "SELECT * FROM pastes WHERE AuthorUUID = @AuthorUUID AND Visibility NOT IN (1,2) ORDER BY Created DESC LIMIT @Limit OFFSET @Offset;";
|
||||
|
||||
command.Parameters.AddWithValue("@AuthorUUID", user.UUID);
|
||||
command.Parameters.AddWithValue("@Limit", limit);
|
||||
command.Parameters.AddWithValue("@Offset", limit * page);
|
||||
|
||||
using (var reader = await command.ExecuteReaderAsync())
|
||||
{
|
||||
if (!reader.HasRows)
|
||||
return null;
|
||||
var pastes = new List<Paste?>();
|
||||
while (await reader.ReadAsync())
|
||||
{
|
||||
pastes.Add(new Paste
|
||||
{
|
||||
UID = reader.GetInt32(0),
|
||||
UUID = reader.GetString(1),
|
||||
ID = reader.GetString(2),
|
||||
Visibility = reader.GetInt32(3),
|
||||
Title = reader.IsDBNull(4) ? null : reader.GetString(4),
|
||||
AuthorUUID = reader.GetString(5),
|
||||
FilePath = reader.GetString(6),
|
||||
Created = reader.GetInt64(7),
|
||||
Edited = reader.GetInt64(8),
|
||||
Size = reader.GetInt32(9),
|
||||
TrueSize = reader.GetInt32(10),
|
||||
Views = reader.GetInt32(11),
|
||||
Syntax = reader.IsDBNull(12) ? null : reader.GetString(12)
|
||||
});
|
||||
}
|
||||
return pastes;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Failed to get user pastes from database.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public async Task<bool> DeletePaste(Paste paste, ILogger logger)
|
||||
{
|
||||
if (paste == null || string.IsNullOrEmpty(paste.UUID))
|
||||
return false;
|
||||
try
|
||||
{
|
||||
using (var connection = new SqliteConnection(_connectionString))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "DELETE FROM pastes WHERE UUID = @UUID;";
|
||||
command.Parameters.AddWithValue("@UUID", paste.UUID);
|
||||
await command.ExecuteNonQueryAsync();
|
||||
}
|
||||
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "DELETE FROM views WHERE PasteUUID = @PasteUUID;";
|
||||
command.Parameters.AddWithValue("@PasteUUID", paste.UUID);
|
||||
await command.ExecuteNonQueryAsync();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(paste.FilePath) && File.Exists(paste.FilePath))
|
||||
{
|
||||
File.Delete(paste.FilePath);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Failed to delete paste from database.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public async Task<Paste?> UpdatePaste(Paste paste, ILogger logger)
|
||||
{
|
||||
if (paste == null || string.IsNullOrEmpty(paste.UUID))
|
||||
return null;
|
||||
try
|
||||
{
|
||||
using (var connection = new SqliteConnection(_connectionString))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "UPDATE pastes SET Visibility = @Visibility, Title = @Title, Edited = @Edited, Size = @Size, TrueSize = @TrueSize, Syntax = @Syntax, FilePath = @FilePath WHERE UUID = @UUID;";
|
||||
command.Parameters.AddWithValue("@Visibility", paste.Visibility ?? 0);
|
||||
command.Parameters.AddWithValue("@Title", paste.Title ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@Edited", DateTimeOffset.UtcNow.ToUnixTimeSeconds());
|
||||
command.Parameters.AddWithValue("@Size", paste.Size ?? 0);
|
||||
command.Parameters.AddWithValue("@TrueSize", paste.TrueSize ?? 0);
|
||||
command.Parameters.AddWithValue("@Syntax", paste.Syntax ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@FilePath", paste.FilePath);
|
||||
command.Parameters.AddWithValue("@UUID", paste.UUID);
|
||||
await command.ExecuteNonQueryAsync();
|
||||
}
|
||||
}
|
||||
return paste;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Failed to update paste in database.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using SharpbinV2.Server.Models;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Bcrypt = BCrypt.Net.BCrypt;
|
||||
|
||||
namespace SharpbinV2.Server.Services
|
||||
{
|
||||
public class HelperService
|
||||
{
|
||||
public static string[] ipHeaders =
|
||||
{
|
||||
"X-Forwarded-For",
|
||||
"X-Real-IP",
|
||||
"CF-Connecting-IP",
|
||||
"True-Client-IP",
|
||||
"X-Cluster-Client-IP",
|
||||
"X-ProxyUser-IP"
|
||||
};
|
||||
|
||||
public static JObject? TryParse(string json)
|
||||
{
|
||||
try
|
||||
{
|
||||
return JObject.Parse(json);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public static JArray? TryParseArray(string json)
|
||||
{
|
||||
try
|
||||
{
|
||||
return JArray.Parse(json);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public static string GenerateToken()
|
||||
{
|
||||
string randomstring = GenerateRandomString(32);
|
||||
string randomguid = Guid.NewGuid().ToString();
|
||||
return Convert.ToBase64String(Encoding.UTF8.GetBytes(Bcrypt.HashPassword(randomstring + randomguid, Bcrypt.GenerateSalt(10))));
|
||||
}
|
||||
public static string GenerateRandomString(int length)
|
||||
{
|
||||
var random = new Random();
|
||||
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
return new string(Enumerable.Repeat(chars, length).Select(s => s[random.Next(s.Length)]).ToArray());
|
||||
}
|
||||
public static RequestDetails GetRequestDetails(HttpContext context)
|
||||
{
|
||||
var requestdetails = new RequestDetails();
|
||||
var headers = context.Request.Headers;
|
||||
if (headers.ContainsKey("User-Agent"))
|
||||
requestdetails.UserAgent = headers["User-Agent"];
|
||||
|
||||
requestdetails.Ip = ipHeaders
|
||||
.FirstOrDefault(header => headers.TryGetValue(header, out var ip) && !string.IsNullOrWhiteSpace(ip))
|
||||
is string matchedHeader ? headers[matchedHeader] : context.Connection.RemoteIpAddress?.ToString();
|
||||
|
||||
if (headers.ContainsKey("Authorization"))
|
||||
requestdetails.Token = headers["Authorization"];
|
||||
else if (context.Request.Cookies.ContainsKey("Authorization"))
|
||||
requestdetails.Token = context.Request.Cookies["Authorization"];
|
||||
|
||||
return requestdetails;
|
||||
}
|
||||
public static string FormatBytes(long bytes)
|
||||
{
|
||||
string[] sizes = { "B", "KB", "MB", "GB", "TB" };
|
||||
double len = bytes;
|
||||
int order = 0;
|
||||
while (len >= 1024 && order < sizes.Length - 1)
|
||||
{
|
||||
order++;
|
||||
len = len / 1024;
|
||||
}
|
||||
return $"{len:0.##} {sizes[order]}";
|
||||
}
|
||||
public static bool IsValidEmail(string email)
|
||||
{
|
||||
return Regex.IsMatch(email, @"^[^@\s]+@[^@\s]+\.[^@\s]+$");
|
||||
}
|
||||
public static string SHA256Hash(string input, string salt = "")
|
||||
{
|
||||
using (SHA256 sha256Hash = SHA256.Create())
|
||||
{
|
||||
string combinedInput = input + salt;
|
||||
byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(combinedInput));
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
foreach (byte b in bytes)
|
||||
{
|
||||
builder.Append(b.ToString("x2"));
|
||||
}
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UserSecretsId>37bd710f-bebc-4da3-b1f2-d9b2885ff0a8</UserSecretsId>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<SignAssembly>False</SignAssembly>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="logs\**" />
|
||||
<Compile Remove="pastes\**" />
|
||||
<Content Remove="logs\**" />
|
||||
<Content Remove="pastes\**" />
|
||||
<EmbeddedResource Remove="logs\**" />
|
||||
<EmbeddedResource Remove="pastes\**" />
|
||||
<None Remove="logs\**" />
|
||||
<None Remove="pastes\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Classes.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.5" />
|
||||
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
||||
<PackageReference Include="UAParser" Version="3.1.47" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="wwwroot\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,9 +1,8 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.10.35004.147
|
||||
VisualStudioVersion = 17.5.2.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sharpbin", "PasteBin\Sharpbin.csproj", "{9C528C66-1818-4BF7-8AC2-EA22DDFE7FFC}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpbinV2.Server", "SharpbinV2.Server.csproj", "{68738FF4-A603-C797-2A44-D510EF342839}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -11,15 +10,15 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{9C528C66-1818-4BF7-8AC2-EA22DDFE7FFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9C528C66-1818-4BF7-8AC2-EA22DDFE7FFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9C528C66-1818-4BF7-8AC2-EA22DDFE7FFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9C528C66-1818-4BF7-8AC2-EA22DDFE7FFC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{68738FF4-A603-C797-2A44-D510EF342839}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{68738FF4-A603-C797-2A44-D510EF342839}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{68738FF4-A603-C797-2A44-D510EF342839}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{68738FF4-A603-C797-2A44-D510EF342839}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {F1C47634-0632-428A-B7BB-4AD87C3184AB}
|
||||
SolutionGuid = {4E1CB94E-6A3B-4EDF-95C2-479B8817C596}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -1,5 +1,4 @@
|
||||
{
|
||||
"DetailedErrors": true,
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
@@ -5,12 +5,5 @@
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"Kestrel": {
|
||||
"EndPoints": {
|
||||
"Http": {
|
||||
"Url": "http://*:5240"
|
||||
}
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Paste Archives - Sharpbin</title>
|
||||
<link rel="preload" href="css/style.css" as="style">
|
||||
<link rel="preload" href="css/archive.css" as="style">
|
||||
<link rel="preload" href="js/archive.js" as="script">
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
<link rel="stylesheet" href="css/archive.css">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Noto+Sans+Mono:wght@100..900&display=swap"
|
||||
rel="stylesheet">
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="main-container">
|
||||
<h1 id="archive-header">Paste Archives</h1>
|
||||
<div class="archive-information">
|
||||
<p id="archive-title">Title</p>
|
||||
<p id="archive-date">Date</p>
|
||||
<p id="archive-syntax">Syntax</p>
|
||||
</div>
|
||||
<ol class="archive-list" id="archives">
|
||||
</ol>
|
||||
<div class="paste-actions">
|
||||
<button id="previous-button"><span id="previous-button-svg"></span></button>
|
||||
<p id="paste-pages">0/0</p>
|
||||
<button id="next-button"><span id="next-button-svg"></span></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="js/archive.js"></script>
|
||||
<script src="js/main.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,229 @@
|
||||
.main-container {
|
||||
max-width: 80%;
|
||||
max-height: 80vh;
|
||||
margin: 2rem auto;
|
||||
margin-top: calc(2rem + 55px);
|
||||
padding: 1.5rem;
|
||||
background-color: var(--neutral-900);
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
#archive-header {
|
||||
font-size: 2rem;
|
||||
font-weight: 700;
|
||||
margin-bottom: 1.5rem;
|
||||
color: var(--neutral-50);
|
||||
text-align: center;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.archive-information {
|
||||
display: grid;
|
||||
grid-template-columns: 2fr 1fr 1fr;
|
||||
gap: 1rem;
|
||||
padding: 0.75rem 1rem;
|
||||
margin-bottom: 1rem;
|
||||
background-color: var(--neutral-800);
|
||||
border-radius: 6px;
|
||||
font-weight: 600;
|
||||
color: var(--neutral-200);
|
||||
border-bottom: 2px solid var(--neutral-700);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.archive-information p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.archive-list {
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
max-height: 70vh;
|
||||
overflow-y: auto;
|
||||
border-radius: 6px;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--neutral-700) var(--neutral-900);
|
||||
}
|
||||
|
||||
.archive-list::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
}
|
||||
|
||||
.archive-list::-webkit-scrollbar-track {
|
||||
background: var(--neutral-900);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.archive-list::-webkit-scrollbar-thumb {
|
||||
background-color: var(--neutral-700);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.archive-list li {
|
||||
margin: 0.75rem 0;
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
.archive-list li:hover {
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.archive-list li a {
|
||||
display: grid;
|
||||
grid-template-columns: 2fr 1fr 1fr;
|
||||
gap: 1rem;
|
||||
padding: 1rem 1.25rem;
|
||||
background-color: var(--neutral-800);
|
||||
color: var(--neutral-50);
|
||||
text-decoration: none;
|
||||
transition: all 0.3s ease;
|
||||
border-radius: 6px;
|
||||
border: 1px solid var(--neutral-700);
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.archive-list li a:hover {
|
||||
background-color: var(--neutral-750);
|
||||
border-color: var(--neutral-600);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.archive-list li a p {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
#archive-title {
|
||||
font-weight: 500;
|
||||
color: var(--neutral-100);
|
||||
}
|
||||
|
||||
#archive-date {
|
||||
color: var(--neutral-300);
|
||||
font-size: 0.9rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#archive-syntax {
|
||||
color: var(--neutral-300);
|
||||
font-size: 0.9rem;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.paste-actions {
|
||||
width: 100%;
|
||||
margin-top: 1.5rem;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
.paste-actions button {
|
||||
padding: 0.4rem 0.8rem;
|
||||
border-radius: 6px;
|
||||
border: 1px solid var(--neutral-700);
|
||||
background-color: var(--neutral-800);
|
||||
color: var(--neutral-50);
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
font-size: 1rem;
|
||||
min-width: 75px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.paste-actions button:hover:not(:disabled) {
|
||||
background-color: var(--neutral-700);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.paste-actions button:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
#paste-pages {
|
||||
font-weight: 500;
|
||||
color: var(--neutral-300);
|
||||
font-size: 1.1rem;
|
||||
margin: 0;
|
||||
padding: 0.5rem 1rem;
|
||||
background-color: var(--neutral-800);
|
||||
border-radius: 6px;
|
||||
min-width: 80px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.archive-information,
|
||||
.archive-list li a {
|
||||
grid-template-columns: 3fr 2fr;
|
||||
}
|
||||
|
||||
#archive-syntax {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.archive-information p:last-child {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.paste-actions button {
|
||||
padding: 0.5rem 1rem;
|
||||
min-width: 80px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.main-container {
|
||||
padding: 1rem;
|
||||
max-width: 95%;
|
||||
}
|
||||
|
||||
#archive-header {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.archive-list {
|
||||
max-height: 60vh;
|
||||
}
|
||||
|
||||
.paste-actions {
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
#paste-pages {
|
||||
min-width: 60px;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
}
|
||||
|
||||
#next-button-svg {
|
||||
background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L242.7 256 73.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z"/></svg>');
|
||||
color: white;
|
||||
width: 1.5em;
|
||||
height: 1.5em;
|
||||
background-size: contain;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
filter: invert(100%);
|
||||
}
|
||||
|
||||
#previous-button-svg {
|
||||
background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l192 192c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256l169.3-169.4c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-192 192z"/></svg>');
|
||||
color: white;
|
||||
width: 1.5em;
|
||||
height: 1.5em;
|
||||
background-size: contain;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
filter: invert(100%);
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
.auth-container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
min-width: 100%;
|
||||
padding: 20px;
|
||||
background-color: var(--neutral-950);
|
||||
}
|
||||
|
||||
.auth-form-container {
|
||||
background-color: var(--neutral-900);
|
||||
border-radius: 8px;
|
||||
padding: 30px;
|
||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
|
||||
width: 100%;
|
||||
max-width: 650px;
|
||||
border: 1px solid var(--neutral-800);
|
||||
}
|
||||
|
||||
.auth-title {
|
||||
text-align: center;
|
||||
font-size: 1.8rem;
|
||||
font-weight: 600;
|
||||
margin-bottom: 24px;
|
||||
color: var(--neutral-100);
|
||||
}
|
||||
|
||||
.auth-description {
|
||||
text-align: center;
|
||||
color: var(--neutral-400);
|
||||
font-size: 0.9rem;
|
||||
margin-bottom: 20px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.auth-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
font-size: 0.9rem;
|
||||
font-weight: 500;
|
||||
color: var(--neutral-300);
|
||||
}
|
||||
|
||||
.form-group input {
|
||||
padding: 12px 16px;
|
||||
border-radius: 6px;
|
||||
border: 1px solid var(--neutral-700);
|
||||
background-color: var(--neutral-800);
|
||||
color: var(--neutral-100);
|
||||
font-size: 1rem;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.form-group input:focus {
|
||||
outline: none;
|
||||
border-color: var(--neutral-500);
|
||||
box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.auth-button {
|
||||
margin-top: 10px;
|
||||
padding: 12px;
|
||||
border-radius: 6px;
|
||||
border: none;
|
||||
background-color: var(--neutral-700);
|
||||
color: var(--neutral-50);
|
||||
font-size: 1rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.auth-button:hover {
|
||||
background-color: var(--neutral-600);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.auth-links {
|
||||
margin-top: 24px;
|
||||
text-align: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.auth-links p {
|
||||
color: var(--neutral-400);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.auth-links a {
|
||||
color: var(--neutral-300);
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
transition: color 0.2s ease;
|
||||
}
|
||||
|
||||
.auth-links a:hover {
|
||||
color: var(--neutral-100);
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.error-message {
|
||||
background-color: rgba(220, 38, 38, 0.1);
|
||||
color: #ef4444;
|
||||
padding: 10px 16px;
|
||||
border-radius: 6px;
|
||||
margin-bottom: 16px;
|
||||
font-size: 0.9rem;
|
||||
display: none;
|
||||
border: 1px solid rgba(220, 38, 38, 0.2);
|
||||
}
|
||||
|
||||
.error-message.visible {
|
||||
display: block;
|
||||
animation: fadeIn 0.3s ease;
|
||||
}
|
||||
|
||||
.success-message {
|
||||
background-color: rgba(34, 197, 94, 0.1);
|
||||
color: #22c55e;
|
||||
padding: 10px 16px;
|
||||
border-radius: 6px;
|
||||
margin-bottom: 16px;
|
||||
font-size: 0.9rem;
|
||||
border: 1px solid rgba(34, 197, 94, 0.2);
|
||||
animation: fadeIn 0.3s ease;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
|
||||
.auth-container {
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
.auth-form-container {
|
||||
padding: 20px;
|
||||
max-width: 100%;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
|
||||
.auth-title {
|
||||
font-size: 1.6rem;
|
||||
}
|
||||
|
||||
.form-group input {
|
||||
padding: 10px 12px;
|
||||
}
|
||||
|
||||
.auth-button {
|
||||
padding: 10px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,502 @@
|
||||
::selection {
|
||||
background-color: var(--neutral-600);
|
||||
color: var(--neutral-100);
|
||||
}
|
||||
|
||||
::-moz-selection {
|
||||
background-color: var(--neutral-600);
|
||||
color: var(--neutral-100);
|
||||
}
|
||||
|
||||
input::selection,
|
||||
textarea::selection {
|
||||
background-color: #3b82f6;
|
||||
color: white;
|
||||
}
|
||||
|
||||
input::-moz-selection,
|
||||
textarea::-moz-selection {
|
||||
background-color: #3b82f6;
|
||||
color: white;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: var(--neutral-950);
|
||||
color: var(--neutral-100);
|
||||
}
|
||||
|
||||
.main-container {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: stretch;
|
||||
margin-top: 2rem;
|
||||
min-height: 400px;
|
||||
padding: 20px;
|
||||
gap: 25px;
|
||||
}
|
||||
|
||||
.account-info,
|
||||
.paste-list {
|
||||
width: 48%;
|
||||
border-radius: 8px;
|
||||
padding: 25px;
|
||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
|
||||
background-color: var(--neutral-900);
|
||||
border: 1px solid var(--neutral-700);
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.paste-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.account-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.account-info:hover,
|
||||
.paste-list:hover {
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
|
||||
border-color: var(--neutral-700);
|
||||
}
|
||||
|
||||
.account-info h1,
|
||||
.paste-list h1 {
|
||||
margin-bottom: 25px;
|
||||
color: var(--neutral-100);
|
||||
text-align: center;
|
||||
font-size: 1.8rem;
|
||||
border-bottom: 2px solid var(--neutral-700);
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.account-info p {
|
||||
margin: 12px 0;
|
||||
padding: 8px;
|
||||
border-bottom: 1px solid var(--neutral-800);
|
||||
font-size: 1.05rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
color: var(--neutral-300);
|
||||
}
|
||||
|
||||
.paste-information {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
padding: 10px 0;
|
||||
border-bottom: 2px solid var(--neutral-700);
|
||||
font-weight: bold;
|
||||
margin-bottom: 15px;
|
||||
color: var(--neutral-300);
|
||||
}
|
||||
|
||||
#pastes {
|
||||
list-style-type: none;
|
||||
width: 100%;
|
||||
max-height: 90%;
|
||||
overflow-y: auto;
|
||||
padding: 0;
|
||||
border-radius: 4px;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--neutral-700) var(--neutral-900);
|
||||
border: none;
|
||||
}
|
||||
|
||||
#pastes li {
|
||||
margin: 0.75rem 0;
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
#pastes li:hover {
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
#pastes li a {
|
||||
display: grid;
|
||||
grid-template-columns: 2fr 1fr 1fr;
|
||||
gap: 0.5rem;
|
||||
padding: 0.5rem 0.75rem;
|
||||
background-color: var(--neutral-800);
|
||||
color: var(--neutral-50);
|
||||
text-decoration: none;
|
||||
transition: all 0.3s ease;
|
||||
border-radius: 6px;
|
||||
border: 1px solid var(--neutral-700);
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
#pastes li a:hover {
|
||||
background-color: var(--neutral-750);
|
||||
border-color: var(--neutral-600);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
#pastes li a p {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
#paste-title {
|
||||
font-weight: 500;
|
||||
color: var(--neutral-100);
|
||||
}
|
||||
|
||||
#paste-date {
|
||||
color: var(--neutral-300);
|
||||
font-size: 0.9rem;
|
||||
text-align: center;
|
||||
overflow: hidden !important;
|
||||
text-overflow: clip !important;
|
||||
white-space: nowrap !important;
|
||||
text-align: left;
|
||||
margin-right: -70px !important;
|
||||
}
|
||||
|
||||
#paste-syntax {
|
||||
color: var(--neutral-300);
|
||||
font-size: 0.9rem;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.paste-actions {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-top: auto;
|
||||
padding-top: 15px;
|
||||
border-top: 1px solid var(--neutral-800);
|
||||
}
|
||||
|
||||
.paste-actions button {
|
||||
background-color: var(--neutral-700);
|
||||
color: var(--neutral-50);
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
padding: 8px 15px;
|
||||
margin: 0 10px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.paste-actions button:hover {
|
||||
background-color: var(--neutral-600);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.paste-actions button:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.paste-actions button:disabled {
|
||||
background-color: var(--neutral-800);
|
||||
color: var(--neutral-500);
|
||||
cursor: not-allowed;
|
||||
opacity: 0.7;
|
||||
box-shadow: none;
|
||||
transform: none;
|
||||
}
|
||||
|
||||
#paste-pages {
|
||||
margin: 0 15px;
|
||||
font-weight: bold;
|
||||
min-width: 40px;
|
||||
text-align: center;
|
||||
color: var(--neutral-300);
|
||||
}
|
||||
|
||||
#pastes::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
}
|
||||
|
||||
#pastes::-webkit-scrollbar-track {
|
||||
background: var(--neutral-900);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
#pastes::-webkit-scrollbar-thumb {
|
||||
background-color: var(--neutral-700);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
#pastes::-webkit-scrollbar-thumb:hover {
|
||||
background-color: var(--neutral-600);
|
||||
}
|
||||
|
||||
@media (max-width: 992px) {
|
||||
.main-container {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.account-info,
|
||||
.paste-list {
|
||||
padding: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.main-container {
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.account-info,
|
||||
.paste-list {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 576px) {
|
||||
.main-container {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.account-info,
|
||||
.paste-list {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.account-info h1,
|
||||
.paste-list h1 {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
#pastes li {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
#pastes li span {
|
||||
margin-top: 5px;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.logout-modal-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 2000;
|
||||
}
|
||||
|
||||
.logout-modal-box {
|
||||
background: var(--neutral-900);
|
||||
color: var(--neutral-100);
|
||||
padding: 2rem 2.5rem;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
|
||||
text-align: center;
|
||||
min-width: 300px;
|
||||
max-width: 90vw;
|
||||
}
|
||||
|
||||
.logout-modal-box h2 {
|
||||
margin-bottom: 1rem;
|
||||
font-size: 1.4rem;
|
||||
color: var(--neutral-50);
|
||||
}
|
||||
|
||||
.logout-modal-box p {
|
||||
margin-bottom: 2rem;
|
||||
color: var(--neutral-300);
|
||||
}
|
||||
|
||||
.logout-modal-box button {
|
||||
margin: 0 0.5rem;
|
||||
padding: 0.7rem 1.5rem;
|
||||
border-radius: 6px;
|
||||
font-weight: 600;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
font-size: 1rem;
|
||||
transition: background 0.2s, color 0.2s;
|
||||
}
|
||||
|
||||
#confirm-logout {
|
||||
background: #e74c3c;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#confirm-logout:hover {
|
||||
background: #c0392b;
|
||||
}
|
||||
|
||||
#cancel-logout {
|
||||
background: var(--neutral-700);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#cancel-logout:hover {
|
||||
background: var(--neutral-600);
|
||||
}
|
||||
|
||||
#logout-button {
|
||||
background-color: var(--neutral-700);
|
||||
color: var(--neutral-50);
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
padding: 10px 24px;
|
||||
margin-top: auto;
|
||||
font-size: 1.08rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s, color 0.2s, box-shadow 0.2s, transform 0.2s;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
#logout-button:hover {
|
||||
background-color: var(--neutral-600);
|
||||
color: var(--neutral-10);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.13);
|
||||
}
|
||||
|
||||
#logout-button:active {
|
||||
background-color: var(--neutral-800);
|
||||
color: var(--neutral-200);
|
||||
transform: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
#delete-account-button {
|
||||
background-color: #e74c3c;
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
padding: 10px 24px;
|
||||
font-size: 1.08rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s, color 0.2s, box-shadow 0.2s, transform 0.2s;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
||||
letter-spacing: 0.5px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
#delete-account-button:hover {
|
||||
background-color: #c0392b;
|
||||
color: #fff;
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.13);
|
||||
}
|
||||
|
||||
#delete-account-button:active {
|
||||
background-color: #a93226;
|
||||
color: #fff;
|
||||
transform: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.delete-modal-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 2100;
|
||||
}
|
||||
|
||||
.delete-modal-box {
|
||||
background: var(--neutral-900);
|
||||
color: var(--neutral-100);
|
||||
padding: 2rem 2.5rem;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
|
||||
text-align: center;
|
||||
min-width: 320px;
|
||||
max-width: 95vw;
|
||||
}
|
||||
|
||||
.delete-modal-box h2 {
|
||||
margin-bottom: 1rem;
|
||||
font-size: 1.4rem;
|
||||
color: #e74c3c;
|
||||
}
|
||||
|
||||
.delete-modal-box p {
|
||||
margin-bottom: 1.2rem;
|
||||
color: var(--neutral-300);
|
||||
}
|
||||
|
||||
.delete-modal-box input {
|
||||
margin-bottom: 0.7rem;
|
||||
width: 90%;
|
||||
padding: 8px;
|
||||
border-radius: 5px;
|
||||
border: 1px solid var(--neutral-700);
|
||||
background: var(--neutral-800);
|
||||
color: var(--neutral-100);
|
||||
font-size: 1rem;
|
||||
outline: none;
|
||||
transition: border 0.2s;
|
||||
}
|
||||
|
||||
.delete-modal-box input:focus {
|
||||
border: 1.5px solid #e74c3c;
|
||||
}
|
||||
|
||||
.delete-modal-box button {
|
||||
margin: 0 0.5rem;
|
||||
padding: 0.7rem 1.5rem;
|
||||
border-radius: 6px;
|
||||
font-weight: 600;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
font-size: 1rem;
|
||||
transition: background 0.2s, color 0.2s;
|
||||
}
|
||||
|
||||
#confirm-delete-account {
|
||||
background: #e74c3c;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#confirm-delete-account:hover {
|
||||
background: #c0392b;
|
||||
}
|
||||
|
||||
#confirm-delete-account:disabled {
|
||||
background: var(--neutral-800);
|
||||
color: var(--neutral-500);
|
||||
cursor: not-allowed;
|
||||
opacity: 0.7;
|
||||
box-shadow: none;
|
||||
transform: none;
|
||||
}
|
||||
|
||||
#cancel-delete-account {
|
||||
background: var(--neutral-700);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#cancel-delete-account:hover {
|
||||
background: var(--neutral-600);
|
||||
}
|
||||
|
||||
#delete-error {
|
||||
color: #e74c3c;
|
||||
font-size: 1rem;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
.nav-bar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0.75rem 2rem;
|
||||
background-color: var(--neutral-900);
|
||||
color: #fff;
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
top: 0;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.nav-brand {
|
||||
flex: 0 0 auto;
|
||||
z-index: 15;
|
||||
}
|
||||
|
||||
.brand-link {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
letter-spacing: 0.5px;
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
.brand-link:hover {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.nav-center {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.nav-links {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
color: rgba(255, 255, 255, 0.85);
|
||||
text-decoration: none;
|
||||
font-size: 1.1rem;
|
||||
padding: 0.6rem 1.2rem;
|
||||
border-radius: 6px;
|
||||
transition: all 0.3s ease;
|
||||
font-weight: 500;
|
||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
|
||||
.nav-link:hover {
|
||||
color: #fff;
|
||||
background-color: rgba(255, 255, 255, 0.1);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
#nav-bar-selected {
|
||||
color: #fff;
|
||||
background-color: rgba(255, 255, 255, 0.15);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.hamburger {
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
width: 30px;
|
||||
height: 21px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
z-index: 15;
|
||||
}
|
||||
|
||||
.hamburger-line {
|
||||
display: block;
|
||||
height: 3px;
|
||||
width: 100%;
|
||||
border-radius: 10px;
|
||||
background: #fff;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
@media (max-width: 800px) {
|
||||
.nav-center {
|
||||
position: static;
|
||||
}
|
||||
|
||||
.nav-links {
|
||||
position: fixed;
|
||||
top: 60px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background-color: var(--neutral-900);
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 0;
|
||||
max-height: 0;
|
||||
overflow: hidden;
|
||||
transition: max-height 0.3s ease-out, padding 0.3s ease;
|
||||
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.nav-links.show {
|
||||
max-height: 300px;
|
||||
padding: 1rem 0;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
width: 90%;
|
||||
text-align: center;
|
||||
padding: 1rem;
|
||||
border-bottom: 1px solid var(--neutral-800);
|
||||
}
|
||||
|
||||
.home-link {
|
||||
border: none;
|
||||
border-bottom: 1px solid var(--neutral-800);
|
||||
order: -1;
|
||||
}
|
||||
|
||||
.nav-link:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.hamburger {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.hamburger.active .hamburger-line:nth-child(1) {
|
||||
transform: translateY(9px) rotate(45deg);
|
||||
}
|
||||
|
||||
.hamburger.active .hamburger-line:nth-child(2) {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.hamburger.active .hamburger-line:nth-child(3) {
|
||||
transform: translateY(-9px) rotate(-45deg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,501 @@
|
||||
#blur[data-decrypted="false"] {
|
||||
-webkit-backdrop-filter: blur(10px);
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
#blur[data-decrypted="true"] {
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
#blur {
|
||||
z-index: 50;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
#notification-container {
|
||||
position: fixed;
|
||||
z-index: 10001;
|
||||
top: 24px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
margin: 0 auto;
|
||||
width: fit-content;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.paste-information {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 10px;
|
||||
border-bottom: 1px solid var(--neutral-700);
|
||||
}
|
||||
|
||||
.paste-information p {
|
||||
margin-left: 2.5px;
|
||||
margin-right: 2.5px;
|
||||
}
|
||||
|
||||
.paste-header {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.main-container {
|
||||
max-height: 80% !important;
|
||||
}
|
||||
|
||||
.paste-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
max-height: 80%;
|
||||
margin-top: 15px;
|
||||
background-color: var(--neutral-800);
|
||||
border-radius: 5px;
|
||||
border: 1px solid var(--neutral-700);
|
||||
}
|
||||
|
||||
#paste-content {
|
||||
padding: 10px;
|
||||
max-width: 100%;
|
||||
max-height: 50vh;
|
||||
overflow-y: scroll;
|
||||
overflow-wrap: break-word;
|
||||
word-wrap: break-word;
|
||||
white-space: pre-wrap;
|
||||
border-radius: 0px;
|
||||
border-bottom-right-radius: 5px;
|
||||
border-bottom-left-radius: 5px;
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
.paste-actions {
|
||||
padding: 10px;
|
||||
width: 100%;
|
||||
border-bottom: 1px solid var(--neutral-700);
|
||||
}
|
||||
|
||||
button {
|
||||
padding: 5px;
|
||||
margin: 5px 0;
|
||||
border-radius: 5px;
|
||||
border: 1px solid var(--neutral-700);
|
||||
background-color: var(--neutral-800);
|
||||
color: var(--neutral-50);
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: var(--neutral-700);
|
||||
border-color: var(--neutral-600);
|
||||
}
|
||||
|
||||
button:active {
|
||||
background-color: var(--neutral-600);
|
||||
border-color: var(--neutral-500);
|
||||
}
|
||||
|
||||
.hljs {
|
||||
padding: 1rem;
|
||||
border-radius: 6px;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.hljs-ln-numbers {
|
||||
border-right: 1px solid var(--neutral-700);
|
||||
padding-right: 8px !important;
|
||||
padding-left: 8px !important;
|
||||
text-align: center;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.hljs-ln-code {
|
||||
padding-left: 16px !important;
|
||||
text-align: left;
|
||||
user-select: text;
|
||||
}
|
||||
|
||||
pre code.hljs {
|
||||
display: block !important;
|
||||
overflow-x: auto;
|
||||
padding: 1em
|
||||
}
|
||||
|
||||
code.hljs {
|
||||
padding: 3px 5px
|
||||
}
|
||||
|
||||
.hljs {
|
||||
color: #c9d1d9;
|
||||
background: #1e1e1e;
|
||||
}
|
||||
|
||||
.hljs-doctag,
|
||||
.hljs-keyword,
|
||||
.hljs-meta .hljs-keyword,
|
||||
.hljs-template-tag,
|
||||
.hljs-template-variable,
|
||||
.hljs-type,
|
||||
.hljs-variable.language_ {
|
||||
color: #ff7b72
|
||||
}
|
||||
|
||||
.hljs-title,
|
||||
.hljs-title.class_,
|
||||
.hljs-title.class_.inherited__,
|
||||
.hljs-title.function_ {
|
||||
color: #d2a8ff
|
||||
}
|
||||
|
||||
.hljs-attr,
|
||||
.hljs-attribute,
|
||||
.hljs-literal,
|
||||
.hljs-meta,
|
||||
.hljs-number,
|
||||
.hljs-operator,
|
||||
.hljs-selector-attr,
|
||||
.hljs-selector-class,
|
||||
.hljs-selector-id,
|
||||
.hljs-variable {
|
||||
color: #79c0ff
|
||||
}
|
||||
|
||||
.hljs-meta .hljs-string,
|
||||
.hljs-regexp,
|
||||
.hljs-string {
|
||||
color: #a5d6ff
|
||||
}
|
||||
|
||||
.hljs-built_in,
|
||||
.hljs-symbol {
|
||||
color: #ffa657
|
||||
}
|
||||
|
||||
.hljs-code,
|
||||
.hljs-comment,
|
||||
.hljs-formula {
|
||||
color: #8b949e
|
||||
}
|
||||
|
||||
.hljs-name,
|
||||
.hljs-quote,
|
||||
.hljs-selector-pseudo,
|
||||
.hljs-selector-tag {
|
||||
color: #7ee787
|
||||
}
|
||||
|
||||
.hljs-subst {
|
||||
color: #c9d1d9
|
||||
}
|
||||
|
||||
.hljs-section {
|
||||
color: #1f6feb;
|
||||
font-weight: 700
|
||||
}
|
||||
|
||||
.hljs-bullet {
|
||||
color: #f2cc60
|
||||
}
|
||||
|
||||
.hljs-emphasis {
|
||||
color: #c9d1d9;
|
||||
font-style: italic
|
||||
}
|
||||
|
||||
.hljs-strong {
|
||||
color: #c9d1d9;
|
||||
font-weight: 700
|
||||
}
|
||||
|
||||
.hljs-addition {
|
||||
color: #aff5b4;
|
||||
background-color: #033a16
|
||||
}
|
||||
|
||||
.hljs-deletion {
|
||||
color: #ffdcd7;
|
||||
background-color: #67060c
|
||||
}
|
||||
|
||||
.throbber {
|
||||
border: 4px solid var(--neutral-700);
|
||||
border-top: 4px solid var(--neutral-50);
|
||||
border-radius: 50%;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
animation: spin 1s linear infinite;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.paste-information-card {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: none;
|
||||
border-radius: 0;
|
||||
box-shadow: none;
|
||||
padding: 0 0 8px 0;
|
||||
margin: 0 0 8px 0;
|
||||
border-bottom: 1px solid var(--neutral-700);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.paste-info-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
font-size: 1rem;
|
||||
color: var(--neutral-100);
|
||||
font-weight: 400;
|
||||
background: none;
|
||||
border-radius: 0;
|
||||
padding: 0 6px;
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.info-icon {
|
||||
font-size: 1em;
|
||||
opacity: 0.7;
|
||||
margin-right: 2px;
|
||||
}
|
||||
|
||||
#author-link {
|
||||
color: var(--neutral-100);
|
||||
text-decoration: underline dotted;
|
||||
font-weight: 400;
|
||||
transition: color 0.2s;
|
||||
}
|
||||
|
||||
#author-link:hover {
|
||||
color: #4ea1f7;
|
||||
}
|
||||
|
||||
.paste-header h1#paste-title {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 600;
|
||||
margin-bottom: 6px;
|
||||
color: var(--neutral-50);
|
||||
letter-spacing: 0.2px;
|
||||
}
|
||||
|
||||
.info-icon {
|
||||
display: inline-block;
|
||||
width: 1.1em;
|
||||
height: 1.1em;
|
||||
margin-right: 4px;
|
||||
vertical-align: middle;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.syntax-icon {
|
||||
background: url('data:image/svg+xml;utf8,<svg fill="none" stroke="%23aaa" stroke-width="2" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M7 7l-4 3 4 3M13 7l4 3-4 3"/></svg>') no-repeat center/1em 1em;
|
||||
}
|
||||
|
||||
.date-icon {
|
||||
background: url('data:image/svg+xml;utf8,<svg fill="none" stroke="%23aaa" stroke-width="2" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><circle cx="10" cy="10" r="8"/><path d="M10 6v4l2 2"/></svg>') no-repeat center/1em 1em;
|
||||
}
|
||||
|
||||
.size-icon {
|
||||
background: url('data:image/svg+xml;utf8,<svg fill="none" stroke="%23aaa" stroke-width="2" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><rect x="4" y="3" width="12" height="14" rx="2"/><path d="M10 7v5m0 0l-2-2m2 2l2-2"/></svg>') no-repeat center/1em 1em;
|
||||
}
|
||||
|
||||
.views-icon {
|
||||
background: url('data:image/svg+xml;utf8,<svg fill="none" stroke="%23aaa" stroke-width="2" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><ellipse cx="10" cy="10" rx="8" ry="5"/><circle cx="10" cy="10" r="2.5"/></svg>') no-repeat center/1em 1em;
|
||||
}
|
||||
|
||||
.author-icon {
|
||||
background: url('data:image/svg+xml;utf8,<svg fill="none" stroke="%23aaa" stroke-width="2" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><circle cx="10" cy="7.5" r="3.5"/><path d="M3 17c0-3.3 3.1-6 7-6s7 2.7 7 6"/></svg>') no-repeat center/1em 1em;
|
||||
}
|
||||
|
||||
.edit-icon {
|
||||
background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="26" height="26" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-edit"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1" /><path d="M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z" /><path d="M16 5l3 3" /></svg>') no-repeat center/1em 1em;
|
||||
}
|
||||
|
||||
#password-modal-bg {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 101;
|
||||
}
|
||||
|
||||
#password-modal {
|
||||
background: var(--neutral-900);
|
||||
padding: 2em 2.5em 1.5em 2.5em;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 4px 32px #000a;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
min-width: 320px;
|
||||
border: 1px solid var(--neutral-800);
|
||||
font-family: inherit;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#password-modal .modal-title {
|
||||
font-weight: bold;
|
||||
font-size: 1.2em;
|
||||
margin-bottom: 0.5em;
|
||||
letter-spacing: 0.5px;
|
||||
color: white
|
||||
}
|
||||
|
||||
#password-modal label {
|
||||
margin-bottom: 1em;
|
||||
color: white;
|
||||
font-size: 1em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#password-modal input[type="password"] {
|
||||
margin-bottom: 1em;
|
||||
padding: 0.7em 1em;
|
||||
width: 100%;
|
||||
border-radius: 6px;
|
||||
border: 1px solid var(--neutral-900);
|
||||
background: var(--neutral-800);
|
||||
color: white;
|
||||
font-size: 1em;
|
||||
outline: none;
|
||||
box-sizing: border-box;
|
||||
transition: border-color 0.2s;
|
||||
}
|
||||
|
||||
#password-modal input[type="password"]:focus {
|
||||
border-color: var(--neutral-700);
|
||||
}
|
||||
|
||||
#password-modal .modal-btn-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
gap: 0.5em;
|
||||
}
|
||||
|
||||
#password-modal button {
|
||||
padding: 0.5em 1.5em;
|
||||
border-radius: 4px;
|
||||
border: none;
|
||||
font-weight: bold;
|
||||
font-size: 1em;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
#password-modal button:first-child {
|
||||
background: var(--neutral-700);
|
||||
border: 1px solid var(--neutral-600);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#password-modal button:first-child:hover {
|
||||
background: var(--neutral-600);
|
||||
border: 1px solid var(--neutral-500);
|
||||
}
|
||||
|
||||
#password-modal button:last-child {
|
||||
background: var(--neutral-700);
|
||||
border: 1px solid var(--neutral-600);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#password-modal button:last-child:hover {
|
||||
background: var(--neutral-600);
|
||||
border: 1px solid var(--neutral-500);
|
||||
}
|
||||
|
||||
.has-true-size-tooltip {
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.true-size-tooltip {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
bottom: 120%;
|
||||
transform: translateX(-50%);
|
||||
background: var(--neutral-900, #23272e);
|
||||
color: var(--neutral-50, #fff);
|
||||
padding: 6px 14px;
|
||||
border-radius: 6px;
|
||||
font-size: 0.95em;
|
||||
white-space: nowrap;
|
||||
box-shadow: 0 2px 8px #0007;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: opacity 0.2s;
|
||||
z-index: 200;
|
||||
border: 1px solid var(--neutral-700, #444);
|
||||
}
|
||||
|
||||
.has-true-size-tooltip:hover .true-size-tooltip {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
|
||||
.main-container {
|
||||
max-height: 100% !important;
|
||||
}
|
||||
|
||||
#password-modal-bg {
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
#password-modal {
|
||||
padding: 1.5em 2em 1em 2em;
|
||||
min-width: auto;
|
||||
}
|
||||
|
||||
#paste-content {
|
||||
word-break: break-all;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.paste-actions {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.paste-actions button {
|
||||
width: 30%;
|
||||
margin: 0;
|
||||
margin-right: 2.5px;
|
||||
margin-left: 2.5px;
|
||||
}
|
||||
|
||||
.paste-information-card {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 4px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
color: white;
|
||||
}
|
||||
|
||||
:root {
|
||||
--neutral-50: #fafafa;
|
||||
--neutral-100: #f5f5f5;
|
||||
--neutral-200: #e5e5e5;
|
||||
--neutral-300: #d4d4d4;
|
||||
--neutral-400: #a3a3a3;
|
||||
--neutral-500: #737373;
|
||||
--neutral-600: #525252;
|
||||
--neutral-700: #404040;
|
||||
--neutral-800: #262626;
|
||||
--neutral-900: #171717;
|
||||
--neutral-950: #0a0a0a;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Roboto', sans-serif;
|
||||
background-color: var(--neutral-950);
|
||||
height: 100vh;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.main-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: var(--neutral-900);
|
||||
padding: 20px;
|
||||
border-radius: 5px;
|
||||
border: 1px solid var(--neutral-800);
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
.create-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.create-form input {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
margin: 5px 0;
|
||||
border-radius: 5px;
|
||||
border: 1px solid var(--neutral-800);
|
||||
background-color: var(--neutral-800);
|
||||
color: var(--neutral-50);
|
||||
transition: border 0.3s;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.create-form input:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.create-form input:hover {
|
||||
border: 1px solid var(--neutral-600);
|
||||
}
|
||||
|
||||
.create-form textarea {
|
||||
width: 100%;
|
||||
min-width: 100%;
|
||||
max-width: 100%;
|
||||
height: 2.5rem;
|
||||
min-height: 2.5rem;
|
||||
font-size: 1rem;
|
||||
max-height: 40%;
|
||||
padding: 10px;
|
||||
margin: 5px 0;
|
||||
border-radius: 5px;
|
||||
border: 1px solid var(--neutral-800);
|
||||
background-color: var(--neutral-800);
|
||||
color: var(--neutral-50);
|
||||
transition: border 0.3s;
|
||||
}
|
||||
|
||||
.create-form textarea:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.create-form textarea:hover {
|
||||
border: 1px solid var(--neutral-600);
|
||||
}
|
||||
|
||||
.create-form button {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
margin: 5px 0;
|
||||
border-radius: 5px;
|
||||
border: 1px solid var(--neutral-800);
|
||||
background-color: var(--neutral-800);
|
||||
color: var(--neutral-50);
|
||||
cursor: pointer;
|
||||
transition: background-color 0.3s;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.create-form button:hover {
|
||||
background-color: var(--neutral-700);
|
||||
}
|
||||
|
||||
select {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
margin: 5px 0;
|
||||
border-radius: 5px;
|
||||
border: 1px solid var(--neutral-800);
|
||||
background-color: var(--neutral-800);
|
||||
color: var(--neutral-50);
|
||||
transition: border 0.3s;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
select:hover {
|
||||
outline: none;
|
||||
border: 1px solid var(--neutral-600);
|
||||
}
|
||||
|
||||
select:focus {
|
||||
outline: none;
|
||||
border: 1px solid var(--neutral-600);
|
||||
}
|
||||
|
||||
#syntax {
|
||||
padding-left: 14rem;
|
||||
}
|
||||
|
||||
#syntax-label {
|
||||
margin-bottom: -2.3rem;
|
||||
margin-top: 1.1rem;
|
||||
z-index: 2;
|
||||
align-self: flex-start;
|
||||
margin-left: 1rem;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 800px) {
|
||||
.main-container {
|
||||
width: 90%;
|
||||
}
|
||||
|
||||
.create-form textarea {
|
||||
max-height: 100%;
|
||||
}
|
||||
|
||||
#syntax-label {
|
||||
margin-bottom: 0.5rem;
|
||||
margin-top: 0.5rem;
|
||||
margin-left: 0;
|
||||
text-align: center;
|
||||
align-self: center;
|
||||
max-width: 12rem;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
/*
|
||||
|
||||
possible style, just not good for small screens on desktop for some reason
|
||||
|
||||
margin-left: 6.7rem;
|
||||
max-width: 12rem;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
margin-bottom: -1.9rem;
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
#syntax {
|
||||
padding-left: 0.7rem;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
body,
|
||||
html {
|
||||
height: 100%;
|
||||
min-height: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.main-container {
|
||||
max-width: 600px;
|
||||
margin: 2.5rem auto;
|
||||
padding: 1.5rem 1.5rem 2.5rem 1.5rem;
|
||||
background-color: var(--neutral-900);
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.user-header {
|
||||
text-align: center;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.user-header h1 {
|
||||
font-size: 2.1rem;
|
||||
font-weight: 700;
|
||||
color: var(--neutral-50);
|
||||
margin: 0 0 0.2rem 0;
|
||||
}
|
||||
|
||||
.user-header p {
|
||||
color: var(--neutral-400);
|
||||
font-size: 1rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.user-pastes-section {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.archive-information {
|
||||
display: grid;
|
||||
grid-template-columns: 2fr 1fr 1fr;
|
||||
gap: 1rem;
|
||||
padding: 0.75rem 1rem;
|
||||
margin-bottom: 1rem;
|
||||
background-color: var(--neutral-800);
|
||||
border-radius: 6px;
|
||||
font-weight: 600;
|
||||
color: var(--neutral-200);
|
||||
border-bottom: 2px solid var(--neutral-700);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.archive-information p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.archive-list {
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
max-height: 70vh;
|
||||
overflow-y: auto;
|
||||
border-radius: 6px;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--neutral-700) var(--neutral-900);
|
||||
}
|
||||
|
||||
.archive-list::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
}
|
||||
|
||||
.archive-list::-webkit-scrollbar-track {
|
||||
background: var(--neutral-900);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.archive-list::-webkit-scrollbar-thumb {
|
||||
background-color: var(--neutral-700);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.archive-list li {
|
||||
margin: 0.75rem 0;
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
.archive-list li:hover {
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.archive-list li a {
|
||||
display: grid;
|
||||
grid-template-columns: 2fr 1fr 1fr;
|
||||
gap: 1rem;
|
||||
padding: 1rem 1.25rem;
|
||||
background-color: var(--neutral-800);
|
||||
color: var(--neutral-50);
|
||||
text-decoration: none;
|
||||
transition: all 0.3s ease;
|
||||
border-radius: 6px;
|
||||
border: 1px solid var(--neutral-700);
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.archive-list li a:hover {
|
||||
background-color: var(--neutral-750);
|
||||
border-color: var(--neutral-600);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.archive-list li a p {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.archive-list li a p:nth-child(2) {
|
||||
padding-left: 1rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.archive-list li a p:nth-child(3) {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#archive-title {
|
||||
font-weight: 500;
|
||||
color: var(--neutral-100);
|
||||
}
|
||||
|
||||
#archive-date {
|
||||
color: var(--neutral-300);
|
||||
font-size: 0.9rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#archive-syntax {
|
||||
color: var(--neutral-300);
|
||||
font-size: 0.9rem;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.user-pastes-throbber {
|
||||
margin: 1.5rem auto;
|
||||
}
|
||||
|
||||
.pastes-actions {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 1.2rem;
|
||||
margin-top: 1.2rem;
|
||||
}
|
||||
|
||||
.pastes-actions button:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.pastes-actions span {
|
||||
color: var(--neutral-300);
|
||||
font-size: 1.1rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.main-container {
|
||||
max-width: 98vw;
|
||||
min-width: 0;
|
||||
padding: 0.5rem;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.archive-list li a p:last-child {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.archive-information,
|
||||
.archive-list li a {
|
||||
grid-template-columns: 3fr 2fr;
|
||||
}
|
||||
|
||||
#archive-syntax {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.archive-information p:last-child {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.main-container {
|
||||
padding: 1rem;
|
||||
margin: 1rem;
|
||||
}
|
||||
|
||||
.user-header h1 {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.archive-list {
|
||||
max-height: 60vh;
|
||||
}
|
||||
}
|
||||
|
||||
#next-button-svg {
|
||||
background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L242.7 256 73.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z"/></svg>');
|
||||
color: white;
|
||||
width: 1.5em;
|
||||
height: 1.5em;
|
||||
background-size: contain;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
filter: invert(100%);
|
||||
}
|
||||
|
||||
#previous-button-svg {
|
||||
background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l192 192c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256l169.3-169.4c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-192 192z"/></svg>');
|
||||
color: white;
|
||||
width: 1.5em;
|
||||
height: 1.5em;
|
||||
background-size: contain;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
filter: invert(100%);
|
||||
}
|
||||
|
||||
.pastes-actions button {
|
||||
padding: 0.4rem 0.8rem;
|
||||
border-radius: 6px;
|
||||
border: 1px solid var(--neutral-700);
|
||||
background-color: var(--neutral-800);
|
||||
color: var(--neutral-50);
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
font-size: 1rem;
|
||||
min-width: 75px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Dashboard - Sharpbin</title>
|
||||
<link rel="preload" href="css/style.css" as="style">
|
||||
<link rel="preload" href="css/dash.css" as="style">
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
<link rel="stylesheet" href="css/dash.css">
|
||||
<link rel="preload" href="js/dash.js" as="script">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Noto+Sans+Mono:wght@100..900&display=swap"
|
||||
rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="main-container">
|
||||
<div class="account-info">
|
||||
<h1 id="account-header">Account Information</h1>
|
||||
<p id="account-username">Username: </p>
|
||||
<p id="account-email">Email: </p>
|
||||
<p id="account-joindate">Joined: </p>
|
||||
<p id="account-lastlogin">Last Login: </p>
|
||||
<p id="account-pastes">Pastes: </p>
|
||||
<button id="logout-button" onclick="logout()">Logout</button>
|
||||
<button id="delete-account-button" onclick="deleteAccount()">Delete Account</button>
|
||||
</div>
|
||||
<div class="paste-list">
|
||||
<h1 id="paste-header">Your Pastes</h1>
|
||||
<div class="paste-information">
|
||||
<p id="paste-title">Title</p>
|
||||
<p id="paste-date">Date</p>
|
||||
<p id="paste-syntax">Syntax</p>
|
||||
</div>
|
||||
<ol class="pastes" id="pastes">
|
||||
|
||||
</ol>
|
||||
<div class="paste-actions">
|
||||
<button id="previous-button" onclick="previousPage()"><</button>
|
||||
<p id="paste-pages">0/0</p>
|
||||
<button id="next-button" onclick="nextPage()">></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script src="js/modal.js"></script>
|
||||
<script src="js/dash.js"></script>
|
||||
<script src="js/main.js"></script>
|
||||
</html>
|
||||
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Error! - Sharpbin</title>
|
||||
<link rel="preload" href="css/style.css" as="style">
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
<link rel="preload" href="js/error.js" as="script">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Noto+Sans+Mono:wght@100..900&display=swap"
|
||||
rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div class="main-container">
|
||||
<h1 id="error-header">Oops! We've ran into an error.</h1>
|
||||
<h3 id="error-message"></p>
|
||||
</div>
|
||||
</body>
|
||||
<script src="js/error.js"></script>
|
||||
<script src="js/main.js"></script>
|
||||
</html>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
@@ -0,0 +1,63 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Sharpbin</title>
|
||||
<link rel="preload" href="css/style.css" as="style">
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
<link rel="preload" href="js/index.js" as="script">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Noto+Sans+Mono:wght@100..900&display=swap"
|
||||
rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="main-container">
|
||||
<form class="create-form" id="create-form">
|
||||
<input type="text" name="title" id="title" placeholder="Title" maxlength="500" autocomplete="off" spellcheck="false">
|
||||
<textarea name="content" id="content" placeholder="Content" autocomplete="off" spellcheck="false"></textarea>
|
||||
<label id="syntax-label">Syntax Highlighting -</label>
|
||||
<select name="syntax" id="syntax">
|
||||
<option value="none">None</option>
|
||||
<option value="AutoHotkey">AutoHotkey</option>
|
||||
<option value="AutoIt">AutoIt</option>
|
||||
<option value="bash">Bash</option>
|
||||
<option value="c">C</option>
|
||||
<option value="cpp">C++</option>
|
||||
<option value="csharp">C#</option>
|
||||
<option value="css">CSS</option>
|
||||
<option value="Dart">Dart</option>
|
||||
<option value="html">HTML</option>
|
||||
<option value="java">Java</option>
|
||||
<option value="javascript">JavaScript</option>
|
||||
<option value="json">JSON</option>
|
||||
<option value="lua">Lua</option>
|
||||
<option value="markdown">Markdown</option>
|
||||
<option value="php">PHP</option>
|
||||
<option value="python">Python</option>
|
||||
<option value="ruby">Ruby</option>
|
||||
<option value="rust">Rust</option>
|
||||
<option value="sql">SQL</option>
|
||||
<option value="swift">Swift</option>
|
||||
<option value="typescript">TypeScript</option>
|
||||
<option value="toml">TOML/Ini</option>
|
||||
<option value="xml">XML</option>
|
||||
</select>
|
||||
<select name="visibility" id="visibility" onchange="changeVisibility()">
|
||||
<option value="0">Public</option>
|
||||
<option value="1">Unlisted</option>
|
||||
<option value="2">Private</option>
|
||||
</select>
|
||||
<input type="password" name="password" id="password" placeholder="Password" style="display: none;" autocomplete="off" spellcheck="false">
|
||||
<button type="submit">Create Paste</button>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
<script src="js/main.js"></script>
|
||||
<script src="js/index.js"></script>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,145 @@
|
||||
let pages = 1;
|
||||
let currentPage = 1;
|
||||
let limit = 25;
|
||||
|
||||
async function renderArchive(page, limit) {
|
||||
const archiveList = document.getElementById("archives");
|
||||
const pagesElement = document.getElementById("paste-pages");
|
||||
const previousButton = document.getElementById("previous-button");
|
||||
const nextButton = document.getElementById("next-button");
|
||||
|
||||
let loadingOverlay = document.getElementById("archive-loading-overlay");
|
||||
if (!loadingOverlay) {
|
||||
loadingOverlay = document.createElement("div");
|
||||
loadingOverlay.id = "archive-loading-overlay";
|
||||
loadingOverlay.innerHTML = '<div class="loading-spinner"><div></div><div></div><div></div></div>';
|
||||
loadingOverlay.style.position = "absolute";
|
||||
loadingOverlay.style.top = 0;
|
||||
loadingOverlay.style.left = 0;
|
||||
loadingOverlay.style.width = "100%";
|
||||
loadingOverlay.style.height = "100%";
|
||||
loadingOverlay.style.display = "flex";
|
||||
loadingOverlay.style.justifyContent = "center";
|
||||
loadingOverlay.style.alignItems = "center";
|
||||
loadingOverlay.style.background = "transparent";
|
||||
loadingOverlay.style.zIndex = 10;
|
||||
archiveList.parentElement.style.position = "relative";
|
||||
archiveList.parentElement.appendChild(loadingOverlay);
|
||||
} else {
|
||||
loadingOverlay.style.display = "flex";
|
||||
}
|
||||
|
||||
try {
|
||||
const archiveData = await getPastes(page, limit);
|
||||
const pastes = archiveData.pastes;
|
||||
pages = archiveData.pages;
|
||||
currentPage = page;
|
||||
|
||||
pagesElement.innerText = `${page}/${pages}`;
|
||||
previousButton.disabled = page <= 1;
|
||||
nextButton.disabled = page >= pages;
|
||||
|
||||
let archiveListHTML = "";
|
||||
if (pastes.length === 0) {
|
||||
archiveListHTML = '<div class="no-pastes">No pastes found</div>';
|
||||
} else {
|
||||
pastes.forEach(paste => {
|
||||
const title = paste.title.length > 30 ? paste.title.substring(0, 30) + '...' : paste.title;
|
||||
archiveListHTML += `
|
||||
<li>
|
||||
<a href="/${paste.id}">
|
||||
<p id="archive-title" title="${paste.title}">${title}</p>
|
||||
<p id="archive-date" title="${formatDate(paste.created)}">${formatDate(paste.created, true)}</p>
|
||||
<p id="archive-syntax">${paste.syntax || 'Plain Text'}</p>
|
||||
</a>
|
||||
</li>
|
||||
`;
|
||||
});
|
||||
}
|
||||
archiveList.innerHTML = archiveListHTML;
|
||||
} catch (error) {
|
||||
console.error('Error fetching pastes:', error);
|
||||
archiveList.innerHTML = '<div class="error-message">Failed to load pastes. Please try again later.</div>';
|
||||
} finally {
|
||||
if (loadingOverlay) loadingOverlay.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
const queries = new URLSearchParams(window.location.search);
|
||||
let page = parseInt(queries.get("page"));
|
||||
limit = parseInt(queries.get("limit"));
|
||||
|
||||
if (isNaN(page) || page < 1) page = 1;
|
||||
if (isNaN(limit) || limit < 1 || limit > 25) limit = 25;
|
||||
|
||||
await renderArchive(page, limit);
|
||||
|
||||
document.getElementById("previous-button").addEventListener("click", previousPage);
|
||||
document.getElementById("next-button").addEventListener("click", nextPage);
|
||||
});
|
||||
|
||||
async function getPastes(page, limit) {
|
||||
const response = await fetch(`/api/pastes/archive?page=${page}&limit=${limit}`);
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! Status: ${response.status}`);
|
||||
}
|
||||
const data = await response.json();
|
||||
return data;
|
||||
}
|
||||
|
||||
function getRelativeTime(date) {
|
||||
const now = new Date();
|
||||
const diff = now - date;
|
||||
const seconds = Math.floor(diff / 1000);
|
||||
const minutes = Math.floor(seconds / 60);
|
||||
const hours = Math.floor(minutes / 60);
|
||||
const days = Math.floor(hours / 24);
|
||||
if (isNaN(date.getTime())) return '';
|
||||
if (seconds < 60) return 'just now';
|
||||
if (minutes < 60) return `${minutes} min ago`;
|
||||
if (hours < 24) return `${hours} hr${hours > 1 ? 's' : ''} ago`;
|
||||
if (days < 7) return `${days} day${days > 1 ? 's' : ''} ago`;
|
||||
return date.toLocaleDateString();
|
||||
}
|
||||
|
||||
|
||||
function formatDate(unix, relative = false) {
|
||||
if (typeof unix !== 'number' || isNaN(unix)) {
|
||||
return 'Invalid date';
|
||||
}
|
||||
const date = new Date(unix * 1000);
|
||||
if (isNaN(date.getTime())) {
|
||||
return 'Invalid date';
|
||||
}
|
||||
if (relative) {
|
||||
return getRelativeTime(date);
|
||||
}
|
||||
return date.toLocaleDateString([], { year: 'numeric', month: '2-digit', day: '2-digit' });
|
||||
}
|
||||
|
||||
function nextPage() {
|
||||
if (currentPage >= pages) return;
|
||||
currentPage++;
|
||||
updateUrlAndRender();
|
||||
}
|
||||
|
||||
function previousPage() {
|
||||
if (currentPage <= 1) return;
|
||||
currentPage--;
|
||||
updateUrlAndRender();
|
||||
}
|
||||
|
||||
function updateUrlAndRender() {
|
||||
const url = `/archive?page=${currentPage}&limit=${limit}`;
|
||||
window.history.pushState({page: currentPage, limit: limit}, '', url);
|
||||
renderArchive(currentPage, limit);
|
||||
}
|
||||
|
||||
window.onpopstate = function(event) {
|
||||
if (event.state) {
|
||||
currentPage = event.state.page;
|
||||
limit = event.state.limit;
|
||||
renderArchive(currentPage, limit);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,268 @@
|
||||
let currentPage = 1;
|
||||
let totalPages = 1;
|
||||
let pastesPerPage = 10;
|
||||
let userPastes = [];
|
||||
|
||||
const userTypes = {
|
||||
"Admin": 255,
|
||||
"User": 0
|
||||
};
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
waitForAuthData().then(data => {
|
||||
if (data.success === false) {
|
||||
window.location.href = '/login';
|
||||
} else {
|
||||
updateAccountInfo(data.user);
|
||||
fetchUserPastes();
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('Error waiting for auth data:', error);
|
||||
window.location.href = '/login';
|
||||
});
|
||||
});
|
||||
|
||||
function waitForAuthData() {
|
||||
return new Promise(resolve => {
|
||||
const interval = setInterval(() => {
|
||||
if (authData) {
|
||||
clearInterval(interval);
|
||||
resolve(authData);
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
|
||||
function updateAccountInfo(data) {
|
||||
document.getElementById('account-username').textContent = `Username: ${data.username}`;
|
||||
document.getElementById('account-email').textContent = `Email: ${data.email || 'Not provided'}`;
|
||||
|
||||
|
||||
if (data.displayname) {
|
||||
const usernameElement = document.getElementById('account-header');
|
||||
usernameElement.textContent = data.displayname;
|
||||
}
|
||||
|
||||
|
||||
const createdDate = new Date(data.created * 1000);
|
||||
const lastLoginDate = new Date(data.lastLogin * 1000);
|
||||
|
||||
document.getElementById('account-joindate').textContent = `Joined: ${formatDate(createdDate)}`;
|
||||
document.getElementById('account-lastlogin').textContent = `Last Login: ${formatDate(lastLoginDate)}`;
|
||||
}
|
||||
|
||||
|
||||
function formatDate(date, minutes = false) {
|
||||
if (isNaN(date.getTime())) {
|
||||
return 'Never';
|
||||
}
|
||||
|
||||
if (minutes)
|
||||
{
|
||||
return date.toLocaleDateString() + ' ' + date.toLocaleTimeString([], { minute: '2-digit', hour: '2-digit' });
|
||||
} else {
|
||||
return date.toLocaleDateString([], { year: 'numeric', month: '2-digit', day: '2-digit' });
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchUserPastes() {
|
||||
try {
|
||||
const response = await fetch('/api/pastes/my?page=1&limit=15');
|
||||
const pastesData = await response.json();
|
||||
|
||||
if (pastesData.message === 'No pastes found.' || pastesData.message === 'Page out of range.') {
|
||||
userPastes = [];
|
||||
document.getElementById('account-pastes').textContent = `Pastes: 0`;
|
||||
totalPages = 0;
|
||||
document.getElementById('paste-pages').textContent = `0/0`;
|
||||
displayPastes();
|
||||
return;
|
||||
}
|
||||
|
||||
userPastes = pastesData.pastes;
|
||||
document.getElementById('account-pastes').textContent = `Pastes: ${userPastes.length}`;
|
||||
totalPages = Math.ceil(userPastes.length / pastesPerPage);
|
||||
document.getElementById('paste-pages').textContent = `${currentPage}/${totalPages || 1}`;
|
||||
displayPastes();
|
||||
} catch (error) {
|
||||
console.error('Error fetching user pastes:', error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function displayPastes() {
|
||||
const pastesList = document.getElementById('pastes');
|
||||
pastesList.innerHTML = '';
|
||||
|
||||
|
||||
const pasteInfoHeader = document.querySelector('.paste-information');
|
||||
const pasteActions = document.querySelector('.paste-actions');
|
||||
const prevButton = document.getElementById('previous-button');
|
||||
const nextButton = document.getElementById('next-button');
|
||||
|
||||
|
||||
if (userPastes.length === 0) {
|
||||
if (pasteInfoHeader) pasteInfoHeader.style.display = 'none';
|
||||
if (pasteActions) pasteActions.style.display = 'none';
|
||||
if (prevButton) prevButton.disabled = true;
|
||||
if (nextButton) nextButton.disabled = true;
|
||||
const noItems = document.createElement('li');
|
||||
noItems.textContent = 'No pastes found';
|
||||
pastesList.appendChild(noItems);
|
||||
return;
|
||||
} else {
|
||||
if (pasteInfoHeader) pasteInfoHeader.style.display = '';
|
||||
if (pasteActions) pasteActions.style.display = '';
|
||||
}
|
||||
|
||||
|
||||
if (prevButton) prevButton.disabled = currentPage <= 1;
|
||||
if (nextButton) nextButton.disabled = currentPage >= totalPages || totalPages <= 1;
|
||||
|
||||
|
||||
const startIndex = (currentPage - 1) * pastesPerPage;
|
||||
const endIndex = Math.min(startIndex + pastesPerPage, userPastes.length);
|
||||
|
||||
|
||||
for (let i = startIndex; i < endIndex; i++) {
|
||||
const paste = userPastes[i];
|
||||
const pasteItem = document.createElement('li');
|
||||
|
||||
|
||||
const pasteLink = document.createElement('a');
|
||||
pasteLink.href = `/${paste.id}`;
|
||||
|
||||
pasteLink.style.display = 'grid';
|
||||
pasteLink.style.gridTemplateColumns = '2fr 1fr 1fr';
|
||||
pasteLink.style.gap = '1rem';
|
||||
|
||||
|
||||
const titleP = document.createElement('p');
|
||||
titleP.id = 'paste-title';
|
||||
titleP.textContent = paste.title || 'Untitled';
|
||||
|
||||
|
||||
const dateP = document.createElement('p');
|
||||
dateP.id = 'paste-date';
|
||||
const createdDate = new Date(paste.created * 1000);
|
||||
dateP.textContent = `${formatDate(createdDate)}`;
|
||||
|
||||
|
||||
const syntaxP = document.createElement('p');
|
||||
syntaxP.id = 'paste-syntax';
|
||||
syntaxP.textContent = paste.syntax || 'plaintext';
|
||||
|
||||
pasteLink.appendChild(titleP);
|
||||
pasteLink.appendChild(dateP);
|
||||
pasteLink.appendChild(syntaxP);
|
||||
pasteItem.appendChild(pasteLink);
|
||||
pastesList.appendChild(pasteItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function previousPage() {
|
||||
if (currentPage > 1) {
|
||||
currentPage--;
|
||||
document.getElementById('paste-pages').textContent = `${currentPage}/${totalPages || 1}`;
|
||||
displayPastes();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function nextPage() {
|
||||
if (currentPage < totalPages) {
|
||||
currentPage++;
|
||||
document.getElementById('paste-pages').textContent = `${currentPage}/${totalPages || 1}`;
|
||||
displayPastes();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function logout() {
|
||||
const confirmed = await Modal.confirm(
|
||||
"Are you sure you want to log out?",
|
||||
"Confirm Logout",
|
||||
"danger"
|
||||
);
|
||||
|
||||
if (confirmed) {
|
||||
try {
|
||||
await fetch('/api/auth/logout', { method: 'POST' });
|
||||
} catch { }
|
||||
window.location.href = '/login';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function deleteAccount() {
|
||||
const username = document.getElementById('account-username').textContent.replace('Username: ', '').trim();
|
||||
const pasteCount = userPastes.length;
|
||||
|
||||
const customContent = document.createElement('div');
|
||||
customContent.innerHTML = `
|
||||
<p style="color: var(--text-color); margin-bottom: 1rem; line-height: 1.6;">
|
||||
This action is <strong>irreversible</strong> and will delete your account and all your ${pasteCount} pastes.
|
||||
</p>
|
||||
<p style="color: var(--text-color); margin-bottom: 1.5rem;">
|
||||
To confirm, type your username <strong>${username}</strong> and your paste count <strong>${pasteCount}</strong>:
|
||||
</p>
|
||||
<div style="margin-bottom: 1rem;">
|
||||
<label class="modal-label">Username:</label>
|
||||
<input type="text" id="delete-username" class="modal-input" placeholder="Username">
|
||||
</div>
|
||||
<div style="margin-bottom: 1.5rem;">
|
||||
<label class="modal-label">Paste count:</label>
|
||||
<input type="number" id="delete-pastecount" class="modal-input" placeholder="Paste count">
|
||||
</div>
|
||||
<div style="display: flex; gap: 0.75rem; justify-content: flex-end;">
|
||||
<button class="btn btn-secondary delete-cancel">Cancel</button>
|
||||
<button class="btn btn-danger delete-confirm" disabled>Delete Account</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
const { body, close } = Modal.custom(customContent, {
|
||||
title: 'Delete Account',
|
||||
className: 'modal-delete-account'
|
||||
});
|
||||
|
||||
const userInput = customContent.querySelector('#delete-username');
|
||||
const countInput = customContent.querySelector('#delete-pastecount');
|
||||
const confirmBtn = customContent.querySelector('.delete-confirm');
|
||||
const cancelBtn = customContent.querySelector('.delete-cancel');
|
||||
|
||||
function validateInputs() {
|
||||
const usernameValid = userInput.value.trim() === username;
|
||||
const countValid = countInput.value.trim() === String(pasteCount);
|
||||
|
||||
if (usernameValid && countValid) {
|
||||
confirmBtn.disabled = false;
|
||||
confirmBtn.style.opacity = '1';
|
||||
} else {
|
||||
confirmBtn.disabled = true;
|
||||
confirmBtn.style.opacity = '0.6';
|
||||
}
|
||||
}
|
||||
|
||||
validateInputs();
|
||||
|
||||
userInput.addEventListener('input', validateInputs);
|
||||
countInput.addEventListener('input', validateInputs);
|
||||
|
||||
cancelBtn.onclick = () => close();
|
||||
|
||||
confirmBtn.onclick = async function () {
|
||||
if (confirmBtn.disabled) return;
|
||||
|
||||
if (userInput.value.trim() !== username || countInput.value.trim() !== String(pasteCount)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await fetch('/api/auth/delete', { method: 'DELETE' });
|
||||
} catch { }
|
||||
window.location.href = '/register';
|
||||
};
|
||||
|
||||
setTimeout(() => userInput.focus(), 100);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
const errors = {
|
||||
"400": "You've made a bad request.",
|
||||
"401": "You are unauthorized to access this page.",
|
||||
"403": "Forbidden! You don't have permission.",
|
||||
"404": "Page not found.",
|
||||
"500": "Internal server error.",
|
||||
};
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
var queries = new URLSearchParams(window.location.search);
|
||||
var error = queries.get("error");
|
||||
var message = queries.get("message");
|
||||
var errorElement = document.getElementById("error-header");
|
||||
var messageElement = document.getElementById("error-message");
|
||||
|
||||
if (error != null) {
|
||||
errorElement.innerText = errors[error];
|
||||
}
|
||||
if (message != null) {
|
||||
messageElement.innerText = message;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,110 @@
|
||||
const siteInfo = [];
|
||||
|
||||
document.addEventListener("DOMContentLoaded", async function () {
|
||||
var visibility = document.getElementById("visibility");
|
||||
visibility.value = "0";
|
||||
getSiteInfo();
|
||||
});
|
||||
|
||||
|
||||
document.getElementById("create-form").addEventListener("submit", async function (event) {
|
||||
event.preventDefault();
|
||||
var title = document.getElementById("title").value;
|
||||
var content = document.getElementById("content").value;
|
||||
|
||||
var visibility = document.getElementById("visibility").value;
|
||||
var password = document.getElementById("password").value;
|
||||
var syntax = document.getElementById("syntax").value;
|
||||
|
||||
if (content.length > siteInfo.maxFileSize) {
|
||||
showNotification("Content exceeds maximum size.", "error");
|
||||
return;
|
||||
}
|
||||
if (content.length === 0) {
|
||||
showNotification("Content cannot be empty.", "error");
|
||||
return;
|
||||
}
|
||||
|
||||
if (visibility === "2" && password !== "" && password.length >= 6) {
|
||||
content = await encryptAES(content, password);
|
||||
}
|
||||
else if (visibility === "2") {
|
||||
showNotification("Password must be at least 6 characters long.", "error");
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(`/api/pastes/create?title=${title}&visibility=${visibility}&syntax=${syntax}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'text/plain'
|
||||
},
|
||||
body: content
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const paste = data.paste;
|
||||
window.location.href = `/${paste.id}`;
|
||||
});
|
||||
});
|
||||
|
||||
function changeVisibility() {
|
||||
var visibility = document.getElementById("visibility").value;
|
||||
var password = document.getElementById("password");
|
||||
if (visibility === "2") {
|
||||
password.style.display = "block";
|
||||
} else {
|
||||
password.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
function getSiteInfo() {
|
||||
fetch("/api/site/info")
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
siteInfo = data.info;
|
||||
var content = document.getElementById("content")
|
||||
content.setAttribute("maxlength", siteInfo.maxFileSize);
|
||||
});
|
||||
}
|
||||
|
||||
async function encryptAES(content, password) {
|
||||
const enc = new TextEncoder();
|
||||
|
||||
const salt = crypto.getRandomValues(new Uint8Array(16));
|
||||
|
||||
const keyMaterial = await window.crypto.subtle.importKey(
|
||||
"raw",
|
||||
enc.encode(password),
|
||||
{ name: "PBKDF2" },
|
||||
false,
|
||||
["deriveKey"]
|
||||
);
|
||||
const key = await window.crypto.subtle.deriveKey(
|
||||
{
|
||||
name: "PBKDF2",
|
||||
salt: salt,
|
||||
iterations: 100000,
|
||||
hash: "SHA-256"
|
||||
},
|
||||
keyMaterial,
|
||||
{ name: "AES-GCM", length: 256 },
|
||||
false,
|
||||
["encrypt"]
|
||||
);
|
||||
const iv = window.crypto.getRandomValues(new Uint8Array(12));
|
||||
const encryptedContent = await window.crypto.subtle.encrypt(
|
||||
{
|
||||
name: "AES-GCM",
|
||||
iv: iv
|
||||
},
|
||||
key,
|
||||
enc.encode(content)
|
||||
);
|
||||
|
||||
const combined = new Uint8Array(salt.length + iv.length + encryptedContent.byteLength);
|
||||
combined.set(salt, 0);
|
||||
combined.set(iv, salt.length);
|
||||
combined.set(new Uint8Array(encryptedContent), salt.length + iv.length);
|
||||
|
||||
return btoa(String.fromCharCode.apply(null, combined));
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const loginForm = document.getElementById('login-form');
|
||||
const errorMessage = document.getElementById('error-message');
|
||||
|
||||
|
||||
checkAuthStatus();
|
||||
|
||||
loginForm.addEventListener('submit', async function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
|
||||
const username = document.getElementById('username').value.trim();
|
||||
const password = document.getElementById('password').value;
|
||||
|
||||
|
||||
if (!username || !password) {
|
||||
showError('Please fill in all required fields');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
const submitButton = loginForm.querySelector('button[type="submit"]');
|
||||
const originalButtonText = submitButton.textContent;
|
||||
submitButton.disabled = true;
|
||||
submitButton.textContent = 'Logging in...';
|
||||
|
||||
|
||||
const isEmail = username.includes('@');
|
||||
const requestData = isEmail
|
||||
? { email: username, password: password }
|
||||
: { username: username, password: password };
|
||||
|
||||
|
||||
const response = await fetch('/api/auth/login', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
|
||||
window.location.href = '/dash';
|
||||
} else {
|
||||
showError(data.message || 'Login failed. Please check your credentials.');
|
||||
submitButton.disabled = false;
|
||||
submitButton.textContent = originalButtonText;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Login error:', error);
|
||||
showError('An unexpected error occurred. Please try again later.');
|
||||
|
||||
const submitButton = loginForm.querySelector('button[type="submit"]');
|
||||
submitButton.disabled = false;
|
||||
submitButton.textContent = 'Login';
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function showError(message) {
|
||||
errorMessage.textContent = message;
|
||||
errorMessage.classList.add('visible');
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
errorMessage.classList.remove('visible');
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
|
||||
async function checkAuthStatus() {
|
||||
try {
|
||||
const response = await fetch('/api/auth/authenticated');
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
|
||||
window.location.href = '/dash';
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
console.log('Not logged in');
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,310 @@
|
||||
const navbarHTML = `
|
||||
<div class="nav-bar">
|
||||
<div class="nav-brand">
|
||||
<a href="/" class="brand-link">Sharpbin</a>
|
||||
</div>
|
||||
<div class="nav-center">
|
||||
<div class="nav-links">
|
||||
<a href="/archive" class="nav-link">Archives</a>
|
||||
<a href="/" class="nav-link home-link">Home</a>
|
||||
<a href="#" class="nav-link">Account</a>
|
||||
</div>
|
||||
</div>
|
||||
<button class="hamburger" onclick="toggleMenu()" aria-label="Toggle menu">
|
||||
<span class="hamburger-line"></span>
|
||||
<span class="hamburger-line"></span>
|
||||
<span class="hamburger-line"></span>
|
||||
</button>
|
||||
<style>
|
||||
.nav-bar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0.75rem 2rem;
|
||||
background-color: var(--neutral-900);
|
||||
color: #fff;
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
top: 0;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.nav-brand {
|
||||
flex: 0 0 auto;
|
||||
z-index: 15;
|
||||
}
|
||||
|
||||
.brand-link {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
letter-spacing: 0.5px;
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
.brand-link:hover {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.nav-center {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.nav-links {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
background-color: #171717;
|
||||
color: rgba(255, 255, 255, 0.85);
|
||||
text-decoration: none;
|
||||
font-size: 1.1rem;
|
||||
padding: 0.6rem 1.2rem;
|
||||
border-radius: 6px;
|
||||
transition: all 0.3s ease;
|
||||
font-weight: 500;
|
||||
text-align: center;
|
||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||
max-width: 125px;
|
||||
width: 125px;
|
||||
}
|
||||
|
||||
.nav-link:hover {
|
||||
color: #fff;
|
||||
background-color: rgba(255, 255, 255, 0.1);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
#nav-bar-selected {
|
||||
color: #fff;
|
||||
background-color: rgba(255, 255, 255, 0.15);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.hamburger {
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
width: 30px;
|
||||
height: 21px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
z-index: 15;
|
||||
}
|
||||
|
||||
.hamburger-line {
|
||||
display: block;
|
||||
height: 3px;
|
||||
width: 100%;
|
||||
border-radius: 10px;
|
||||
background: #fff;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
@media (max-width: 800px) {
|
||||
.nav-center {
|
||||
position: static;
|
||||
}
|
||||
|
||||
.nav-links {
|
||||
position: fixed;
|
||||
top: 55px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background-color: var(--neutral-900);
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 0;
|
||||
max-height: 0;
|
||||
overflow: hidden;
|
||||
transition: max-height 0.3s ease-out, padding 0.3s ease;
|
||||
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.nav-links.show {
|
||||
max-height: 350px;
|
||||
padding: 1rem 0;
|
||||
padding-bottom: 2rem;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
width: 90%;
|
||||
max-width: 90%;
|
||||
text-align: center;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.home-link {
|
||||
order: -1;
|
||||
}
|
||||
|
||||
.hamburger {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.hamburger.active .hamburger-line:nth-child(1) {
|
||||
transform: translateY(9px) rotate(45deg);
|
||||
}
|
||||
|
||||
.hamburger.active .hamburger-line:nth-child(2) {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.hamburger.active .hamburger-line:nth-child(3) {
|
||||
transform: translateY(-9px) rotate(-45deg);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</div>
|
||||
`;
|
||||
|
||||
let authData = null;
|
||||
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
document.body.insertAdjacentHTML('afterbegin', navbarHTML);
|
||||
var path = window.location.pathname;
|
||||
var links = document.querySelectorAll('.nav-link');
|
||||
|
||||
let accountHref = '/login';
|
||||
try {
|
||||
const resp = await fetch('/api/auth/authenticated');
|
||||
const data = await resp.json();
|
||||
authData = data;
|
||||
if (data && data.success !== false) {
|
||||
accountHref = '/dash';
|
||||
}
|
||||
} catch {}
|
||||
|
||||
const accountLink = document.querySelector('.nav-link[href="#"]');
|
||||
if (accountLink) {
|
||||
accountLink.setAttribute('href', accountHref);
|
||||
}
|
||||
|
||||
links.forEach(link => {
|
||||
const href = link.getAttribute('href');
|
||||
if (href === path) {
|
||||
link.id = 'nav-bar-selected';
|
||||
}
|
||||
|
||||
if ((path === '/dash' || path === '/login' || path === '/register') && (href === '/dash' || href === '/login')) {
|
||||
link.id = 'nav-bar-selected';
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
window.toggleMenu = function () {
|
||||
const nav = document.querySelector('.nav-links');
|
||||
const hamburger = document.querySelector('.hamburger');
|
||||
nav.classList.toggle('show');
|
||||
hamburger.classList.toggle('active');
|
||||
};
|
||||
|
||||
function showNotification(message, type = 'info', duration = 3000) {
|
||||
if (!document.getElementById('notification-style')) {
|
||||
const style = document.createElement('style');
|
||||
style.id = 'notification-style';
|
||||
style.textContent = `
|
||||
.notification-container {
|
||||
position: fixed;
|
||||
bottom: 32px;
|
||||
right: 32px;
|
||||
z-index: 1000;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
.notification {
|
||||
min-width: 240px;
|
||||
max-width: 350px;
|
||||
padding: 12px 20px;
|
||||
border-radius: 8px;
|
||||
color: #ef4444;
|
||||
font-size: 1rem;
|
||||
font-weight: 500;
|
||||
box-shadow: 0 6px 24px rgba(0,0,0,0.28);
|
||||
margin-top: 0.5rem;
|
||||
opacity: 0;
|
||||
transform: translateY(20px);
|
||||
animation: notification-in 0.3s forwards;
|
||||
border: 1px solid rgba(220, 38, 38, 0.2);
|
||||
background: rgba(220, 38, 38, 0.1);
|
||||
letter-spacing: 0.01em;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75em;
|
||||
}
|
||||
.notification-info {
|
||||
color: #e5e7eb;
|
||||
background: var(--neutral-900, #181a20);
|
||||
border: 1px solid var(--neutral-800, #23272f);
|
||||
}
|
||||
.notification-warning {
|
||||
color: #f59e42;
|
||||
background: rgba(245, 158, 66, 0.10);
|
||||
border: 1px solid rgba(245, 158, 66, 0.18);
|
||||
}
|
||||
.notification-error {
|
||||
color: #ef4444;
|
||||
background: rgba(220, 38, 38, 0.1);
|
||||
border: 1px solid rgba(220, 38, 38, 0.2);
|
||||
}
|
||||
@keyframes notification-in {
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.notification-container {
|
||||
right: 8px;
|
||||
bottom: 8px;
|
||||
}
|
||||
.notification {
|
||||
min-width: 160px;
|
||||
max-width: 90vw;
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
}
|
||||
`;
|
||||
document.head.appendChild(style);
|
||||
}
|
||||
|
||||
let container = document.querySelector('.notification-container');
|
||||
if (!container) {
|
||||
container = document.createElement('div');
|
||||
container.className = 'notification-container';
|
||||
document.body.appendChild(container);
|
||||
}
|
||||
|
||||
const notif = document.createElement('div');
|
||||
notif.className = `notification notification-${type}`;
|
||||
notif.textContent = message;
|
||||
container.appendChild(notif);
|
||||
|
||||
setTimeout(() => {
|
||||
notif.style.opacity = '0';
|
||||
notif.style.transform = 'translateY(20px)';
|
||||
setTimeout(() => {
|
||||
notif.remove();
|
||||
if (container.childElementCount === 0) {
|
||||
container.remove();
|
||||
}
|
||||
}, 300);
|
||||
}, duration);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,707 @@
|
||||
const Modal = {
|
||||
createModal(options = {}) {
|
||||
const {
|
||||
id = 'modal-' + Date.now(),
|
||||
title = '',
|
||||
className = '',
|
||||
closable = true,
|
||||
backdrop = true,
|
||||
noAnimation = false
|
||||
} = options;
|
||||
|
||||
this.removeModal(id);
|
||||
|
||||
const modalBg = this.createElement('div', {
|
||||
id: id + '-bg',
|
||||
className: `modal-backdrop ${className} ${noAnimation ? 'no-animation' : ''}`,
|
||||
style: backdrop ? '' : 'pointer-events: none;'
|
||||
});
|
||||
|
||||
const modal = this.createElement('div', {
|
||||
className: `modal ${noAnimation ? 'no-animation' : ''}`,
|
||||
style: 'pointer-events: auto;'
|
||||
});
|
||||
|
||||
if (title) {
|
||||
const header = this.createElement('div', {
|
||||
className: 'modal-header',
|
||||
innerHTML: `
|
||||
<h3 class="modal-title">${title}</h3>
|
||||
${closable ? '<button class="modal-close" aria-label="Close">×</button>' : ''}
|
||||
`
|
||||
});
|
||||
modal.appendChild(header);
|
||||
}
|
||||
|
||||
const body = this.createElement('div', { className: 'modal-body' });
|
||||
modal.appendChild(body);
|
||||
|
||||
modalBg.appendChild(modal);
|
||||
document.body.appendChild(modalBg);
|
||||
|
||||
this.addModalStyles();
|
||||
|
||||
const closeModal = () => this.removeModal(id);
|
||||
|
||||
if (closable) {
|
||||
const closeBtn = modal.querySelector('.modal-close');
|
||||
if (closeBtn) closeBtn.onclick = closeModal;
|
||||
|
||||
modal.addEventListener('keydown', e => {
|
||||
if (e.key === 'Escape') closeModal();
|
||||
});
|
||||
|
||||
if (backdrop) {
|
||||
modalBg.addEventListener('click', e => {
|
||||
if (e.target === modalBg) closeModal();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
modal.querySelector('.modal-body').focus = () => {
|
||||
const focusable = modal.querySelector('input, select, textarea, button');
|
||||
if (focusable) focusable.focus();
|
||||
};
|
||||
|
||||
setTimeout(() => modal.querySelector('.modal-body').focus(), 100);
|
||||
|
||||
return {
|
||||
modal,
|
||||
body: modal.querySelector('.modal-body'),
|
||||
close: closeModal,
|
||||
updateContent: (newContent) => {
|
||||
const body = modal.querySelector('.modal-body');
|
||||
if (typeof newContent === 'string') {
|
||||
body.innerHTML = newContent;
|
||||
} else if (newContent instanceof HTMLElement) {
|
||||
body.innerHTML = '';
|
||||
body.appendChild(newContent);
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
const focusable = body.querySelector('input, select, textarea, button');
|
||||
if (focusable) focusable.focus();
|
||||
}, 50);
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
createElement(tag, props = {}) {
|
||||
const element = document.createElement(tag);
|
||||
Object.assign(element, props);
|
||||
return element;
|
||||
},
|
||||
|
||||
removeModal(id) {
|
||||
const existingModal = document.getElementById(id + '-bg');
|
||||
if (existingModal) existingModal.remove();
|
||||
},
|
||||
|
||||
confirm(message, title = 'Confirm', type = 'default') {
|
||||
return new Promise((resolve) => {
|
||||
const { body, close } = this.createModal({ title, className: `modal-confirm modal-confirm-${type}` });
|
||||
|
||||
const confirmButtonClass = type === 'danger' ? 'btn-danger' : 'btn-primary';
|
||||
|
||||
body.innerHTML = `
|
||||
<p class="modal-message">${message}</p>
|
||||
<div class="modal-buttons">
|
||||
<button class="btn btn-secondary modal-cancel">Cancel</button>
|
||||
<button class="btn ${confirmButtonClass} modal-confirm-btn">Confirm</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
const handleResult = (result) => {
|
||||
close();
|
||||
resolve(result);
|
||||
};
|
||||
|
||||
body.querySelector('.modal-cancel').onclick = () => handleResult(false);
|
||||
body.querySelector('.modal-confirm-btn').onclick = () => handleResult(true);
|
||||
|
||||
body.addEventListener('keydown', e => {
|
||||
if (e.key === 'Enter') handleResult(true);
|
||||
else if (e.key === 'Escape') handleResult(false);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
prompt(message, defaultValue = '', title = 'Input', inputType = 'text', options = {}) {
|
||||
return new Promise((resolve) => {
|
||||
const { keepOpen = false } = options;
|
||||
const { body, close, updateContent } = this.createModal({
|
||||
title,
|
||||
className: 'modal-prompt',
|
||||
...options
|
||||
});
|
||||
|
||||
const createPromptContent = (message, defaultValue = '', clearValue = false) => {
|
||||
const inputId = 'modal-input-' + Date.now();
|
||||
return `
|
||||
<label for="${inputId}" class="modal-label">${message}</label>
|
||||
<input type="${inputType}" id="${inputId}" class="modal-input" value="${clearValue ? '' : defaultValue}" autocomplete="off">
|
||||
<div class="modal-buttons">
|
||||
<button class="btn btn-secondary modal-cancel">Cancel</button>
|
||||
<button class="btn btn-primary modal-ok">OK</button>
|
||||
</div>
|
||||
`;
|
||||
};
|
||||
|
||||
body.innerHTML = createPromptContent(message, defaultValue);
|
||||
|
||||
const handleResult = (result) => {
|
||||
if (!keepOpen) {
|
||||
close();
|
||||
}
|
||||
resolve(result);
|
||||
};
|
||||
|
||||
const setupEventListeners = () => {
|
||||
const input = body.querySelector('.modal-input');
|
||||
const cancelBtn = body.querySelector('.modal-cancel');
|
||||
const okBtn = body.querySelector('.modal-ok');
|
||||
|
||||
const newCancelBtn = cancelBtn.cloneNode(true);
|
||||
const newOkBtn = okBtn.cloneNode(true);
|
||||
cancelBtn.parentNode.replaceChild(newCancelBtn, cancelBtn);
|
||||
okBtn.parentNode.replaceChild(newOkBtn, okBtn);
|
||||
|
||||
newCancelBtn.onclick = () => handleResult(null);
|
||||
newOkBtn.onclick = () => handleResult(input.value);
|
||||
|
||||
input.addEventListener('keydown', e => {
|
||||
if (e.key === 'Enter') handleResult(input.value);
|
||||
else if (e.key === 'Escape') handleResult(null);
|
||||
});
|
||||
|
||||
input.focus();
|
||||
input.select();
|
||||
};
|
||||
|
||||
setupEventListeners();
|
||||
|
||||
if (keepOpen) {
|
||||
resolve({
|
||||
value: null,
|
||||
update: (newMessage, clearInput = true) => {
|
||||
return new Promise((updateResolve) => {
|
||||
updateContent(createPromptContent(newMessage, defaultValue, clearInput));
|
||||
|
||||
const handleUpdateResult = (result) => {
|
||||
updateResolve(result);
|
||||
};
|
||||
|
||||
const setupUpdateListeners = () => {
|
||||
const input = body.querySelector('.modal-input');
|
||||
const cancelBtn = body.querySelector('.modal-cancel');
|
||||
const okBtn = body.querySelector('.modal-ok');
|
||||
|
||||
cancelBtn.onclick = () => handleUpdateResult(null);
|
||||
okBtn.onclick = () => handleUpdateResult(input.value);
|
||||
|
||||
input.addEventListener('keydown', e => {
|
||||
if (e.key === 'Enter') handleUpdateResult(input.value);
|
||||
else if (e.key === 'Escape') handleUpdateResult(null);
|
||||
});
|
||||
|
||||
input.focus();
|
||||
input.select();
|
||||
};
|
||||
|
||||
setupUpdateListeners();
|
||||
});
|
||||
},
|
||||
close
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
select(message, options = [], title = 'Select') {
|
||||
return new Promise((resolve) => {
|
||||
const { body, close } = this.createModal({ title, className: 'modal-select' });
|
||||
|
||||
const selectId = 'modal-select-' + Date.now();
|
||||
const optionsHtml = options.map(opt => {
|
||||
const value = typeof opt === 'object' ? opt.value : opt;
|
||||
const label = typeof opt === 'object' ? opt.label : opt;
|
||||
return `<option value="${value}">${label}</option>`;
|
||||
}).join('');
|
||||
|
||||
body.innerHTML = `
|
||||
<label for="${selectId}" class="modal-label">${message}</label>
|
||||
<select id="${selectId}" class="modal-select-input">
|
||||
${optionsHtml}
|
||||
</select>
|
||||
<div class="modal-buttons">
|
||||
<button class="btn btn-secondary modal-cancel">Cancel</button>
|
||||
<button class="btn btn-primary modal-ok">OK</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
const select = body.querySelector('.modal-select-input');
|
||||
const handleResult = (result) => {
|
||||
close();
|
||||
resolve(result);
|
||||
};
|
||||
|
||||
body.querySelector('.modal-cancel').onclick = () => handleResult(null);
|
||||
body.querySelector('.modal-ok').onclick = () => handleResult(select.value);
|
||||
|
||||
select.addEventListener('keydown', e => {
|
||||
if (e.key === 'Enter') handleResult(select.value);
|
||||
else if (e.key === 'Escape') handleResult(null);
|
||||
});
|
||||
|
||||
select.focus();
|
||||
});
|
||||
},
|
||||
|
||||
date(message, defaultDate = '', title = 'Select Date') {
|
||||
return new Promise((resolve) => {
|
||||
const { body, close } = this.createModal({ title, className: 'modal-date' });
|
||||
|
||||
const inputId = 'modal-date-' + Date.now();
|
||||
const dateValue = defaultDate || new Date().toISOString().split('T')[0];
|
||||
|
||||
body.innerHTML = `
|
||||
<label for="${inputId}" class="modal-label">${message}</label>
|
||||
<input type="date" id="${inputId}" class="modal-input" value="${dateValue}">
|
||||
<div class="modal-buttons">
|
||||
<button class="btn btn-secondary modal-cancel">Cancel</button>
|
||||
<button class="btn btn-primary modal-ok">OK</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
const input = body.querySelector('.modal-input');
|
||||
const handleResult = (result) => {
|
||||
close();
|
||||
resolve(result);
|
||||
};
|
||||
|
||||
body.querySelector('.modal-cancel').onclick = () => handleResult(null);
|
||||
body.querySelector('.modal-ok').onclick = () => handleResult(input.value);
|
||||
|
||||
input.addEventListener('keydown', e => {
|
||||
if (e.key === 'Enter') handleResult(input.value);
|
||||
else if (e.key === 'Escape') handleResult(null);
|
||||
});
|
||||
|
||||
input.focus();
|
||||
});
|
||||
},
|
||||
|
||||
form(fields = [], title = 'Form') {
|
||||
return new Promise((resolve) => {
|
||||
const { body, close } = this.createModal({ title, className: 'modal-form' });
|
||||
|
||||
const formHtml = fields.map((field, index) => {
|
||||
const id = `modal-field-${Date.now()}-${index}`;
|
||||
const {
|
||||
type = 'text',
|
||||
label = '',
|
||||
name = `field_${index}`,
|
||||
value = '',
|
||||
required = false,
|
||||
options = []
|
||||
} = field;
|
||||
|
||||
let inputHtml = '';
|
||||
switch (type) {
|
||||
case 'select':
|
||||
const optionsHtml = options.map(opt => {
|
||||
const optValue = typeof opt === 'object' ? opt.value : opt;
|
||||
const optLabel = typeof opt === 'object' ? opt.label : opt;
|
||||
return `<option value="${optValue}" ${optValue === value ? 'selected' : ''}>${optLabel}</option>`;
|
||||
}).join('');
|
||||
inputHtml = `<select id="${id}" name="${name}" class="modal-input" ${required ? 'required' : ''}>${optionsHtml}</select>`;
|
||||
break;
|
||||
case 'textarea':
|
||||
inputHtml = `<textarea id="${id}" name="${name}" class="modal-input" ${required ? 'required' : ''}>${value}</textarea>`;
|
||||
break;
|
||||
case 'checkbox':
|
||||
inputHtml = `<input type="checkbox" id="${id}" name="${name}" class="modal-checkbox" ${value ? 'checked' : ''} ${required ? 'required' : ''}>`;
|
||||
break;
|
||||
default:
|
||||
inputHtml = `<input type="${type}" id="${id}" name="${name}" class="modal-input" value="${value}" ${required ? 'required' : ''}>`;
|
||||
}
|
||||
|
||||
return `
|
||||
<div class="modal-field">
|
||||
<label for="${id}" class="modal-label">${label}${required ? ' *' : ''}</label>
|
||||
${inputHtml}
|
||||
</div>
|
||||
`;
|
||||
}).join('');
|
||||
|
||||
body.innerHTML = `
|
||||
<form class="modal-form-content">
|
||||
${formHtml}
|
||||
<div class="modal-buttons">
|
||||
<button type="button" class="btn btn-secondary modal-cancel">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary modal-submit">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
`;
|
||||
|
||||
const form = body.querySelector('.modal-form-content');
|
||||
const handleResult = (result) => {
|
||||
close();
|
||||
resolve(result);
|
||||
};
|
||||
|
||||
body.querySelector('.modal-cancel').onclick = () => handleResult(null);
|
||||
|
||||
form.addEventListener('submit', e => {
|
||||
e.preventDefault();
|
||||
const formData = new FormData(form);
|
||||
const result = {};
|
||||
|
||||
fields.forEach(field => {
|
||||
const name = field.name || `field_${fields.indexOf(field)}`;
|
||||
if (field.type === 'checkbox') {
|
||||
result[name] = formData.has(name);
|
||||
} else {
|
||||
result[name] = formData.get(name);
|
||||
}
|
||||
});
|
||||
|
||||
handleResult(result);
|
||||
});
|
||||
|
||||
const firstInput = body.querySelector('.modal-input');
|
||||
if (firstInput) firstInput.focus();
|
||||
});
|
||||
},
|
||||
|
||||
alert(message, title = 'Alert', type = 'info') {
|
||||
return new Promise((resolve) => {
|
||||
const { body, close } = this.createModal({ title, className: `modal-alert modal-alert-${type}` });
|
||||
|
||||
const icon = {
|
||||
info: 'ℹ️',
|
||||
warning: '⚠️',
|
||||
error: '❌',
|
||||
success: '✅'
|
||||
}[type] || 'ℹ️';
|
||||
|
||||
body.innerHTML = `
|
||||
<div class="modal-alert-content">
|
||||
<span class="modal-alert-icon">${icon}</span>
|
||||
<p class="modal-message">${message}</p>
|
||||
</div>
|
||||
<div class="modal-buttons">
|
||||
<button class="btn btn-primary modal-ok">OK</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
const handleResult = () => {
|
||||
close();
|
||||
resolve();
|
||||
};
|
||||
|
||||
body.querySelector('.modal-ok').onclick = handleResult;
|
||||
|
||||
body.addEventListener('keydown', e => {
|
||||
if (e.key === 'Enter' || e.key === 'Escape') handleResult();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
custom(content, options = {}) {
|
||||
const { body, close } = this.createModal(options);
|
||||
|
||||
if (typeof content === 'string') {
|
||||
body.innerHTML = content;
|
||||
} else if (content instanceof HTMLElement) {
|
||||
body.appendChild(content);
|
||||
}
|
||||
|
||||
return { body, close };
|
||||
},
|
||||
|
||||
addModalStyles() {
|
||||
if (document.getElementById('modal-styles')) return;
|
||||
|
||||
const style = document.createElement('style');
|
||||
style.id = 'modal-styles';
|
||||
style.textContent = `
|
||||
.modal ::selection {
|
||||
background-color: var(--neutral-600, #525252);
|
||||
color: var(--neutral-100, #f5f5f5);
|
||||
}
|
||||
|
||||
.modal ::-moz-selection {
|
||||
background-color: var(--neutral-600, #525252);
|
||||
color: var(--neutral-100, #f5f5f5);
|
||||
}
|
||||
|
||||
.modal input::selection,
|
||||
.modal textarea::selection,
|
||||
.modal-input::selection,
|
||||
.modal-backdrop input::selection,
|
||||
.modal-backdrop textarea::selection {
|
||||
background-color: #3b82f6;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.modal input::-moz-selection,
|
||||
.modal textarea::-moz-selection,
|
||||
.modal-input::-moz-selection,
|
||||
.modal-backdrop input::-moz-selection,
|
||||
.modal-backdrop textarea::-moz-selection {
|
||||
background-color: #3b82f6;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.modal-backdrop {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 999;
|
||||
animation: modal-fade-in 0.2s ease-out;
|
||||
}
|
||||
|
||||
.modal-backdrop.no-animation {
|
||||
animation: none;
|
||||
}
|
||||
|
||||
.modal {
|
||||
background: var(--neutral-900, #1a1a1a);
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
|
||||
max-width: 500px;
|
||||
width: 90%;
|
||||
max-height: 80vh;
|
||||
overflow-y: auto;
|
||||
border: 1px solid var(--neutral-800, #333);
|
||||
animation: modal-slide-in 0.2s ease-out;
|
||||
}
|
||||
|
||||
.modal.no-animation {
|
||||
animation: none;
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 1.5rem 1.5rem 1rem;
|
||||
border-bottom: 1px solid var(--neutral-800, #333);
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-color, #fff);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.modal-close {
|
||||
background: none;
|
||||
border: none;
|
||||
font-size: 1.5rem;
|
||||
color: var(--text-color-secondary, #aaa);
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 4px;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.modal-close:hover {
|
||||
background: var(--neutral-800, #333);
|
||||
color: var(--text-color, #fff);
|
||||
}
|
||||
|
||||
.modal-body {
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.modal-label {
|
||||
display: block;
|
||||
font-weight: 500;
|
||||
color: var(--text-color, #fff);
|
||||
margin-bottom: 0.75rem;
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
|
||||
.modal-input, .modal-select-input {
|
||||
width: 100%;
|
||||
padding: 0.75rem;
|
||||
border: 1px solid var(--neutral-700, #444);
|
||||
border-radius: 6px;
|
||||
background: var(--neutral-800, #2a2a2a);
|
||||
color: var(--text-color, #fff);
|
||||
font-size: 1rem;
|
||||
transition: border-color 0.2s ease;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.modal-input:focus, .modal-select-input:focus {
|
||||
outline: none;
|
||||
border-color: var(--primary-color, #3b82f6);
|
||||
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
|
||||
}
|
||||
|
||||
textarea.modal-input {
|
||||
resize: vertical;
|
||||
min-height: 100px;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.modal-checkbox {
|
||||
width: auto !important;
|
||||
margin-right: 0.5rem;
|
||||
accent-color: var(--primary-color, #3b82f6);
|
||||
}
|
||||
|
||||
.modal-field {
|
||||
margin-bottom: 1.25rem;
|
||||
}
|
||||
|
||||
.modal-field:last-of-type {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.modal-message {
|
||||
color: var(--text-color, #fff);
|
||||
margin: 0 0 1.5rem 0;
|
||||
line-height: 1.6;
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
|
||||
.modal-buttons {
|
||||
display: flex;
|
||||
gap: 0.75rem;
|
||||
justify-content: flex-end;
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 0.75rem 1.25rem;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
font-size: 0.9rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
min-width: 80px;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: var(--primary-color, #3b82f6);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background: var(--primary-hover, #2563eb);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background: var(--neutral-700, #444);
|
||||
color: var(--text-color, #fff);
|
||||
border: 1px solid var(--neutral-600, #555);
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background: var(--neutral-600, #555);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
background: #dc2626;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-danger:hover {
|
||||
background: #b91c1c;
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.modal-alert-content {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 1rem;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.modal-alert-icon {
|
||||
font-size: 1.5rem;
|
||||
flex-shrink: 0;
|
||||
margin-top: 0.1rem;
|
||||
}
|
||||
|
||||
.modal-confirm-danger .modal-title {
|
||||
color: #fca5a5;
|
||||
}
|
||||
|
||||
.modal-confirm-danger .modal-message {
|
||||
color: #f3f4f6;
|
||||
}
|
||||
|
||||
.modal-alert-error .modal-alert-icon {
|
||||
filter: hue-rotate(0deg);
|
||||
}
|
||||
|
||||
.modal-alert-warning .modal-alert-icon {
|
||||
filter: hue-rotate(45deg);
|
||||
}
|
||||
|
||||
.modal-alert-success .modal-alert-icon {
|
||||
filter: hue-rotate(120deg);
|
||||
}
|
||||
|
||||
@keyframes modal-fade-in {
|
||||
from { opacity: 0; }
|
||||
to { opacity: 1; }
|
||||
}
|
||||
|
||||
@keyframes modal-slide-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(-20px) scale(0.95);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0) scale(1);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.modal {
|
||||
width: 95%;
|
||||
max-height: 90vh;
|
||||
}
|
||||
|
||||
.modal-header, .modal-body {
|
||||
padding-left: 1rem;
|
||||
padding-right: 1rem;
|
||||
}
|
||||
|
||||
.modal-buttons {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.btn {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
`;
|
||||
document.head.appendChild(style);
|
||||
}
|
||||
};
|
||||
|
||||
window.Modal = Modal;
|
||||
@@ -0,0 +1,271 @@
|
||||
const visibility = [{ id: 0, name: "Public" }, { id: 1, name: "Unlisted" }, { id: 2, name: "Private" }];
|
||||
|
||||
let paste = null;
|
||||
|
||||
const ELEMENTS = {
|
||||
get: (id) => document.getElementById(id),
|
||||
create: (tag, props = {}) => {
|
||||
const element = document.createElement(tag);
|
||||
Object.assign(element, props);
|
||||
return element;
|
||||
},
|
||||
setText: (id, text) => ELEMENTS.get(id).innerText = text,
|
||||
setStyle: (id, styles) => Object.assign(ELEMENTS.get(id).style, styles),
|
||||
hide: (id) => ELEMENTS.get(id).style.display = "none",
|
||||
show: (id, display = "inline-block") => ELEMENTS.get(id).style.display = display
|
||||
};
|
||||
|
||||
document.addEventListener("DOMContentLoaded", async function () {
|
||||
const id = window.location.pathname.split("/")[1];
|
||||
const [content, info] = await Promise.all([
|
||||
fetch(`/api/pastes/${id}`).then(response => response.text()),
|
||||
fetch(`/api/pastes/${id}/info`).then(response => response.json())
|
||||
]);
|
||||
|
||||
const blur = ELEMENTS.create("div", { id: "blur" });
|
||||
blur.dataset.decrypted = "false";
|
||||
document.body.appendChild(blur);
|
||||
|
||||
paste = info.paste;
|
||||
const finalContent = paste.visibility === 2 ? await handlePrivatePaste(content) : content;
|
||||
|
||||
if (finalContent) {
|
||||
blur.dataset.decrypted = "true";
|
||||
addContent(finalContent, paste.syntax);
|
||||
}
|
||||
|
||||
document.title = `${paste.title} - Sharpbin`;
|
||||
addInfo(paste);
|
||||
});
|
||||
|
||||
async function handlePrivatePaste(content) {
|
||||
try {
|
||||
const modalController = await Modal.prompt(
|
||||
"Enter the password to view this paste:",
|
||||
"",
|
||||
"Private Paste",
|
||||
"password",
|
||||
{ keepOpen: true }
|
||||
);
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
const password = await modalController.update("Enter the password to view this paste:");
|
||||
|
||||
if (password === null) {
|
||||
modalController.close();
|
||||
return null;
|
||||
}
|
||||
|
||||
const decrypted = await decryptAES(content, password);
|
||||
modalController.close();
|
||||
return decrypted;
|
||||
} catch (error) {
|
||||
showNotification("Incorrect password. Please try again.", "error", 3000);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error in handlePrivatePaste:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function addInfo(paste) {
|
||||
const isAnonymous = paste.username === "Anonymous";
|
||||
|
||||
ELEMENTS.setText("paste-title", paste.title);
|
||||
ELEMENTS.setText("paste-date", convertUnixToLocal(paste.created));
|
||||
ELEMENTS.setText("paste-syntax", paste.syntax);
|
||||
ELEMENTS.setText("paste-size", paste.size === 0 ? "" : formatSize(paste.size));
|
||||
|
||||
setupSizeTooltip(paste);
|
||||
setupAuthorLink(paste, isAnonymous);
|
||||
|
||||
ELEMENTS.setText("paste-views", paste.views);
|
||||
ELEMENTS.hide("info-throbber");
|
||||
|
||||
setupActionButtons(paste);
|
||||
setupDeleteButton(paste);
|
||||
}
|
||||
|
||||
function setupSizeTooltip(paste) {
|
||||
if (paste.size !== paste.trueSize && paste.trueSize) {
|
||||
const sizeElem = ELEMENTS.get("paste-size");
|
||||
sizeElem.classList.add("has-true-size-tooltip");
|
||||
const tooltip = ELEMENTS.create("div", {
|
||||
className: "true-size-tooltip",
|
||||
innerText: `True size: ${formatSize(paste.trueSize)}`
|
||||
});
|
||||
sizeElem.appendChild(tooltip);
|
||||
sizeElem.onmouseenter = () => tooltip.style.opacity = 1;
|
||||
sizeElem.onmouseleave = () => tooltip.style.opacity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
function setupAuthorLink(paste, isAnonymous) {
|
||||
const authorLink = ELEMENTS.get("author-link");
|
||||
ELEMENTS.setText("paste-author", paste.username);
|
||||
|
||||
if (isAnonymous) {
|
||||
Object.assign(authorLink, {
|
||||
innerText: "Anonymous",
|
||||
href: ""
|
||||
});
|
||||
Object.assign(authorLink.style, {
|
||||
pointerEvents: "none",
|
||||
textDecoration: "none"
|
||||
});
|
||||
} else {
|
||||
authorLink.href = `/u/${paste.username}`;
|
||||
}
|
||||
}
|
||||
|
||||
function setupActionButtons(paste) {
|
||||
const actions = [
|
||||
{
|
||||
id: "copy-button",
|
||||
action: () => {
|
||||
const content = ELEMENTS.get("paste-content").innerText;
|
||||
navigator.clipboard.writeText(content);
|
||||
showNotification("Paste copied to clipboard!", "info", 2000);
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "download-button",
|
||||
action: () => downloadPaste(paste.title)
|
||||
},
|
||||
{
|
||||
id: "raw-button",
|
||||
action: () => window.location.href = `/raw/${paste.id}`
|
||||
}
|
||||
];
|
||||
|
||||
actions.forEach(({ id, action }) => {
|
||||
ELEMENTS.get(id).addEventListener("click", action);
|
||||
});
|
||||
}
|
||||
|
||||
function downloadPaste(title) {
|
||||
const content = ELEMENTS.get("paste-content").innerText;
|
||||
const blob = new Blob([content], { type: "text/plain" });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = ELEMENTS.create("a", {
|
||||
href: url,
|
||||
download: `${title}.txt`
|
||||
});
|
||||
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
showNotification("Paste downloaded!", "info", 2000);
|
||||
}
|
||||
|
||||
function setupDeleteButton(paste) {
|
||||
waitForAuthData().then(() => {
|
||||
if (authData.user.uuid === paste.authorUUID || authData.user.type === 255) {
|
||||
ELEMENTS.show("delete-button");
|
||||
ELEMENTS.get("delete-button").addEventListener("click", async () => {
|
||||
const confirmed = await Modal.confirm(
|
||||
"Are you sure you want to delete this paste? This action cannot be undone.",
|
||||
"Delete Paste",
|
||||
"danger"
|
||||
);
|
||||
if (confirmed) {
|
||||
deletePaste(paste.id);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function deletePaste(pasteId) {
|
||||
fetch(`/api/pastes/${pasteId}`, { method: "DELETE" })
|
||||
.then(response => {
|
||||
const message = response.ok ? "Paste deleted!" : "Failed to delete paste.";
|
||||
const type = response.ok ? "info" : "error";
|
||||
showNotification(message, type, 2000);
|
||||
if (response.ok) window.location.href = "/";
|
||||
});
|
||||
}
|
||||
|
||||
function waitForAuthData() {
|
||||
return new Promise((resolve) => {
|
||||
const checkAuth = setInterval(() => {
|
||||
if (authData) {
|
||||
clearInterval(checkAuth);
|
||||
resolve();
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
|
||||
function addContent(content, syntax) {
|
||||
const code = ELEMENTS.create("code", {
|
||||
textContent: content,
|
||||
id: "paste-content"
|
||||
});
|
||||
const pre = ELEMENTS.get("paste-content");
|
||||
|
||||
pre.innerText = "";
|
||||
pre.appendChild(code);
|
||||
pre.removeAttribute("id");
|
||||
|
||||
const isPlaintext = ["plaintext", "none", "", null].includes(syntax);
|
||||
code.classList.add(`language-${isPlaintext ? "none" : syntax}`);
|
||||
|
||||
if (!isPlaintext) {
|
||||
hljs.highlightElement(code);
|
||||
code.style.padding = "0px";
|
||||
}
|
||||
|
||||
hljs.lineNumbersBlock(code);
|
||||
ELEMENTS.hide("content-throbber");
|
||||
}
|
||||
|
||||
async function decryptAES(content, password) {
|
||||
const rawData = atob(content);
|
||||
const rawDataArray = Uint8Array.from(rawData, c => c.charCodeAt(0));
|
||||
const [salt, iv, ciphertext] = [
|
||||
rawDataArray.slice(0, 16),
|
||||
rawDataArray.slice(16, 28),
|
||||
rawDataArray.slice(28)
|
||||
];
|
||||
|
||||
const keyMaterial = await crypto.subtle.importKey(
|
||||
"raw",
|
||||
new TextEncoder().encode(password),
|
||||
{ name: "PBKDF2" },
|
||||
false,
|
||||
["deriveKey"]
|
||||
);
|
||||
|
||||
const key = await crypto.subtle.deriveKey(
|
||||
{
|
||||
name: "PBKDF2",
|
||||
salt,
|
||||
iterations: 100000,
|
||||
hash: "SHA-256"
|
||||
},
|
||||
keyMaterial,
|
||||
{ name: "AES-GCM", length: 256 },
|
||||
false,
|
||||
["decrypt"]
|
||||
);
|
||||
|
||||
const decrypted = await crypto.subtle.decrypt(
|
||||
{ name: "AES-GCM", iv },
|
||||
key,
|
||||
ciphertext
|
||||
);
|
||||
|
||||
return new TextDecoder().decode(decrypted);
|
||||
}
|
||||
|
||||
const convertUnixToLocal = (unix) => new Date(unix * 1000).toLocaleString();
|
||||
|
||||
const formatSize = (bytes) => {
|
||||
if (bytes < 1024) return `${bytes} B`;
|
||||
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(2)} KB`;
|
||||
return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;
|
||||
};
|
||||
@@ -0,0 +1,111 @@
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const registerForm = document.getElementById('register-form');
|
||||
const errorMessage = document.getElementById('error-message');
|
||||
|
||||
|
||||
checkAuthStatus();
|
||||
|
||||
registerForm.addEventListener('submit', async function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
|
||||
const username = document.getElementById('username').value.trim();
|
||||
const email = document.getElementById('email').value.trim();
|
||||
const password = document.getElementById('password').value;
|
||||
const confirmPassword = document.getElementById('confirm-password').value;
|
||||
|
||||
|
||||
if (!username || !password) {
|
||||
showError('Please fill in all required fields');
|
||||
return;
|
||||
}
|
||||
|
||||
if (password !== confirmPassword) {
|
||||
showError('Passwords do not match');
|
||||
return;
|
||||
}
|
||||
|
||||
if (password.length < 6) {
|
||||
showError('Password must be at least 6 characters long');
|
||||
return;
|
||||
}
|
||||
|
||||
if (username.length < 3) {
|
||||
showError('Username must be at least 3 characters long');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
const submitButton = registerForm.querySelector('button[type="submit"]');
|
||||
const originalButtonText = submitButton.textContent;
|
||||
submitButton.disabled = true;
|
||||
submitButton.textContent = 'Creating account...';
|
||||
|
||||
|
||||
const requestData = {
|
||||
username: username,
|
||||
password: password
|
||||
};
|
||||
|
||||
|
||||
if (email) {
|
||||
requestData.email = email;
|
||||
}
|
||||
|
||||
|
||||
const response = await fetch('/api/auth/register', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
|
||||
window.location.href = '/dash';
|
||||
} else {
|
||||
showError(data.message || 'Registration failed. Please try again.');
|
||||
submitButton.disabled = false;
|
||||
submitButton.textContent = originalButtonText;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Registration error:', error);
|
||||
showError('An unexpected error occurred. Please try again later.');
|
||||
|
||||
const submitButton = registerForm.querySelector('button[type="submit"]');
|
||||
submitButton.disabled = false;
|
||||
submitButton.textContent = 'Register';
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function showError(message) {
|
||||
errorMessage.textContent = message;
|
||||
errorMessage.classList.add('visible');
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
errorMessage.classList.remove('visible');
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
|
||||
async function checkAuthStatus() {
|
||||
try {
|
||||
const response = await fetch('/api/auth/authenticated');
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
|
||||
window.location.href = '/dash';
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
console.log('Not logged in');
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,76 @@
|
||||
let currentPage = 0;
|
||||
const PAGE_SIZE = 25;
|
||||
let totalPastes = 0;
|
||||
let lastPage = false;
|
||||
|
||||
async function loadUserPastes(userData, page = 0) {
|
||||
const pastesRes = await fetch(`/api/users/${userData.uuid}/pastes?limit=${PAGE_SIZE}&page=${page}`);
|
||||
const data = await pastesRes.json();
|
||||
let pastes = [];
|
||||
if (pastesRes.ok) {
|
||||
pastes = data.pastes || [];
|
||||
totalPastes = data.total || 0;
|
||||
lastPage = pastes.length < PAGE_SIZE;
|
||||
}
|
||||
const list = document.getElementById("user-pastes-list");
|
||||
list.innerHTML = "";
|
||||
if (!pastes.length) {
|
||||
list.innerHTML = "<p style='color:var(--neutral-400)'>No pastes found.</p>";
|
||||
return;
|
||||
}
|
||||
for (const paste of pastes) {
|
||||
const li = document.createElement("li");
|
||||
const link = document.createElement("a");
|
||||
link.href = `/${paste.id}`;
|
||||
link.innerHTML = `
|
||||
<p>${paste.title}</p>
|
||||
<p>${new Date(paste.created * 1000).toLocaleDateString()}</p>
|
||||
<p>${paste.syntax || "Plaintext"}</p>
|
||||
`;
|
||||
li.appendChild(link);
|
||||
list.appendChild(li);
|
||||
}
|
||||
document.getElementById("paste-pages").innerText = `${page + 1}/${data.pages + 1}`;
|
||||
document.getElementById("next-button").disabled = page === 0;
|
||||
document.getElementById("previous-button").disabled = lastPage;
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", async function () {
|
||||
const username = window.location.pathname.split("/")[2]
|
||||
if (!username) {
|
||||
window.location.href = "/error?code=404&message=User not found";
|
||||
return;
|
||||
}
|
||||
const userInfoRes = await fetch(`/api/users/username/${username}`);
|
||||
if (!userInfoRes.ok) {
|
||||
document.getElementById("user-name").innerText = "User not found";
|
||||
document.getElementById("user-pastes-list").innerHTML = "<p style='color:var(--neutral-400)'>No user data.</p>";
|
||||
return;
|
||||
}
|
||||
const user = await userInfoRes.json();
|
||||
const userData = user.user ? user.user : user;
|
||||
document.title = `${userData.username} - Sharpbin`;
|
||||
document.getElementById("user-name").innerText = userData.username;
|
||||
document.getElementById("user-uuid").innerText = userData.uuid;
|
||||
|
||||
await loadUserPastes(userData, 0);
|
||||
currentPage = 0;
|
||||
document.getElementById("previous-button").onclick = async function () {
|
||||
if (currentPage > 0) {
|
||||
currentPage--;
|
||||
await loadUserPastes(userData, currentPage);
|
||||
}
|
||||
};
|
||||
document.getElementById("next-button").onclick = async function () {
|
||||
if (!lastPage) {
|
||||
currentPage++;
|
||||
await loadUserPastes(userData, currentPage);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
function formatSize(bytes) {
|
||||
if (bytes < 1024) return bytes + ' B';
|
||||
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(2) + ' KB';
|
||||
return (bytes / (1024 * 1024)).toFixed(2) + ' MB';
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Login - Sharpbin</title>
|
||||
<link rel="preload" href="css/style.css" as="style">
|
||||
<link rel="preload" href="css/auth.css" as="style">
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
<link rel="stylesheet" href="css/auth.css">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Noto+Sans+Mono:wght@100..900&display=swap" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="auth-container">
|
||||
<div class="auth-form-container">
|
||||
<h1 class="auth-title">Login to Sharpbin</h1>
|
||||
<div id="error-message" class="error-message"></div>
|
||||
<form id="login-form" class="auth-form">
|
||||
<div class="form-group">
|
||||
<label for="username">Username or Email</label>
|
||||
<input type="text" id="username" name="username" placeholder="Enter your username or email" required autocomplete="off" spellcheck="false">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password">Password</label>
|
||||
<input type="password" id="password" name="password" placeholder="Enter your password" required autocomplete="off" spellcheck="false">
|
||||
</div>
|
||||
<button type="submit" class="auth-button">Login</button>
|
||||
</form> <div class="auth-links">
|
||||
<p>Don't have an account? <a href="register.html">Register</a></p>
|
||||
<p>Forgot your password? <a href="reset-password.html">Reset Password</a></p>
|
||||
<p><a href="/">Back to Home</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="js/login.js"></script>
|
||||
<script src="js/main.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,52 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="preload" href="css/style.css" as="style">
|
||||
<link rel="preload" href="css/paste.css" as="style">
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
<link rel="stylesheet" href="css/paste.css">
|
||||
<link rel="preload" href="js/paste.js" as="script">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Noto+Sans+Mono:wght@100..900&display=swap"
|
||||
rel="stylesheet">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlightjs-line-numbers.js/2.8.0/highlightjs-line-numbers.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="main-container">
|
||||
<div class="paste-header">
|
||||
<div style="display: flex;">
|
||||
<h1 id="paste-title">Title</h1>
|
||||
<span class="edit-icon" id="edit-button" style="width: 32px; height: 32px; display: none;" id="edit-button" title="Edit Paste"></span>
|
||||
</div>
|
||||
<div class="paste-information-card">
|
||||
<div id="info-throbber" class="throbber"></div>
|
||||
<div class="paste-info-item"><span class="info-icon syntax-icon"></span><span id="paste-syntax">Syntax</span></div>
|
||||
<div class="paste-info-item"><span class="info-icon date-icon"></span><span id="paste-date">Date</span></div>
|
||||
<div class="paste-info-item"><span class="info-icon size-icon"></span><span id="paste-size">Size</span></div>
|
||||
<div class="paste-info-item"><span class="info-icon views-icon"></span><span id="paste-views">Views</span></div>
|
||||
<div class="paste-info-item"><span class="info-icon author-icon"></span><a id="author-link" href="#"><span id="paste-author">Author</span></a></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paste-content">
|
||||
<div class="paste-actions">
|
||||
<button id="copy-button">Copy</button>
|
||||
<button id="download-button">Download</button>
|
||||
<button id="raw-button">Raw</button>
|
||||
<button id="delete-button" style="display: none;">Delete</button>
|
||||
</div>
|
||||
<div id="content-throbber" class="throbber"></div>
|
||||
<pre id="paste-content">Loading...</pre>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script src="js/modal.js"></script>
|
||||
<script src="js/paste.js"></script>
|
||||
<script src="js/main.js"></script>
|
||||
</html>
|
||||
@@ -0,0 +1,52 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Register - Sharpbin</title>
|
||||
<link rel="preload" href="css/style.css" as="style">
|
||||
<link rel="preload" href="css/auth.css" as="style">
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
<link rel="stylesheet" href="css/auth.css">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Noto+Sans+Mono:wght@100..900&display=swap" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="auth-container">
|
||||
<div class="auth-form-container">
|
||||
<h1 class="auth-title">Create an Account</h1>
|
||||
<div id="error-message" class="error-message"></div>
|
||||
<form id="register-form" class="auth-form">
|
||||
<div class="form-group">
|
||||
<label for="username">Username</label>
|
||||
<input type="text" id="username" name="username" placeholder="Choose a username" required autocomplete="off" spellcheck="false">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">Email (optional)</label>
|
||||
<input type="email" id="email" name="email" placeholder="Enter your email" autocomplete="off" spellcheck="false">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password">Password</label>
|
||||
<input type="password" id="password" name="password" placeholder="Create a password" required autocomplete="off" spellcheck="false">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="confirm-password">Confirm Password</label>
|
||||
<input type="password" id="confirm-password" name="confirm-password" placeholder="Confirm your password" required autocomplete="off" spellcheck="false">
|
||||
</div>
|
||||
<button type="submit" class="auth-button">Register</button>
|
||||
</form>
|
||||
<div class="auth-links">
|
||||
<p>Already have an account? <a href="login.html">Login</a></p>
|
||||
<p><a href="/">Back to Home</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="js/register.js"></script>
|
||||
<script src="js/main.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,46 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Loading - Sharpbin</title>
|
||||
<link rel="preload" href="/css/style.css" as="style">
|
||||
<link rel="preload" href="/css/user.css" as="style">
|
||||
<link rel="stylesheet" href="/css/style.css">
|
||||
<link rel="stylesheet" href="/css/user.css">
|
||||
<link rel="preload" href="/js/user.js" as="script">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Noto+Sans+Mono:wght@100..900&display=swap"
|
||||
rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="main-container">
|
||||
<div class="user-header">
|
||||
<h1 id="user-name">Loading...</h1>
|
||||
<p id="user-uuid"></p>
|
||||
</div>
|
||||
<div class="user-pastes-section">
|
||||
<div class="archive-information">
|
||||
<p id="archive-title">Title</p>
|
||||
<p id="archive-date">Date</p>
|
||||
<p id="archive-syntax">Syntax</p>
|
||||
</div>
|
||||
<ul id="user-pastes-list" class="archive-list">
|
||||
<div class="user-pastes-throbber throbber"></div>
|
||||
</ul>
|
||||
<div class="pastes-actions">
|
||||
<button id="previous-button"><span id="previous-button-svg"></span></button>
|
||||
<p id="paste-pages">0/0</p>
|
||||
<button id="next-button"><span id="next-button-svg"></span></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script src="/js/user.js"></script>
|
||||
<script src="/js/main.js"></script>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.10.35122.118
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpbinV2.Server", "SharpbinV2.Server\SharpbinV2.Server.csproj", "{AEEAD9CC-3EB9-4576-98D0-51C04F1B8D21}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{AEEAD9CC-3EB9-4576-98D0-51C04F1B8D21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AEEAD9CC-3EB9-4576-98D0-51C04F1B8D21}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AEEAD9CC-3EB9-4576-98D0-51C04F1B8D21}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AEEAD9CC-3EB9-4576-98D0-51C04F1B8D21}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {481923D9-3518-41F9-9878-65AC793960AB}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
Reference in New Issue
Block a user