diff --git a/ImageBoardServerApp/Data/PostData.cs b/ImageBoardServerApp/Data/PostData.cs index 6f54e37..1b3f14d 100644 --- a/ImageBoardServerApp/Data/PostData.cs +++ b/ImageBoardServerApp/Data/PostData.cs @@ -42,4 +42,8 @@ public class PostData public List Comments { get; set; } public ReportData? Report { get; set; } + + public bool IsSticky { get; set; } + + public bool IsLocked { get; set; } } \ No newline at end of file diff --git a/ImageBoardServerApp/Data/TheManager.cs b/ImageBoardServerApp/Data/TheManager.cs index f011cd4..68ef45f 100644 --- a/ImageBoardServerApp/Data/TheManager.cs +++ b/ImageBoardServerApp/Data/TheManager.cs @@ -38,6 +38,8 @@ public class TheManager { for (int i = board.maxThreads + 1; i >= sortedThreads.Count; ++i) { + if (sortedThreads[i].IsSticky) + continue; await deleteThread(sortedThreads[i]); } } diff --git a/ImageBoardServerApp/ImageBoardServerApp.csproj b/ImageBoardServerApp/ImageBoardServerApp.csproj index d009a75..5db28fa 100644 --- a/ImageBoardServerApp/ImageBoardServerApp.csproj +++ b/ImageBoardServerApp/ImageBoardServerApp.csproj @@ -22,10 +22,13 @@ - + + + + diff --git a/ImageBoardServerApp/Pages/Basic/Index.razor b/ImageBoardServerApp/Pages/Basic/Index.razor index 63fc5c2..8987e60 100644 --- a/ImageBoardServerApp/Pages/Basic/Index.razor +++ b/ImageBoardServerApp/Pages/Basic/Index.razor @@ -7,7 +7,7 @@ This is a simple Imageboard made in Razor.
We're currently hosting @amountOfPosts Threads, @amountOfComments Comments and @amountOfUsers Users. - +
@Details diff --git a/ImageBoardServerApp/Pages/Boards/M.razor b/ImageBoardServerApp/Pages/Boards/Au.razor similarity index 69% rename from ImageBoardServerApp/Pages/Boards/M.razor rename to ImageBoardServerApp/Pages/Boards/Au.razor index 6be39ba..e73c04b 100644 --- a/ImageBoardServerApp/Pages/Boards/M.razor +++ b/ImageBoardServerApp/Pages/Boards/Au.razor @@ -1,4 +1,4 @@ -@page "/m/" +@page "/e/" @@ -8,7 +8,7 @@ { BoardID = 0, maxThreads = 10, - Tag = "m", - Topic = "Main" + Tag = "e", + Topic = "Everything" }; } \ No newline at end of file diff --git a/ImageBoardServerApp/Pages/Boards/E.razor b/ImageBoardServerApp/Pages/Boards/E.razor new file mode 100644 index 0000000..8179161 --- /dev/null +++ b/ImageBoardServerApp/Pages/Boards/E.razor @@ -0,0 +1,14 @@ +@page "/au/" + + + +@code { + + private BoardData m { get; set; } = new() + { + BoardID = 0, + maxThreads = 10, + Tag = "au", + Topic = "Autism" + }; +} \ No newline at end of file diff --git a/ImageBoardServerApp/Shared/Components/Board.razor.css b/ImageBoardServerApp/Shared/Components/Board.razor.css index dfe7f18..0b0436f 100644 --- a/ImageBoardServerApp/Shared/Components/Board.razor.css +++ b/ImageBoardServerApp/Shared/Components/Board.razor.css @@ -13,5 +13,5 @@ margin-right: auto; width: 500px; max-height: 500px; - max-width: 90vw !important; + max-width: 80vw !important; } \ No newline at end of file diff --git a/ImageBoardServerApp/Shared/Components/Comment.razor b/ImageBoardServerApp/Shared/Components/Comment.razor index 8799322..dbe28c1 100644 --- a/ImageBoardServerApp/Shared/Components/Comment.razor +++ b/ImageBoardServerApp/Shared/Components/Comment.razor @@ -1,4 +1,5 @@ @using System.ComponentModel.DataAnnotations +@using System.Text.RegularExpressions @using ImageBoardServerApp.Auth @using ImageBoardServerApp.Data @using ImageBoardServerApp.Data.Repository @@ -28,14 +29,33 @@
@foreach (string s in @comment.Content.Split("\n")) { - @if (s.StartsWith(">")) + var className = ""; + @if (s.StartsWith(">") && !Regex.IsMatch(s, "^>{2,}")) { - @s - } - else - { - @s + className = "greenText"; } + + + @foreach (string line in s.Split(" ")) + { + var className2 = ""; + @if (@Regex.IsMatch(line, ">>\\d+")) + { + className2 = "redText"; + >(\\d+)").Value.Substring(2)" class="threadMsg @className2"> + @line + + } + else + { + + @line + + } +   + + } + }
@@ -59,7 +79,7 @@ var user = await cauthStateProvder.GetAuthenticationStateAsync(); var usr = user.User; UserData foundusr = await UsersRepository.getUserByEmailAsync(usr.Identity.Name); - if (foundusr.PermissionInteger >= 50 || comment.UserID == foundusr.UserID) + if (foundusr.Role != "User" || comment.UserID == foundusr.UserID) { await TheManager.deleteComment(comment); } diff --git a/ImageBoardServerApp/Shared/Components/Comment.razor.css b/ImageBoardServerApp/Shared/Components/Comment.razor.css index 4de11ba..fc40707 100644 --- a/ImageBoardServerApp/Shared/Components/Comment.razor.css +++ b/ImageBoardServerApp/Shared/Components/Comment.razor.css @@ -16,6 +16,11 @@ color: #339305; } +.redText { + color: #a91e1e; +} + + .threadHeader{ text-align: left; } @@ -53,7 +58,7 @@ } .threadText{ - display: grid; + display: block; } .threadTextContainer{ diff --git a/ImageBoardServerApp/Shared/Components/Forms/CommentForm.razor b/ImageBoardServerApp/Shared/Components/Forms/CommentForm.razor index 34f7c16..5a9c509 100644 --- a/ImageBoardServerApp/Shared/Components/Forms/CommentForm.razor +++ b/ImageBoardServerApp/Shared/Components/Forms/CommentForm.razor @@ -98,6 +98,14 @@ foundusr.lastActionTimeStamp = DateTimeOffset.Now.ToUnixTimeMilliseconds(); await UsersRepository.updateUserAsync(foundusr); + PostData updatedPost = await PostsRepository.getPostByIdAsync(post.PostID); + if (updatedPost.IsLocked) + { + hasErr = true; + postErr = "This Post is locked."; + return; + } + bool hasImage = selectedFile != null; CommentData commentToCreate; diff --git a/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor b/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor index b88a9a3..73c52b2 100644 --- a/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor +++ b/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor @@ -146,7 +146,9 @@ Content = postContent, Interactions = 0, CreatedAt = DateTimeOffset.Now.ToUnixTimeMilliseconds(), - Board = board.Tag + Board = board.Tag, + IsLocked = false, + IsSticky = false }; int postId = await PostsRepository.createPostAsync(postToPost); if (postId != -1) diff --git a/ImageBoardServerApp/Shared/Components/Post.razor b/ImageBoardServerApp/Shared/Components/Post.razor index a94f943..2956967 100644 --- a/ImageBoardServerApp/Shared/Components/Post.razor +++ b/ImageBoardServerApp/Shared/Components/Post.razor @@ -1,16 +1,19 @@ @using System.ComponentModel.DataAnnotations +@using System.Text.RegularExpressions @using ImageBoardServerApp.Auth @using ImageBoardServerApp.Data @using ImageBoardServerApp.Data.Repository +@using Microsoft.AspNetCore.Html @inject AuthenticationStateProvider authStateProvider @inject NavigationManager navigationManager; +
@if (showOpenThread) { [ @toggleText - ] + ] } @post.Title @post.Username @@ -27,6 +30,14 @@ (@value) + @if (post.IsSticky) + { + Stickied + } + @if (post.IsLocked) + { + Locked + }
@if (opened) { @@ -44,18 +55,31 @@
@foreach (string s in @post.Content.Split("\n")) { - @if (@s.StartsWith(">")) + var className = ""; + @if (s.StartsWith(">") && !Regex.IsMatch(s, "^>{2,}")) { - @s - } - else - { - @s + className = "greenText"; } + + @s  }
+
+ +
+ + + [ + Sticky + ] + [ + Lock + ] + + + [ Delete ] @@ -80,6 +104,19 @@ @code { + + private async Task lockMe() + { + post.IsLocked = !post.IsLocked; + await PostsRepository.updatePostAsync(post); + } + + private async Task 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); @@ -94,13 +131,14 @@ var user = await cauthStateProvder.GetAuthenticationStateAsync(); var usr = user.User; UserData foundusr = await UsersRepository.getUserByEmailAsync(usr.Identity.Name); - if (foundusr.PermissionInteger >= 50 || post.UserID == foundusr.UserID) + if (foundusr.Role != "User" || post.UserID == foundusr.UserID) { await TheManager.deleteThread(post); navigationManager.NavigateTo($"/{boardTag}"); } } - + + private bool opened = true; private string toggleText = "-"; diff --git a/ImageBoardServerApp/Shared/Components/Post.razor.css b/ImageBoardServerApp/Shared/Components/Post.razor.css index 2cee082..a0be3b3 100644 --- a/ImageBoardServerApp/Shared/Components/Post.razor.css +++ b/ImageBoardServerApp/Shared/Components/Post.razor.css @@ -61,9 +61,13 @@ } .threadText{ - display: grid; + display: block; } .threadTextContainer{ margin: 0; +} + +.threadMsg { + display: inline-block; } \ No newline at end of file diff --git a/ImageBoardServerApp/Shared/Components/UserEntry.razor b/ImageBoardServerApp/Shared/Components/UserEntry.razor index 76be7d7..61a7a9f 100644 --- a/ImageBoardServerApp/Shared/Components/UserEntry.razor +++ b/ImageBoardServerApp/Shared/Components/UserEntry.razor @@ -5,7 +5,6 @@ @user.Comments.Count Comments | @user.SubmittedReports.Count Reports submitted | @user.RecivedReports.Count Reports recived | -Edit