From 3e8344c8f3b64770daa68aab72c002859e84e1d3 Mon Sep 17 00:00:00 2001 From: jvyden Date: Fri, 19 Aug 2022 21:15:41 -0400 Subject: [PATCH] Refresh the website's UI Squashed commit of the following: commit 47d268cc29560e72b5102eabc80d1f5743c103bb Author: jvyden Date: Fri Aug 19 21:14:09 2022 -0400 Make profile pictures square commit a5ae8a53918708fea215a5676beea2116078bd34 Merge: f5d8a9e f06fcc4 Author: jvyden Date: Fri Aug 19 18:43:26 2022 -0400 Merge branch 'main' into ui-refresh commit f5d8a9e5ed2d9aaafd63d113a5b064d042f7ba48 Merge: fbf1695 2ad9804 Author: jvyden Date: Fri Aug 19 17:03:33 2022 -0400 Merge branch 'main' into ui-refresh commit fbf16953893b2e294df21a0c60e561dbb409aa92 Author: jvyden Date: Fri Aug 19 17:02:32 2022 -0400 Fix test failures commit 70cb5513cb8bae9d85b2b04bc9a3fb194f0a66a5 Author: jvyden Date: Fri Aug 19 16:56:43 2022 -0400 Improve 404 logic commit b2743c4c8af736d2501c7bdd47cce19a6a01902d Author: jvyden Date: Fri Aug 19 16:44:36 2022 -0400 Add 404 page commit 3d0926d3c99d347617e5147ac632d8ec6bab18f9 Author: jvyden Date: Fri Aug 19 16:27:03 2022 -0400 Update icons for slots and team picks commit c61405d83d71d9e67ab4c2775f76b3f7d6c2e827 Author: jvyden Date: Fri Aug 19 16:12:45 2022 -0400 Add background color, put content on segment commit f7d9ee6a0accc9d664f8d2aefabcce4eb8789cd6 Author: jvyden Date: Fri Aug 19 15:53:58 2022 -0400 Add colors to mod/admin panel buttons, update fomantic commit e680c5e6eb14f22792dc62bda029072d3f11f423 Author: jvyden Date: Fri Aug 19 03:20:16 2022 -0400 Fix landing page title commit c779aa4b417af623aa47db0ce9875f49a9ee5c4b Author: jvyden Date: Fri Aug 19 03:13:32 2022 -0400 Remove useless css commit 57f6387c1214b319fe3e0b14df32a7bbecf51548 Author: jvyden Date: Fri Aug 19 03:11:45 2022 -0400 Add hover effect to logo commit 15746911f92037abec115a83fa625ef0fda39e3a Author: jvyden Date: Fri Aug 19 02:39:04 2022 -0400 Change currently_online string to english better commit b98a90f1e9f0b3af7e65104cdd0acbc74c6a244e Author: jvyden Date: Fri Aug 19 02:33:41 2022 -0400 Run GameApiTests sequentially, fix web tests commit 630c08d3b80b74be11b0648b24011f89de705130 Author: jvyden Date: Fri Aug 19 02:20:01 2022 -0400 Add user links to comments commit a91f136c87bc973300c74d6f97696cd7cbf1046a Author: jvyden Date: Fri Aug 19 02:14:22 2022 -0400 Add ability for photos to have user links commit d9e2a58e37dafe842b0b10b463cde1a2cb962052 Author: jvyden Date: Fri Aug 19 01:33:21 2022 -0400 Add ability to link to users and include their profile picture commit 200196ce1f58638da7da368025ec0a88cacc14b6 Author: jvyden Date: Fri Aug 19 01:33:07 2022 -0400 Rename "users" to "people" in Landing Page commit 07d229821099c069979a21bbd529b549c6f4e6b6 Author: jvyden Date: Fri Aug 19 00:59:17 2022 -0400 Fix bug with name on mobile commit aecad7aeb69b63c0e517e85fba0c4de292d202f4 Author: jvyden Date: Fri Aug 19 00:44:56 2022 -0400 Make gap between header and title 17px commit 46fa79b84e46b7ae90232724d82f7bd9e1a74f17 Author: jvyden Date: Fri Aug 19 00:40:00 2022 -0400 Fix user card stats oddity commit 3b4c19f5b7e0199baeb88e27c918fbb17b5f777a Author: jvyden Date: Fri Aug 19 00:24:38 2022 -0400 Mobile improvements, make avatars rounded commit cf9533410042cabf456be0cba34ac5d80ef86046 Author: jvyden Date: Fri Aug 19 00:02:01 2022 -0400 Redesign header commit f24aec0367d8375f3eaea94ea3579d86256c94be Author: jvyden Date: Thu Aug 18 23:36:42 2022 -0400 Fix runtime compilation not working commit 3147e12865feecf792a46088711691160c76b0c6 Author: jvyden Date: Thu Aug 18 22:43:21 2022 -0400 Add support for custom fomantic theme --- Documentation/Theming.md | 7 + .../BaseLayout.resx | 2 +- .../LandingPage.resx | 2 +- .../Extensions/PartialExtensions.cs | 35 + .../Middlewares/HandlePageErrorMiddleware.cs | 27 + .../Pages/Admin/AdminPanelPage.cshtml | 4 +- .../Pages/Errors/NotFoundPage.cshtml | 11 + .../Pages/Errors/NotFoundPage.cshtml.cs | 15 + .../Pages/LandingPage.cshtml | 34 +- .../Pages/LandingPage.cshtml.cs | 4 - .../Pages/Layouts/BaseLayout.cshtml | 75 +- .../Pages/Layouts/BaseLayout.cshtml.cs | 5 +- .../Pages/Moderation/ModPanelPage.cshtml | 2 +- .../Pages/Partials/CommentsPartial.cshtml | 9 +- .../Partials/Links/UserLinkPartial.cshtml | 11 + .../Pages/Partials/PhotoPartial.cshtml | 28 +- .../Pages/Partials/SlotCardPartial.cshtml | 14 +- .../Pages/Partials/UserCardPartial.cshtml | 4 +- .../Pages/PasswordResetRequiredPage.cshtml | 2 + .../Pages/PhotosPage.cshtml | 5 +- .../Pages/SlotPage.cshtml | 36 +- .../Pages/SlotsPage.cshtml | 3 +- .../Pages/UserPage.cshtml | 38 +- ...se.Servers.Website.csproj.DotSettings.user | 3 + .../Startup/WebsiteStartup.cs | 2 + .../Tests/AdminTests.cs | 6 +- .../Tests/AuthenticationTests.cs | 2 +- .../SetUserPermissionLevelCommands.cs | 77 - .../FakeRemoteIPAddressMiddleware.cs | 6 +- ProjectLighthouse/Middlewares/Middleware.cs | 7 +- .../Middlewares/RequestLogMiddleware.cs | 14 +- ProjectLighthouse/PlayerData/Photo.cs | 4 +- .../StaticFiles/css/semantic.min.css | 11 + ProjectLighthouse/StaticFiles/css/styles.css | 50 + .../default/assets/fonts/brand-icons.eot | Bin 0 -> 133034 bytes .../default/assets/fonts/brand-icons.svg | 3570 ++++++++++++ .../default/assets/fonts/brand-icons.ttf | Bin 0 -> 132728 bytes .../default/assets/fonts/brand-icons.woff | Bin 0 -> 89824 bytes .../default/assets/fonts/brand-icons.woff2 | Bin 0 -> 76612 bytes .../css/themes/default/assets/fonts/icons.eot | Bin 0 -> 202902 bytes .../css/themes/default/assets/fonts/icons.svg | 4938 +++++++++++++++++ .../css/themes/default/assets/fonts/icons.ttf | Bin 0 -> 202616 bytes .../themes/default/assets/fonts/icons.woff | Bin 0 -> 103300 bytes .../themes/default/assets/fonts/icons.woff2 | Bin 0 -> 79444 bytes .../default/assets/fonts/outline-icons.eot | Bin 0 -> 34390 bytes .../default/assets/fonts/outline-icons.svg | 803 +++ .../default/assets/fonts/outline-icons.ttf | Bin 0 -> 34092 bytes .../default/assets/fonts/outline-icons.woff | Bin 0 -> 16800 bytes .../default/assets/fonts/outline-icons.woff2 | Bin 0 -> 13584 bytes .../themes/default/assets/images/flags.png | Bin 0 -> 28123 bytes ProjectLighthouse/StaticFiles/logo-color.png | Bin 0 -> 147263 bytes ProjectLighthouse/StaticFiles/logo-mono.png | Bin 0 -> 150414 bytes ProjectLighthouse/StaticFiles/logo.svg | 1 + ProjectLighthouse/Types/PageNavigationItem.cs | 4 +- 54 files changed, 9695 insertions(+), 176 deletions(-) create mode 100644 Documentation/Theming.md create mode 100644 ProjectLighthouse.Servers.Website/Extensions/PartialExtensions.cs create mode 100644 ProjectLighthouse.Servers.Website/Middlewares/HandlePageErrorMiddleware.cs create mode 100644 ProjectLighthouse.Servers.Website/Pages/Errors/NotFoundPage.cshtml create mode 100644 ProjectLighthouse.Servers.Website/Pages/Errors/NotFoundPage.cshtml.cs create mode 100644 ProjectLighthouse.Servers.Website/Pages/Partials/Links/UserLinkPartial.cshtml create mode 100644 ProjectLighthouse.Servers.Website/ProjectLighthouse.Servers.Website.csproj.DotSettings.user delete mode 100644 ProjectLighthouse/Administration/Maintenance/SetUserPermissionLevelCommands.cs create mode 100644 ProjectLighthouse/StaticFiles/css/semantic.min.css create mode 100644 ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/brand-icons.eot create mode 100644 ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/brand-icons.svg create mode 100644 ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/brand-icons.ttf create mode 100644 ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/brand-icons.woff create mode 100644 ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/brand-icons.woff2 create mode 100644 ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/icons.eot create mode 100644 ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/icons.svg create mode 100644 ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/icons.ttf create mode 100644 ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/icons.woff create mode 100644 ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/icons.woff2 create mode 100644 ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/outline-icons.eot create mode 100644 ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/outline-icons.svg create mode 100644 ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/outline-icons.ttf create mode 100644 ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/outline-icons.woff create mode 100644 ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/outline-icons.woff2 create mode 100644 ProjectLighthouse/StaticFiles/css/themes/default/assets/images/flags.png create mode 100644 ProjectLighthouse/StaticFiles/logo-color.png create mode 100644 ProjectLighthouse/StaticFiles/logo-mono.png create mode 100644 ProjectLighthouse/StaticFiles/logo.svg diff --git a/Documentation/Theming.md b/Documentation/Theming.md new file mode 100644 index 00000000..10f64b0a --- /dev/null +++ b/Documentation/Theming.md @@ -0,0 +1,7 @@ +# Theming + +Theming in Project Lighthouse is done under [Fomantic UI](https://fomantic-ui.com). + +We use a custom theme for Lighthouse. This can be accessed [here](https://github.com/LBPUnion/LighthouseFomantic). + +Further instructions and documentation are included inside this repository, and Fomantic UI's documentation. diff --git a/ProjectLighthouse.Localization/BaseLayout.resx b/ProjectLighthouse.Localization/BaseLayout.resx index 6ba09a5c..f2b8515d 100644 --- a/ProjectLighthouse.Localization/BaseLayout.resx +++ b/ProjectLighthouse.Localization/BaseLayout.resx @@ -58,7 +58,7 @@ A quick shortcut on the header to take you to your profile if logged in. - Admin Panel + Admin A header link that takes you to the admin panel if available. diff --git a/ProjectLighthouse.Localization/LandingPage.resx b/ProjectLighthouse.Localization/LandingPage.resx index 698b66b7..2979c630 100644 --- a/ProjectLighthouse.Localization/LandingPage.resx +++ b/ProjectLighthouse.Localization/LandingPage.resx @@ -30,7 +30,7 @@ - You are currently logged in as {0}. + Greetings, {0}. A greeting on the main page of the website. diff --git a/ProjectLighthouse.Servers.Website/Extensions/PartialExtensions.cs b/ProjectLighthouse.Servers.Website/Extensions/PartialExtensions.cs new file mode 100644 index 00000000..78306838 --- /dev/null +++ b/ProjectLighthouse.Servers.Website/Extensions/PartialExtensions.cs @@ -0,0 +1,35 @@ +using LBPUnion.ProjectLighthouse.Levels; +using LBPUnion.ProjectLighthouse.PlayerData; +using LBPUnion.ProjectLighthouse.PlayerData.Profiles; +using Microsoft.AspNetCore.Html; +using Microsoft.AspNetCore.Mvc.Rendering; +using Microsoft.AspNetCore.Mvc.ViewFeatures; + +namespace LBPUnion.ProjectLighthouse.Servers.Website.Extensions; + +public static class PartialExtensions +{ + // ReSharper disable once SuggestBaseTypeForParameter + public static ViewDataDictionary WithLang(this ViewDataDictionary viewData, string language) + { + try + { + return new(viewData) + { + { + "Language", language + }, + }; + } + catch + { + return viewData; + } + } + + public static Task ToLink(this User user, IHtmlHelper helper, ViewDataDictionary viewData, string language) + => helper.PartialAsync("Partials/Links/UserLinkPartial", user, viewData.WithLang(language)); + + public static Task ToHtml(this Photo photo, IHtmlHelper helper, ViewDataDictionary viewData, string language) + => helper.PartialAsync("Partials/PhotoPartial", photo, viewData.WithLang(language)); +} \ No newline at end of file diff --git a/ProjectLighthouse.Servers.Website/Middlewares/HandlePageErrorMiddleware.cs b/ProjectLighthouse.Servers.Website/Middlewares/HandlePageErrorMiddleware.cs new file mode 100644 index 00000000..61405d7a --- /dev/null +++ b/ProjectLighthouse.Servers.Website/Middlewares/HandlePageErrorMiddleware.cs @@ -0,0 +1,27 @@ +using LBPUnion.ProjectLighthouse.Middlewares; + +namespace LBPUnion.ProjectLighthouse.Servers.Website.Middlewares; + +public class HandlePageErrorMiddleware : Middleware +{ + public HandlePageErrorMiddleware(RequestDelegate next) : base(next) + {} + + public override async Task InvokeAsync(HttpContext ctx) + { + await this.next(ctx); +// ReSharper disable once ConditionalAccessQualifierIsNonNullableAccordingToAPIContract + if (ctx.Response.StatusCode == 404 && !ctx.Request.Path.StartsWithSegments("/gameAssets")) + { + try + { + ctx.Request.Path = "/404"; + } + finally + { + // not much we can do to save us, carry on anyways + await next(ctx); + } + } + } +} \ No newline at end of file diff --git a/ProjectLighthouse.Servers.Website/Pages/Admin/AdminPanelPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/Admin/AdminPanelPage.cshtml index 8c007fc5..51af9cf8 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Admin/AdminPanelPage.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/Admin/AdminPanelPage.cshtml @@ -24,7 +24,7 @@ @if (!this.Request.IsMobile()) { -
+
@foreach (AdminPanelStatistic statistic in Model.Statistics) { @await Html.PartialAsync("Partials/AdminPanelStatisticPartial", statistic) @@ -41,7 +41,7 @@ else } } - + View Mod Panel diff --git a/ProjectLighthouse.Servers.Website/Pages/Errors/NotFoundPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/Errors/NotFoundPage.cshtml new file mode 100644 index 00000000..ae9af46d --- /dev/null +++ b/ProjectLighthouse.Servers.Website/Pages/Errors/NotFoundPage.cshtml @@ -0,0 +1,11 @@ +@page "/404" +@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Errors.NotFoundPage + +@{ + Layout = "Layouts/BaseLayout"; + Model.Title = "Not Found"; + Model.Description = "The page was not found."; +} + +

@Model.Description

+

This may be due to a lack of permission such as not being signed in, or maybe the page just isn't there.

diff --git a/ProjectLighthouse.Servers.Website/Pages/Errors/NotFoundPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Errors/NotFoundPage.cshtml.cs new file mode 100644 index 00000000..a1d72fc4 --- /dev/null +++ b/ProjectLighthouse.Servers.Website/Pages/Errors/NotFoundPage.cshtml.cs @@ -0,0 +1,15 @@ +using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Errors; + +public class NotFoundPage : BaseLayout +{ + public NotFoundPage(Database database) : base(database) + {} + + public void OnGet() + { + + } +} \ No newline at end of file diff --git a/ProjectLighthouse.Servers.Website/Pages/LandingPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/LandingPage.cshtml index 60dbddf0..22f6a763 100644 --- a/ProjectLighthouse.Servers.Website/Pages/LandingPage.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/LandingPage.cshtml @@ -4,14 +4,19 @@ @using LBPUnion.ProjectLighthouse.PlayerData.Profiles @using LBPUnion.ProjectLighthouse.Levels @using LBPUnion.ProjectLighthouse.Localization.StringLists +@using LBPUnion.ProjectLighthouse.Servers.Website.Extensions @model LBPUnion.ProjectLighthouse.Servers.Website.Pages.LandingPage @{ Layout = "Layouts/BaseLayout"; Model.ShowTitleInPage = false; + bool isMobile = this.Request.IsMobile(); + string language = Model.GetLanguage(); } -

