mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-28 07:58:40 +00:00
Display the latest announcement (if any) on the landing page
This commit is contained in:
parent
e1cc214f44
commit
a5ba5844f8
2 changed files with 35 additions and 1 deletions
|
@ -60,7 +60,34 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<br><br>
|
@if (Model.LatestAnnouncement != null)
|
||||||
|
{
|
||||||
|
<div class="ui blue segment" style="position: relative;">
|
||||||
|
<div>
|
||||||
|
<h3>@Model.LatestAnnouncement.Title</h3>
|
||||||
|
<div style="padding-bottom: 2em;">
|
||||||
|
<span style="white-space: pre-line">
|
||||||
|
@(Model.LatestAnnouncement.Content.Length > 250
|
||||||
|
? Model.LatestAnnouncement.Content[..250] + $"... [read more]({ServerConfiguration.Instance.ExternalUrl}/notifications)"
|
||||||
|
: Model.LatestAnnouncement.Content)
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
@if (Model.LatestAnnouncement.Publisher != null)
|
||||||
|
{
|
||||||
|
<div class="ui tiny bottom left attached label">
|
||||||
|
Posted by
|
||||||
|
<a style="color: black" href="~/user/@Model.LatestAnnouncement.Publisher.UserId">
|
||||||
|
@Model.LatestAnnouncement.Publisher.Username
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<br /><br />
|
||||||
|
}
|
||||||
|
|
||||||
<div class="@(isMobile ? "" : "ui center aligned grid")">
|
<div class="@(isMobile ? "" : "ui center aligned grid")">
|
||||||
<div class="eight wide column">
|
<div class="eight wide column">
|
||||||
|
|
|
@ -5,6 +5,7 @@ using LBPUnion.ProjectLighthouse.Helpers;
|
||||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||||
|
using LBPUnion.ProjectLighthouse.Types.Entities.Website;
|
||||||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
@ -19,6 +20,8 @@ public class LandingPage : BaseLayout
|
||||||
public int PendingAuthAttempts;
|
public int PendingAuthAttempts;
|
||||||
public List<UserEntity> PlayersOnline = new();
|
public List<UserEntity> PlayersOnline = new();
|
||||||
|
|
||||||
|
public WebsiteAnnouncementEntity? LatestAnnouncement;
|
||||||
|
|
||||||
public LandingPage(DatabaseContext database) : base(database)
|
public LandingPage(DatabaseContext database) : base(database)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
@ -54,6 +57,10 @@ public class LandingPage : BaseLayout
|
||||||
.Include(s => s.Creator)
|
.Include(s => s.Creator)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
this.LatestAnnouncement = await this.Database.WebsiteAnnouncements.Include(a => a.Publisher)
|
||||||
|
.OrderByDescending(a => a.AnnouncementId)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
return this.Page();
|
return this.Page();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue