mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-29 08:28:39 +00:00
Implement URL slugs (#931)
* Implement URL slugs for Users and Slots * Fix extra spaces in slot slugs
This commit is contained in:
parent
aea66b4a74
commit
1eb3bfa2ec
8 changed files with 55 additions and 8 deletions
|
@ -1,6 +1,7 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Interaction;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
|
@ -28,7 +29,7 @@ public class SlotPage : BaseLayout
|
|||
public SlotPage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public async Task<IActionResult> OnGet([FromRoute] int id)
|
||||
public async Task<IActionResult> OnGet([FromRoute] int id, string? slug)
|
||||
{
|
||||
SlotEntity? slot = await this.Database.Slots.Include(s => s.Creator)
|
||||
.Where(s => s.Type == SlotType.User || (this.User != null && this.User.PermissionLevel >= PermissionLevel.Moderator))
|
||||
|
@ -45,6 +46,12 @@ public class SlotPage : BaseLayout
|
|||
if ((slot.Hidden || slot.SubLevel && (this.User == null && this.User != slot.Creator)) && !(this.User?.IsModerator ?? false))
|
||||
return this.NotFound();
|
||||
|
||||
string slotSlug = slot.GenerateSlug();
|
||||
if (slug == null || slotSlug != slug)
|
||||
{
|
||||
return this.Redirect($"~/slot/{id}/{slotSlug}");
|
||||
}
|
||||
|
||||
this.Slot = slot;
|
||||
|
||||
List<int> blockedUsers = this.User == null
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue