mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-10-03 22:59:41 +00:00
# Conflicts: # .config/dotnet-tools.json # ProjectLighthouse.Servers.Website/Pages/Partials/ReviewPartial.cshtml
145 lines
No EOL
5.9 KiB
Text
145 lines
No EOL
5.9 KiB
Text
@using System.Web
|
|
@using LBPUnion.ProjectLighthouse.Configuration
|
|
@using LBPUnion.ProjectLighthouse.Files
|
|
@using LBPUnion.ProjectLighthouse.Helpers
|
|
@using LBPUnion.ProjectLighthouse.Types.Entities.Level
|
|
@using LBPUnion.ProjectLighthouse.Types.Serialization.Review
|
|
|
|
@{
|
|
bool isMobile = (bool?)ViewData["IsMobile"] ?? false;
|
|
bool canDelete = (bool?)ViewData["CanDelete"] ?? false;
|
|
}
|
|
|
|
<div class="eight wide column" id="reviews">
|
|
<div class="ui purple segment">
|
|
@if (Model.Reviews.Count == 0 && Model.ReviewsEnabled)
|
|
{
|
|
<p>There are no reviews.</p>
|
|
}
|
|
else if (!Model.ReviewsEnabled)
|
|
{
|
|
<b>
|
|
<i>Reviews are disabled on this level.</i>
|
|
</b>
|
|
}
|
|
else
|
|
{
|
|
int count = Model.Reviews.Count;
|
|
<p>There @(count == 1 ? "is" : "are") @count review@(count == 1 ? "" : "s").</p>
|
|
<div class="ui divider"></div>
|
|
}
|
|
|
|
@if (ServerConfiguration.Instance.UserGeneratedContentLimits.ReadOnlyMode)
|
|
{
|
|
<div class="ui red segment">
|
|
<p>
|
|
<i>
|
|
@ServerConfiguration.Instance.Customization.ServerName is currently in read-only mode.
|
|
You will not be able to post reviews in-game until read-only mode is disabled.
|
|
</i>
|
|
</p>
|
|
</div>
|
|
}
|
|
|
|
@for(int i = 0; i < Model.Reviews.Count; i++)
|
|
{
|
|
ReviewEntity review = Model.Reviews[i];
|
|
string faceHash = (review.Thumb switch {
|
|
-1 => review.Reviewer?.BooHash,
|
|
0 => review.Reviewer?.MehHash,
|
|
1 => review.Reviewer?.YayHash,
|
|
|
|
_ => throw new ArgumentOutOfRangeException(),
|
|
}) ?? "";
|
|
|
|
if (string.IsNullOrWhiteSpace(faceHash) || !FileHelper.ResourceExists(faceHash))
|
|
{
|
|
faceHash = ServerConfiguration.Instance.WebsiteConfiguration.MissingIconHash;
|
|
}
|
|
|
|
string faceAlt = review.Thumb switch {
|
|
-1 => "Boo!",
|
|
0 => "Meh.",
|
|
1 => "Yay!",
|
|
|
|
_ => throw new ArgumentOutOfRangeException(),
|
|
};
|
|
|
|
int size = isMobile ? 50 : 100;
|
|
|
|
<div class="card">
|
|
<div>
|
|
<img class="cardIcon slotCardIcon" src="@ServerConfiguration.Instance.ExternalUrl/gameAssets/@faceHash" alt="@faceAlt" title="@faceAlt" style="min-width: @(size)px; width: @(size)px; height: @(size)px">
|
|
</div>
|
|
<div class="cardStats">
|
|
<a href="/user/@review.Reviewer?.UserId">
|
|
<h3 style="margin-bottom: 5px;">@review.Reviewer?.Username</h3>
|
|
</a>
|
|
@if (review.Deleted)
|
|
{
|
|
if (review.DeletedBy == DeletedBy.LevelAuthor)
|
|
{
|
|
<p>
|
|
<i>This review has been deleted by the level author.</i>
|
|
</p>
|
|
}
|
|
else
|
|
{
|
|
<p>
|
|
<i>This review has been deleted by a moderator.</i>
|
|
</p>
|
|
}
|
|
}
|
|
else
|
|
{
|
|
@if (review.Labels.Length > 1)
|
|
{
|
|
<div style="padding-bottom: 5px;">
|
|
@foreach (string reviewLabel in review.Labels)
|
|
{
|
|
<div class="ui blue label">@LabelHelper.TranslateTag(reviewLabel)</div>
|
|
}
|
|
</div>
|
|
}
|
|
@if (string.IsNullOrWhiteSpace(review.Text))
|
|
{
|
|
<p>
|
|
<i>This review contains no text.</i>
|
|
</p>
|
|
}
|
|
else
|
|
{
|
|
{
|
|
<p>@HttpUtility.HtmlDecode(review.Text)</p>
|
|
}
|
|
}
|
|
}
|
|
</div>
|
|
@if (canDelete && !review.Deleted)
|
|
{
|
|
<div style="display: inline-block; right: 1em; position: absolute;">
|
|
<button class="ui red icon button" onclick="deleteReview(@review.ReviewId)">
|
|
<i class="trash icon"></i>
|
|
</button>
|
|
<script>
|
|
function deleteReview(reviewId){
|
|
if (window.confirm("Are you sure you want to delete this?\nThis action cannot be undone.")){
|
|
window.location.hash = "reviews";
|
|
window.location.href = "/moderation/deleteReview/" + reviewId + "?callbackUrl=" + this.window.location;
|
|
}
|
|
}
|
|
</script>
|
|
</div>
|
|
}
|
|
</div>
|
|
@if (i != Model.Reviews.Count - 1)
|
|
{
|
|
<div class="ui divider"></div>
|
|
}
|
|
}
|
|
</div>
|
|
@if (isMobile)
|
|
{
|
|
<br/>
|
|
}
|
|
</div> |