@Model.Translate(LandingPageStrings.Welcome, ServerConfiguration.Instance.Customization.ServerName)

+

+ @Model.Translate(LandingPageStrings.Welcome, ServerConfiguration.Instance.Customization.ServerName) +

@if (Model.User != null) { @@ -24,25 +29,26 @@ } } -@if (Model.PlayersOnlineCount == 1) +@if (Model.PlayersOnline.Count == 1) {

@Model.Translate(LandingPageStrings.UsersSingle)

- @foreach (User user in Model.PlayersOnline) - { - @user.Username - } } -else if (Model.PlayersOnlineCount == 0) +else if (Model.PlayersOnline.Count == 0) {

@Model.Translate(LandingPageStrings.UsersNone)

} else { -

@Model.Translate(LandingPageStrings.UsersMultiple, Model.PlayersOnlineCount)

- @foreach (User user in Model.PlayersOnline) +

@Model.Translate(LandingPageStrings.UsersMultiple, Model.PlayersOnline.Count)

+} + +@{ + int i = 0; + foreach (User user in Model.PlayersOnline) { - @user.Username + i++; + @await user.ToLink(Html, ViewData, language)if (i != Model.PlayersOnline.Count){,} @* whitespace has forced my hand *@ } } @@ -50,8 +56,8 @@ else
-
-

