mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-29 16:38:37 +00:00
Website announcements fixes and additions (#818)
* Render line breaks in announcement content * Track announcement publisher * Change paragraph tag to a div for consistency * Fix bottom padding for announcement content * Track publisher user entity rather than just the username * Potentially fix a migration failure * Final code cleanup * Fix linq statement chaining style --------- Co-authored-by: Dagg <daggintosh@outlook.com>
This commit is contained in:
parent
14ebad07f3
commit
f965be88b7
5 changed files with 96 additions and 11 deletions
|
@ -37,11 +37,21 @@
|
|||
@foreach (WebsiteAnnouncementEntity announcement in Model.Announcements)
|
||||
{
|
||||
<div class="ui blue segment" style="position: relative;">
|
||||
<h3>@announcement.Title</h3>
|
||||
<p style="white-space: initial;">
|
||||
@announcement.Content
|
||||
</p>
|
||||
|
||||
<div>
|
||||
<h3>@announcement.Title</h3>
|
||||
<div style="padding-bottom: 2em;">
|
||||
<span style="white-space: pre-line; ">@announcement.Content</span>
|
||||
</div>
|
||||
@if (announcement.Publisher != null)
|
||||
{
|
||||
<div class="ui tiny bottom left attached label">
|
||||
Posted by
|
||||
<a style="color: black" href="~/user/@announcement.Publisher.UserId">
|
||||
@announcement.Publisher.Username
|
||||
</a>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@if (Model.User != null && Model.User.IsAdmin)
|
||||
{
|
||||
<form method="post">
|
||||
|
@ -57,7 +67,7 @@
|
|||
</form>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -22,6 +22,7 @@ public class AnnouncePage : BaseLayout
|
|||
public async Task<IActionResult> OnGet()
|
||||
{
|
||||
this.Announcements = await this.Database.WebsiteAnnouncements
|
||||
.Include(a => a.Publisher)
|
||||
.OrderByDescending(a => a.AnnouncementId)
|
||||
.ToListAsync();
|
||||
|
||||
|
@ -42,8 +43,9 @@ public class AnnouncePage : BaseLayout
|
|||
|
||||
WebsiteAnnouncementEntity announcement = new()
|
||||
{
|
||||
Title = title,
|
||||
Content = content,
|
||||
Title = title.Trim(),
|
||||
Content = content.Trim(),
|
||||
PublisherId = user.UserId,
|
||||
};
|
||||
|
||||
await this.Database.WebsiteAnnouncements.AddAsync(announcement);
|
||||
|
@ -55,8 +57,7 @@ public class AnnouncePage : BaseLayout
|
|||
? content[..250] + $"... [read more]({ServerConfiguration.Instance.ExternalUrl}/announce)"
|
||||
: content;
|
||||
|
||||
await WebhookHelper.SendWebhook($":mega: {title}",
|
||||
truncatedAnnouncement);
|
||||
await WebhookHelper.SendWebhook($":mega: {title}", truncatedAnnouncement);
|
||||
}
|
||||
|
||||
return this.RedirectToPage();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue