divan/GanjooRazor/Pages/Partials/GanjoorPage/_CommentPartial.cshtml
Hamid Reza Mohammadi ab254fefd5 commennt sanitization
2026-09-26 21:32:02 +03:30

73 lines
4.3 KiB
Plaintext

@model GanjooRazor.Pages._CommentPartialModel
@using DNTPersianUtils.Core
@{
Layout = null;
}
@if (Model.Comment == null)
{
<div class="item" id="comment-error" data-sanitizer-remaining-text="@Model.SanitizerRemainingText">
<p style="color:red">خطا</p>
@Model.Error
</div>
}
else
{
<div class="ganjoor-comment" id="comment-@Model.Comment.Id@Model.DivSuffix">
@if (!string.IsNullOrEmpty(Model.Comment.PublishStatus))
{
<div class="red-color">@Model.Comment.PublishStatus</div>
}
@if (Model.Comment.UserId != null)
{
<div class="comment-author"><a href="/hashieha/?userid=@Model.Comment.UserId">@(string.IsNullOrEmpty(Model.Comment.AuthorName) ? "#" : Model.Comment.AuthorName)</a> <small>در @Html.Raw($"{Model.Comment.CommentDate.ToFriendlyPersianDateTextify()}")</small> @Model.Wrote:</div>
}
else
{
<div class="comment-author">@(string.IsNullOrEmpty(Model.Comment.AuthorName) ? "ناشناس" : Model.Comment.AuthorName) <small>در @Html.Raw($"{Model.Comment.CommentDate.ToFriendlyPersianDateTextify()}")</small> @Model.Wrote:</div>
}
@if (Model.Comment.CoupletIndex != -1)
{
<div class="commentquote">دربارهٔ <a href="@($"#bn{Model.Comment.CoupletIndex + 1}")">@Model.Comment.CoupletSummary</a></div>
}
<blockquote id="comment-text-@Model.Comment.Id@Model.DivSuffix">
@Html.Raw(Model.Comment.HtmlComment)
</blockquote>
<p>
@if (Model.Comment.MyComment)
{
<a role="button" title="حذف حاشیه" onclick="deleteMyComment(@Model.Comment.Id, '@Model.Comment.CoupletIndex')"><i class="notranslate pageicons">delete</i></a>
<a role="button" title="ویرایش حاشیه" onclick="editMyComment(@Model.Comment.Id, '@Model.Comment.CoupletIndex')"><i class="notranslate pageicons">edit</i></a>
}
<a role="button" title="پاسخگویی به این حاشیه" onclick="replyComment(@Model.Comment.Id, @(Model.LoggedIn ? "true" : "false"), '@Model.DivSuffix')"><i class="notranslate pageicons">reply</i></a>
@if (!Model.Comment.MyComment)
{
<a role="button" title="پسندیدن" id="like-btn-@Model.Comment.Id@Model.DivSuffix" class="cursor-pointer@(Model.Comment.CurrentUserRatingValue == 1 ? " green-color" : "")" onclick="rateComment(@Model.Comment.Id, 1, @(Model.LoggedIn ? "true" : "false"), '@Model.DivSuffix')"><i class="notranslate pageicons">thumb_up</i></a>
}
<small id="like-count-@Model.Comment.Id@Model.DivSuffix">@Model.Comment.LikeCount.ToPersianNumbers()</small>
@if (!Model.Comment.MyComment)
{
<a role="button" title="نپسندیدن" id="dislike-btn-@Model.Comment.Id@Model.DivSuffix" class="cursor-pointer@(Model.Comment.CurrentUserRatingValue == -1 ? " red-color" : "")" onclick="rateComment(@Model.Comment.Id, -1, @(Model.LoggedIn ? "true" : "false"), '@Model.DivSuffix')"><i class="notranslate pageicons">thumb_down</i></a>
}
<small id="dislike-count-@Model.Comment.Id@Model.DivSuffix">@Model.Comment.DislikeCount.ToPersianNumbers()</small>
<a href="/ReportComment/?CommentId=@Model.Comment.Id" title="گزارش حاشیهٔ نامناسب" onclick="wpopen(this.href); return false"><i class="notranslate pageicons">flag</i></a>
<a role="button" onclick="copyCommentUrl(@Model.Comment.Id)"><i class="notranslate pageicons">link</i></a>
@if (Model.LoggedIn)
{
<a role="button" id="bookmark-comment-@Model.Comment.Id@Model.DivSuffix" class="cursor-pointer" onclick="switchBookmark(@Model.PoemId, -@Model.Comment.Id, '@Model.DivSuffix')"><i class="notranslate pageicons" id="bookmark-icon-comment-@Model.Comment.Id@Model.DivSuffix">@(@Model.Comment.IsBookmarked ? "star" : "star_border")</i></a>
}
</p>
<div class='spacer'>&nbsp;</div>
@foreach (var reply in Model.Comment.Replies ?? Array.Empty<RMuseum.Models.Ganjoor.ViewModels.GanjoorCommentSummaryViewModel>())
{
<partial name="_CommentPartial.cshtml" model=Model.GetCommentModel(reply) />
}
</div>
}