@using ImageBoardServerApp.Data.Repository @using ImageBoardServerApp.Util @using ImageBoardServerApp.Auth @using System.ComponentModel.DataAnnotations @using System.Text.RegularExpressions @inject AuthenticationStateProvider authStateProvider @inject NavigationManager navigationManager;
@if (showOpenThread) { [ @toggleText ] } @post.Title @post.Username @if (post.User.Role != "User" && !post.shouldAnon) { ##@post.User.Role  }   @getTimeFromUnix(post.CreatedAt) No.@post.GET @if (post.IsSticky) { Stickied } @if (post.IsLocked) { Locked }
@if (opened) {
@if (@post.Image != null) { string isActiveClass = isActive ? "active" : ""; No Image found } else { [No Image] }
@if (showOpenThread) { @foreach (string s in post.Content.Split("\n").Take(6)) { var className = ""; @if (s.StartsWith(">") && !Regex.IsMatch(s, "^>{2,}")) { className = "greenText"; }

@foreach (string s2 in s.Split(" ")) { @if (s2.StartsWith("https://") || s2.StartsWith("http://")) { @s2 } else { @s2 } @(" ") }

} @if (post.Content.Split("\n").Length > 6) {

[Open thread to read more...]

} } else { @foreach (string s in post.Content.Split("\n")) { var className = ""; @if (s.StartsWith(">") && !Regex.IsMatch(s, "^>{2,}")) { className = "greenText"; }

@foreach (string s2 in s.Split(" ")) { @if (s2.StartsWith("https://") || s2.StartsWith("http://")) { @s2 } else { @s2 } @(" ") }

} }

[ @if (post.IsSticky) { } else { } @if (post.IsLocked) { } else { } ] [ Report @if (canDel) { } @if (showOpenThread) { @openThreadName } else { @post.Comments.Count Comments } ]
}
@code { private string reportURL { get; set; } private string threadURL { get; set; } private string openThreadName { get; set; } public bool canDel { get; set; } = false; public bool isActive { get; set; } = false; private int linecnt = 0; private async void lockMe() { post.IsLocked = !post.IsLocked; await PostsRepository.updatePostAsync(post); } private async void stickyMe() { post.IsSticky = !post.IsSticky; await PostsRepository.updatePostAsync(post); } 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 async Task deletePost() { string boardTag = post.Board; var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider; var user = await cauthStateProvder.GetAuthenticationStateAsync(); var usr = user.User; UserData foundusr = await UsersRepository.getUserByEmailRawAsync(usr.Identity.Name); if (foundusr.Role != "User" || post.UserID == foundusr.UserID) { await TheManager.deleteThread(post); navigationManager.NavigateTo($"/sys/click/red/_{boardTag}"); } } private bool opened = true; private string toggleText = "-"; private string value; private void ToggleOpened() { opened = !opened; toggleText = opened ? "-" : "+"; } protected override async Task OnInitializedAsync() { value = TheManager.getBumpValue(post) + "v"; reportURL = $"/sys/report/op/{post.Board}/{post.PostID}"; threadURL = $"/{post.Board}/thread/{post.PostID}"; openThreadName = $"({post.Comments.Count}) View Thread"; var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider; var user = await cauthStateProvder.GetAuthenticationStateAsync(); UserData foundusr = await UsersRepository.getUserByEmailRawAsync(user.User.Identity.Name); if (foundusr != null && (foundusr.Role != "User" || post.UserID == foundusr.UserID)) { canDel = true; return; } canDel = false; await base.OnInitializedAsync(); } [Parameter] [Required] public PostData post { get; set; } [Parameter] [Required] public bool showOpenThread { get; set; } }