mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-29 16:38:37 +00:00
Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
2fee6c62e1
11 changed files with 80 additions and 31 deletions
|
@ -1,4 +1,5 @@
|
||||||
#nullable enable
|
#nullable enable
|
||||||
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace LBPUnion.ProjectLighthouse.Helpers;
|
||||||
|
|
||||||
public static class WebhookHelper
|
public static class WebhookHelper
|
||||||
{
|
{
|
||||||
private static readonly DiscordWebhookClient client = new(ServerSettings.Instance.DiscordWebhookUrl);
|
private static readonly DiscordWebhookClient client = (ServerSettings.Instance.DiscordWebhookEnabled ? new DiscordWebhookClient(ServerSettings.Instance.DiscordWebhookUrl) : null);
|
||||||
public static readonly Color UnionColor = new(0, 140, 255);
|
public static readonly Color UnionColor = new(0, 140, 255);
|
||||||
|
|
||||||
public static Task SendWebhook(EmbedBuilder builder) => SendWebhook(builder.Build());
|
public static Task SendWebhook(EmbedBuilder builder) => SendWebhook(builder.Build());
|
||||||
|
|
|
@ -11,9 +11,10 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function onSubmit(form) {
|
function onSubmit(form) {
|
||||||
const password = form['password'];
|
const passwordInput = document.getElementById("password");
|
||||||
|
const passwordSubmit = document.getElementById("password-submit");
|
||||||
|
|
||||||
password.value = sha256(password.value);
|
passwordSubmit.value = sha256(passwordInput.value);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +44,8 @@
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label>Password</label>
|
<label>Password</label>
|
||||||
<div class="ui left icon input">
|
<div class="ui left icon input">
|
||||||
<input type="password" name="password" id="password" placeholder="Password">
|
<input type="password" id="password" placeholder="Password">
|
||||||
|
<input type="hidden" id="password-submit" name="password">
|
||||||
<i class="lock icon"></i>
|
<i class="lock icon"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -9,6 +9,14 @@
|
||||||
|
|
||||||
<p>There are @Model.PhotoCount total photos!</p>
|
<p>There are @Model.PhotoCount total photos!</p>
|
||||||
|
|
||||||
|
<form action="/photos/0">
|
||||||
|
<div class="ui icon input">
|
||||||
|
<input type="text" name="name" placeholder="Search photos..." value="@Model.SearchValue">
|
||||||
|
<i class="search icon"></i>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div class="ui divider"></div>
|
||||||
|
|
||||||
@foreach (Photo photo in Model.Photos)
|
@foreach (Photo photo in Model.Photos)
|
||||||
{
|
{
|
||||||
<div class="ui segment">
|
<div class="ui segment">
|
||||||
|
@ -18,10 +26,10 @@
|
||||||
|
|
||||||
@if (Model.PageNumber != 0)
|
@if (Model.PageNumber != 0)
|
||||||
{
|
{
|
||||||
<a href="/photos/@(Model.PageNumber - 1)">Previous Page</a>
|
<a href="/photos/@(Model.PageNumber - 1)@(Model.SearchValue.Length == 0 ? "" : "?name=" + Model.SearchValue)">Previous Page</a>
|
||||||
}
|
}
|
||||||
@(Model.PageNumber + 1) / @(Model.PageAmount)
|
@(Model.PageNumber + 1) / @(Model.PageAmount)
|
||||||
@if (Model.PageNumber < Model.PageAmount - 1)
|
@if (Model.PageNumber < Model.PageAmount - 1)
|
||||||
{
|
{
|
||||||
<a href="/photos/@(Model.PageNumber + 1)">Next Page</a>
|
<a href="/photos/@(Model.PageNumber + 1)@(Model.SearchValue.Length == 0 ? "" : "?name=" + Model.SearchValue)">Next Page</a>
|
||||||
}
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
|
#nullable enable
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using LBPUnion.ProjectLighthouse.Helpers;
|
|
||||||
using LBPUnion.ProjectLighthouse.Pages.Layouts;
|
using LBPUnion.ProjectLighthouse.Pages.Layouts;
|
||||||
using LBPUnion.ProjectLighthouse.Types;
|
using LBPUnion.ProjectLighthouse.Types;
|
||||||
using LBPUnion.ProjectLighthouse.Types.Settings;
|
using LBPUnion.ProjectLighthouse.Types.Settings;
|
||||||
|
@ -22,20 +22,26 @@ public class PhotosPage : BaseLayout
|
||||||
public int PhotoCount;
|
public int PhotoCount;
|
||||||
|
|
||||||
public List<Photo> Photos;
|
public List<Photo> Photos;
|
||||||
|
|
||||||
|
public string SearchValue;
|
||||||
public PhotosPage([NotNull] Database database) : base(database)
|
public PhotosPage([NotNull] Database database) : base(database)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
public async Task<IActionResult> OnGet([FromRoute] int pageNumber)
|
public async Task<IActionResult> OnGet([FromRoute] int pageNumber, [FromQuery] string? name)
|
||||||
{
|
{
|
||||||
this.PhotoCount = await StatisticsHelper.PhotoCount();
|
if (string.IsNullOrWhiteSpace(name)) name = "";
|
||||||
|
|
||||||
|
this.PhotoCount = await this.Database.Photos.CountAsync(p => p.Creator.Username.Contains(name) || p.PhotoSubjectCollection.Contains(name));
|
||||||
|
|
||||||
|
this.SearchValue = name;
|
||||||
this.PageNumber = pageNumber;
|
this.PageNumber = pageNumber;
|
||||||
this.PageAmount = (int)Math.Ceiling((double)this.PhotoCount / ServerStatics.PageSize);
|
this.PageAmount = Math.Max(1, (int)Math.Ceiling((double)this.PhotoCount / ServerStatics.PageSize));
|
||||||
|
|
||||||
if (this.PageNumber < 0 || this.PageNumber >= this.PageAmount) return this.Redirect($"/photos/{Math.Clamp(this.PageNumber, 0, this.PageAmount - 1)}");
|
if (this.PageNumber < 0 || this.PageNumber >= this.PageAmount) return this.Redirect($"/photos/{Math.Clamp(this.PageNumber, 0, this.PageAmount - 1)}");
|
||||||
|
|
||||||
this.Photos = await this.Database.Photos.Include
|
this.Photos = await this.Database.Photos.Include
|
||||||
(p => p.Creator)
|
(p => p.Creator)
|
||||||
|
.Where(p => p.Creator.Username.Contains(name) || p.PhotoSubjectCollection.Contains(name))
|
||||||
.OrderByDescending(p => p.Timestamp)
|
.OrderByDescending(p => p.Timestamp)
|
||||||
.Skip(pageNumber * ServerStatics.PageSize)
|
.Skip(pageNumber * ServerStatics.PageSize)
|
||||||
.Take(ServerStatics.PageSize)
|
.Take(ServerStatics.PageSize)
|
||||||
|
|
|
@ -10,11 +10,12 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function onSubmit(form) {
|
function onSubmit(form) {
|
||||||
const password = form['password'];
|
const passwordInput = document.getElementById("password");
|
||||||
const confirmPassword = form['confirmPassword'];
|
const confirmPasswordInput = document.getElementById("confirmPassword");
|
||||||
|
const passwordSubmit = document.getElementById("password-submit");
|
||||||
password.value = sha256(password.value);
|
const confirmPasswordSubmit = document.getElementById("confirm-submit");
|
||||||
confirmPassword.value = sha256(confirmPassword.value);
|
passwordSubmit.value = sha256(passwordInput.value);
|
||||||
|
confirmPasswordSubmit.value = sha256(confirmPasswordInput.value);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +45,8 @@
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label>Password</label>
|
<label>Password</label>
|
||||||
<div class="ui left icon input">
|
<div class="ui left icon input">
|
||||||
<input type="password" name="password" id="password" placeholder="Password">
|
<input type="password" id="password" placeholder="Password">
|
||||||
|
<input type="hidden" name="password" id="password-submit">
|
||||||
<i class="lock icon"></i>
|
<i class="lock icon"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -52,7 +54,8 @@
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label>Confirm Password</label>
|
<label>Confirm Password</label>
|
||||||
<div class="ui left icon input">
|
<div class="ui left icon input">
|
||||||
<input type="password" name="confirmPassword" id="confirmPassword" placeholder="Confirm Password">
|
<input type="password" id="confirmPassword" placeholder="Confirm Password">
|
||||||
|
<input type="hidden" name="confirmPassword" id="confirm-submit">
|
||||||
<i class="lock icon"></i>
|
<i class="lock icon"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -10,6 +10,14 @@
|
||||||
|
|
||||||
<p>There are @Model.SlotCount total levels!</p>
|
<p>There are @Model.SlotCount total levels!</p>
|
||||||
|
|
||||||
|
<form action="/slots/0">
|
||||||
|
<div class="ui icon input">
|
||||||
|
<input type="text" name="name" placeholder="Search levels..." value="@Model.SearchValue">
|
||||||
|
<i class="search icon"></i>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div class="ui divider"></div>
|
||||||
|
|
||||||
@foreach (Slot slot in Model.Slots)
|
@foreach (Slot slot in Model.Slots)
|
||||||
{
|
{
|
||||||
bool isMobile = Model.Request.IsMobile();
|
bool isMobile = Model.Request.IsMobile();
|
||||||
|
@ -34,10 +42,10 @@
|
||||||
|
|
||||||
@if (Model.PageNumber != 0)
|
@if (Model.PageNumber != 0)
|
||||||
{
|
{
|
||||||
<a href="/slots/@(Model.PageNumber - 1)">Previous Page</a>
|
<a href="/slots/@(Model.PageNumber - 1)@(Model.SearchValue.Length == 0 ? "" : "?name=" + Model.SearchValue)">Previous Page</a>
|
||||||
}
|
}
|
||||||
@(Model.PageNumber + 1) / @(Model.PageAmount)
|
@(Model.PageNumber + 1) / @(Model.PageAmount)
|
||||||
@if (Model.PageNumber < Model.PageAmount - 1)
|
@if (Model.PageNumber < Model.PageAmount - 1)
|
||||||
{
|
{
|
||||||
<a href="/slots/@(Model.PageNumber + 1)">Next Page</a>
|
<a href="/slots/@(Model.PageNumber + 1)@(Model.SearchValue.Length == 0 ? "" : "?name=" + Model.SearchValue)">Next Page</a>
|
||||||
}
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
|
#nullable enable
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -22,20 +23,26 @@ public class SlotsPage : BaseLayout
|
||||||
public int SlotCount;
|
public int SlotCount;
|
||||||
|
|
||||||
public List<Slot> Slots;
|
public List<Slot> Slots;
|
||||||
|
|
||||||
|
public string SearchValue;
|
||||||
|
|
||||||
public SlotsPage([NotNull] Database database) : base(database)
|
public SlotsPage([NotNull] Database database) : base(database)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
public async Task<IActionResult> OnGet([FromRoute] int pageNumber)
|
public async Task<IActionResult> OnGet([FromRoute] int pageNumber, [FromQuery] string? name)
|
||||||
{
|
{
|
||||||
this.SlotCount = await StatisticsHelper.SlotCount();
|
if (string.IsNullOrWhiteSpace(name)) name = "";
|
||||||
|
|
||||||
|
this.SlotCount = await this.Database.Slots.CountAsync(p => p.Name.Contains(name));
|
||||||
|
|
||||||
|
this.SearchValue = name;
|
||||||
this.PageNumber = pageNumber;
|
this.PageNumber = pageNumber;
|
||||||
this.PageAmount = (int)Math.Ceiling((double)this.SlotCount / ServerStatics.PageSize);
|
this.PageAmount = Math.Max(1, (int) Math.Ceiling((double) this.SlotCount / ServerStatics.PageSize));
|
||||||
|
|
||||||
if (this.PageNumber < 0 || this.PageNumber >= this.PageAmount) return this.Redirect($"/slots/{Math.Clamp(this.PageNumber, 0, this.PageAmount - 1)}");
|
if (this.PageNumber < 0 || this.PageNumber >= this.PageAmount) return this.Redirect($"/slots/{Math.Clamp(this.PageNumber, 0, this.PageAmount - 1)}");
|
||||||
|
|
||||||
this.Slots = await this.Database.Slots.Include
|
this.Slots = await this.Database.Slots.Where
|
||||||
(p => p.Creator)
|
(p => p.Name.Contains(name))
|
||||||
.OrderByDescending(p => p.FirstUploaded)
|
.OrderByDescending(p => p.FirstUploaded)
|
||||||
.Skip(pageNumber * ServerStatics.PageSize)
|
.Skip(pageNumber * ServerStatics.PageSize)
|
||||||
.Take(ServerStatics.PageSize)
|
.Take(ServerStatics.PageSize)
|
||||||
|
|
|
@ -9,6 +9,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
<p>There are @Model.UserCount total users.</p>
|
<p>There are @Model.UserCount total users.</p>
|
||||||
|
|
||||||
|
<form action="/users/0">
|
||||||
|
<div class="ui icon input">
|
||||||
|
<input type="text" name="name" placeholder="Search users..." value="@Model.SearchValue">
|
||||||
|
<i class="search icon"></i>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div class="ui divider"></div>
|
||||||
|
|
||||||
@foreach (User user in Model.Users)
|
@foreach (User user in Model.Users)
|
||||||
{
|
{
|
||||||
|
@ -28,10 +36,10 @@
|
||||||
|
|
||||||
@if (Model.PageNumber != 0)
|
@if (Model.PageNumber != 0)
|
||||||
{
|
{
|
||||||
<a href="/users/@(Model.PageNumber - 1)">Previous Page</a>
|
<a href="/users/@(Model.PageNumber - 1)@(Model.SearchValue.Length == 0 ? "" : "?name=" + Model.SearchValue)">Previous Page</a>
|
||||||
}
|
}
|
||||||
@(Model.PageNumber + 1) / @(Model.PageAmount)
|
@(Model.PageNumber + 1) / @(Model.PageAmount)
|
||||||
@if (Model.PageNumber < Model.PageAmount - 1)
|
@if (Model.PageNumber < Model.PageAmount - 1)
|
||||||
{
|
{
|
||||||
<a href="/users/@(Model.PageNumber + 1)">Next Page</a>
|
<a href="/users/@(Model.PageNumber + 1)@(Model.SearchValue.Length == 0 ? "" : "?name=" + Model.SearchValue)">Next Page</a>
|
||||||
}
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
|
#nullable enable
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using LBPUnion.ProjectLighthouse.Helpers;
|
|
||||||
using LBPUnion.ProjectLighthouse.Pages.Layouts;
|
using LBPUnion.ProjectLighthouse.Pages.Layouts;
|
||||||
using LBPUnion.ProjectLighthouse.Types;
|
using LBPUnion.ProjectLighthouse.Types;
|
||||||
using LBPUnion.ProjectLighthouse.Types.Settings;
|
using LBPUnion.ProjectLighthouse.Types.Settings;
|
||||||
|
@ -22,20 +22,25 @@ public class UsersPage : BaseLayout
|
||||||
|
|
||||||
public List<User> Users;
|
public List<User> Users;
|
||||||
|
|
||||||
|
public string SearchValue;
|
||||||
|
|
||||||
public UsersPage([NotNull] Database database) : base(database)
|
public UsersPage([NotNull] Database database) : base(database)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
public async Task<IActionResult> OnGet([FromRoute] int pageNumber)
|
public async Task<IActionResult> OnGet([FromRoute] int pageNumber, [FromQuery] string? name)
|
||||||
{
|
{
|
||||||
this.UserCount = await StatisticsHelper.UserCount();
|
if (string.IsNullOrWhiteSpace(name)) name = "";
|
||||||
|
|
||||||
|
this.UserCount = await this.Database.Users.CountAsync(u => !u.Banned && u.Username.Contains(name));
|
||||||
|
|
||||||
|
this.SearchValue = name;
|
||||||
this.PageNumber = pageNumber;
|
this.PageNumber = pageNumber;
|
||||||
this.PageAmount = (int)Math.Ceiling((double)this.UserCount / ServerStatics.PageSize);
|
this.PageAmount = Math.Max(1, (int)Math.Ceiling((double)this.UserCount / ServerStatics.PageSize));
|
||||||
|
|
||||||
if (this.PageNumber < 0 || this.PageNumber >= this.PageAmount) return this.Redirect($"/users/{Math.Clamp(this.PageNumber, 0, this.PageAmount - 1)}");
|
if (this.PageNumber < 0 || this.PageNumber >= this.PageAmount) return this.Redirect($"/users/{Math.Clamp(this.PageNumber, 0, this.PageAmount - 1)}");
|
||||||
|
|
||||||
this.Users = await this.Database.Users.Where
|
this.Users = await this.Database.Users.Where
|
||||||
(u => !u.Banned)
|
(u => !u.Banned && u.Username.Contains(name))
|
||||||
.OrderByDescending(b => b.UserId)
|
.OrderByDescending(b => b.UserId)
|
||||||
.Skip(pageNumber * ServerStatics.PageSize)
|
.Skip(pageNumber * ServerStatics.PageSize)
|
||||||
.Take(ServerStatics.PageSize)
|
.Take(ServerStatics.PageSize)
|
||||||
|
|
|
@ -82,6 +82,7 @@ public static class Program
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FileHelper.EnsureDirectoryCreated(Path.Combine(Environment.CurrentDirectory, "png"));
|
||||||
if (Directory.Exists("r"))
|
if (Directory.Exists("r"))
|
||||||
{
|
{
|
||||||
Logger.Log
|
Logger.Log
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue