2023-03-17 23:49:50 +00:00
|
|
|
@using ImageBoardServerApp.Data.Repository
|
|
|
|
@using System.ComponentModel.DataAnnotations
|
2023-06-12 16:51:25 +00:00
|
|
|
@using System.Text.RegularExpressions
|
|
|
|
<div class="comment">
|
|
|
|
|
|
|
|
<span class="name">@comment.Username</span>
|
|
|
|
@if (@role != "User")
|
|
|
|
{
|
|
|
|
<span class="@role">##@role </span>
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
<span> </span>
|
|
|
|
}
|
|
|
|
<span class="date">@getTimeFromUnix(comment.CreatedAt)</span>
|
|
|
|
<span class="post-id">No.@comment.GET</span>
|
|
|
|
<div class="threadContent">
|
2023-03-17 23:49:50 +00:00
|
|
|
@if (image != null)
|
|
|
|
{
|
2023-06-12 16:51:25 +00:00
|
|
|
<div class="threadImage">
|
|
|
|
<img src="@($"{image.ImageLocation}?size=258x258")" alt="No Image found"/>
|
|
|
|
</div>
|
2023-03-17 23:49:50 +00:00
|
|
|
}
|
2023-06-12 16:51:25 +00:00
|
|
|
<div class="threadTextContainer">
|
|
|
|
@foreach (string s in @comment.Content.Split("\n"))
|
2023-03-17 23:49:50 +00:00
|
|
|
{
|
2023-06-12 16:51:25 +00:00
|
|
|
var className = "";
|
|
|
|
@if (s.StartsWith(">") && !Regex.IsMatch(s, "^>{2,}"))
|
2023-03-17 23:49:50 +00:00
|
|
|
{
|
2023-06-12 16:51:25 +00:00
|
|
|
className = "greenText";
|
|
|
|
}
|
|
|
|
|
|
|
|
<span class='threadText @className'>
|
|
|
|
@foreach (string line in s.Split(" "))
|
2023-03-17 23:49:50 +00:00
|
|
|
{
|
2023-06-12 16:51:25 +00:00
|
|
|
var className2 = "";
|
|
|
|
@if (@Regex.IsMatch(line, ">>\\d+"))
|
|
|
|
{
|
|
|
|
className2 = "redText";
|
|
|
|
<a href="/@comment.Board/@comment.PostID/@Regex.Match(s, ">>(\\d+)").Value.Substring(2)" class="threadMsg @className2">
|
|
|
|
@line
|
|
|
|
</a>
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
<span class="threadMsg">
|
|
|
|
@line
|
|
|
|
</span>
|
|
|
|
}
|
|
|
|
<span> </span>
|
2023-03-17 23:49:50 +00:00
|
|
|
}
|
2023-06-12 16:51:25 +00:00
|
|
|
</span>
|
|
|
|
}
|
|
|
|
</div>
|
2023-03-17 23:49:50 +00:00
|
|
|
</div>
|
2023-06-12 16:51:25 +00:00
|
|
|
</div>
|
|
|
|
|
2023-03-17 23:49:50 +00:00
|
|
|
@code {
|
|
|
|
private ImageData image;
|
|
|
|
private string role;
|
|
|
|
|
|
|
|
private static DateTime getTimeFromUnix(double javaTimeStamp)
|
|
|
|
{
|
|
|
|
var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
2023-06-12 16:51:25 +00:00
|
|
|
dateTime = dateTime.AddMilliseconds(javaTimeStamp).ToLocalTime();
|
2023-03-17 23:49:50 +00:00
|
|
|
return dateTime;
|
|
|
|
}
|
2023-06-12 16:51:25 +00:00
|
|
|
|
2023-03-17 23:49:50 +00:00
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
{
|
|
|
|
await base.OnInitializedAsync();
|
|
|
|
int i;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
i = (int)comment.ImageID;
|
|
|
|
}
|
|
|
|
catch (InvalidOperationException ioe)
|
|
|
|
{
|
|
|
|
i = -1;
|
|
|
|
}
|
|
|
|
if (i != null)
|
|
|
|
{
|
|
|
|
image = await ImagesRepository.getImageByIdAsync(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
var cmt = await CommentsRepository.getCommentByIdAsync(comment.CommentID);
|
|
|
|
role = cmt.User.Role;
|
|
|
|
}
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
[Required]
|
|
|
|
public CommentData comment { get; set; }
|
2023-06-12 16:51:25 +00:00
|
|
|
|
2023-03-17 23:49:50 +00:00
|
|
|
}
|