diff --git a/ProjectLighthouse/Pages/Partials/CommentsPartial.cshtml b/ProjectLighthouse/Pages/Partials/CommentsPartial.cshtml index f921e5ad..35df6b8f 100644 --- a/ProjectLighthouse/Pages/Partials/CommentsPartial.cshtml +++ b/ProjectLighthouse/Pages/Partials/CommentsPartial.cshtml @@ -28,6 +28,10 @@ + @if (Model.Comments.Count > 0) + { +
+ } } @for(int i = 0; i < Model.Comments.Count; i++) diff --git a/ProjectLighthouse/Pages/SlotPage.cshtml b/ProjectLighthouse/Pages/SlotPage.cshtml index eaed5b40..397d9fb5 100644 --- a/ProjectLighthouse/Pages/SlotPage.cshtml +++ b/ProjectLighthouse/Pages/SlotPage.cshtml @@ -79,8 +79,9 @@ { int count = Model.Reviews.Count;

There @(count == 1 ? "is" : "are") @count review@(count == 1 ? "" : "s").

+
} -
+ @for(int i = 0; i < Model.Reviews.Count; i++) { @@ -147,7 +148,7 @@ else { { -

@review.Text

+

@HttpUtility.HtmlDecode(review.Text)

} } } diff --git a/ProjectLighthouse/Pages/SlotsPage.cshtml.cs b/ProjectLighthouse/Pages/SlotsPage.cshtml.cs index 0e15b011..2a87d653 100644 --- a/ProjectLighthouse/Pages/SlotsPage.cshtml.cs +++ b/ProjectLighthouse/Pages/SlotsPage.cshtml.cs @@ -2,8 +2,10 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text; using System.Threading.Tasks; using LBPUnion.ProjectLighthouse.Pages.Layouts; +using LBPUnion.ProjectLighthouse.Types; using LBPUnion.ProjectLighthouse.Types.Levels; using LBPUnion.ProjectLighthouse.Types.Settings; using Microsoft.AspNetCore.Mvc; @@ -31,6 +33,27 @@ public class SlotsPage : BaseLayout { if (string.IsNullOrWhiteSpace(name)) name = ""; + string? targetAuthor = null; + GameVersion? targetGame = null; + StringBuilder finalSearch = new(); + foreach (string part in name.Split(" ")) + { + if (part.Contains("by:")) + { + targetAuthor = part.Replace("by:", ""); + } else if (part.Contains("game:")) + { + if (part.Contains('1')) targetGame = GameVersion.LittleBigPlanet1; + else if (part.Contains('2')) targetGame = GameVersion.LittleBigPlanet2; + else if (part.Contains('3')) targetGame = GameVersion.LittleBigPlanet3; + else if (part.Contains('v')) targetGame = GameVersion.LittleBigPlanetVita; + } + else + { + finalSearch.Append(part); + } + } + this.SearchValue = name.Trim(); this.SlotCount = await this.Database.Slots.CountAsync(p => p.Name.Contains(this.SearchValue)); @@ -41,12 +64,16 @@ public class SlotsPage : BaseLayout if (this.PageNumber < 0 || this.PageNumber >= this.PageAmount) return this.Redirect($"/slots/{Math.Clamp(this.PageNumber, 0, this.PageAmount - 1)}"); this.Slots = await this.Database.Slots.Include(p => p.Creator) - .Where(p => p.Name.Contains(this.SearchValue)) + .Where(p => p.Name.Contains(finalSearch.ToString())) + .Where(p => p.Creator != null && (targetAuthor == null || string.Equals(p.Creator.Username.ToLower(), targetAuthor.ToLower()))) + .Where(p => targetGame == null || p.GameVersion == targetGame) .OrderByDescending(p => p.FirstUploaded) .Skip(pageNumber * ServerStatics.PageSize) .Take(ServerStatics.PageSize) .ToListAsync(); + this.SlotCount = this.Slots.Count; + return this.Page(); } } \ No newline at end of file