bulletboards/ImageBoardServerApp/Shared/Components/Post.razor

71 lines
2 KiB
Text
Raw Normal View History

2023-01-18 12:56:24 +00:00
@using System.ComponentModel.DataAnnotations
@using ImageBoardServerApp.Data
<div class="threadHeader">
<span>[</span>
<a class="toggleOpened" onclick="@ToggleOpened">@toggleText</a>
<span>]</span>
<span class="title">@post.Title</span>
<span class="name">@post.Username</span>
<span class="date">@getTimeFromUnix(post.CreatedAt)</span>
<span class="post-id">No.@post.PostID</span>
</div>
@if (opened)
{
<div class="threadContent">
<div class="threadImage">
<!-- TODO: Make Images Required. -->
@if (@post.Image != null)
{
<img src="@($"data:image/jpeg;base64,{Convert.ToBase64String(@post.Image.Image)}")" alt="No Image found" />
}
else
{
<span>[No Image]</span>
}
</div>
<div class="threadTextContainer">
@foreach (string s in @post.Content.Split("\n"))
{
<span class='threadText'>@s</span>
}
</div>
</div>
<div class="threadFooter">
<!--<RadzenButton class="bump" Text="bump"></RadzenButton> -->
<span>[</span>
<a class="report" href="/report/@post.Board/@post.PostID" target="_blank">Report</a>
<span>]</span>
<span>[</span>
<a class="openThread" href="/@post.Board/@post.PostID" target="_blank">(@post.Interactions) Open Thread</a>
<span>]</span>
</div>
}
@code {
private static DateTime getTimeFromUnix(double javaTimeStamp)
{
var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
dateTime = dateTime.AddMilliseconds( javaTimeStamp ).ToLocalTime();
return dateTime;
}
private bool opened = true;
private string toggleText = "-";
private void ToggleOpened()
{
opened = !opened;
toggleText = opened ? "-" : "+";
}
[Parameter]
[Required]
public PostData post { get; set; }
}