From df7bb7d356f6364b88b45723b49fadade92dc4c3 Mon Sep 17 00:00:00 2001 From: Slendy Date: Sun, 30 Jan 2022 21:25:53 -0600 Subject: [PATCH 1/4] Added basic search functionality and fixed some bugs --- .../Controllers/ResourcesController.cs | 5 +++++ ProjectLighthouse/Helpers/WebhookHelper.cs | 2 +- ProjectLighthouse/Pages/LoginForm.cshtml | 9 +++++---- ProjectLighthouse/Pages/PhotosPage.cshtml | 12 ++++++++++-- ProjectLighthouse/Pages/PhotosPage.cshtml.cs | 15 ++++++++++----- ProjectLighthouse/Pages/RegisterForm.cshtml | 17 ++++++++++------- ProjectLighthouse/Pages/SlotsPage.cshtml | 12 ++++++++++-- ProjectLighthouse/Pages/SlotsPage.cshtml.cs | 16 +++++++++++----- ProjectLighthouse/Pages/UsersPage.cshtml | 12 ++++++++++-- ProjectLighthouse/Pages/UsersPage.cshtml.cs | 15 +++++++++------ 10 files changed, 81 insertions(+), 34 deletions(-) diff --git a/ProjectLighthouse/Controllers/ResourcesController.cs b/ProjectLighthouse/Controllers/ResourcesController.cs index f9ff9346..47e7f26d 100644 --- a/ProjectLighthouse/Controllers/ResourcesController.cs +++ b/ProjectLighthouse/Controllers/ResourcesController.cs @@ -1,4 +1,5 @@ #nullable enable +using System; using System.IO; using System.Linq; using System.Threading.Tasks; @@ -56,6 +57,10 @@ public class ResourcesController : ControllerBase { string path = $"png/{hash}.png"; + if (!IOFile.Exists("png")) + { + FileHelper.EnsureDirectoryCreated(Path.Combine(Environment.CurrentDirectory, "png")); + } if (IOFile.Exists(path)) { return this.File(IOFile.OpenRead(path), "image/png"); diff --git a/ProjectLighthouse/Helpers/WebhookHelper.cs b/ProjectLighthouse/Helpers/WebhookHelper.cs index c624fc45..9d0ea1c2 100644 --- a/ProjectLighthouse/Helpers/WebhookHelper.cs +++ b/ProjectLighthouse/Helpers/WebhookHelper.cs @@ -7,7 +7,7 @@ namespace LBPUnion.ProjectLighthouse.Helpers; public static class WebhookHelper { - private static readonly DiscordWebhookClient client = new(ServerSettings.Instance.DiscordWebhookUrl); + private static readonly DiscordWebhookClient client = (ServerSettings.Instance.DiscordWebhookEnabled ? new DiscordWebhookClient(ServerSettings.Instance.DiscordWebhookUrl) : null); public static readonly Color UnionColor = new(0, 140, 255); public static Task SendWebhook(EmbedBuilder builder) => SendWebhook(builder.Build()); diff --git a/ProjectLighthouse/Pages/LoginForm.cshtml b/ProjectLighthouse/Pages/LoginForm.cshtml index ede86b66..b04b21bc 100644 --- a/ProjectLighthouse/Pages/LoginForm.cshtml +++ b/ProjectLighthouse/Pages/LoginForm.cshtml @@ -11,9 +11,9 @@