feat: started working on stickys and locking, started working on replying in threads, added banners, added autism board, other small changes
This commit is contained in:
parent
d8fcc93394
commit
5fdebe3fc1
18 changed files with 132 additions and 35 deletions
|
@ -42,4 +42,8 @@ public class PostData
|
|||
public List<CommentData> Comments { get; set; }
|
||||
|
||||
public ReportData? Report { get; set; }
|
||||
|
||||
public bool IsSticky { get; set; }
|
||||
|
||||
public bool IsLocked { get; set; }
|
||||
}
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,10 +22,13 @@
|
|||
<ItemGroup>
|
||||
<Folder Include="Data\Migrations" />
|
||||
<Folder Include="wwwroot\img\dynamic\comment\art" />
|
||||
<Folder Include="wwwroot\img\dynamic\comment\m" />
|
||||
<Folder Include="wwwroot\img\dynamic\comment\au" />
|
||||
<Folder Include="wwwroot\img\dynamic\comment\e" />
|
||||
<Folder Include="wwwroot\img\dynamic\comment\tec" />
|
||||
<Folder Include="wwwroot\img\dynamic\comment\vg" />
|
||||
<Folder Include="wwwroot\img\dynamic\op\art" />
|
||||
<Folder Include="wwwroot\img\dynamic\op\au" />
|
||||
<Folder Include="wwwroot\img\dynamic\op\e" />
|
||||
<Folder Include="wwwroot\img\dynamic\op\tec" />
|
||||
<Folder Include="wwwroot\img\dynamic\op\vg" />
|
||||
<Folder Include="wwwroot\img\thumb" />
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<span>This is a simple Imageboard made in Razor.</span>
|
||||
<br/>
|
||||
<span>We're currently hosting @amountOfPosts Threads, @amountOfComments Comments and @amountOfUsers Users.</span>
|
||||
<sr/>
|
||||
<br/>
|
||||
<span>@Details</span>
|
||||
<AuthorizeView>
|
||||
<Authorized>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@page "/m/"
|
||||
@page "/e/"
|
||||
|
||||
<Board board="@m"/>
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
|||
{
|
||||
BoardID = 0,
|
||||
maxThreads = 10,
|
||||
Tag = "m",
|
||||
Topic = "Main"
|
||||
Tag = "e",
|
||||
Topic = "Everything"
|
||||
};
|
||||
}
|
14
ImageBoardServerApp/Pages/Boards/E.razor
Normal file
14
ImageBoardServerApp/Pages/Boards/E.razor
Normal file
|
@ -0,0 +1,14 @@
|
|||
@page "/au/"
|
||||
|
||||
<Board board="@m"/>
|
||||
|
||||
@code {
|
||||
|
||||
private BoardData m { get; set; } = new()
|
||||
{
|
||||
BoardID = 0,
|
||||
maxThreads = 10,
|
||||
Tag = "au",
|
||||
Topic = "Autism"
|
||||
};
|
||||
}
|
|
@ -13,5 +13,5 @@
|
|||
margin-right: auto;
|
||||
width: 500px;
|
||||
max-height: 500px;
|
||||
max-width: 90vw !important;
|
||||
max-width: 80vw !important;
|
||||
}
|
|
@ -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 @@
|
|||
<div class="threadTextContainer">
|
||||
@foreach (string s in @comment.Content.Split("\n"))
|
||||
{
|
||||
@if (s.StartsWith(">"))
|
||||
var className = "";
|
||||
@if (s.StartsWith(">") && !Regex.IsMatch(s, "^>{2,}"))
|
||||
{
|
||||
<span class="threadText greenText">@s</span>
|
||||
className = "greenText";
|
||||
}
|
||||
|
||||
<span class='threadText @className'>
|
||||
@foreach (string line in s.Split(" "))
|
||||
{
|
||||
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='threadText'>@s</span>
|
||||
<span class="threadMsg">
|
||||
@line
|
||||
</span>
|
||||
}
|
||||
<span> </span>
|
||||
|
||||
}
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,11 @@
|
|||
color: #339305;
|
||||
}
|
||||
|
||||
.redText {
|
||||
color: #a91e1e;
|
||||
}
|
||||
|
||||
|
||||
.threadHeader{
|
||||
text-align: left;
|
||||
}
|
||||
|
@ -53,7 +58,7 @@
|
|||
}
|
||||
|
||||
.threadText{
|
||||
display: grid;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.threadTextContainer{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
<div class="threadHeader">
|
||||
@if (showOpenThread)
|
||||
{
|
||||
<span>[</span>
|
||||
<a class="toggleOpened" onclick="@ToggleOpened">@toggleText</a>
|
||||
<span>]</span>
|
||||
<span>] </span>
|
||||
}
|
||||
<span class="title">@post.Title</span>
|
||||
<span class="name">@post.Username </span>
|
||||
|
@ -27,6 +30,14 @@
|
|||
<span>(@value)</span>
|
||||
</Authorized>
|
||||
</AuthorizeView>
|
||||
@if (post.IsSticky)
|
||||
{
|
||||
<img src="img/static/sys/sticky.png" alt="Stickied"/>
|
||||
}
|
||||
@if (post.IsLocked)
|
||||
{
|
||||
<img src="img/static/sys/locked.png" alt="Locked"/>
|
||||
}
|
||||
</div>
|
||||
@if (opened)
|
||||
{
|
||||
|
@ -44,18 +55,31 @@
|
|||
<div class="threadTextContainer">
|
||||
@foreach (string s in @post.Content.Split("\n"))
|
||||
{
|
||||
@if (@s.StartsWith(">"))
|
||||
var className = "";
|
||||
@if (s.StartsWith(">") && !Regex.IsMatch(s, "^>{2,}"))
|
||||
{
|
||||
<span class="threadText greenText">@s</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class='threadText'>@s</span>
|
||||
className = "greenText";
|
||||
}
|
||||
|
||||
<span class='threadText @className'>@s </span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="threadFooter">
|
||||
<div class="sticky">
|
||||
|
||||
</div>
|
||||
<AuthorizeView Roles="Admin, Mod">
|
||||
<Authorized>
|
||||
<span>[</span>
|
||||
<a onclick="@stickyMe()" href="javascript:void(0)">Sticky</a>
|
||||
<span>]</span>
|
||||
<span>[</span>
|
||||
<a onclick="@lockMe()" href="javascript:void(0)">Lock</a>
|
||||
<span>]</span>
|
||||
</Authorized>
|
||||
</AuthorizeView>
|
||||
|
||||
<span>[</span>
|
||||
<a @onclick="@deletePost" href="javascript:void(0)">Delete</a>
|
||||
<span>]</span>
|
||||
|
@ -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 = "-";
|
||||
|
|
|
@ -61,9 +61,13 @@
|
|||
}
|
||||
|
||||
.threadText{
|
||||
display: grid;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.threadTextContainer{
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.threadMsg {
|
||||
display: inline-block;
|
||||
}
|
|
@ -5,7 +5,6 @@
|
|||
<span>@user.Comments.Count Comments | </span>
|
||||
<span>@user.SubmittedReports.Count Reports submitted | </span>
|
||||
<span>@user.RecivedReports.Count Reports recived | </span>
|
||||
<a onclick="@editF()" href="javascript:void(0)">Edit</a>
|
||||
<span> </span>
|
||||
<select name="role" id="role" @bind="@selectedRole">
|
||||
<option value="User">User</option>
|
||||
|
@ -19,7 +18,6 @@
|
|||
|
||||
@code {
|
||||
private string selectedRole;
|
||||
private bool edit = false;
|
||||
|
||||
[Parameter]
|
||||
[Required]
|
||||
|
@ -27,15 +25,9 @@
|
|||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
edit = false;
|
||||
selectedRole = user.Role;
|
||||
}
|
||||
|
||||
private async Task editF()
|
||||
{
|
||||
edit = !edit;
|
||||
}
|
||||
|
||||
private async Task updateRole()
|
||||
{
|
||||
user.Role = selectedRole;
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="m">
|
||||
<span class="oi oi-list-rich" aria-hidden="true"></span> /m/ - Main
|
||||
<NavLink class="nav-link" href="e">
|
||||
<span class="oi oi-list-rich" aria-hidden="true"></span> /e/ - Everything
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
|
@ -46,6 +46,11 @@
|
|||
<span class="oi oi-list-rich" aria-hidden="true"></span> /vg/ - Video Games
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="au">
|
||||
<span class="oi oi-list-rich" aria-hidden="true"></span> /au/ - Autism
|
||||
</NavLink>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 77 KiB |
Binary file not shown.
Before Width: | Height: | Size: 168 KiB |
Binary file not shown.
Before Width: | Height: | Size: 248 KiB After Width: | Height: | Size: 248 KiB |
Loading…
Reference in a new issue