From 1382fb9f0776e2c6bff4423756aef9a3372fd6af Mon Sep 17 00:00:00 2001
From: whoswhip <124531971+whoswhip@users.noreply.github.com>
Date: Mon, 19 May 2025 02:11:24 -0400
Subject: [PATCH] Refactor navbar implementation: replace navbar.js with
main.js, update HTML references, and enhance button styles. Add author
username to paste retrieval response and implement clipboard notification
feature.
### Copilot Generated Commit Message
---
SharpbinV2.Server/Program.cs | 25 +++-
SharpbinV2.Server/wwwroot/archive.html | 2 +-
SharpbinV2.Server/wwwroot/css/paste.css | 12 +-
SharpbinV2.Server/wwwroot/css/style.css | 48 +++++++-
SharpbinV2.Server/wwwroot/dash.html | 2 +-
SharpbinV2.Server/wwwroot/error.html | 2 +-
SharpbinV2.Server/wwwroot/index.html | 4 +-
.../wwwroot/js/{navbar.js => main.js} | 110 ++++++++++++++++--
SharpbinV2.Server/wwwroot/js/paste.js | 1 +
SharpbinV2.Server/wwwroot/login.html | 2 +-
SharpbinV2.Server/wwwroot/paste.html | 2 +-
SharpbinV2.Server/wwwroot/register.html | 2 +-
12 files changed, 189 insertions(+), 23 deletions(-)
rename SharpbinV2.Server/wwwroot/js/{navbar.js => main.js} (67%)
diff --git a/SharpbinV2.Server/Program.cs b/SharpbinV2.Server/Program.cs
index c0a6437..e45115c 100644
--- a/SharpbinV2.Server/Program.cs
+++ b/SharpbinV2.Server/Program.cs
@@ -843,6 +843,7 @@ namespace SharpbinV2.Server
return;
}
var paste = await Database.GetPasteFromID(pasteid);
+ string authorUsername = null;
if (paste == null)
{
context.Response.StatusCode = 400;
@@ -852,15 +853,33 @@ namespace SharpbinV2.Server
if (paste.AuthorUUID != "0")
{
var user = await Database.UserFromUUID(paste.AuthorUUID);
- paste.AuthorUUID = user.Username;
+ authorUsername = user?.Username;
}
else
{
paste.AuthorUUID = "Anonymous";
+ authorUsername = "Anonymous";
}
- paste.FilePath = null;
context.Response.StatusCode = 200;
- await context.Response.WriteAsJsonAsync(new { success = true, paste = paste });
+ await context.Response.WriteAsJsonAsync(new
+ {
+ success = true,
+ paste = new
+ {
+ paste.UUID,
+ paste.ID,
+ paste.Visibility,
+ paste.Title,
+ paste.AuthorUUID,
+ username = authorUsername,
+ paste.Created,
+ paste.Edited,
+ paste.Size,
+ paste.TrueSize,
+ paste.Views,
+ paste.Syntax
+ }
+ });
});
app.MapGet("/api/pastes/{pasteid}", async (HttpContext context) =>
{
diff --git a/SharpbinV2.Server/wwwroot/archive.html b/SharpbinV2.Server/wwwroot/archive.html
index 07d31f9..2fd5611 100644
--- a/SharpbinV2.Server/wwwroot/archive.html
+++ b/SharpbinV2.Server/wwwroot/archive.html
@@ -33,6 +33,6 @@
-
+