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() +
+