@Model.Translate(LandingPageStrings.LatestTeamPicks)

+
+

@Model.Translate(LandingPageStrings.LatestTeamPicks)

@foreach (Slot slot in Model.LatestTeamPicks!) @* Can't reach a point where this is null *@ @@ -67,8 +73,8 @@ else
}
-
-

@Model.Translate(LandingPageStrings.NewestLevels)

+
+

@Model.Translate(LandingPageStrings.NewestLevels)

@foreach (Slot slot in Model.NewestLevels!) @* Can't reach a point where this is null *@ diff --git a/ProjectLighthouse.Servers.Website/Pages/LandingPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/LandingPage.cshtml.cs index db99fd84..f9ad4b07 100644 --- a/ProjectLighthouse.Servers.Website/Pages/LandingPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/LandingPage.cshtml.cs @@ -18,8 +18,6 @@ public class LandingPage : BaseLayout public int PendingAuthAttempts; public List PlayersOnline = new(); - public int PlayersOnlineCount; - public List? LatestTeamPicks; public List? NewestLevels; @@ -29,8 +27,6 @@ public class LandingPage : BaseLayout User? user = this.Database.UserFromWebRequest(this.Request); if (user != null && user.PasswordResetRequired) return this.Redirect("~/passwordResetRequired"); - this.PlayersOnlineCount = await StatisticsHelper.RecentMatches(); - if (user != null) this.PendingAuthAttempts = await this.Database.AuthenticationAttempts.Include (a => a.GameToken) diff --git a/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml b/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml index 8cd56d17..cad582bc 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml @@ -6,7 +6,7 @@ @model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts.BaseLayout @{ - if (Model!.User == null) + if (Model.User == null) { Model.NavigationItemsRight.Add(new PageNavigationItem(BaseLayoutStrings.HeaderLoginRegister, "/login", "sign in")); } @@ -16,30 +16,22 @@ { Model.NavigationItems.Add(new PageNavigationItem(BaseLayoutStrings.HeaderAuthentication, "/authentication", "key")); } - Model.NavigationItemsRight.Add(new PageNavigationItem(BaseLayoutStrings.HeaderProfile, "/user/" + Model.User.UserId, "user alternate")); @if (Model.User.IsAdmin) { - Model.NavigationItemsRight.Add(new PageNavigationItem(BaseLayoutStrings.HeaderAdminPanel, "/admin", "cogs")); + Model.NavigationItemsRight.Add(new PageNavigationItem(BaseLayoutStrings.HeaderAdminPanel, "/admin", "wrench", "yellow")); } else if (Model.User.IsModerator) { - Model.NavigationItemsRight.Add(new PageNavigationItem(BaseLayoutStrings.HeaderModPanel, "/moderation", "user shield")); + Model.NavigationItemsRight.Add(new PageNavigationItem(BaseLayoutStrings.HeaderModPanel, "/moderation", "user shield", "green")); } - Model.NavigationItemsRight.Add(new PageNavigationItem(BaseLayoutStrings.HeaderLogout, "/logout", "user alternate slash")); // should always be last } Model.IsMobile = Model.Request.IsMobile(); - string title; - if (Model.Title == string.Empty) - { - title = ServerConfiguration.Instance.Customization.ServerName; - } - else - { - title = $"{Model.Title} - {ServerConfiguration.Instance.Customization.ServerName}"; - } + string title = Model.Title == string.Empty + ? ServerConfiguration.Instance.Customization.ServerName + : $"{Model.Title} - {ServerConfiguration.Instance.Customization.ServerName}"; } @@ -48,7 +40,7 @@ @title - + @* Favicon *@ @@ -85,37 +77,56 @@
-
-
- @if (Model.ShowTitleInPage) - { -

@Model.Title

+ @{ + // on mobile, only show page contents + string segment = Model.IsMobile ? "" : "ui attached segment"; } - @RenderBody() -
@* makes it look nicer *@ +
+
+ @if (Model.ShowTitleInPage) + { +

@Model.Title

+ } + @RenderBody() +
+