summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJake Mannens <jake@asger.xyz>2026-05-22 12:46:00 +1000
committerJake Mannens <jake@asger.xyz>2026-05-23 22:13:00 +1000
commit4ea3ddb38d010c2f85c22b7f1c3f2d7e0c1355e3 (patch)
tree90af9203059d645eb77216f1a091722ee9702438
parent6de5d7f5364fe1d54703da6d6b7cb08ea26e939f (diff)
Initial commitwasm-oldserver
-rw-r--r--App.razor19
-rw-r--r--Controllers/ApiFeedController.cs25
-rw-r--r--Controllers/ApiMediaController.cs221
-rw-r--r--Controllers/ApiTagController.cs253
-rw-r--r--Controllers/ApiUserController.cs109
-rw-r--r--Controllers/LoginController.cs49
-rw-r--r--Controllers/MediaController.cs155
-rw-r--r--Dockerfile16
-rw-r--r--ExceptionMiddleware.cs64
-rw-r--r--HBContext.cs84
-rw-r--r--HBObject.cs14
-rw-r--r--IDialog.cs8
-rw-r--r--LICENSE.txt661
-rw-r--r--MainLayout.razor11
-rw-r--r--MainLayout.razor.css9
-rw-r--r--Media.cs92
-rw-r--r--Migrations/20260131125650_InitialMigration.Designer.cs362
-rw-r--r--Migrations/20260131125650_InitialMigration.cs319
-rw-r--r--Migrations/HBContextModelSnapshot.cs359
-rw-r--r--OldServer.csproj (renamed from Server.csproj)18
-rw-r--r--Pages/Component/AboutDialog.razor736
-rw-r--r--Pages/Component/AboutDialog.razor.css29
-rw-r--r--Pages/Component/ButtonContainer.razor8
-rw-r--r--Pages/Component/ButtonContainer.razor.css10
-rw-r--r--Pages/Component/Dialog.razor70
-rw-r--r--Pages/Component/Dialog.razor.css35
-rw-r--r--Pages/Component/MediaTagTable.razor72
-rw-r--r--Pages/Component/MediaTagTable.razor.css9
-rw-r--r--Pages/Component/MobileMenu.razor26
-rw-r--r--Pages/Component/MobileMenu.razor.css46
-rw-r--r--Pages/Component/NsfwSwitch.razor8
-rw-r--r--Pages/Component/ProgressBar.razor17
-rw-r--r--Pages/Component/ProgressBar.razor.css17
-rw-r--r--Pages/Component/RedirectLogin.razor6
-rw-r--r--Pages/Component/Switch.razor20
-rw-r--r--Pages/Component/Switch.razor.css25
-rw-r--r--Pages/Component/TabContainer.razor35
-rw-r--r--Pages/Component/TabContainer.razor.css27
-rw-r--r--Pages/Component/TabPane.razor29
-rw-r--r--Pages/Component/TabPane.razor.css1
-rw-r--r--Pages/Component/TagEditDialog.razor96
-rw-r--r--Pages/Component/TagEditDialog.razor.css11
-rw-r--r--Pages/Component/TagSelectDialog.razor192
-rw-r--r--Pages/Component/TagSelectDialog.razor.css29
-rw-r--r--Pages/Component/Titlebar.razor87
-rw-r--r--Pages/Component/Titlebar.razor.css99
-rw-r--r--Pages/Gallery.razor141
-rw-r--r--Pages/Gallery.razor.css15
-rw-r--r--Pages/Login.razor17
-rw-r--r--Pages/Login.razor.css6
-rw-r--r--Pages/TagDefinitions.razor187
-rw-r--r--Pages/TagDefinitions.razor.css5
-rw-r--r--Pages/Upload.razor43
-rw-r--r--Pages/Upload.razor.css48
-rw-r--r--Pages/ViewMedia.razor265
-rw-r--r--Pages/ViewMedia.razor.css222
-rw-r--r--Pages/_Host.cshtml37
-rw-r--r--Program.cs31
-rw-r--r--Services/ConfigService.cs72
-rw-r--r--Services/FeedService.cs212
-rw-r--r--Services/MediaService.cs400
-rw-r--r--Services/OcrService.cs128
-rw-r--r--Services/SourceService.cs20
-rw-r--r--Services/TagService.cs305
-rw-r--r--Services/UserService.cs76
-rw-r--r--Tag.cs37
-rw-r--r--Todo.md41
-rw-r--r--User.cs15
-rw-r--r--Util.cs120
-rw-r--r--_Imports.razor9
-rw-r--r--appsettings.json3
-rw-r--r--tessdata/eng.traineddatabin15400601 -> 0 bytes
-rw-r--r--wwwroot/css/site.css28
-rw-r--r--wwwroot/favicon.icobin3262 -> 0 bytes
-rw-r--r--wwwroot/icon-192.pngbin31523 -> 0 bytes
-rw-r--r--wwwroot/icon-512.pngbin136487 -> 0 bytes
-rw-r--r--wwwroot/images/book.svg7
-rw-r--r--wwwroot/images/checkmark.svg7
-rw-r--r--wwwroot/images/cross.svg7
-rw-r--r--wwwroot/images/edit.svg7
-rw-r--r--wwwroot/images/info.svg63
-rw-r--r--wwwroot/images/loginbg.webpbin2247672 -> 0 bytes
-rw-r--r--wwwroot/images/photo.svg7
-rw-r--r--wwwroot/images/tag.svg7
-rw-r--r--wwwroot/images/trash.svg7
-rw-r--r--wwwroot/js/dialog.js78
-rw-r--r--wwwroot/js/keyboard.js57
-rw-r--r--wwwroot/js/mobile.js7
-rw-r--r--wwwroot/loginbg.webmbin390877 -> 0 bytes
-rw-r--r--wwwroot/manifest.webmanifest6
-rw-r--r--wwwroot/styles/data-table.css21
-rw-r--r--wwwroot/styles/global.css214
92 files changed, 0 insertions, 7566 deletions
diff --git a/App.razor b/App.razor
deleted file mode 100644
index b4e47c9..0000000
--- a/App.razor
+++ /dev/null
@@ -1,19 +0,0 @@
-<CascadingAuthenticationState>
- <Router AppAssembly="@typeof(App).Assembly">
- <Found Context="routeData">
- <AuthorizeRouteView
- RouteData="@routeData"
- DefaultLayout="@typeof(MainLayout)">
- <NotAuthorized>
- <RedirectLogin/>
- </NotAuthorized>
- </AuthorizeRouteView>
- </Found>
- <NotFound>
- <PageTitle>Not found</PageTitle>
- <LayoutView Layout="@typeof(MainLayout)">
- <p role="alert">Sorry, there's nothing at this address.</p>
- </LayoutView>
- </NotFound>
- </Router>
-</CascadingAuthenticationState>
diff --git a/Controllers/ApiFeedController.cs b/Controllers/ApiFeedController.cs
deleted file mode 100644
index 382169e..0000000
--- a/Controllers/ApiFeedController.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using HyperBooru.ApiModels;
-using HyperBooru.Services;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.EntityFrameworkCore;
-
-namespace HyperBooru.Controllers;
-
-[ApiController]
-[Authorize]
-[Route("/api/feed")]
-public class ApiFeedController : Controller {
- private IFeedService feedService;
-
- public ApiFeedController(IDbContextFactory<HBContext> dbFactory, IFeedService feedService) =>
- this.feedService = feedService;
-
- [HttpPost]
- public IActionResult FetchChunkAsync([FromBody] FeedRequest feedRequest) {
- if(feedRequest.Count > 1000)
- return BadRequest("Total number of requested items exceeds maximum");
-
- return Ok(feedService.LoadChunk(feedRequest).Select(m => m.Guid).ToArray());
- }
-}
diff --git a/Controllers/ApiMediaController.cs b/Controllers/ApiMediaController.cs
deleted file mode 100644
index a1b07b1..0000000
--- a/Controllers/ApiMediaController.cs
+++ /dev/null
@@ -1,221 +0,0 @@
-using HyperBooru.ApiModels;
-using HyperBooru.Services;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.EntityFrameworkCore;
-using System.Text.Json;
-
-namespace HyperBooru.Controllers;
-
-[ApiController]
-[Authorize]
-[Route("/api/media")]
-public class ApiMediaController : Controller {
- private IDbContextFactory<HBContext> dbFactory;
- private IMediaService mediaService;
-
- public ApiMediaController(IDbContextFactory<HBContext> dbFactory, IMediaService mediaService) {
- this.dbFactory = dbFactory;
- this.mediaService = mediaService;
- }
-
- [HttpGet("{mediaId}")]
- public async Task<IActionResult> Get([FromRoute] Guid mediaId) {
- using var db = dbFactory.CreateDbContext();
-
- var media = await db.Media.FirstOrDefaultAsync(m => m.Guid == mediaId);
-
- if(media is null)
- throw new ObjectNotFoundException(mediaId);
-
- return Ok((ApiModels.Media) media);
- }
-
- [HttpGet("{mediaId}/files")]
- public async Task<IActionResult> GetUploadedFiles([FromRoute] Guid mediaId) {
- using var db = dbFactory.CreateDbContext();
-
- var media = await db.Media
- .Include(m => m.UploadedFiles)
- .FirstOrDefaultAsync(m => m.Guid == mediaId);
-
- if(media is null)
- throw new ObjectNotFoundException(mediaId);
-
- return Ok(media.UploadedFiles.Select(uf => (ApiModels.UploadedFile) uf).ToArray());
- }
-
- [HttpPatch]
- public async Task<IActionResult> UpdateMedia([FromBody] ApiModels.Media updatedMedia) {
- using var db = dbFactory.CreateDbContext();
- using var transaction = await db.Database.BeginTransactionAsync();
-
- var media = await db.Media.FirstOrDefaultAsync(m => m.Guid == updatedMedia.MediaId);
- if(media is null)
- return NotFound();
-
- media.ShortDescription = updatedMedia.ShortDescription;
- media.LongDescription = updatedMedia.LongDescription;
-
- await db.SaveChangesAsync();
- await transaction.CommitAsync();
-
- return Ok();
- }
-
- [HttpPost]
- public IActionResult Upload() {
- if(Request.Form.Files.Count == 0)
- return BadRequest("No files");
- if(Request.Form.Files.Count > 1)
- return BadRequest("More than one file supplied");
-
- var metadataString = Request.Form.Files
- .First()
- .Headers["X-HyperBooru-Metadata"]
- .ElementAtOrDefault(0);
-
- MediaUploadRequest? metadata = metadataString is null ? null :
- JsonSerializer.Deserialize<MediaUploadRequest>(metadataString);
-
- var formFile = Request.Form.Files.First();
-
- var media = mediaService.Create(
- formFile.OpenReadStream(),
- formFile.FileName,
- metadata?.Checksum,
- metadata?.LastAccessTime,
- metadata?.LastWriteTime,
- metadata?.CreateTime,
- metadata?.Path,
- metadata?.PathType,
- metadata?.Tags);
-
- return Ok((ApiModels.Media) media);
- }
-
- [HttpDelete("{mediaId}")]
- public void Delete([FromRoute] Guid mediaId) =>
- mediaService.Delete(mediaId);
-
- [HttpGet("{mediaId}/tags")]
- public async Task<IActionResult> GetMediaTagsAsync([FromRoute] Guid mediaId) {
- using var db = dbFactory.CreateDbContext();
-
- var media = await db.Media
- .Include(m => m.Tags)
- .ThenInclude(t => t.TagDefinition)
- .ThenInclude(td => td.ImplicitTags)
- .FirstOrDefaultAsync(m => m.Guid == mediaId);
- if(media is null)
- return NotFound();
-
- return Ok(media.Tags.Select(t => (ApiModels.TagDefinition) t.TagDefinition).ToArray());
- }
-
- [HttpPatch("{mediaId}/tags")]
- public async Task<IActionResult> AddTagsToMediaAsync(
- [FromRoute] Guid mediaId,
- [FromBody] Guid[] tagIds) {
-
- using var db = dbFactory.CreateDbContext();
- using var transaction = await db.Database.BeginTransactionAsync();
-
- var media = await db.Media
- .Include(m => m.Tags)
- .ThenInclude(t => t.TagDefinition)
- .ThenInclude(td => td.ImplicitTags)
- .FirstOrDefaultAsync(m => m.Guid == mediaId);
- if(media is null)
- return NotFound();
-
- tagIds = tagIds.Distinct().ToArray();
-
- var tags = await db.TagDefinitions
- .Where(td => tagIds.Contains(td.Guid))
- .ToArrayAsync();
-
- if(tags.Count() < tagIds.Count())
- return NotFound("Invalid tag IDs specified");
-
- media.Tags.AddRange(tags
- .Where(td => !media.Tags.Select(t => t.TagDefinition.Guid).Contains(td.Guid))
- .Select(td => new Tag() { TagDefinition = td }));
-
- await db.SaveChangesAsync();
- await transaction.CommitAsync();
-
- return Ok(media.Tags.Select(t => (ApiModels.TagDefinition) t.TagDefinition).ToArray());
- }
-
- [HttpPut("{mediaId}/tags")]
- public async Task<IActionResult> ReplaceMediaTagsAsync(
- [FromRoute] Guid mediaId,
- [FromBody] Guid[] tagIds) {
-
- using var db = dbFactory.CreateDbContext();
- using var transaction = await db.Database.BeginTransactionAsync();
-
- var media = await db.Media
- .Include(m => m.Tags)
- .ThenInclude(t => t.TagDefinition)
- .ThenInclude(td => td.ImplicitTags)
- .FirstOrDefaultAsync(m => m.Guid == mediaId);
- if(media is null)
- return NotFound();
-
- tagIds = tagIds.Distinct().Order().ToArray();
- var tags = await db.TagDefinitions
- .Where(td => tagIds.Contains(td.Guid))
- .ToArrayAsync();
-
- var missingTags = tagIds.Except(tags.Select(td => td.Guid));
- var missingTagsString = string.Join(", ", missingTags.Select(t => t.ToString()));
- if(missingTags.Any())
- return BadRequest($"Invalid tag IDs specified: {missingTagsString}");
-
- media.Tags.AddRange(tags
- .Where(td => !media.Tags.Select(t => t.TagDefinition.Guid).Contains(td.Guid))
- .Select(td => new Tag() { TagDefinition = td }));
-
- db.Tags.RemoveRange(
- media.Tags.Where(t => !tagIds.Contains(t.TagDefinition.Guid)));
-
- await db.SaveChangesAsync();
- await transaction.CommitAsync();
-
- return Ok(media.Tags.Select(t => (ApiModels.TagDefinition) t.TagDefinition).ToArray());
- }
-
- [HttpPatch("{mediaId}/tags/delete")]
- public async Task<IActionResult> DeleteTagsFromMediaAsync(
- [FromRoute] Guid mediaId,
- [FromBody] Guid[] tagIds) {
-
- using var db = dbFactory.CreateDbContext();
- using var transaction = await db.Database.BeginTransactionAsync();
-
- var media = await db.Media
- .Include(m => m.Tags)
- .ThenInclude(t => t.TagDefinition)
- .ThenInclude(td => td.ImplicitTags)
- .FirstOrDefaultAsync(m => m.Guid == mediaId);
- if(media is null)
- return NotFound();
-
- tagIds = tagIds.Distinct().Order().ToArray();
-
- var missingTags = tagIds.Except(media.Tags.Select(t => t.TagDefinition.Guid));
- var missingTagsString = string.Join(", ", missingTags.Select(t => t.ToString()));
- if(missingTags.Any())
- return BadRequest($"Media does not contain the following tags: {missingTagsString}");
-
- db.Tags.RemoveRange(
- media.Tags.Where(t => tagIds.Contains(t.TagDefinition.Guid)));
-
- await db.SaveChangesAsync();
- await transaction.CommitAsync();
-
- return Ok(media.Tags.Select(t => (ApiModels.TagDefinition) t.TagDefinition).ToArray());
- }
-}
diff --git a/Controllers/ApiTagController.cs b/Controllers/ApiTagController.cs
deleted file mode 100644
index f48cc05..0000000
--- a/Controllers/ApiTagController.cs
+++ /dev/null
@@ -1,253 +0,0 @@
-using HyperBooru.ApiModels;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.EntityFrameworkCore;
-
-namespace HyperBooru.Controllers;
-
-[ApiController]
-[Authorize]
-[Route("/api/tag")]
-public class ApiTagController : Controller {
- private IDbContextFactory<HBContext> dbFactory;
-
- public ApiTagController(IDbContextFactory<HBContext> dbFactory) =>
- this.dbFactory = dbFactory;
-
- [HttpGet("definition")]
- public async Task<IActionResult> GetAllTagDefinitionsAsync() {
- using var db = dbFactory.CreateDbContext();
-
- var definitions = await db.TagDefinitions
- .Include(td => td.ImplicitTags)
- .Select(td => (ApiModels.TagDefinition)td)
- .ToArrayAsync();
-
- return Ok(definitions);
- }
-
- [HttpGet("definition/{tagDefinitionId}")]
- public async Task<IActionResult> GetTagDefinitionAsync([FromRoute] Guid tagDefinitionId) {
- using var db = dbFactory.CreateDbContext();
-
- var tagDefinition = await db.TagDefinitions
- .Include(td => td.ImplicitTags)
- .FirstOrDefaultAsync(td => td.Guid == tagDefinitionId);
-
- return tagDefinition is not null ? Ok(tagDefinition) : NotFound();
- }
-
- [HttpPost("definition")]
- public async Task<IActionResult> CreateTagDefinitionAsync([FromBody] TagCreateRequest request) {
- using var db = dbFactory.CreateDbContext();
- using var transaction = await db.Database.BeginTransactionAsync();
-
- if(db.TagDefinitions.Any(td => td.Name == request.Name))
- return BadRequest("Name already exists");
-
- if(request.Alias is not null)
- if(db.TagDefinitions.Any(td => td.Alias == request.Alias))
- return BadRequest("Alias already exists");
-
- List<TagDefinition> implicitTags = new();
- if(request.ImplicitTags is not null) {
- implicitTags = await db.TagDefinitions
- .Where(td => request.ImplicitTags.Distinct().Contains(td.Guid))
- .ToListAsync();
- }
-
- var tagDefinition = new TagDefinition {
- Source = TagSource.UserTag,
- Namespace = request.Namespace,
- Name = request.Name,
- Alias = request.Alias,
- ImplicitTags = implicitTags
- };
-
- db.TagDefinitions.Add(tagDefinition);
-
- await db.SaveChangesAsync();
- await transaction.CommitAsync();
-
- return Ok((ApiModels.TagDefinition) tagDefinition);
- }
-
- [HttpDelete("definition/{tagDefinitionId}")]
- public async Task<IActionResult> DeleteTagDefinitionAsync([FromRoute] Guid tagDefinitionId) {
- using var db = dbFactory.CreateDbContext();
- using var transaction = await db.Database.BeginTransactionAsync();
-
- var tagDefinition = await db.TagDefinitions
- .FirstOrDefaultAsync(td => td.Guid == tagDefinitionId);
-
- if(tagDefinition is null)
- return NotFound("Tag definition not found");
-
- if(tagDefinition.ObjectId < 0)
- return BadRequest("Cannot delete built-in tag definition");
-
- db.TagDefinitions.Remove(tagDefinition);
-
- await db.SaveChangesAsync();
- await transaction.CommitAsync();
-
- return Ok();
- }
-
- [HttpPatch("definition/{tagDefinitionId}")]
- public async Task<IActionResult> UpdateTagDefinitionAsync(
- [FromRoute] Guid tagDefinitionId,
- [FromBody] TagUpdateRequest request) {
-
- using var db = dbFactory.CreateDbContext();
- using var transaction = await db.Database.BeginTransactionAsync();
-
- var tagDefinition = await db.TagDefinitions
- .FirstOrDefaultAsync(td => td.Guid == tagDefinitionId);
-
- if(tagDefinition is null)
- return NotFound("Tag definition not found");
-
- if(tagDefinition.ObjectId < 0)
- return BadRequest("Cannot update built-in tag definition");
-
- if(request.Name is not null)
- if(db.TagDefinitions.Any(td => td.Name == request.Name))
- return BadRequest("Name already exists");
-
- if(request.Alias is not null)
- if(db.TagDefinitions.Any(td => td.Alias == request.Alias))
- return BadRequest("Alias already exists");
-
- tagDefinition.Namespace = request.Namespace ?? tagDefinition.Namespace;
- tagDefinition.Name = request.Name ?? tagDefinition.Name;
- tagDefinition.Alias = request.Alias ?? tagDefinition.Alias;
-
- await db.SaveChangesAsync();
- await transaction.CommitAsync();
-
- return Ok((ApiModels.TagDefinition) tagDefinition);
- }
-
- [HttpPatch("definition/{tagDefinitionId}/implicit")]
- public async Task<IActionResult> AddImplicitTagsAsync(
- [FromRoute] Guid tagDefinitionId,
- [FromBody] Guid[] implicitTagIds) {
-
- using var db = dbFactory.CreateDbContext();
- using var transaction = await db.Database.BeginTransactionAsync();
-
- var tagDefinition = await db.TagDefinitions
- .Include(td => td.ImplicitTags)
- .FirstOrDefaultAsync(td => td.Guid == tagDefinitionId);
-
- if(tagDefinition is null)
- return NotFound("Tag definition not found");
-
- if(tagDefinition.ObjectId < 0)
- return BadRequest("Cannot update built-in tag definition");
-
- implicitTagIds = implicitTagIds.Distinct().ToArray();
-
- var implicitTags = db.TagDefinitions
- .Where(td => implicitTagIds.Contains(td.Guid))
- .ToArray();
-
- var missingTags = implicitTagIds.Except(implicitTags.Select(td => td.Guid));
- var missingTagsString = string.Join(", ", missingTags.Select(td => td.ToString()));
- if(missingTags.Any())
- return BadRequest($"Invalid tag IDs specified: {missingTagsString}");
-
- tagDefinition.ImplicitTags.AddRange(
- implicitTags.ExceptBy(tagDefinition.ImplicitTags.Select(td => td.Guid), td => td.Guid));
-
- await db.SaveChangesAsync();
- await transaction.CommitAsync();
-
- return Ok();
- }
-
- [HttpPut("definition/{tagDefinitionId}/implicit")]
- public async Task<IActionResult> ReplaceImplicitTagsAsync(
- [FromRoute] Guid tagDefinitionId,
- [FromBody] Guid[] implicitTagIds) {
-
- using var db = dbFactory.CreateDbContext();
- using var transaction = await db.Database.BeginTransactionAsync();
-
- var tagDefinition = await db.TagDefinitions
- .Include(td => td.ImplicitTags)
- .FirstOrDefaultAsync(td => td.Guid == tagDefinitionId);
-
- if(tagDefinition is null)
- return NotFound("Tag definition not found");
-
- if(tagDefinition.ObjectId < 0)
- return BadRequest("Cannot update built-in tag definition");
-
- implicitTagIds = implicitTagIds.Distinct().ToArray();
-
- var implicitTags = db.TagDefinitions
- .Where(td => implicitTagIds.Contains(td.Guid))
- .ToArray();
-
- var missingTags = implicitTagIds.Except(implicitTags.Select(td => td.Guid));
- var missingTagsString = string.Join(", ", missingTags.Select(td => td.ToString()));
- if(missingTags.Any())
- return BadRequest($"Invalid tag IDs specified: {missingTagsString}");
-
- tagDefinition.ImplicitTags.AddRange(
- implicitTags.ExceptBy(tagDefinition.ImplicitTags.Select(td => td.Guid), td => td.Guid));
-
- var toRemove = tagDefinition.ImplicitTags
- .Where(td => !implicitTags.Select(td => td.Guid).Contains(td.Guid))
- .ToArray();
-
- foreach(var td in toRemove)
- tagDefinition.ImplicitTags.Remove(td);
-
- await db.SaveChangesAsync();
- await transaction.CommitAsync();
-
- return Ok();
- }
-
- [HttpPost("definition/{tagDefinitionId}/implicit/delete")]
- public async Task<IActionResult> DeleteImplicitTagAsync(
- [FromRoute] Guid tagDefinitionId,
- [FromBody] Guid[] implicitTagIds) {
-
- using var db = dbFactory.CreateDbContext();
- using var transaction = await db.Database.BeginTransactionAsync();
-
- var tagDefinition = await db.TagDefinitions
- .Include(td => td.ImplicitTags)
- .FirstOrDefaultAsync(td => td.Guid == tagDefinitionId);
-
- if(tagDefinition is null)
- return NotFound("Tag definition not found");
-
- if(tagDefinition.ObjectId < 0)
- return BadRequest("Cannot update built-in tag definition");
-
- implicitTagIds = implicitTagIds.Distinct().ToArray();
-
- var missingTagIds = implicitTagIds
- .Except(tagDefinition.ImplicitTags.Select(td => td.Guid));
- var missingTagsString = string.Join(", ", missingTagIds.Select(td => td.ToString()));
- if(missingTagIds.Any())
- return BadRequest($"Invalid tag IDs specified: {missingTagsString}");
-
- var toRemove = tagDefinition.ImplicitTags
- .Where(td => !implicitTagIds.Contains(td.Guid))
- .ToArray();
-
- foreach(var td in toRemove)
- tagDefinition.ImplicitTags.Remove(td);
-
- await db.SaveChangesAsync();
- await transaction.CommitAsync();
-
- return Ok();
- }
-}
diff --git a/Controllers/ApiUserController.cs b/Controllers/ApiUserController.cs
deleted file mode 100644
index d678287..0000000
--- a/Controllers/ApiUserController.cs
+++ /dev/null
@@ -1,109 +0,0 @@
-using HyperBooru.Services;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.EntityFrameworkCore;
-
-namespace HyperBooru.Controllers;
-
-[ApiController]
-[Authorize]
-[Route("/api/user")]
-public class ApiUserController : Controller {
- private IDbContextFactory<HBContext> dbFactory;
-
- public ApiUserController(IDbContextFactory<HBContext> dbFactory) =>
- this.dbFactory = dbFactory;
-
- [HttpGet]
- public async Task<IActionResult> GetAllUsersAsync() {
- using var db = dbFactory.CreateDbContext();
-
- return Ok(await db.Users
- .Select(u => (ApiModels.User) u)
- .ToArrayAsync());
- }
-
- [HttpGet("{userId}")]
- public async Task<IActionResult> GetUserAsync([FromRoute] Guid userId) {
- using var db = dbFactory.CreateDbContext();
-
- var user = await db.Users
- .FirstOrDefaultAsync(u => u.Guid == userId);
-
- return user is null ? NotFound() : Ok((ApiModels.User) user);
- }
-
- [HttpPost]
- public async Task<IActionResult> CreateUserAsync([FromBody] ApiModels.UserCreateRequest request) {
- using var db = dbFactory.CreateDbContext();
-
- using var transaction = await db.Database.BeginTransactionAsync();
-
- if(await db.Users.AnyAsync(u => u.Username == request.Username))
- return BadRequest("Username already exists");
-
- var user = new User() {
- Username = request.Username,
- PasswordHash = UserService.HashPassword(request.Password)
- };
-
- db.Users.Add(user);
-
- await db.SaveChangesAsync();
- await transaction.CommitAsync();
-
- return Ok((ApiModels.User) user);
- }
-
- [HttpPatch("{userId}")]
- public async Task<IActionResult> UpdateUserAsync(
- [FromRoute] Guid userId,
- [FromBody] ApiModels.UserUpdateRequest request) {
-
- using var db = dbFactory.CreateDbContext();
-
- using var transaction = await db.Database.BeginTransactionAsync();
-
- var user = await db.Users.FirstOrDefaultAsync(u => u.Guid == userId);
- if(user is null)
- return NotFound();
-
- if(request.Username is not null) {
- if(string.IsNullOrWhiteSpace(request.Username))
- return BadRequest("Username cannot be empty");
- user.Username = request.Username;
- }
-
- if(request.Password is not null) {
- if(string.IsNullOrWhiteSpace(request.Password))
- return BadRequest("Password cannot be empty");
- user.PasswordHash = UserService.HashPassword(request.Password);
- }
-
- await db.SaveChangesAsync();
- await transaction.CommitAsync();
-
- return Ok((ApiModels.User) user);
- }
-
- [HttpDelete("{userId}")]
- public async Task<IActionResult> DeleteUserAsync([FromRoute] Guid userId) {
- if(userId == HBContext.AdminUser)
- return BadRequest("Cannot delete the admin user");
-
- using var db = dbFactory.CreateDbContext();
-
- using var transaction = await db.Database.BeginTransactionAsync();
-
- var user = await db.Users.FirstOrDefaultAsync(u => u.Guid == userId);
- if(user is null)
- return NotFound();
-
- db.Users.Remove(user);
-
- await db.SaveChangesAsync();
- await transaction.CommitAsync();
-
- return Ok((ApiModels.User) user);
- }
-}
diff --git a/Controllers/LoginController.cs b/Controllers/LoginController.cs
deleted file mode 100644
index c93f0d5..0000000
--- a/Controllers/LoginController.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using HyperBooru.Services;
-using Microsoft.AspNetCore.Authentication;
-using Microsoft.AspNetCore.Authentication.Cookies;
-using Microsoft.AspNetCore.Mvc;
-using System.Security.Claims;
-
-namespace HyperBooru.Controllers;
-
-[ApiController]
-[Route("/")]
-public class LoginController : Controller {
- private IHttpContextAccessor httpContextAccessor;
-
- public LoginController(IHttpContextAccessor httpContextAccessor) =>
- this.httpContextAccessor = httpContextAccessor;
-
- [HttpPost("Login")]
- public async Task<IActionResult> Login(
- [FromForm] string username,
- [FromForm] string password,
- HBContext db) {
-
- var user = db.Users.FirstOrDefault(u => u.Username == username);
- if(user is null)
- return StatusCode(403);
-
- var hash = UserService.HashPassword(password);
- if(hash != user.PasswordHash)
- return StatusCode(403);
-
- var claims = new Claim[] {
- new Claim(ClaimTypes.Name, user.Username),
- new Claim("ObjectId", user.ObjectId.ToString())
- };
-
- var claimsIdentity = new ClaimsIdentity(
- claims,
- CookieAuthenticationDefaults.AuthenticationScheme);
-
- var claimsPrincipal = new ClaimsPrincipal(claimsIdentity);
-
- await httpContextAccessor.HttpContext!.SignInAsync(claimsPrincipal);
- return Ok();
- }
-
- [HttpPost("Logout")]
- public async Task Logout() =>
- await httpContextAccessor.HttpContext!.SignOutAsync();
-}
diff --git a/Controllers/MediaController.cs b/Controllers/MediaController.cs
deleted file mode 100644
index 6a9e1fc..0000000
--- a/Controllers/MediaController.cs
+++ /dev/null
@@ -1,155 +0,0 @@
-using HyperBooru.ApiModels;
-using HyperBooru.Services;
-using HyperBooru.Util;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.EntityFrameworkCore;
-
-namespace HyperBooru.Controllers;
-
-[ApiController]
-[Authorize]
-[Route("/media")]
-public class MediaController : Controller {
- private IHttpContextAccessor httpContextAccessor;
- private IMediaService mediaService;
- private IConfigService config;
- private HBContext db;
-
- private readonly string[] FormatPriority = [
- "image/webp",
- "image/png"
- ];
-
- public MediaController(
- IHttpContextAccessor httpContextAccessor,
- IMediaService mediaService,
- IConfigService config,
- HBContext db) {
-
- this.httpContextAccessor = httpContextAccessor;
- this.mediaService = mediaService;
- this.config = config;
- this.db = db;
- }
-
- [HttpGet("{mediaId}")]
- public IActionResult Fetch([FromRoute] Guid mediaId) {
- var media = db.Media
- .Include(m => m.CurrentUploadedFile)
- .First(m => m.Guid == mediaId);
- if(media is null)
- return NotFound();
-
- // Check if the requested media item is a HEIC image and if it is, convert it
- // otherwise, return the original file content, unaltered
- if(media.CurrentUploadedFile!.MimeType == "image/heic") {
- // If the media needs to be converted, check the HTTP request for allowed
- // media formats, and convert to the best available format or WebP otherwise
- var allowedTypes = httpContextAccessor
- .HttpContext?
- .Request
- .GetTypedHeaders().Accept.Select(h => h.MediaType.ToString()) ?? Array.Empty<string>();
-
- var format = FormatPriority.FirstOrDefault(f => allowedTypes.Contains(f)) ?? "image/webp";
-
- var fs = mediaService.GetConverted(media, format);
-
- return new FileStreamResult(fs, format);
- } else {
- var fs = System.IO.File.OpenRead(mediaService.GetPath(media));
- return new FileStreamResult(fs, media.CurrentUploadedFile!.MimeType);
- }
- }
-
- [HttpGet("thumb/{mediaId}")]
- public IActionResult Thumbnail(
- [FromRoute] Guid mediaId,
- [FromQuery(Name = "w")] int? width,
- [FromQuery(Name = "h")] int? height) {
-
- try {
- var thumb = mediaService.GetThumbnail(mediaId, width, height);
- return new FileStreamResult(thumb, "image/jpeg");
- } catch(ThumbnailException e) {
- return BadRequest(e.Message);
- } catch(ObjectNotFoundException e) {
- return NotFound(e.Message);
- }
- }
-
- [HttpDelete("{mediaId}")]
- public void Delete([FromRoute] Guid mediaId) {
- mediaService.Delete(mediaId);
- }
-
- [HttpPost]
- public IActionResult Upload() {
- if(Request.Form.Files.Count == 0)
- return BadRequest("No files");
-
- Media media = new();
-
- foreach(var formFile in Request.Form.Files) {
- try {
- // Parse timestamps from headers
- DateTime? lastAccessTime =
- formFile.Headers["X-HyperBooru-LastAccessTime"]
- .ElementAtOrDefault(0)?
- .TryParseDateTimeUtc();
- DateTime? lastWriteTime =
- formFile.Headers["X-HyperBooru-LastWriteTime"]
- .ElementAtOrDefault(0)?
- .TryParseDateTimeUtc();
- DateTime? createTime =
- formFile.Headers["X-HyperBooru-CreateTime"]
- .ElementAtOrDefault(0)?
- .TryParseDateTimeUtc();
-
- // Parse original path from headers
- string? path =
- formFile.Headers["X-HyperBooru-Path"]
- .ElementAtOrDefault(0);
-
- object? pathType = null;
- string? pathTypeString =
- formFile.Headers["X-HyperBooru-PathType"]
- .ElementAtOrDefault(0);
- Enum.TryParse(typeof(PathType), pathTypeString, true, out pathType);
-
- // Parse tag IDs from headers
- Guid[]? tagIds = formFile.Headers["X-HyperBooru-Tags"]
- .ElementAtOrDefault(0)?
- .Split(',')
- .Select(t => Guid.Parse(t))
- .ToArray();
-
- media = mediaService.Create(
- formFile.OpenReadStream(),
- formFile.FileName,
- formFile.Headers["X-HyperBooru-Checksum"]
- .ElementAtOrDefault(0),
- lastAccessTime,
- lastWriteTime,
- createTime,
- path,
- (PathType?) pathType,
- tagIds);
-
- // Return the GUID of the new media object if requested
- bool returnMetadataParsed = bool.TryParse(
- formFile.Headers["X-HyperBooru-ReturnMediaId"], out var returnMetadata);
-
- if(returnMetadataParsed && returnMetadata)
- return Content(media.Guid.ToString());
- } catch(MediaCreateException e) {
- return BadRequest(e.Message);
- }
- }
-
- if(Request.Form.Files.Count == 1)
- return Redirect($"/ViewMedia?m={media.Guid}");
- else
- return Redirect($"/Gallery");
- }
-} \ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
deleted file mode 100644
index 7769bf4..0000000
--- a/Dockerfile
+++ /dev/null
@@ -1,16 +0,0 @@
-FROM mcr.microsoft.com/dotnet/sdk:10.0@sha256:f061e5a7532b36fa1d1b684857fe1f504ba92115b9934f154643266613c44c62 AS build
-WORKDIR /App/Server
-
-COPY Server /App/Server
-COPY ApiModels /App/ApiModels
-RUN dotnet restore
-RUN dotnet publish -o out
-
-FROM mcr.microsoft.com/dotnet/aspnet:10.0@sha256:ccdca44cd4f256d50187f920dc8ccc2a9ea7a8a4597ac1d51e08fddb2e3b3205
-RUN apt update
-RUN apt install -y imagemagick tesseract-ocr tesseract-ocr-eng
-RUN apt clean
-RUN rm -rf /var/lib/apt/lists/*
-WORKDIR /App
-COPY --from=build /App/Server/out .
-ENTRYPOINT [ "dotnet", "HyperBooru.dll" ]
diff --git a/ExceptionMiddleware.cs b/ExceptionMiddleware.cs
deleted file mode 100644
index 29d0e10..0000000
--- a/ExceptionMiddleware.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-using HyperBooru.ApiModels;
-using System.Reflection;
-using System.Text.Json;
-using System.Text.Json.Serialization;
-using System.Text.Json.Serialization.Metadata;
-
-namespace HyperBooru;
-
-// Middleware class to intercept API controller exceptions and
-// return said exceptions to API clients as serialized JSON objects
-public sealed class ExceptionMiddleware {
- private RequestDelegate next;
-
- public ExceptionMiddleware(RequestDelegate next) =>
- this.next = next;
-
- public async Task Invoke(HttpContext context) {
- try {
- await next(context);
- } catch(HBException e) {
- context.Response.ContentType = "application/json";
- context.Response.StatusCode =
- e.GetType().GetCustomAttribute<ExceptionStatusCodeAttribute>()?.StatusCode ??
- StatusCodes.Status500InternalServerError;
-
- await context.Response.WriteAsJsonAsync(e);
-
- var x = 1;
- } catch(Exception) {
- context.Response.StatusCode = StatusCodes.Status500InternalServerError;
- context.Response.ContentType = "application/json";
-
- context.Response.Clear();
-
- await context.Response.WriteAsync(string.Empty);
- }
- }
-}
-
-// This class is needed as the JSON serializer often fails to serialize
-// members of the native 'Exception' class
-public sealed class ExceptionJsonResolver : DefaultJsonTypeInfoResolver {
- public override JsonTypeInfo GetTypeInfo(Type type, JsonSerializerOptions options) {
- var info = base.GetTypeInfo(type, options);
-
- if(!typeof(Exception).IsAssignableFrom(type))
- return info;
-
- string[] excludedProps = [
- "data",
- "hResult",
- "helpLink",
- "innerException",
- "source",
- "stackTrace",
- "targetSite"
- ];
-
- foreach(var p in info.Properties.Where(p => excludedProps.Contains(p.Name)))
- p.ShouldSerialize = (_, _) => false;
-
- return info;
- }
-}
diff --git a/HBContext.cs b/HBContext.cs
deleted file mode 100644
index b684a51..0000000
--- a/HBContext.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-using HyperBooru.Services;
-using Microsoft.EntityFrameworkCore;
-
-namespace HyperBooru;
-
-enum HBObjectId {
- NsfwTag = -1,
- IngestTag = -2,
- AdminUser = -3
-}
-
-public class HBContext : DbContext {
- public static readonly Guid NsfwTag = new("EBDAD4F8-455A-4351-8017-1D4854D6FA38");
- public static readonly Guid IngestTag = new("EA212801-5BCC-4C0E-814F-FB9D30DB58BC");
- public static readonly Guid AdminUser = new("4FA948F4-7C45-4F81-BB6B-E417491E6C96");
-
- public DbSet<HBObject> Objects { get; set; }
- public DbSet<User> Users { get; set; }
- public DbSet<TagDefinition> TagDefinitions { get; set; }
- public DbSet<Tag> Tags { get; set; }
- public DbSet<Media> Media { get; set; }
- public DbSet<UploadedFile> UploadedFiles { get; set; }
- public DbSet<OcrData> OcrData { get; set; }
-
- private IConfigService config;
-
- public HBContext(DbContextOptions<HBContext> options, IConfigService config) : base(options) =>
- this.config = config;
-
- protected override void OnConfiguring(DbContextOptionsBuilder options) {
- options.UseNpgsql(config.DbConnectionString);
-
- #if DEBUG
- options.EnableSensitiveDataLogging();
- #endif
- }
-
- protected override void OnModelCreating(ModelBuilder modelBuilder) {
- // Don't use shared tables for inherited types
- modelBuilder.Entity<HBObject>().ToTable("Objects");
- modelBuilder.Entity<TagDefinition>().ToTable("TagDefinitions");
- modelBuilder.Entity<Tag>().ToTable("Tags");
- modelBuilder.Entity<Media>().ToTable("Media");
- modelBuilder.Entity<UploadedFile>().ToTable("UploadedFiles");
-
- // Seed internal tag definitions
- // These should NEVER change
- modelBuilder.Entity<TagDefinition>().HasData(new TagDefinition[] {
- new() {
- ObjectId = (int) HBObjectId.NsfwTag,
- Guid = NsfwTag,
- Source = TagSource.Internal,
- Name = "nsfw"
- },
- new() {
- ObjectId = (int) HBObjectId.IngestTag,
- Guid = IngestTag,
- Source = TagSource.Internal,
- Name = "ingest"
- }
- });
-
- // Seed initial admin user
- modelBuilder.Entity<User>().HasData(new User[] {
- new() {
- ObjectId = (int) HBObjectId.AdminUser,
- Guid = AdminUser,
- Username = "admin",
- PasswordHash = UserService.HashPassword("admin")
- }
- });
-
- // Some complex relationships cannot be inferred and require
- // additional configuration, as seen below.
- modelBuilder.Entity<TagDefinition>()
- .HasMany(e => e.ImplicitTags)
- .WithMany();
-
- modelBuilder.Entity<Media>()
- .HasOne(m => m.CurrentUploadedFile)
- .WithOne()
- .HasForeignKey<Media>("CurrentUploadedFileId");
- }
-} \ No newline at end of file
diff --git a/HBObject.cs b/HBObject.cs
deleted file mode 100644
index 8001ea3..0000000
--- a/HBObject.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using Microsoft.EntityFrameworkCore;
-using System.ComponentModel.DataAnnotations;
-using System.ComponentModel.DataAnnotations.Schema;
-
-namespace HyperBooru;
-
-[Index(nameof(Guid))]
-public class HBObject {
- [Key]
- [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
- public int ObjectId { get; set; }
- public Guid Guid { get; set; } = Guid.NewGuid();
- public virtual List<Tag> Tags { get; set; } = new();
-} \ No newline at end of file
diff --git a/IDialog.cs b/IDialog.cs
deleted file mode 100644
index 41e86a8..0000000
--- a/IDialog.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace HyperBooru;
-
-public interface IDialog {
- public bool Visible { get; set; }
-
- public void Show();
- public void Hide();
-}
diff --git a/LICENSE.txt b/LICENSE.txt
deleted file mode 100644
index 0ad25db..0000000
--- a/LICENSE.txt
+++ /dev/null
@@ -1,661 +0,0 @@
- GNU AFFERO GENERAL PUBLIC LICENSE
- Version 3, 19 November 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU Affero General Public License is a free, copyleft license for
-software and other kinds of works, specifically designed to ensure
-cooperation with the community in the case of network server software.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-our General Public Licenses are intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- Developers that use our General Public Licenses protect your rights
-with two steps: (1) assert copyright on the software, and (2) offer
-you this License which gives you legal permission to copy, distribute
-and/or modify the software.
-
- A secondary benefit of defending all users' freedom is that
-improvements made in alternate versions of the program, if they
-receive widespread use, become available for other developers to
-incorporate. Many developers of free software are heartened and
-encouraged by the resulting cooperation. However, in the case of
-software used on network servers, this result may fail to come about.
-The GNU General Public License permits making a modified version and
-letting the public access it on a server without ever releasing its
-source code to the public.
-
- The GNU Affero General Public License is designed specifically to
-ensure that, in such cases, the modified source code becomes available
-to the community. It requires the operator of a network server to
-provide the source code of the modified version running there to the
-users of that server. Therefore, public use of a modified version, on
-a publicly accessible server, gives the public access to the source
-code of the modified version.
-
- An older license, called the Affero General Public License and
-published by Affero, was designed to accomplish similar goals. This is
-a different license, not a version of the Affero GPL, but Affero has
-released a new version of the Affero GPL which permits relicensing under
-this license.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU Affero General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Remote Network Interaction; Use with the GNU General Public License.
-
- Notwithstanding any other provision of this License, if you modify the
-Program, your modified version must prominently offer all users
-interacting with it remotely through a computer network (if your version
-supports such interaction) an opportunity to receive the Corresponding
-Source of your version by providing access to the Corresponding Source
-from a network server at no charge, through some standard or customary
-means of facilitating copying of software. This Corresponding Source
-shall include the Corresponding Source for any work covered by version 3
-of the GNU General Public License that is incorporated pursuant to the
-following paragraph.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the work with which it is combined will remain governed by version
-3 of the GNU General Public License.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU Affero General Public License from time to time. Such new versions
-will be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU Affero General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU Affero General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU Affero General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
- If your software can interact with users remotely through a computer
-network, you should also make sure that it provides a way for users to
-get its source. For example, if your program is a web application, its
-interface could display a "Source" link that leads users to an archive
-of the code. There are many ways you could offer source, and different
-solutions will be better for different programs; see section 13 for the
-specific requirements.
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU AGPL, see
-<https://www.gnu.org/licenses/>.
diff --git a/MainLayout.razor b/MainLayout.razor
deleted file mode 100644
index 8e9f6bd..0000000
--- a/MainLayout.razor
+++ /dev/null
@@ -1,11 +0,0 @@
-@inherits LayoutComponentBase
-
-<link href="@(nameof(HyperBooru)).styles.css" rel="stylesheet" />
-
-<Titlebar/>
-
-<MobileMenu/>
-
-<div id="content">
- @Body
-</div>
diff --git a/MainLayout.razor.css b/MainLayout.razor.css
deleted file mode 100644
index c2b5603..0000000
--- a/MainLayout.razor.css
+++ /dev/null
@@ -1,9 +0,0 @@
-div#content {
- flex: 1 1 calc(100vh - 59px);
- overflow-x: hidden;
- overflow-y: auto;
-}
-
-body.mobile-menu-visible div#content {
- display: none;
-}
diff --git a/Media.cs b/Media.cs
deleted file mode 100644
index 2ff9e63..0000000
--- a/Media.cs
+++ /dev/null
@@ -1,92 +0,0 @@
-using HyperBooru.ApiModels;
-using Microsoft.EntityFrameworkCore;
-using System.ComponentModel.DataAnnotations;
-using System.ComponentModel.DataAnnotations.Schema;
-
-namespace HyperBooru;
-
-public class Media : HBObject {
- public string? ShortDescription { get; set; }
- public string? LongDescription { get; set; }
- public virtual OcrData? OcrData { get; set; }
- public virtual UploadedFile? CurrentUploadedFile { get; set; }
- public virtual List<UploadedFile> UploadedFiles { get; set; } = new();
-
- public bool IsIngest => Tags
- .Select(t => t.TagDefinitionId)
- .Contains((int) HBObjectId.IngestTag);
-
- public string? DisplayName {
- get {
- if(ShortDescription is not null)
- return ShortDescription;
-
- return UploadedFiles
- .OrderBy(f => f.UploadTime)
- .First()?.Filename ?? Guid.ToString().ToUpper();
- }
- }
-
- public static explicit operator ApiModels.Media(Media media) =>
- new() {
- MediaId = media.Guid,
- ShortDescription = media.ShortDescription,
- LongDescription = media.LongDescription
- };
-}
-
-public class UploadedFile : HBObject {
- public string Checksum { get; set; }
- public bool ChecksumVerified { get; set; } = false;
- public string? Filename { get; set; }
- public long Length { get; set; }
- public string MimeType { get; set; }
- public int? Width { get; set; }
- public int? Height { get; set; }
- public DateTime UploadTime { get; set; } = DateTime.UtcNow;
- public DateTime? LastAccessTime { get; set; }
- public DateTime? LastWriteTime { get; set; }
- public DateTime? CreateTime { get; set; }
- public string? Path { get; set; }
- public PathType? PathType { get; set; }
- public virtual Media Media { get; set; }
-
- public static explicit operator ApiModels.UploadedFile(UploadedFile uploadedFile) =>
- new() {
- MediaId = uploadedFile.Media.Guid,
- UploadedFileId = uploadedFile.Guid,
- Checksum = uploadedFile.Checksum,
- ChecksumVerified = uploadedFile.ChecksumVerified,
- Filename = uploadedFile.Filename,
- Length = uploadedFile.Length,
- MimeType = uploadedFile.MimeType,
- Width = uploadedFile.Width,
- Height = uploadedFile.Height,
- UploadTime = uploadedFile.UploadTime,
- LastAccessTime = uploadedFile.LastAccessTime,
- LastWriteTime = uploadedFile.LastWriteTime,
- CreateTime = uploadedFile.CreateTime,
- Path = uploadedFile.Path,
- PathType = (ApiModels.PathType?) uploadedFile.PathType
- };
-}
-
-public class OcrData {
- [Key]
- [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
- public int OcrDataId { get; set; }
- [ForeignKey("ObjectId")]
- public int MediaId { get; set; }
- public string Text { get; set; }
- public string SearchableText { get; set; }
- public DateTime Timestamp { get; set; }
- public virtual Media Media { get; set; }
-
- public static explicit operator ApiModels.OcrData(OcrData ocrData) =>
- new() {
- MediaId = ocrData.Media.Guid,
- Text = ocrData.Text,
- SearchableText = ocrData.SearchableText,
- Timestamp = ocrData.Timestamp
- };
-} \ No newline at end of file
diff --git a/Migrations/20260131125650_InitialMigration.Designer.cs b/Migrations/20260131125650_InitialMigration.Designer.cs
deleted file mode 100644
index 2e4a05e..0000000
--- a/Migrations/20260131125650_InitialMigration.Designer.cs
+++ /dev/null
@@ -1,362 +0,0 @@
-// <auto-generated />
-using System;
-using HyperBooru;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
-
-#nullable disable
-
-namespace HyperBooru.Migrations
-{
- [DbContext(typeof(HBContext))]
- [Migration("20260131125650_InitialMigration")]
- partial class InitialMigration
- {
- /// <inheritdoc />
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "8.0.23")
- .HasAnnotation("Relational:MaxIdentifierLength", 63);
-
- NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
-
- modelBuilder.Entity("HyperBooru.HBObject", b =>
- {
- b.Property<int>("ObjectId")
- .ValueGeneratedOnAdd()
- .HasColumnType("integer");
-
- NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("ObjectId"));
-
- b.Property<Guid>("Guid")
- .HasColumnType("uuid");
-
- b.HasKey("ObjectId");
-
- b.HasIndex("Guid");
-
- b.ToTable("Objects", (string)null);
-
- b.UseTptMappingStrategy();
- });
-
- modelBuilder.Entity("HyperBooru.OcrData", b =>
- {
- b.Property<int>("OcrDataId")
- .ValueGeneratedOnAdd()
- .HasColumnType("integer");
-
- NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("OcrDataId"));
-
- b.Property<int>("MediaId")
- .HasColumnType("integer");
-
- b.Property<string>("SearchableText")
- .IsRequired()
- .HasColumnType("text");
-
- b.Property<string>("Text")
- .IsRequired()
- .HasColumnType("text");
-
- b.Property<DateTime>("Timestamp")
- .HasColumnType("timestamp with time zone");
-
- b.HasKey("OcrDataId");
-
- b.HasIndex("MediaId")
- .IsUnique();
-
- b.ToTable("OcrData");
- });
-
- modelBuilder.Entity("TagDefinitionTagDefinition", b =>
- {
- b.Property<int>("ImplicitTagsObjectId")
- .HasColumnType("integer");
-
- b.Property<int>("TagDefinitionObjectId")
- .HasColumnType("integer");
-
- b.HasKey("ImplicitTagsObjectId", "TagDefinitionObjectId");
-
- b.HasIndex("TagDefinitionObjectId");
-
- b.ToTable("TagDefinitionTagDefinition");
- });
-
- modelBuilder.Entity("HyperBooru.Media", b =>
- {
- b.HasBaseType("HyperBooru.HBObject");
-
- b.Property<int?>("CurrentUploadedFileId")
- .HasColumnType("integer");
-
- b.Property<string>("LongDescription")
- .HasColumnType("text");
-
- b.Property<string>("ShortDescription")
- .HasColumnType("text");
-
- b.HasIndex("CurrentUploadedFileId")
- .IsUnique();
-
- b.ToTable("Media", (string)null);
- });
-
- modelBuilder.Entity("HyperBooru.Tag", b =>
- {
- b.HasBaseType("HyperBooru.HBObject");
-
- b.Property<DateTime>("CreateTime")
- .HasColumnType("timestamp with time zone");
-
- b.Property<int>("TagDefinitionId")
- .HasColumnType("integer");
-
- b.Property<int>("TargetObjectId")
- .HasColumnType("integer");
-
- b.HasIndex("TagDefinitionId");
-
- b.HasIndex("TargetObjectId");
-
- b.ToTable("Tags", (string)null);
- });
-
- modelBuilder.Entity("HyperBooru.TagDefinition", b =>
- {
- b.HasBaseType("HyperBooru.HBObject");
-
- b.Property<string>("Alias")
- .HasColumnType("text");
-
- b.Property<string>("Name")
- .IsRequired()
- .HasColumnType("text");
-
- b.Property<string>("Namespace")
- .HasColumnType("text");
-
- b.Property<int>("Source")
- .HasColumnType("integer");
-
- b.ToTable("TagDefinitions", (string)null);
-
- b.HasData(
- new
- {
- ObjectId = -1,
- Guid = new Guid("ebdad4f8-455a-4351-8017-1d4854d6fa38"),
- Name = "nsfw",
- Source = 0
- },
- new
- {
- ObjectId = -2,
- Guid = new Guid("ea212801-5bcc-4c0e-814f-fb9d30db58bc"),
- Name = "ingest",
- Source = 0
- });
- });
-
- modelBuilder.Entity("HyperBooru.UploadedFile", b =>
- {
- b.HasBaseType("HyperBooru.HBObject");
-
- b.Property<string>("Checksum")
- .IsRequired()
- .HasColumnType("text");
-
- b.Property<bool>("ChecksumVerified")
- .HasColumnType("boolean");
-
- b.Property<DateTime?>("CreateTime")
- .HasColumnType("timestamp with time zone");
-
- b.Property<string>("Filename")
- .HasColumnType("text");
-
- b.Property<int?>("Height")
- .HasColumnType("integer");
-
- b.Property<DateTime?>("LastAccessTime")
- .HasColumnType("timestamp with time zone");
-
- b.Property<DateTime?>("LastWriteTime")
- .HasColumnType("timestamp with time zone");
-
- b.Property<long>("Length")
- .HasColumnType("bigint");
-
- b.Property<int>("MediaObjectId")
- .HasColumnType("integer");
-
- b.Property<string>("MimeType")
- .IsRequired()
- .HasColumnType("text");
-
- b.Property<string>("Path")
- .HasColumnType("text");
-
- b.Property<int?>("PathType")
- .HasColumnType("integer");
-
- b.Property<DateTime>("UploadTime")
- .HasColumnType("timestamp with time zone");
-
- b.Property<int?>("Width")
- .HasColumnType("integer");
-
- b.HasIndex("MediaObjectId");
-
- b.ToTable("UploadedFiles", (string)null);
- });
-
- modelBuilder.Entity("HyperBooru.User", b =>
- {
- b.HasBaseType("HyperBooru.HBObject");
-
- b.Property<string>("PasswordHash")
- .IsRequired()
- .HasColumnType("text");
-
- b.Property<string>("Username")
- .IsRequired()
- .HasColumnType("text");
-
- b.HasIndex("Username");
-
- b.ToTable("Users");
-
- b.HasData(
- new
- {
- ObjectId = -3,
- Guid = new Guid("4fa948f4-7c45-4f81-bb6b-e417491e6c96"),
- PasswordHash = "P4geAuE2yX/PDRHuJSq74FF5vO782rWz5c0LAQPR8m45DEYAONhu1wYnAn60PSNyjocqEBdnCeKCJfK3sKyuWw==",
- Username = "admin"
- });
- });
-
- modelBuilder.Entity("HyperBooru.OcrData", b =>
- {
- b.HasOne("HyperBooru.Media", "Media")
- .WithOne("OcrData")
- .HasForeignKey("HyperBooru.OcrData", "MediaId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Media");
- });
-
- modelBuilder.Entity("TagDefinitionTagDefinition", b =>
- {
- b.HasOne("HyperBooru.TagDefinition", null)
- .WithMany()
- .HasForeignKey("ImplicitTagsObjectId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("HyperBooru.TagDefinition", null)
- .WithMany()
- .HasForeignKey("TagDefinitionObjectId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("HyperBooru.Media", b =>
- {
- b.HasOne("HyperBooru.UploadedFile", "CurrentUploadedFile")
- .WithOne()
- .HasForeignKey("HyperBooru.Media", "CurrentUploadedFileId");
-
- b.HasOne("HyperBooru.HBObject", null)
- .WithOne()
- .HasForeignKey("HyperBooru.Media", "ObjectId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("CurrentUploadedFile");
- });
-
- modelBuilder.Entity("HyperBooru.Tag", b =>
- {
- b.HasOne("HyperBooru.HBObject", null)
- .WithOne()
- .HasForeignKey("HyperBooru.Tag", "ObjectId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("HyperBooru.TagDefinition", "TagDefinition")
- .WithMany()
- .HasForeignKey("TagDefinitionId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("HyperBooru.HBObject", "Target")
- .WithMany("Tags")
- .HasForeignKey("TargetObjectId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("TagDefinition");
-
- b.Navigation("Target");
- });
-
- modelBuilder.Entity("HyperBooru.TagDefinition", b =>
- {
- b.HasOne("HyperBooru.HBObject", null)
- .WithOne()
- .HasForeignKey("HyperBooru.TagDefinition", "ObjectId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("HyperBooru.UploadedFile", b =>
- {
- b.HasOne("HyperBooru.Media", "Media")
- .WithMany("UploadedFiles")
- .HasForeignKey("MediaObjectId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("HyperBooru.HBObject", null)
- .WithOne()
- .HasForeignKey("HyperBooru.UploadedFile", "ObjectId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Media");
- });
-
- modelBuilder.Entity("HyperBooru.User", b =>
- {
- b.HasOne("HyperBooru.HBObject", null)
- .WithOne()
- .HasForeignKey("HyperBooru.User", "ObjectId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("HyperBooru.HBObject", b =>
- {
- b.Navigation("Tags");
- });
-
- modelBuilder.Entity("HyperBooru.Media", b =>
- {
- b.Navigation("OcrData");
-
- b.Navigation("UploadedFiles");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/Migrations/20260131125650_InitialMigration.cs b/Migrations/20260131125650_InitialMigration.cs
deleted file mode 100644
index a1a7d8f..0000000
--- a/Migrations/20260131125650_InitialMigration.cs
+++ /dev/null
@@ -1,319 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
-
-#nullable disable
-
-#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
-
-namespace HyperBooru.Migrations
-{
- /// <inheritdoc />
- public partial class InitialMigration : Migration
- {
- /// <inheritdoc />
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "Objects",
- columns: table => new
- {
- ObjectId = table.Column<int>(type: "integer", nullable: false)
- .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
- Guid = table.Column<Guid>(type: "uuid", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Objects", x => x.ObjectId);
- });
-
- migrationBuilder.CreateTable(
- name: "TagDefinitions",
- columns: table => new
- {
- ObjectId = table.Column<int>(type: "integer", nullable: false),
- Source = table.Column<int>(type: "integer", nullable: false),
- Namespace = table.Column<string>(type: "text", nullable: true),
- Name = table.Column<string>(type: "text", nullable: false),
- Alias = table.Column<string>(type: "text", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_TagDefinitions", x => x.ObjectId);
- table.ForeignKey(
- name: "FK_TagDefinitions_Objects_ObjectId",
- column: x => x.ObjectId,
- principalTable: "Objects",
- principalColumn: "ObjectId",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateTable(
- name: "Users",
- columns: table => new
- {
- ObjectId = table.Column<int>(type: "integer", nullable: false),
- Username = table.Column<string>(type: "text", nullable: false),
- PasswordHash = table.Column<string>(type: "text", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Users", x => x.ObjectId);
- table.ForeignKey(
- name: "FK_Users_Objects_ObjectId",
- column: x => x.ObjectId,
- principalTable: "Objects",
- principalColumn: "ObjectId",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateTable(
- name: "TagDefinitionTagDefinition",
- columns: table => new
- {
- ImplicitTagsObjectId = table.Column<int>(type: "integer", nullable: false),
- TagDefinitionObjectId = table.Column<int>(type: "integer", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_TagDefinitionTagDefinition", x => new { x.ImplicitTagsObjectId, x.TagDefinitionObjectId });
- table.ForeignKey(
- name: "FK_TagDefinitionTagDefinition_TagDefinitions_ImplicitTagsObjec~",
- column: x => x.ImplicitTagsObjectId,
- principalTable: "TagDefinitions",
- principalColumn: "ObjectId",
- onDelete: ReferentialAction.Cascade);
- table.ForeignKey(
- name: "FK_TagDefinitionTagDefinition_TagDefinitions_TagDefinitionObje~",
- column: x => x.TagDefinitionObjectId,
- principalTable: "TagDefinitions",
- principalColumn: "ObjectId",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateTable(
- name: "Tags",
- columns: table => new
- {
- ObjectId = table.Column<int>(type: "integer", nullable: false),
- TagDefinitionId = table.Column<int>(type: "integer", nullable: false),
- CreateTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
- TargetObjectId = table.Column<int>(type: "integer", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Tags", x => x.ObjectId);
- table.ForeignKey(
- name: "FK_Tags_Objects_ObjectId",
- column: x => x.ObjectId,
- principalTable: "Objects",
- principalColumn: "ObjectId",
- onDelete: ReferentialAction.Cascade);
- table.ForeignKey(
- name: "FK_Tags_Objects_TargetObjectId",
- column: x => x.TargetObjectId,
- principalTable: "Objects",
- principalColumn: "ObjectId",
- onDelete: ReferentialAction.Cascade);
- table.ForeignKey(
- name: "FK_Tags_TagDefinitions_TagDefinitionId",
- column: x => x.TagDefinitionId,
- principalTable: "TagDefinitions",
- principalColumn: "ObjectId",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateTable(
- name: "Media",
- columns: table => new
- {
- ObjectId = table.Column<int>(type: "integer", nullable: false),
- ShortDescription = table.Column<string>(type: "text", nullable: true),
- LongDescription = table.Column<string>(type: "text", nullable: true),
- CurrentUploadedFileId = table.Column<int>(type: "integer", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Media", x => x.ObjectId);
- table.ForeignKey(
- name: "FK_Media_Objects_ObjectId",
- column: x => x.ObjectId,
- principalTable: "Objects",
- principalColumn: "ObjectId",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateTable(
- name: "OcrData",
- columns: table => new
- {
- OcrDataId = table.Column<int>(type: "integer", nullable: false)
- .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
- MediaId = table.Column<int>(type: "integer", nullable: false),
- Text = table.Column<string>(type: "text", nullable: false),
- SearchableText = table.Column<string>(type: "text", nullable: false),
- Timestamp = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_OcrData", x => x.OcrDataId);
- table.ForeignKey(
- name: "FK_OcrData_Media_MediaId",
- column: x => x.MediaId,
- principalTable: "Media",
- principalColumn: "ObjectId",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateTable(
- name: "UploadedFiles",
- columns: table => new
- {
- ObjectId = table.Column<int>(type: "integer", nullable: false),
- Checksum = table.Column<string>(type: "text", nullable: false),
- ChecksumVerified = table.Column<bool>(type: "boolean", nullable: false),
- Filename = table.Column<string>(type: "text", nullable: true),
- Length = table.Column<long>(type: "bigint", nullable: false),
- MimeType = table.Column<string>(type: "text", nullable: false),
- Width = table.Column<int>(type: "integer", nullable: true),
- Height = table.Column<int>(type: "integer", nullable: true),
- UploadTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
- LastAccessTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
- LastWriteTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
- CreateTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
- Path = table.Column<string>(type: "text", nullable: true),
- PathType = table.Column<int>(type: "integer", nullable: true),
- MediaObjectId = table.Column<int>(type: "integer", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_UploadedFiles", x => x.ObjectId);
- table.ForeignKey(
- name: "FK_UploadedFiles_Media_MediaObjectId",
- column: x => x.MediaObjectId,
- principalTable: "Media",
- principalColumn: "ObjectId",
- onDelete: ReferentialAction.Cascade);
- table.ForeignKey(
- name: "FK_UploadedFiles_Objects_ObjectId",
- column: x => x.ObjectId,
- principalTable: "Objects",
- principalColumn: "ObjectId",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.InsertData(
- table: "Objects",
- columns: new[] { "ObjectId", "Guid" },
- values: new object[,]
- {
- { -3, new Guid("4fa948f4-7c45-4f81-bb6b-e417491e6c96") },
- { -2, new Guid("ea212801-5bcc-4c0e-814f-fb9d30db58bc") },
- { -1, new Guid("ebdad4f8-455a-4351-8017-1d4854d6fa38") }
- });
-
- migrationBuilder.InsertData(
- table: "TagDefinitions",
- columns: new[] { "ObjectId", "Alias", "Name", "Namespace", "Source" },
- values: new object[,]
- {
- { -2, null, "ingest", null, 0 },
- { -1, null, "nsfw", null, 0 }
- });
-
- migrationBuilder.InsertData(
- table: "Users",
- columns: new[] { "ObjectId", "PasswordHash", "Username" },
- values: new object[] { -3, "P4geAuE2yX/PDRHuJSq74FF5vO782rWz5c0LAQPR8m45DEYAONhu1wYnAn60PSNyjocqEBdnCeKCJfK3sKyuWw==", "admin" });
-
- migrationBuilder.CreateIndex(
- name: "IX_Media_CurrentUploadedFileId",
- table: "Media",
- column: "CurrentUploadedFileId",
- unique: true);
-
- migrationBuilder.CreateIndex(
- name: "IX_Objects_Guid",
- table: "Objects",
- column: "Guid");
-
- migrationBuilder.CreateIndex(
- name: "IX_OcrData_MediaId",
- table: "OcrData",
- column: "MediaId",
- unique: true);
-
- migrationBuilder.CreateIndex(
- name: "IX_TagDefinitionTagDefinition_TagDefinitionObjectId",
- table: "TagDefinitionTagDefinition",
- column: "TagDefinitionObjectId");
-
- migrationBuilder.CreateIndex(
- name: "IX_Tags_TagDefinitionId",
- table: "Tags",
- column: "TagDefinitionId");
-
- migrationBuilder.CreateIndex(
- name: "IX_Tags_TargetObjectId",
- table: "Tags",
- column: "TargetObjectId");
-
- migrationBuilder.CreateIndex(
- name: "IX_UploadedFiles_MediaObjectId",
- table: "UploadedFiles",
- column: "MediaObjectId");
-
- migrationBuilder.CreateIndex(
- name: "IX_Users_Username",
- table: "Users",
- column: "Username");
-
- migrationBuilder.AddForeignKey(
- name: "FK_Media_UploadedFiles_CurrentUploadedFileId",
- table: "Media",
- column: "CurrentUploadedFileId",
- principalTable: "UploadedFiles",
- principalColumn: "ObjectId");
- }
-
- /// <inheritdoc />
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropForeignKey(
- name: "FK_Media_Objects_ObjectId",
- table: "Media");
-
- migrationBuilder.DropForeignKey(
- name: "FK_UploadedFiles_Objects_ObjectId",
- table: "UploadedFiles");
-
- migrationBuilder.DropForeignKey(
- name: "FK_Media_UploadedFiles_CurrentUploadedFileId",
- table: "Media");
-
- migrationBuilder.DropTable(
- name: "OcrData");
-
- migrationBuilder.DropTable(
- name: "TagDefinitionTagDefinition");
-
- migrationBuilder.DropTable(
- name: "Tags");
-
- migrationBuilder.DropTable(
- name: "Users");
-
- migrationBuilder.DropTable(
- name: "TagDefinitions");
-
- migrationBuilder.DropTable(
- name: "Objects");
-
- migrationBuilder.DropTable(
- name: "UploadedFiles");
-
- migrationBuilder.DropTable(
- name: "Media");
- }
- }
-}
diff --git a/Migrations/HBContextModelSnapshot.cs b/Migrations/HBContextModelSnapshot.cs
deleted file mode 100644
index 422037f..0000000
--- a/Migrations/HBContextModelSnapshot.cs
+++ /dev/null
@@ -1,359 +0,0 @@
-// <auto-generated />
-using System;
-using HyperBooru;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
-
-#nullable disable
-
-namespace HyperBooru.Migrations
-{
- [DbContext(typeof(HBContext))]
- partial class HBContextModelSnapshot : ModelSnapshot
- {
- protected override void BuildModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "8.0.23")
- .HasAnnotation("Relational:MaxIdentifierLength", 63);
-
- NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
-
- modelBuilder.Entity("HyperBooru.HBObject", b =>
- {
- b.Property<int>("ObjectId")
- .ValueGeneratedOnAdd()
- .HasColumnType("integer");
-
- NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("ObjectId"));
-
- b.Property<Guid>("Guid")
- .HasColumnType("uuid");
-
- b.HasKey("ObjectId");
-
- b.HasIndex("Guid");
-
- b.ToTable("Objects", (string)null);
-
- b.UseTptMappingStrategy();
- });
-
- modelBuilder.Entity("HyperBooru.OcrData", b =>
- {
- b.Property<int>("OcrDataId")
- .ValueGeneratedOnAdd()
- .HasColumnType("integer");
-
- NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("OcrDataId"));
-
- b.Property<int>("MediaId")
- .HasColumnType("integer");
-
- b.Property<string>("SearchableText")
- .IsRequired()
- .HasColumnType("text");
-
- b.Property<string>("Text")
- .IsRequired()
- .HasColumnType("text");
-
- b.Property<DateTime>("Timestamp")
- .HasColumnType("timestamp with time zone");
-
- b.HasKey("OcrDataId");
-
- b.HasIndex("MediaId")
- .IsUnique();
-
- b.ToTable("OcrData");
- });
-
- modelBuilder.Entity("TagDefinitionTagDefinition", b =>
- {
- b.Property<int>("ImplicitTagsObjectId")
- .HasColumnType("integer");
-
- b.Property<int>("TagDefinitionObjectId")
- .HasColumnType("integer");
-
- b.HasKey("ImplicitTagsObjectId", "TagDefinitionObjectId");
-
- b.HasIndex("TagDefinitionObjectId");
-
- b.ToTable("TagDefinitionTagDefinition");
- });
-
- modelBuilder.Entity("HyperBooru.Media", b =>
- {
- b.HasBaseType("HyperBooru.HBObject");
-
- b.Property<int?>("CurrentUploadedFileId")
- .HasColumnType("integer");
-
- b.Property<string>("LongDescription")
- .HasColumnType("text");
-
- b.Property<string>("ShortDescription")
- .HasColumnType("text");
-
- b.HasIndex("CurrentUploadedFileId")
- .IsUnique();
-
- b.ToTable("Media", (string)null);
- });
-
- modelBuilder.Entity("HyperBooru.Tag", b =>
- {
- b.HasBaseType("HyperBooru.HBObject");
-
- b.Property<DateTime>("CreateTime")
- .HasColumnType("timestamp with time zone");
-
- b.Property<int>("TagDefinitionId")
- .HasColumnType("integer");
-
- b.Property<int>("TargetObjectId")
- .HasColumnType("integer");
-
- b.HasIndex("TagDefinitionId");
-
- b.HasIndex("TargetObjectId");
-
- b.ToTable("Tags", (string)null);
- });
-
- modelBuilder.Entity("HyperBooru.TagDefinition", b =>
- {
- b.HasBaseType("HyperBooru.HBObject");
-
- b.Property<string>("Alias")
- .HasColumnType("text");
-
- b.Property<string>("Name")
- .IsRequired()
- .HasColumnType("text");
-
- b.Property<string>("Namespace")
- .HasColumnType("text");
-
- b.Property<int>("Source")
- .HasColumnType("integer");
-
- b.ToTable("TagDefinitions", (string)null);
-
- b.HasData(
- new
- {
- ObjectId = -1,
- Guid = new Guid("ebdad4f8-455a-4351-8017-1d4854d6fa38"),
- Name = "nsfw",
- Source = 0
- },
- new
- {
- ObjectId = -2,
- Guid = new Guid("ea212801-5bcc-4c0e-814f-fb9d30db58bc"),
- Name = "ingest",
- Source = 0
- });
- });
-
- modelBuilder.Entity("HyperBooru.UploadedFile", b =>
- {
- b.HasBaseType("HyperBooru.HBObject");
-
- b.Property<string>("Checksum")
- .IsRequired()
- .HasColumnType("text");
-
- b.Property<bool>("ChecksumVerified")
- .HasColumnType("boolean");
-
- b.Property<DateTime?>("CreateTime")
- .HasColumnType("timestamp with time zone");
-
- b.Property<string>("Filename")
- .HasColumnType("text");
-
- b.Property<int?>("Height")
- .HasColumnType("integer");
-
- b.Property<DateTime?>("LastAccessTime")
- .HasColumnType("timestamp with time zone");
-
- b.Property<DateTime?>("LastWriteTime")
- .HasColumnType("timestamp with time zone");
-
- b.Property<long>("Length")
- .HasColumnType("bigint");
-
- b.Property<int>("MediaObjectId")
- .HasColumnType("integer");
-
- b.Property<string>("MimeType")
- .IsRequired()
- .HasColumnType("text");
-
- b.Property<string>("Path")
- .HasColumnType("text");
-
- b.Property<int?>("PathType")
- .HasColumnType("integer");
-
- b.Property<DateTime>("UploadTime")
- .HasColumnType("timestamp with time zone");
-
- b.Property<int?>("Width")
- .HasColumnType("integer");
-
- b.HasIndex("MediaObjectId");
-
- b.ToTable("UploadedFiles", (string)null);
- });
-
- modelBuilder.Entity("HyperBooru.User", b =>
- {
- b.HasBaseType("HyperBooru.HBObject");
-
- b.Property<string>("PasswordHash")
- .IsRequired()
- .HasColumnType("text");
-
- b.Property<string>("Username")
- .IsRequired()
- .HasColumnType("text");
-
- b.HasIndex("Username");
-
- b.ToTable("Users");
-
- b.HasData(
- new
- {
- ObjectId = -3,
- Guid = new Guid("4fa948f4-7c45-4f81-bb6b-e417491e6c96"),
- PasswordHash = "P4geAuE2yX/PDRHuJSq74FF5vO782rWz5c0LAQPR8m45DEYAONhu1wYnAn60PSNyjocqEBdnCeKCJfK3sKyuWw==",
- Username = "admin"
- });
- });
-
- modelBuilder.Entity("HyperBooru.OcrData", b =>
- {
- b.HasOne("HyperBooru.Media", "Media")
- .WithOne("OcrData")
- .HasForeignKey("HyperBooru.OcrData", "MediaId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Media");
- });
-
- modelBuilder.Entity("TagDefinitionTagDefinition", b =>
- {
- b.HasOne("HyperBooru.TagDefinition", null)
- .WithMany()
- .HasForeignKey("ImplicitTagsObjectId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("HyperBooru.TagDefinition", null)
- .WithMany()
- .HasForeignKey("TagDefinitionObjectId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("HyperBooru.Media", b =>
- {
- b.HasOne("HyperBooru.UploadedFile", "CurrentUploadedFile")
- .WithOne()
- .HasForeignKey("HyperBooru.Media", "CurrentUploadedFileId");
-
- b.HasOne("HyperBooru.HBObject", null)
- .WithOne()
- .HasForeignKey("HyperBooru.Media", "ObjectId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("CurrentUploadedFile");
- });
-
- modelBuilder.Entity("HyperBooru.Tag", b =>
- {
- b.HasOne("HyperBooru.HBObject", null)
- .WithOne()
- .HasForeignKey("HyperBooru.Tag", "ObjectId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("HyperBooru.TagDefinition", "TagDefinition")
- .WithMany()
- .HasForeignKey("TagDefinitionId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("HyperBooru.HBObject", "Target")
- .WithMany("Tags")
- .HasForeignKey("TargetObjectId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("TagDefinition");
-
- b.Navigation("Target");
- });
-
- modelBuilder.Entity("HyperBooru.TagDefinition", b =>
- {
- b.HasOne("HyperBooru.HBObject", null)
- .WithOne()
- .HasForeignKey("HyperBooru.TagDefinition", "ObjectId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("HyperBooru.UploadedFile", b =>
- {
- b.HasOne("HyperBooru.Media", "Media")
- .WithMany("UploadedFiles")
- .HasForeignKey("MediaObjectId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("HyperBooru.HBObject", null)
- .WithOne()
- .HasForeignKey("HyperBooru.UploadedFile", "ObjectId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Media");
- });
-
- modelBuilder.Entity("HyperBooru.User", b =>
- {
- b.HasOne("HyperBooru.HBObject", null)
- .WithOne()
- .HasForeignKey("HyperBooru.User", "ObjectId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("HyperBooru.HBObject", b =>
- {
- b.Navigation("Tags");
- });
-
- modelBuilder.Entity("HyperBooru.Media", b =>
- {
- b.Navigation("OcrData");
-
- b.Navigation("UploadedFiles");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/Server.csproj b/OldServer.csproj
index 45bb9bd..2ac3891 100644
--- a/Server.csproj
+++ b/OldServer.csproj
@@ -36,22 +36,4 @@
<None Remove="Data/**" />
</ItemGroup>
- <ItemGroup>
- <PackageReference Include="Magick.NET-Q16-AnyCPU" Version="14.13.0" />
- <PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.7" />
- <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.7">
- <PrivateAssets>all</PrivateAssets>
- <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
- </PackageReference>
- <PackageReference Include="Mime-Detective" Version="25.8.1" />
- <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.1" />
- <PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.7" />
- <PackageReference Include="System.Drawing.Common" Version="10.0.7" />
- <PackageReference Include="Tesseract" Version="5.2.0" />
- </ItemGroup>
-
- <ItemGroup>
- <ProjectReference Include="..\ApiModels\ApiModels.csproj" />
- </ItemGroup>
-
</Project>
diff --git a/Pages/Component/AboutDialog.razor b/Pages/Component/AboutDialog.razor
deleted file mode 100644
index 1229dc7..0000000
--- a/Pages/Component/AboutDialog.razor
+++ /dev/null
@@ -1,736 +0,0 @@
-@using System.Reflection
-@using Microsoft.AspNetCore.Hosting
-@inject IDbContextFactory<HBContext> dbFactory
-@inject IHostingEnvironment hostingEnvironment
-@implements IDialog
-
-<Dialog @ref=dialog>
- <p id="title">@Title</p>
- <p id="author">Created by Jake Mannens</p>
- <div id="license">
- <center>GNU AFFERO GENERAL PUBLIC LICENSE</center><br/>
- <center>Version 3, 19 November 2007</center>
- <br/><br/>
- Copyright (C) 2007 Free Software Foundation, Inc.
- &lt<a href="https://fsf.org/" target="_blank">https://fsf.org/</a>&gt
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
- <br/><br/>
- <center>Preamble</center>
- <br/><br/>
- The GNU Affero General Public License is a free, copyleft license for
- software and other kinds of works, specifically designed to ensure
- cooperation with the community in the case of network server software.
- <br/><br/>
- The licenses for most software and other practical works are designed
- to take away your freedom to share and change the works. By contrast,
- our General Public Licenses are intended to guarantee your freedom to
- share and change all versions of a program--to make sure it remains free
- software for all its users.
- <br/><br/>
- When we speak of free software, we are referring to freedom, not
- price. Our General Public Licenses are designed to make sure that you
- have the freedom to distribute copies of free software (and charge for
- them if you wish), that you receive source code or can get it if you
- want it, that you can change the software or use pieces of it in new
- free programs, and that you know you can do these things.
- <br/><br/>
- Developers that use our General Public Licenses protect your rights
- with two steps: (1) assert copyright on the software, and (2) offer
- you this License which gives you legal permission to copy, distribute
- and/or modify the software.
- <br/><br/>
- A secondary benefit of defending all users' freedom is that
- improvements made in alternate versions of the program, if they
- receive widespread use, become available for other developers to
- incorporate. Many developers of free software are heartened and
- encouraged by the resulting cooperation. However, in the case of
- software used on network servers, this result may fail to come about.
- The GNU General Public License permits making a modified version and
- letting the public access it on a server without ever releasing its
- source code to the public.
- <br/><br/>
- The GNU Affero General Public License is designed specifically to
- ensure that, in such cases, the modified source code becomes available
- to the community. It requires the operator of a network server to
- provide the source code of the modified version running there to the
- users of that server. Therefore, public use of a modified version, on
- a publicly accessible server, gives the public access to the source
- code of the modified version.
- <br/><br/>
- An older license, called the Affero General Public License and
- published by Affero, was designed to accomplish similar goals. This is
- a different license, not a version of the Affero GPL, but Affero has
- released a new version of the Affero GPL which permits relicensing under
- this license.
- <br/><br/>
- The precise terms and conditions for copying, distribution and
- modification follow.
- <br/><br/>
- <center>TERMS AND CONDITIONS</center>
- <br/><br/>
- 0. Definitions.
- <br/><br/>
- "This License" refers to version 3 of the GNU Affero General Public License.
- <br/><br/>
- "Copyright" also means copyright-like laws that apply to other kinds of
- works, such as semiconductor masks.
- <br/><br/>
- "The Program" refers to any copyrightable work licensed under this
- License. Each licensee is addressed as "you". "Licensees" and
- "recipients" may be individuals or organizations.
- <br/><br/>
- To "modify" a work means to copy from or adapt all or part of the work
- in a fashion requiring copyright permission, other than the making of an
- exact copy. The resulting work is called a "modified version" of the
- earlier work or a work "based on" the earlier work.
- <br/><br/>
- A "covered work" means either the unmodified Program or a work based
- on the Program.
- <br/><br/>
- To "propagate" a work means to do anything with it that, without
- permission, would make you directly or secondarily liable for
- infringement under applicable copyright law, except executing it on a
- computer or modifying a private copy. Propagation includes copying,
- distribution (with or without modification), making available to the
- public, and in some countries other activities as well.
- <br/><br/>
- To "convey" a work means any kind of propagation that enables other
- parties to make or receive copies. Mere interaction with a user through
- a computer network, with no transfer of a copy, is not conveying.
- <br/><br/>
- An interactive user interface displays "Appropriate Legal Notices"
- to the extent that it includes a convenient and prominently visible
- feature that (1) displays an appropriate copyright notice, and (2)
- tells the user that there is no warranty for the work (except to the
- extent that warranties are provided), that licensees may convey the
- work under this License, and how to view a copy of this License. If
- the interface presents a list of user commands or options, such as a
- menu, a prominent item in the list meets this criterion.
- <br/><br/>
- 1. Source Code.
- <br/><br/>
- The "source code" for a work means the preferred form of the work
- for making modifications to it. "Object code" means any non-source
- form of a work.
- <br/><br/>
- A "Standard Interface" means an interface that either is an official
- standard defined by a recognized standards body, or, in the case of
- interfaces specified for a particular programming language, one that
- is widely used among developers working in that language.
- <br/><br/>
- The "System Libraries" of an executable work include anything, other
- than the work as a whole, that (a) is included in the normal form of
- packaging a Major Component, but which is not part of that Major
- Component, and (b) serves only to enable use of the work with that
- Major Component, or to implement a Standard Interface for which an
- implementation is available to the public in source code form. A
- "Major Component", in this context, means a major essential component
- (kernel, window system, and so on) of the specific operating system
- (if any) on which the executable work runs, or a compiler used to
- produce the work, or an object code interpreter used to run it.
- <br/><br/>
- The "Corresponding Source" for a work in object code form means all
- the source code needed to generate, install, and (for an executable
- work) run the object code and to modify the work, including scripts to
- control those activities. However, it does not include the work's
- System Libraries, or general-purpose tools or generally available free
- programs which are used unmodified in performing those activities but
- which are not part of the work. For example, Corresponding Source
- includes interface definition files associated with source files for
- the work, and the source code for shared libraries and dynamically
- linked subprograms that the work is specifically designed to require,
- such as by intimate data communication or control flow between those
- subprograms and other parts of the work.
- <br/><br/>
- The Corresponding Source need not include anything that users
- can regenerate automatically from other parts of the Corresponding
- Source.
- <br/><br/>
- The Corresponding Source for a work in source code form is that
- same work.
- <br/><br/>
- 2. Basic Permissions.
- <br/><br/>
- All rights granted under this License are granted for the term of
- copyright on the Program, and are irrevocable provided the stated
- conditions are met. This License explicitly affirms your unlimited
- permission to run the unmodified Program. The output from running a
- covered work is covered by this License only if the output, given its
- content, constitutes a covered work. This License acknowledges your
- rights of fair use or other equivalent, as provided by copyright law.
- <br/><br/>
- You may make, run and propagate covered works that you do not
- convey, without conditions so long as your license otherwise remains
- in force. You may convey covered works to others for the sole purpose
- of having them make modifications exclusively for you, or provide you
- with facilities for running those works, provided that you comply with
- the terms of this License in conveying all material for which you do
- not control copyright. Those thus making or running the covered works
- for you must do so exclusively on your behalf, under your direction
- and control, on terms that prohibit them from making any copies of
- your copyrighted material outside their relationship with you.
- <br/><br/>
- Conveying under any other circumstances is permitted solely under
- the conditions stated below. Sublicensing is not allowed; section 10
- makes it unnecessary.
- <br/><br/>
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
- <br/><br/>
- No covered work shall be deemed part of an effective technological
- measure under any applicable law fulfilling obligations under article
- 11 of the WIPO copyright treaty adopted on 20 December 1996, or
- similar laws prohibiting or restricting circumvention of such
- measures.
- <br/><br/>
- When you convey a covered work, you waive any legal power to forbid
- circumvention of technological measures to the extent such circumvention
- is effected by exercising rights under this License with respect to
- the covered work, and you disclaim any intention to limit operation or
- modification of the work as a means of enforcing, against the work's
- users, your or third parties' legal rights to forbid circumvention of
- technological measures.
- <br/><br/>
- 4. Conveying Verbatim Copies.
- <br/><br/>
- You may convey verbatim copies of the Program's source code as you
- receive it, in any medium, provided that you conspicuously and
- appropriately publish on each copy an appropriate copyright notice;
- keep intact all notices stating that this License and any
- non-permissive terms added in accord with section 7 apply to the code;
- keep intact all notices of the absence of any warranty; and give all
- recipients a copy of this License along with the Program.
- <br/><br/>
- You may charge any price or no price for each copy that you convey,
- and you may offer support or warranty protection for a fee.
- <br/><br/>
- 5. Conveying Modified Source Versions.
- <br/><br/>
- You may convey a work based on the Program, or the modifications to
- produce it from the Program, in the form of source code under the
- terms of section 4, provided that you also meet all of these conditions:
- <br/><br/>
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
- <br/><br/>
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
- <br/><br/>
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
- <br/><br/>
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
- <br/><br/>
- A compilation of a covered work with other separate and independent
- works, which are not by their nature extensions of the covered work,
- and which are not combined with it such as to form a larger program,
- in or on a volume of a storage or distribution medium, is called an
- "aggregate" if the compilation and its resulting copyright are not
- used to limit the access or legal rights of the compilation's users
- beyond what the individual works permit. Inclusion of a covered work
- in an aggregate does not cause this License to apply to the other
- parts of the aggregate.
- <br/><br/>
- 6. Conveying Non-Source Forms.
- <br/><br/>
- You may convey a covered work in object code form under the terms
- of sections 4 and 5, provided that you also convey the
- machine-readable Corresponding Source under the terms of this License,
- in one of these ways:
- <br/><br/>
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
- <br/><br/>
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
- <br/><br/>
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
- <br/><br/>
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
- <br/><br/>
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
- <br/><br/>
- A separable portion of the object code, whose source code is excluded
- from the Corresponding Source as a System Library, need not be
- included in conveying the object code work.
- <br/><br/>
- A "User Product" is either (1) a "consumer product", which means any
- tangible personal property which is normally used for personal, family,
- or household purposes, or (2) anything designed or sold for incorporation
- into a dwelling. In determining whether a product is a consumer product,
- doubtful cases shall be resolved in favor of coverage. For a particular
- product received by a particular user, "normally used" refers to a
- typical or common use of that class of product, regardless of the status
- of the particular user or of the way in which the particular user
- actually uses, or expects or is expected to use, the product. A product
- is a consumer product regardless of whether the product has substantial
- commercial, industrial or non-consumer uses, unless such uses represent
- the only significant mode of use of the product.
- <br/><br/>
- "Installation Information" for a User Product means any methods,
- procedures, authorization keys, or other information required to install
- and execute modified versions of a covered work in that User Product from
- a modified version of its Corresponding Source. The information must
- suffice to ensure that the continued functioning of the modified object
- code is in no case prevented or interfered with solely because
- modification has been made.
- <br/><br/>
- If you convey an object code work under this section in, or with, or
- specifically for use in, a User Product, and the conveying occurs as
- part of a transaction in which the right of possession and use of the
- User Product is transferred to the recipient in perpetuity or for a
- fixed term (regardless of how the transaction is characterized), the
- Corresponding Source conveyed under this section must be accompanied
- by the Installation Information. But this requirement does not apply
- if neither you nor any third party retains the ability to install
- modified object code on the User Product (for example, the work has
- been installed in ROM).
- <br/><br/>
- The requirement to provide Installation Information does not include a
- requirement to continue to provide support service, warranty, or updates
- for a work that has been modified or installed by the recipient, or for
- the User Product in which it has been modified or installed. Access to a
- network may be denied when the modification itself materially and
- adversely affects the operation of the network or violates the rules and
- protocols for communication across the network.
- <br/><br/>
- Corresponding Source conveyed, and Installation Information provided,
- in accord with this section must be in a format that is publicly
- documented (and with an implementation available to the public in
- source code form), and must require no special password or key for
- unpacking, reading or copying.
- <br/><br/>
- 7. Additional Terms.
- <br/><br/>
- "Additional permissions" are terms that supplement the terms of this
- License by making exceptions from one or more of its conditions.
- Additional permissions that are applicable to the entire Program shall
- be treated as though they were included in this License, to the extent
- that they are valid under applicable law. If additional permissions
- apply only to part of the Program, that part may be used separately
- under those permissions, but the entire Program remains governed by
- this License without regard to the additional permissions.
- <br/><br/>
- When you convey a copy of a covered work, you may at your option
- remove any additional permissions from that copy, or from any part of
- it. (Additional permissions may be written to require their own
- removal in certain cases when you modify the work.) You may place
- additional permissions on material, added by you to a covered work,
- for which you have or can give appropriate copyright permission.
- <br/><br/>
- Notwithstanding any other provision of this License, for material you
- add to a covered work, you may (if authorized by the copyright holders of
- that material) supplement the terms of this License with terms:
- <br/><br/>
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
- <br/><br/>
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
- <br/><br/>
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
- <br/><br/>
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
- <br/><br/>
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
- <br/><br/>
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
- <br/><br/>
- All other non-permissive additional terms are considered "further
- restrictions" within the meaning of section 10. If the Program as you
- received it, or any part of it, contains a notice stating that it is
- governed by this License along with a term that is a further
- restriction, you may remove that term. If a license document contains
- a further restriction but permits relicensing or conveying under this
- License, you may add to a covered work material governed by the terms
- of that license document, provided that the further restriction does
- not survive such relicensing or conveying.
- <br/><br/>
- If you add terms to a covered work in accord with this section, you
- must place, in the relevant source files, a statement of the
- additional terms that apply to those files, or a notice indicating
- where to find the applicable terms.
- <br/><br/>
- Additional terms, permissive or non-permissive, may be stated in the
- form of a separately written license, or stated as exceptions;
- the above requirements apply either way.
- <br/><br/>
- 8. Termination.
- <br/><br/>
- You may not propagate or modify a covered work except as expressly
- provided under this License. Any attempt otherwise to propagate or
- modify it is void, and will automatically terminate your rights under
- this License (including any patent licenses granted under the third
- paragraph of section 11).
- <br/><br/>
- However, if you cease all violation of this License, then your
- license from a particular copyright holder is reinstated (a)
- provisionally, unless and until the copyright holder explicitly and
- finally terminates your license, and (b) permanently, if the copyright
- holder fails to notify you of the violation by some reasonable means
- prior to 60 days after the cessation.
- <br/><br/>
- Moreover, your license from a particular copyright holder is
- reinstated permanently if the copyright holder notifies you of the
- violation by some reasonable means, this is the first time you have
- received notice of violation of this License (for any work) from that
- copyright holder, and you cure the violation prior to 30 days after
- your receipt of the notice.
- <br/><br/>
- Termination of your rights under this section does not terminate the
- licenses of parties who have received copies or rights from you under
- this License. If your rights have been terminated and not permanently
- reinstated, you do not qualify to receive new licenses for the same
- material under section 10.
- <br/><br/>
- 9. Acceptance Not Required for Having Copies.
- <br/><br/>
- You are not required to accept this License in order to receive or
- run a copy of the Program. Ancillary propagation of a covered work
- occurring solely as a consequence of using peer-to-peer transmission
- to receive a copy likewise does not require acceptance. However,
- nothing other than this License grants you permission to propagate or
- modify any covered work. These actions infringe copyright if you do
- not accept this License. Therefore, by modifying or propagating a
- covered work, you indicate your acceptance of this License to do so.
- <br/><br/>
- 10. Automatic Licensing of Downstream Recipients.
- <br/><br/>
- Each time you convey a covered work, the recipient automatically
- receives a license from the original licensors, to run, modify and
- propagate that work, subject to this License. You are not responsible
- for enforcing compliance by third parties with this License.
- <br/><br/>
- An "entity transaction" is a transaction transferring control of an
- organization, or substantially all assets of one, or subdividing an
- organization, or merging organizations. If propagation of a covered
- work results from an entity transaction, each party to that
- transaction who receives a copy of the work also receives whatever
- licenses to the work the party's predecessor in interest had or could
- give under the previous paragraph, plus a right to possession of the
- Corresponding Source of the work from the predecessor in interest, if
- the predecessor has it or can get it with reasonable efforts.
- <br/><br/>
- You may not impose any further restrictions on the exercise of the
- rights granted or affirmed under this License. For example, you may
- not impose a license fee, royalty, or other charge for exercise of
- rights granted under this License, and you may not initiate litigation
- (including a cross-claim or counterclaim in a lawsuit) alleging that
- any patent claim is infringed by making, using, selling, offering for
- sale, or importing the Program or any portion of it.
- <br/><br/>
- 11. Patents.
- <br/><br/>
- A "contributor" is a copyright holder who authorizes use under this
- License of the Program or a work on which the Program is based. The
- work thus licensed is called the contributor's "contributor version".
- <br/><br/>
- A contributor's "essential patent claims" are all patent claims
- owned or controlled by the contributor, whether already acquired or
- hereafter acquired, that would be infringed by some manner, permitted
- by this License, of making, using, or selling its contributor version,
- but do not include claims that would be infringed only as a
- consequence of further modification of the contributor version. For
- purposes of this definition, "control" includes the right to grant
- patent sublicenses in a manner consistent with the requirements of
- this License.
- <br/><br/>
- Each contributor grants you a non-exclusive, worldwide, royalty-free
- patent license under the contributor's essential patent claims, to
- make, use, sell, offer for sale, import and otherwise run, modify and
- propagate the contents of its contributor version.
- <br/><br/>
- In the following three paragraphs, a "patent license" is any express
- agreement or commitment, however denominated, not to enforce a patent
- (such as an express permission to practice a patent or covenant not to
- sue for patent infringement). To "grant" such a patent license to a
- party means to make such an agreement or commitment not to enforce a
- patent against the party.
- <br/><br/>
- If you convey a covered work, knowingly relying on a patent license,
- and the Corresponding Source of the work is not available for anyone
- to copy, free of charge and under the terms of this License, through a
- publicly available network server or other readily accessible means,
- then you must either (1) cause the Corresponding Source to be so
- available, or (2) arrange to deprive yourself of the benefit of the
- patent license for this particular work, or (3) arrange, in a manner
- consistent with the requirements of this License, to extend the patent
- license to downstream recipients. "Knowingly relying" means you have
- actual knowledge that, but for the patent license, your conveying the
- covered work in a country, or your recipient's use of the covered work
- in a country, would infringe one or more identifiable patents in that
- country that you have reason to believe are valid.
- <br/><br/>
- If, pursuant to or in connection with a single transaction or
- arrangement, you convey, or propagate by procuring conveyance of, a
- covered work, and grant a patent license to some of the parties
- receiving the covered work authorizing them to use, propagate, modify
- or convey a specific copy of the covered work, then the patent license
- you grant is automatically extended to all recipients of the covered
- work and works based on it.
- <br/><br/>
- A patent license is "discriminatory" if it does not include within
- the scope of its coverage, prohibits the exercise of, or is
- conditioned on the non-exercise of one or more of the rights that are
- specifically granted under this License. You may not convey a covered
- work if you are a party to an arrangement with a third party that is
- in the business of distributing software, under which you make payment
- to the third party based on the extent of your activity of conveying
- the work, and under which the third party grants, to any of the
- parties who would receive the covered work from you, a discriminatory
- patent license (a) in connection with copies of the covered work
- conveyed by you (or copies made from those copies), or (b) primarily
- for and in connection with specific products or compilations that
- contain the covered work, unless you entered into that arrangement,
- or that patent license was granted, prior to 28 March 2007.
- <br/><br/>
- Nothing in this License shall be construed as excluding or limiting
- any implied license or other defenses to infringement that may
- otherwise be available to you under applicable patent law.
- <br/><br/>
- 12. No Surrender of Others' Freedom.
- <br/><br/>
- If conditions are imposed on you (whether by court order, agreement or
- otherwise) that contradict the conditions of this License, they do not
- excuse you from the conditions of this License. If you cannot convey a
- covered work so as to satisfy simultaneously your obligations under this
- License and any other pertinent obligations, then as a consequence you may
- not convey it at all. For example, if you agree to terms that obligate you
- to collect a royalty for further conveying from those to whom you convey
- the Program, the only way you could satisfy both those terms and this
- License would be to refrain entirely from conveying the Program.
- <br/><br/>
- 13. Remote Network Interaction; Use with the GNU General Public License.
- <br/><br/>
- Notwithstanding any other provision of this License, if you modify the
- Program, your modified version must prominently offer all users
- interacting with it remotely through a computer network (if your version
- supports such interaction) an opportunity to receive the Corresponding
- Source of your version by providing access to the Corresponding Source
- from a network server at no charge, through some standard or customary
- means of facilitating copying of software. This Corresponding Source
- shall include the Corresponding Source for any work covered by version 3
- of the GNU General Public License that is incorporated pursuant to the
- following paragraph.
- <br/><br/>
- Notwithstanding any other provision of this License, you have
- permission to link or combine any covered work with a work licensed
- under version 3 of the GNU General Public License into a single
- combined work, and to convey the resulting work. The terms of this
- License will continue to apply to the part which is the covered work,
- but the work with which it is combined will remain governed by version
- 3 of the GNU General Public License.
- <br/><br/>
- 14. Revised Versions of this License.
- <br/><br/>
- The Free Software Foundation may publish revised and/or new versions of
- the GNU Affero General Public License from time to time. Such new versions
- will be similar in spirit to the present version, but may differ in detail to
- address new problems or concerns.
- <br/><br/>
- Each version is given a distinguishing version number. If the
- Program specifies that a certain numbered version of the GNU Affero General
- Public License "or any later version" applies to it, you have the
- option of following the terms and conditions either of that numbered
- version or of any later version published by the Free Software
- Foundation. If the Program does not specify a version number of the
- GNU Affero General Public License, you may choose any version ever published
- by the Free Software Foundation.
- <br/><br/>
- If the Program specifies that a proxy can decide which future
- versions of the GNU Affero General Public License can be used, that proxy's
- public statement of acceptance of a version permanently authorizes you
- to choose that version for the Program.
- <br/><br/>
- Later license versions may give you additional or different
- permissions. However, no additional obligations are imposed on any
- author or copyright holder as a result of your choosing to follow a
- later version.
- <br/><br/>
- 15. Disclaimer of Warranty.
- <br/><br/>
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
- APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
- HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
- OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
- IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
- ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
- <br/><br/>
- 16. Limitation of Liability.
- <br/><br/>
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
- WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
- THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
- GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
- USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
- DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
- PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
- EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
- SUCH DAMAGES.
- <br/><br/>
- 17. Interpretation of Sections 15 and 16.
- <br/><br/>
- If the disclaimer of warranty and limitation of liability provided
- above cannot be given local legal effect according to their terms,
- reviewing courts shall apply local law that most closely approximates
- an absolute waiver of all civil liability in connection with the
- Program, unless a warranty or assumption of liability accompanies a
- copy of the Program in return for a fee.
- <br/><br/>
- <center>END OF TERMS AND CONDITIONS</center>
- <br/><br/>
- <center>How to Apply These Terms to Your New Programs</center>
- <br/><br/>
- If you develop a new program, and you want it to be of the greatest
- possible use to the public, the best way to achieve this is to make it
- free software which everyone can redistribute and change under these terms.
- <br/><br/>
- To do so, attach the following notices to the program. It is safest
- to attach them to the start of each source file to most effectively
- state the exclusion of warranty; and each file should have at least
- the "copyright" line and a pointer to where the full notice is found.
- <br/><br/>
- &ltone line to give the program's name and a brief idea of what it does.&gt
- Copyright (C) &ltyear&gt &ltname of author&gt
- <br/><br/>
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- <br/><br/>
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
- <br/><br/>
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see
- &lt<a href="https://www.gnu.org/licenses/" target="_blank">https://www.gnu.org/licenses/</a>&gt.
- <br/><br/>
- Also add information on how to contact you by electronic and paper mail.
- <br/><br/>
- If your software can interact with users remotely through a computer
- network, you should also make sure that it provides a way for users to
- get its source. For example, if your program is a web application, its
- interface could display a "Source" link that leads users to an archive
- of the code. There are many ways you could offer source, and different
- solutions will be better for different programs; see section 13 for the
- specific requirements.
- <br/><br/>
- You should also get your employer (if you work as a programmer) or school,
- if any, to sign a "copyright disclaimer" for the program, if necessary.
- For more information on this, and how to apply and follow the GNU AGPL, see
- &lt<a href="https://www.gnu.org/licenses/" target="_blank">https://www.gnu.org/licenses/</a>&gt.
- </div>
- <a href="https://gitlab.com/plasmicplexus/HyperBooru-Server" target="_blank">Source</a>
- <div id="progressContainer">
- @if(progress.HasValue) {
- var untagged = progress.Value.Untagged.ToString("N0");
- var total = progress.Value.Total.ToString("N0");
- var percent = (progress.Value.Untagged * 100f / progress.Value.Total).ToString("f1");
- <p id="progress">Untagged: @($"{untagged}/{total} ({percent}%)")</p>
- }
- <ProgressBar @ref=progressBar />
- </div>
- <ButtonContainer>
- <button @onclick=Hide>Close</button>
- </ButtonContainer>
-</Dialog>
-
-@code {
- private Dialog dialog;
-
- private ProgressBar progressBar;
-
- private (long Untagged, long Total)? progress;
-
- public bool Visible {
- get => dialog.Visible;
- set {
- dialog.Visible = value;
- if(value) {
- using var db = dbFactory.CreateDbContext();
- progress = (
- Untagged: db.Media
- .Where(m => m.Tags.Any(t => t.TagDefinition.ObjectId == (int) HBObjectId.IngestTag))
- .Count(),
- Total: db.Media.Count()
- );
- progressBar.Progress = (float) progress.Value!.Untagged / (float) progress.Value!.Total;
- InvokeAsync(() => StateHasChanged());
- }
- }
- }
-
- public void Show() => Visible = true;
- public void Hide() => Visible = false;
-
- public string Title =>
- $"HyperBooru v{Version} {Development}";
-
- public string? Version =>
- GetType()
- .Assembly
- .GetCustomAttribute<AssemblyInformationalVersionAttribute>()?
- .InformationalVersion;
-
- public string? Development {
- get {
- #if DEBUG
- return "(Development)";
- #else
- return hostingEnvironment.IsDevelopment() ? "(Development)" : null;
- #endif
- }
- }
-}
diff --git a/Pages/Component/AboutDialog.razor.css b/Pages/Component/AboutDialog.razor.css
deleted file mode 100644
index cbc4b59..0000000
--- a/Pages/Component/AboutDialog.razor.css
+++ /dev/null
@@ -1,29 +0,0 @@
-p#title {
- margin-bottom: 0;
-}
-
-p#author {
- font-size: 8pt;
-}
-
-p#progress {
- flex: 1 0 auto;
- font-size: 8pt;
- margin-right: 10px;
-}
-
-div#license {
- background: #222;
- border-radius: 10px;
- box-sizing: border-box;
- font-family: 'Lucida Console';
- font-size: 8pt;
- max-height: 300px;
- overflow-y: auto;
- padding: 20px;
-}
-
-div#progressContainer {
- align-items: center;
- display: flex;
-}
diff --git a/Pages/Component/ButtonContainer.razor b/Pages/Component/ButtonContainer.razor
deleted file mode 100644
index a631dcc..0000000
--- a/Pages/Component/ButtonContainer.razor
+++ /dev/null
@@ -1,8 +0,0 @@
-<div>
- @ChildContent
-</div>
-
-@code {
- [Parameter]
- public RenderFragment ChildContent { get; set; }
-}
diff --git a/Pages/Component/ButtonContainer.razor.css b/Pages/Component/ButtonContainer.razor.css
deleted file mode 100644
index c2d5d25..0000000
--- a/Pages/Component/ButtonContainer.razor.css
+++ /dev/null
@@ -1,10 +0,0 @@
-div {
- display: flex;
- justify-content: flex-end;
-}
-
-@media (hover: none) and (pointer: coarse) {
- div {
- justify-content: center;
- }
-}
diff --git a/Pages/Component/Dialog.razor b/Pages/Component/Dialog.razor
deleted file mode 100644
index 673ec2f..0000000
--- a/Pages/Component/Dialog.razor
+++ /dev/null
@@ -1,70 +0,0 @@
-@inject IJSRuntime jsRuntime
-@implements IDialog
-
-<div
- class="dialog"
- onmousedown="dialogMouseDown(event)"
- style="opacity:0;visibility:hidden;@(heightStyle)"
- @ref=dialogDiv>
- @if(Title is not null) {
- <div class="titlebar" onmousedown="dialogTitleMouseDown(event)">
- <p class="title">@Title</p>
- <hr/>
- </div>
- }
- <div class="content">
- @ChildContent
- </div>
-</div>
-
-@code {
- [Parameter]
- public string? Title { get; set; }
-
- [Parameter]
- public RenderFragment ChildContent { get; set; }
-
- [Parameter]
- public int HeightPixels { set => height = $"{value}px"; }
- [Parameter]
- public int HeightPercent { set => height = $"{value}%"; }
-
- public bool Visible {
- get => visible;
- set {
- visible = value;
- jsRuntime.InvokeVoidAsync(
- "setDialogVisibility",
- new object?[] { dialogDiv, value });
- }
- }
-
- private bool visible = false;
-
- private string? height;
-
- private ElementReference dialogDiv;
-
- public void Show() => Visible = true;
- public void Hide() => Visible = false;
-
- protected override async void OnAfterRender(bool firstRender) {
- if(firstRender) {
- await jsRuntime.InvokeVoidAsync("dialogAddObjectReference", new object[] {
- dialogDiv,
- DotNetObjectReference.Create(this)
- });
- }
- }
-
- [JSInvokable("KeyHandler")]
- public void KeyHandler(string key) {
- if(key == "Escape") {
- Hide();
- return;
- }
- }
-
- private string heightStyle =>
- $"{(height is null ? "" : $"max-height:{height};")}";
-}
diff --git a/Pages/Component/Dialog.razor.css b/Pages/Component/Dialog.razor.css
deleted file mode 100644
index 93680c5..0000000
--- a/Pages/Component/Dialog.razor.css
+++ /dev/null
@@ -1,35 +0,0 @@
-div.dialog {
- background: var(--col-dialog-bg);
- border-radius: 20px;
- box-shadow: 0px 5px 10px 10px rgb(0 0 0 / 25%);
- display: flex;
- flex-direction: column;
- left: 50%;
- padding: 0;
- position: absolute;
- top: 50%;
- transform: translate(-50%, -50%);
- transition: visibility 0.1s, opacity 0.1s linear;
- width: min(450px, 100%);
- z-index: 1000;
-}
-
-hr {
- margin: 0;
-}
-
-div.titlebar {
- cursor: grab;
-}
-
-div.titlebar p.title {
- font-size: 10pt;
- margin: 0;
- padding: 10px 20px 10px 20px;
-}
-
-div.content {
- display: flex;
- flex-direction: column;
- padding: 20px;
-}
diff --git a/Pages/Component/MediaTagTable.razor b/Pages/Component/MediaTagTable.razor
deleted file mode 100644
index e687529..0000000
--- a/Pages/Component/MediaTagTable.razor
+++ /dev/null
@@ -1,72 +0,0 @@
-@inject IDbContextFactory<HBContext> dbFactory
-@inject ITagService tagService
-
-<link rel="stylesheet" href="@(nameof(HyperBooru)).styles.css"/>
-
-<table class="data-table">
- <tr>
- <th>Namespace</th>
- <th>Tag Name</th>
- <th></th>
- </tr>
- @foreach(var e in tagDefs) {
- <tr>
- <td>
- @if(e.isImplicit) {
- <i>@e.tagDef.Namespace</i>
- } else {
- @e.tagDef.Namespace
- }
- </td>
- <td>
- <a href="/Gallery?t=@(e.tagDef.Guid)" class="nondecorated">
- @if(e.isImplicit) {
- <i>@e.tagDef.Name</i>
- } else {
- @e.tagDef.Name
- }
- </a>
- </td>
- <td>
- @if(!e.isImplicit) {
- <a href="javascript:;" @onclick=@(() => Delete(e.tagDef))>Delete</a>
- } else {
- <a href="javascript:;" @onclick=@(() => MakeExplicit(e.tagDef))>Make Explicit</a>
- }
- </td>
- </tr>
- }
-</table>
-
-@code {
- [Parameter]
- public Media Media { get; set; }
-
- private (TagDefinition tagDef, bool isImplicit)[] tagDefs;
-
- protected override void OnInitialized() => LoadTagDefs();
-
- public void Refresh() {
- LoadTagDefs();
- StateHasChanged();
- }
-
- private void Delete(TagDefinition tagDef) {
- tagService.RemoveTag(Media.Guid, tagDef.Guid);
- Refresh();
- }
-
- private void LoadTagDefs() {
- using var db = dbFactory.CreateDbContext();
- var media = db.Media.First(m => m.ObjectId == Media.ObjectId);
-
- tagDefs = tagService.GetAllTags(Media)
- .Where(e => e.tagDefinition.Source == TagSource.UserTag)
- .ToArray();
- }
-
- private void MakeExplicit(TagDefinition tagDef) {
- tagService.AddTag(Media, tagDef);
- Refresh();
- }
-}
diff --git a/Pages/Component/MediaTagTable.razor.css b/Pages/Component/MediaTagTable.razor.css
deleted file mode 100644
index 4dedb3f..0000000
--- a/Pages/Component/MediaTagTable.razor.css
+++ /dev/null
@@ -1,9 +0,0 @@
-th, td {
- font-size: 8pt;
-}
-
-@media (hover: none) and (pointer: coarse) {
- th, td {
- font-size: 7pt;
- }
-}
diff --git a/Pages/Component/MobileMenu.razor b/Pages/Component/MobileMenu.razor
deleted file mode 100644
index 49c45d5..0000000
--- a/Pages/Component/MobileMenu.razor
+++ /dev/null
@@ -1,26 +0,0 @@
-@inject NavigationManager navigationManager
-@inject IJSRuntime jsRuntime
-@implements IDisposable
-
-<div id="mobile-menu" class="hidden">
- <a href="/">Home</a>
- <a href="/TagDefinitions">Tags</a>
- <a href="/Gallery?ingest=true">Ingest</a>
- <a href="/Upload">Upload</a>
- <div id="nsfw-switch">
- <p id="nsfw-label">NSFW</p>
- <NsfwSwitch/>
- </div>
- <a href="javascript:logout();">Logout</a>
-</div>
-
-@code {
- protected override void OnInitialized() =>
- navigationManager.LocationChanged += LocationChanged;
-
- public async void LocationChanged(object? sender, LocationChangedEventArgs e) =>
- await jsRuntime.InvokeVoidAsync("hideMobileMenu");
-
- public void Dispose() =>
- navigationManager.LocationChanged -= LocationChanged;
-}
diff --git a/Pages/Component/MobileMenu.razor.css b/Pages/Component/MobileMenu.razor.css
deleted file mode 100644
index 0237cf1..0000000
--- a/Pages/Component/MobileMenu.razor.css
+++ /dev/null
@@ -1,46 +0,0 @@
-div#mobile-menu {
- background: var(--col-bg);
- display: none;
- flex-direction: column;
- flex: 1 1 calc(100vh - 59px);
- height: 100%;
- overflow-y: auto;
- position: relative;
- width: 100%;
-}
-
-body.mobile-menu-visible div#mobile-menu {
- display: flex;
-}
-
-div#mobile-menu > a {
- color: #fff;
- padding: 20px;
-}
-
-div#mobile-menu > a:not(:last-of-type) {
- border-bottom: 1px solid var(--col-hr);
-}
-
-div#mobile-menu > a:hover {
- background: var(--col-dialog-bg);
- filter: none;
-}
-
-div#mobile-menu > a:active {
- background: #fff;
- color: var(--col-bg);
- filter: none;
-}
-
-div#nsfw-switch {
- align-items: center;
- border-bottom: 1px solid var(--col-hr);
- display: flex;
- flex-direction: row;
- padding: 5px 20px 5px 20px;
-}
-
-div#nsfw-switch > p#nsfw-label {
- margin-right: auto;
-}
diff --git a/Pages/Component/NsfwSwitch.razor b/Pages/Component/NsfwSwitch.razor
deleted file mode 100644
index b96606d..0000000
--- a/Pages/Component/NsfwSwitch.razor
+++ /dev/null
@@ -1,8 +0,0 @@
-@inject IUserService userService
-
-<Switch InitialValue=userService.UserSessionState.ShowNsfw OnToggle=ToggleNsfw/>
-
-@code {
- private void ToggleNsfw(bool showNsfw) =>
- userService.UserSessionState.ShowNsfw = showNsfw;
-} \ No newline at end of file
diff --git a/Pages/Component/ProgressBar.razor b/Pages/Component/ProgressBar.razor
deleted file mode 100644
index aa22194..0000000
--- a/Pages/Component/ProgressBar.razor
+++ /dev/null
@@ -1,17 +0,0 @@
-<div id="outer">
- <div id="inner" style="width:@(Progress * 100)%">
- </div>
-</div>
-
-@code {
- private float progress = 0;
-
- [Parameter]
- public float Progress {
- get => progress;
- set {
- progress = value;
- InvokeAsync(() => StateHasChanged());
- }
- }
-}
diff --git a/Pages/Component/ProgressBar.razor.css b/Pages/Component/ProgressBar.razor.css
deleted file mode 100644
index f49c982..0000000
--- a/Pages/Component/ProgressBar.razor.css
+++ /dev/null
@@ -1,17 +0,0 @@
-div#outer {
- background: var(--col-progbar-bg);
- border-radius: 15px;
- height: 15px;
- margin: 0;
- padding: 0;
- width: 100%;
-}
-
-div#inner {
- background: var(--col-progbar-fg);
- border-radius: 15px;
- height: 100%;
- margin: 0;
- padding: 0;
- transition: width 0.5s ease;
-}
diff --git a/Pages/Component/RedirectLogin.razor b/Pages/Component/RedirectLogin.razor
deleted file mode 100644
index 290a7ac..0000000
--- a/Pages/Component/RedirectLogin.razor
+++ /dev/null
@@ -1,6 +0,0 @@
-@inject NavigationManager navigationManager
-
-@code {
- protected override void OnInitialized() =>
- navigationManager.NavigateTo("/Login", true);
-} \ No newline at end of file
diff --git a/Pages/Component/Switch.razor b/Pages/Component/Switch.razor
deleted file mode 100644
index d11ac81..0000000
--- a/Pages/Component/Switch.razor
+++ /dev/null
@@ -1,20 +0,0 @@
-<link rel="stylesheet" href="@(nameof(HyperBooru)).styles.css"/>
-
-<label>
- <input
- type="checkbox"
- checked=@InitialValue
- @onchange=@(e => OnToggle.InvokeAsync((e.Value as bool?) ?? false))
- hidden/>
- <div class="switch-outer">
- <div class="switch-inner"/>
- </div>
-</label>
-
-@code {
- [Parameter]
- public bool InitialValue { get; set; } = false;
-
- [Parameter]
- public EventCallback<bool> OnToggle { get; set; }
-}
diff --git a/Pages/Component/Switch.razor.css b/Pages/Component/Switch.razor.css
deleted file mode 100644
index 6b1f5d5..0000000
--- a/Pages/Component/Switch.razor.css
+++ /dev/null
@@ -1,25 +0,0 @@
-div.switch-outer {
- background: var(--col-switch-bg);
- border-radius: 20px;
- border: 1px solid var(--col-switch-fg);
- cursor: pointer;
- height: 20px;
- transition: background 0.1s linear;
- width: 40px;
-}
-
-div.switch-inner {
- background: var(--col-switch-fg);
- border-radius: 20px;
- height: 20px;
- transition: margin-left 0.1s linear;
- width: 20px;
-}
-
-input:checked + div.switch-outer {
- background: var(--col-switch-bg-hl);
-}
-
-input:checked + div.switch-outer > div.switch-inner {
- margin-left: 20px;
-}
diff --git a/Pages/Component/TabContainer.razor b/Pages/Component/TabContainer.razor
deleted file mode 100644
index 3caab0b..0000000
--- a/Pages/Component/TabContainer.razor
+++ /dev/null
@@ -1,35 +0,0 @@
-<link rel="stylesheet" href="@(nameof(HyperBooru)).styles.css"/>
-
-<div class="tabs">
- @foreach(var pane in Panes) {
- <a href="javascript:;" @onclick=@(() => ActivePane = pane) class="@(pane == ActivePane ? "selected" : "")">
- @pane.Title
- </a>
- }
-</div>
-
-<CascadingValue Value="this">
- @ChildContent
-</CascadingValue>
-
-@code {
- [Parameter]
- public RenderFragment ChildContent { get; set; }
-
- public TabPane? ActivePane { get; set; }
- List<TabPane> Panes = new();
-
- public void AddPane(TabPane tabPane) {
- Panes.Add(tabPane);
- if(Panes.Count == 1)
- ActivePane = tabPane;
- StateHasChanged();
- }
-
- public void RemovePane(TabPane tabPane) {
- if(ActivePane == tabPane)
- ActivePane = Panes.ElementAtOrDefault(0);
- Panes.Remove(tabPane);
- StateHasChanged();
- }
-} \ No newline at end of file
diff --git a/Pages/Component/TabContainer.razor.css b/Pages/Component/TabContainer.razor.css
deleted file mode 100644
index bfb5694..0000000
--- a/Pages/Component/TabContainer.razor.css
+++ /dev/null
@@ -1,27 +0,0 @@
-div.tabs {
- display: inherit !important;
- border-bottom: 1px solid white;
-}
-
-div.tabs > a {
- display: inline-block;
- padding: 10px 10px 9px 10px;
-}
-
-div.tabs > a.selected {
- border-bottom: 4px solid white;
- padding-bottom: 5px;
-}
-
-@media (hover: hover) {
- div.tabs > a:hover {
- background: rgba(255, 255, 255, 0.4);
- filter: none;
- }
-}
-
-@media (hover: none) and (pointer: coarse) {
- div.tabs > a {
- font-size: 8pt;
- }
-}
diff --git a/Pages/Component/TabPane.razor b/Pages/Component/TabPane.razor
deleted file mode 100644
index ba4a13a..0000000
--- a/Pages/Component/TabPane.razor
+++ /dev/null
@@ -1,29 +0,0 @@
-@implements IDisposable
-
-<link rel="stylesheet" href="@(nameof(HyperBooru)).styles.css"/>
-
-@if(Parent.ActivePane == this) {
- @ChildContent
-}
-
-@code {
- [CascadingParameter]
- private TabContainer Parent { get; set; }
-
- [Parameter]
- public string Title { get; set; }
-
- [Parameter]
- public RenderFragment ChildContent { get; set; }
-
- protected override void OnInitialized() {
- if (Parent is null)
- throw new ArgumentNullException(nameof(Parent), "TabPane must exist within a TabContainer");
-
- Parent.AddPane(this);
- }
-
- public void Dispose() {
- Parent.RemovePane(this);
- }
-} \ No newline at end of file
diff --git a/Pages/Component/TabPane.razor.css b/Pages/Component/TabPane.razor.css
deleted file mode 100644
index 5f28270..0000000
--- a/Pages/Component/TabPane.razor.css
+++ /dev/null
@@ -1 +0,0 @@
- \ No newline at end of file
diff --git a/Pages/Component/TagEditDialog.razor b/Pages/Component/TagEditDialog.razor
deleted file mode 100644
index afa312e..0000000
--- a/Pages/Component/TagEditDialog.razor
+++ /dev/null
@@ -1,96 +0,0 @@
-@inject IDbContextFactory<HBContext> dbFactory;
-@inject ITagService tagService
-@implements IDialog
-
-<Dialog Title=@Title @ref=dialog>
- <label>
- Name
- @if(nameExists) {
- <p class="error">Tag with that name already exists!</p>
- }
- </label>
- <input type="text" @bind=tagName required/>
- <label>Namespace</label>
- <input type="text" @bind=tagNamespace/>
- <label>
- Alias
- @if(aliasExists) {
- <p class="error">Tag with that alias already exists!</p>
- }
- </label>
- <input type="text" @bind=tagAlias/>
- <ButtonContainer>
- <button @onclick=Hide class="secondary">Cancel</button>
- <button @onclick=Submit>@(TagDefinition is null ? "Create" : "Apply")</button>
- </ButtonContainer>
-</Dialog>
-
-@code {
- [Parameter]
- public TagDefinition? TagDefinition { get; set; }
-
- [Parameter]
- public EventHandler OnTagUpdate { get; set; }
-
- public bool Visible {
- get => visible;
- set {
- if(value)
- Load();
- visible = dialog.Visible = value;
- }
- }
-
- private string Title =>
- TagDefinition is null ? "Create a new tag definition" : "Edit tag definition";
-
- private Dialog dialog;
-
- private string? tagName;
- private string? tagNamespace;
- private string? tagAlias;
-
- private bool nameExists = false;
- private bool aliasExists = false;
-
- private bool visible = false;
-
- public void Show() => Visible = true;
- public void Hide() => Visible = false;
-
- public void Show(TagDefinition? toEdit) {
- TagDefinition = toEdit;
- Visible = true;
- }
-
- public void Show(string? @namespace) {
- TagDefinition = null;
- Visible = true;
- tagNamespace = @namespace;
- }
-
- private void Load() {
- tagName = TagDefinition?.Name;
- tagNamespace = TagDefinition?.Namespace;
- tagAlias = TagDefinition?.Alias;
- nameExists = false;
- aliasExists = false;
- }
-
- private void Submit() {
- try {
- if(TagDefinition is null) {
- tagService.CreateTagDefinition(tagName, tagNamespace, tagAlias);
- } else {
- tagService.UpdateTagDefinition(TagDefinition, tagName, tagNamespace, tagAlias);
- }
- } catch(ApiModels.TagDuplicateException e) {
- nameExists = e.NameExists;
- aliasExists = e.AliasExists;
- return;
- }
-
- OnTagUpdate.Invoke(this, new EventArgs());
- Hide();
- }
-}
diff --git a/Pages/Component/TagEditDialog.razor.css b/Pages/Component/TagEditDialog.razor.css
deleted file mode 100644
index 02781c0..0000000
--- a/Pages/Component/TagEditDialog.razor.css
+++ /dev/null
@@ -1,11 +0,0 @@
-p.error {
- color: var(--col-error-pri);
- display: inline;
- font-size: 8pt;
- margin-left: 5px;
- vertical-align: middle;
-}
-
-input {
- width: 100%;
-}
diff --git a/Pages/Component/TagSelectDialog.razor b/Pages/Component/TagSelectDialog.razor
deleted file mode 100644
index 87065d7..0000000
--- a/Pages/Component/TagSelectDialog.razor
+++ /dev/null
@@ -1,192 +0,0 @@
-@inject IDbContextFactory<HBContext> dbFactory
-@inject ITagService tagService
-@inject IUserService userService
-@implements IDisposable
-@implements IDialog
-
-<link rel="stylesheet" href="@(nameof(HyperBooru)).styles.css"/>
-
-<Dialog Title=@(Title ?? "Select one or more tag(s)") @ref=dialog>
- <input
- type="text"
- placeholder="Search"
- autocorrect="off"
- autocapitalize="off"
- autocomplete="off"
- @ref=queryInput
- @oninput=QueryInput
- @onkeypress=QueryKey
- value=@query/>
- <div class="tag-definitions">
- @for(int i = 0; i < tagDefinitions.Count(); i++) {
- if(!MatchesQuery(tagDefinitions[i].tagDefinition))
- continue;
- var local = i;
- var ns = tagDefinitions[i].tagDefinition.Namespace;
- var alias = tagDefinitions[i].tagDefinition.Alias;
- var title = string.Join(" ", new[] {
- ns,
- alias is not null ? $"({alias})" : null
- });
- <input
- type="checkbox"
- id="tagDef-@tagDefinitions[i].tagDefinition.Guid"
- @bind=tagDefinitions[local].selected />
- <label
- for="tagDef-@tagDefinitions[i].tagDefinition.Guid"
- title=@title>
- @tagDefinitions[i].tagDefinition.Name
- </label>
- }
- </div>
- <ButtonContainer>
- <button @onclick=@(() => dialog.Hide()) class="secondary">Cancel</button>
- <button @onclick=@(() => Submit())>Accept</button>
- </ButtonContainer>
-</Dialog>
-
-@code {
- [Parameter]
- public string? Title { get; set; }
-
- [Parameter]
- public EventCallback<TagDefinition[]> OnSubmit { get; set; }
-
- public TagDefinition[] SelectedTags { get; set; } =
- Array.Empty<TagDefinition>();
-
- public bool Visible {
- get => visible;
- set {
- if(value)
- LoadTags();
- query = null;
- visible = dialog.Visible = value;
- }
- }
-
- private (TagDefinition tagDefinition, bool selected)[] tagDefinitions;
-
- private HBContext db;
-
- private Dialog dialog;
-
- private bool visible;
-
- private string? query;
- private ElementReference queryInput;
-
- public void Show() => Visible = true;
- public void Hide() => Visible = false;
-
- protected override void OnInitialized() {
- userService.UserSessionState.OnStateChange += ShowNsfwChanged;
- LoadTags();
- }
-
- private void LoadTags() {
- db = dbFactory.CreateDbContext();
-
- var selected = SelectedTags.Select(td => td.Guid);
-
- int[] nsfwTags = Array.Empty<int>();
- if(!userService.UserSessionState.ShowNsfw)
- nsfwTags = tagService.TagsThatImply(HBContext.NsfwTag)
- .Select(td => td.ObjectId)
- .ToArray();
-
- tagDefinitions = db.TagDefinitions
- .Include(td => td.ImplicitTags)
- .Where(td => td.Source == TagSource.UserTag)
- .OrderBy(td => td.Name)
- .AsEnumerable()
- .Where(td => userService.UserSessionState.ShowNsfw || !td.ImplicitTags
- .IntersectBy(nsfwTags, td => td.ObjectId)
- .Any())
- .Select(td => new Tuple<TagDefinition, bool>(
- td,
- selected.Contains(td.Guid)).ToValueTuple())
- .ToArray();
- }
-
- private void QueryInput(ChangeEventArgs e) {
- query = (string?) e.Value;
- StateHasChanged();
- }
-
- private void QueryKey(KeyboardEventArgs e) {
- if(e.Code != "Enter" && e.Code != "NumpadEnter")
- return;
-
- if(string.IsNullOrEmpty(query)) {
- Submit();
- return;
- }
-
- int c = 0;
- int? last = null;
- for(int i = 0; i < tagDefinitions.Count(); i++) {
- if(!MatchesQuery(tagDefinitions[i].tagDefinition))
- continue;
- last = i;
- c++;
- }
-
- if(c == 1 && last is not null)
- tagDefinitions[(int) last].selected =
- !tagDefinitions[(int) last].selected;
-
- query = null;
- StateHasChanged();
- }
-
- private bool MatchesQuery(TagDefinition tagDef) {
- TagDefinition? singleTag = null;
-
- if(string.IsNullOrEmpty(query))
- return true;
-
- singleTag = tagDefinitions.FirstOrDefault(
- e => string.Equals(
- e.tagDefinition.Alias,
- query,
- StringComparison.OrdinalIgnoreCase)).tagDefinition;
-
- if(singleTag is not null)
- return tagDef.Guid == singleTag.Guid;
-
- singleTag = tagDefinitions.FirstOrDefault(
- e => string.Equals(
- e.tagDefinition.Name,
- query,
- StringComparison.OrdinalIgnoreCase)).tagDefinition;
-
- if(singleTag is not null)
- return tagDef.Guid == singleTag.Guid;
-
- return tagDef.Name.ToLower().Contains(query.ToLower());
- }
-
- private async void Submit() {
- await OnSubmit.InvokeAsync(
- tagDefinitions
- .Where(e => e.selected)
- .Select(e => e.tagDefinition)
- .ToArray());
- for(int i = 0; i < tagDefinitions.Count(); i++)
- tagDefinitions[i].selected = false;
- Hide();
- StateHasChanged();
- }
-
- public async void ShowNsfwChanged(UserSessionState userSessionState) =>
- await InvokeAsync(() => {
- LoadTags();
- StateHasChanged();
- });
-
- public void Dispose() {
- db.Dispose();
- userService.UserSessionState.OnStateChange -= ShowNsfwChanged;
- }
-}
diff --git a/Pages/Component/TagSelectDialog.razor.css b/Pages/Component/TagSelectDialog.razor.css
deleted file mode 100644
index dadd0c4..0000000
--- a/Pages/Component/TagSelectDialog.razor.css
+++ /dev/null
@@ -1,29 +0,0 @@
-div.tag-definitions {
- max-height: 450px;
- overflow-y: auto;
- user-select: none;
-}
-
-div.tag-definitions label {
- background: #555;
- border-radius: 10px;
- display: inline-block;
- font-size: 10pt;
- margin: 0 5px 5px 0;
- padding: 5px 7px 5px 7px;
- transition: background 0.1s linear;
-}
-
-@media(hover: hover) {
- div.tag-definitions label:hover {
- background: #777;
- }
-}
-
-div.tag-definitions input:checked + label {
- background: #aaa;
-}
-
-div.tag-definitions input {
- display: none;
-}
diff --git a/Pages/Component/Titlebar.razor b/Pages/Component/Titlebar.razor
deleted file mode 100644
index 48257b2..0000000
--- a/Pages/Component/Titlebar.razor
+++ /dev/null
@@ -1,87 +0,0 @@
-@inject IJSRuntime jsRuntime
-@inject IUserService userService
-
-<script suppress-error="BL9992">
- async function login() {
- var username = document.querySelector('input#username');
- var password = document.querySelector('input#password');
-
- var formData = new FormData();
- formData.append('username', username.value);
- formData.append('password', password.value);
-
- var resp = await fetch('/Login', {
- method: 'POST',
- body: formData
- });
-
- if(resp.ok) {
- window.location.href = '/';
- } else if(resp.status == 403) {
- var form = document.querySelector('form.login');
- form.classList.remove('bad-login');
- @* TODO: improve this hacky method of triggering reflow *@
- form.offsetWidth;
- form.classList.add('bad-login');
- username.value = password.value = null;
- username.focus();
- } else {
- alert('Unknown error while attempting to login!');
- }
- }
-
- async function logout() {
- var resp = await fetch('/Logout', { method: 'POST' });
- if(resp.ok) {
- window.location.href = '/Login';
- } else {
- alert('Error logging out!');
- }
- }
-</script>
-
-<AuthorizeView>
- <Authorized>
- <div id="navbar">
- <p class="mobile">HyperBooru</p>
- <a class="mobile menu-button" href="javascript:toggleMobileMenu();">&#x2630</a>
-
- <a class="desktop" href="/">Home</a>
- <a class="desktop" href="/TagDefinitions">Tags</a>
- <a class="desktop" href="/Gallery?ingest=true">Ingest</a>
- <a class="desktop" href="/Upload">Upload</a>
- <a class="desktop" href="javascript:;" @onclick=@(() => aboutDialog.Show())>About</a>
-
- <p class="desktop" id="nsfw-label">NSFW</p>
- <div id="nsfw-switch" class="desktop">
- <NsfwSwitch/>
- </div>
- <form action="/Gallery" method="get" class="desktop">
- <input type="text" name="q" placeholder="Search"/>
- </form>
- <a class="desktop" href="javascript:logout();">Logout</a>
- </div>
- <AboutDialog @ref=aboutDialog/>
- </Authorized>
- <NotAuthorized>
- <div id="navbar">
- <h2>Login</h2>
- <form class="login" action="javascript:login();">
- <input
- id="username"
- placeholder="Username"
- type="text"
- autocorrect="off"
- autocapitalize="off"
- autocomplete="off"
- autofocus/>
- <input id="password" placeholder="Password" type="password"/>
- </form>
- <a href="javascript:login();">Login</a>
- </div>
- </NotAuthorized>
-</AuthorizeView>
-
-@code {
- private AboutDialog aboutDialog;
-}
diff --git a/Pages/Component/Titlebar.razor.css b/Pages/Component/Titlebar.razor.css
deleted file mode 100644
index 58a1c0c..0000000
--- a/Pages/Component/Titlebar.razor.css
+++ /dev/null
@@ -1,99 +0,0 @@
-div#navbar {
- align-items: center;
- background: var(--col-navbar-bg);
- box-shadow: rgba(0, 0, 0, 0.5) 0px 10px 10px;
- display: flex;
- height: 59px;
- z-index: 100;
-}
-
-div#navbar > h2 {
- margin-left: 20px;
-}
-
-div#navbar > a, div#navbar > p {
- align-items: center;
- color: white;
- display: flex;
- height: 100%;
- padding: 0 20px 0 20px;
- user-select: none;
-}
-
-@media (hover: hover) and (pointer: fine) {
- div#navbar > a:hover {
- background: rgba(255, 255, 255, 0.4);
- filter: none;
- }
-}
-
-div#navbar > a:active {
- background: #fff;
- color: var(--col-navbar-bg);
-}
-
-div#navbar > a.menu-button {
- font-size: 18pt;
- margin-left: auto;
-}
-
-p#nsfw-label {
- align-self: center;
- font-size: 9pt;
- margin-left: auto;
-}
-
-div#nsfw-switch {
- align-self: center;
- margin-left: 10px;
-}
-
-form {
- display: flex;
- margin: 0 20px 0 20px;
- min-width: 30%;
-}
-
-form.login {
- margin-left: auto;
-}
-
-form.login.bad-login {
- animation-iteration-count: 3;
- animation-timing-function: linear;
- animation: bad-login 0.2s;
-}
-
-@keyframes bad-login {
- 0% { transform: translateX(0); }
- 33% { transform: translateX(-20px); }
- 66% { transform: translateX(+20px); }
- 100% { transform: translateX(0); }
-}
-
-input[type="text"], input[type="password"] {
- align-self: center;
- background: var(--col-bg);
- border-radius: 0;
- color: white;
- font-size: 12pt;
- height: 40px !important;
- margin: 0;
- width: 100%;
-}
-
-input[type="password"] {
- margin-left: 20px;
-}
-
-@media (hover: none) and (pointer: coarse) {
- .desktop {
- display: none !important;
- }
-}
-
-@media (hover: hover) and (pointer: fine) {
- .mobile {
- display: none !important;
- }
-}
diff --git a/Pages/Gallery.razor b/Pages/Gallery.razor
deleted file mode 100644
index 743485e..0000000
--- a/Pages/Gallery.razor
+++ /dev/null
@@ -1,141 +0,0 @@
-@page "/"
-@page "/Gallery"
-@inject ITagService tagService
-@inject IFeedService feedService
-@inject IUserService userService
-@inject IJSRuntime jsRuntime
-@implements IDisposable
-@attribute [Authorize]
-
-<PageTitle>@Title</PageTitle>
-
-@if(Ingest && !userService.UserSessionState.ShowNsfw) {
- <div id="feed-error">
- <p><center>Ingest feed is not available unless NSFW mode is enabled!</center></p>
- <p><center><i>You must enable NSFW mode to continue...</i></center></p>
- </div>
-} else if(TagId is not null && Query is not null) {
- <div id="feed-error">
- <p><center>Invalid query parameters! Both a search query and</center></p>
- <p><center>a tag ID have been specified!</center></p>
- </div>
-} else {
- <div style="padding:var(--size-default-gap);">
- @foreach(var media in displayMedia) {
- // Precalculate thumbnail size to help the browser
- // lay out the images during initial page load
- int width = (int) media.CurrentUploadedFile!.Width! * 200 / (int) media.CurrentUploadedFile.Height!;
- <a href="/ViewMedia?m=@(media.Guid)">
- <img src="/media/thumb/@(media.Guid)?h=200" width=@width height="200"/>
- </a>
- }
- <div id="canary" style="height:1px;"></div>
- </div>
-}
-
-<script suppress-error="BL9992">
- function registerScrollObserver(dotNetObject) {
- var scrollObserver = new IntersectionObserver(
- async (e) => {
- if(e[0].isIntersecting) {
- await dotNetObject.invokeMethodAsync('LoadMedia', false);
- }
- },
- {
- root: document.getElementById('content'),
- threshold: 0
- });
- scrollObserver.observe(document.getElementById("canary"));
- }
-</script>
-
-@code {
- [Parameter]
- [SupplyParameterFromQuery(Name = "t")]
- public Guid? TagId { get; set; }
-
- [Parameter]
- [SupplyParameterFromQuery(Name = "q")]
- public string? Query { get; set; }
-
- [Parameter]
- [SupplyParameterFromQuery(Name = "s")]
- public string? SortOrder { get; set; }
-
- [Parameter]
- [SupplyParameterFromQuery]
- public bool Ingest { get; set; } = false;
-
- public const int PageSize = 50;
-
- private string Title {
- get {
- if(Query is null)
- return Ingest ? "Ingest Feed" : "Gallery";
- else
- return "Search Results";
- }
- }
-
- private List<Media> displayMedia;
-
- protected override void OnInitialized() =>
- userService.UserSessionState.OnStateChange += ShowNsfwChanged;
-
- protected override void OnParametersSet() => LoadMedia(true);
-
- protected override void OnAfterRender(bool firstRender) {
- if(firstRender)
- jsRuntime.InvokeVoidAsync(
- "registerScrollObserver",
- DotNetObjectReference.Create(this));
- }
-
- [JSInvokable("LoadMedia")]
- public void LoadMedia(bool initial = false) {
- Media? key = displayMedia?.Any() ?? false && !initial ? displayMedia.Last() : null;
-
- if(initial)
- displayMedia = new();
-
- ApiModels.SortOrder? sortOrder = null;
- if(Enum.TryParse<ApiModels.SortOrder>(SortOrder, true, out var so))
- sortOrder = so;
-
- if(TagId is not null && Query is null) {
- displayMedia!.AddRange(feedService.LoadChunk(
- selectIngest: Ingest,
- includeNsfw: userService.UserSessionState.ShowNsfw,
- tagId: (Guid) TagId!,
- key: key,
- count: PageSize,
- sortOrder: sortOrder ?? default));
- } else if(Query is not null && TagId is null) {
- displayMedia!.AddRange(feedService.LoadChunk(
- selectIngest: Ingest,
- includeNsfw: userService.UserSessionState.ShowNsfw,
- query: string.IsNullOrWhiteSpace(Query) ? null : Query,
- key: key,
- count: PageSize,
- sortOrder: sortOrder ?? default));
- } else {
- displayMedia!.AddRange(feedService.LoadChunk(
- selectIngest: Ingest,
- includeNsfw: userService.UserSessionState.ShowNsfw,
- key: key,
- count: PageSize,
- sortOrder: sortOrder ?? default));
- }
-
- StateHasChanged();
- }
-
- private async void ShowNsfwChanged(UserSessionState userSessionState) {
- await InvokeAsync(() => {
- LoadMedia(true);
- });
- }
-
- public void Dispose() =>
- userService.UserSessionState.OnStateChange -= ShowNsfwChanged;
-}
diff --git a/Pages/Gallery.razor.css b/Pages/Gallery.razor.css
deleted file mode 100644
index 6226d9b..0000000
--- a/Pages/Gallery.razor.css
+++ /dev/null
@@ -1,15 +0,0 @@
-img {
- height: auto;
- margin-right: 5px;
- max-height: 200px;
- max-width: 100%;
- width: auto;
-}
-
-div#feed-error {
- left: 50%;
- padding: 10px;
- position: relative;
- top: 50%;
- transform: translate(-50%, -50%);
-} \ No newline at end of file
diff --git a/Pages/Login.razor b/Pages/Login.razor
deleted file mode 100644
index 723a78a..0000000
--- a/Pages/Login.razor
+++ /dev/null
@@ -1,17 +0,0 @@
-@page "/Login"
-@inject NavigationManager navigationManager
-
-<PageTitle>HyperBooru Login</PageTitle>
-
-<div/>
-
-@code {
- [CascadingParameter]
- public Task<AuthenticationState> AuthenticationState{ get; set; }
-
- protected override void OnInitialized() {
- var authState = AuthenticationState.GetAwaiter().GetResult();
- if(authState!.User.Identity?.IsAuthenticated ?? false)
- navigationManager.NavigateTo("/");
- }
-} \ No newline at end of file
diff --git a/Pages/Login.razor.css b/Pages/Login.razor.css
deleted file mode 100644
index fc8c8ca..0000000
--- a/Pages/Login.razor.css
+++ /dev/null
@@ -1,6 +0,0 @@
-div {
- background: url('/images/loginbg.webp');
- filter: brightness(0.6);
- height: 100%;
- width: 100%;
-} \ No newline at end of file
diff --git a/Pages/TagDefinitions.razor b/Pages/TagDefinitions.razor
deleted file mode 100644
index f3dca0f..0000000
--- a/Pages/TagDefinitions.razor
+++ /dev/null
@@ -1,187 +0,0 @@
-@page "/TagDefinitions"
-@inject IDbContextFactory<HBContext> dbFactory
-@inject ITagService tagService
-@inject IUserService userService
-@implements IDisposable
-@attribute [Authorize]
-
-<PageTitle>Tag Definitions</PageTitle>
-
-<div style="padding:var(--size-default-gap);">
- <ButtonContainer>
- <button @onclick=PromptTagCreate data-keyboard-shortcut="c"><u>C</u>reate</button>
- </ButtonContainer>
-
- <TabContainer @ref=tabContainer>
- @foreach(var ns in tagNamespaces) {
- <TabPane Title="@(ns ?? "Default")">
- <table id="tag-definitions" class="data-table">
- <tr>
- <th>Alias</th>
- <th>Name</th>
- <th>Implicit Tags</th>
- <th></th>
- </tr>
- @foreach(var tagDef in tagDefinitions.Where(td => td.Namespace == ns)) {
- <tr data-guid="@tagDef.Guid">
- <td>@tagDef.Alias</td>
- <td>
- <a href="/Gallery?t=@tagDef.Guid" class="nondecorated">
- @tagDef.Name
- </a>
- </td>
- <td>
- <i>
- @{
- var implicitTags = tagDef.ImplicitTags
- .Where(td => td.Source == TagSource.UserTag);
- foreach(var tag in implicitTags) {
- <a href="/Gallery?q=@tag.Name" class="nondecorated">
- @tag.Name
- </a>
- if(tag != implicitTags.Last())
- @(", ")
- }
- }
- </i>
- </td>
- <td class="actions">
- <a href="javascript:;" @onclick=@(() => tagEditDialog.Show(tagDef))>Edit</a>
- <a href="javascript:;" @onclick=@(() => PromptToDelete(tagDef))>
- Delete
- </a>
- <a href="javascript:;" @onclick=@(() => PromptImplicitTags(tagDef))>
- Implicit Tags
- </a>
- @if(tagDef.ImplicitTags.Select(td => td.Guid).Contains(HBContext.NsfwTag)) {
- <a href="javascript:;" @onclick=@(() => SetNsfw(tagDef, false))>Make SFW</a>
- } else {
- <a href="javascript:;" @onclick=@(() => SetNsfw(tagDef, true))>Make NSFW</a>
- }
- </td>
- </tr>
- }
- </table>
- </TabPane>
- }
- </TabContainer>
-</div>
-
-<Dialog Title="Are you sure you want to delete this tag definition?" @ref=deleteTagDialog>
- <ButtonContainer>
- <button @onclick=@(() => deleteTagDialog.Hide()) class="secondary">Cancel</button>
- <button @onclick=@(() => DeleteTagDefinition()) class="warning">Confirm</button>
- </ButtonContainer>
-</Dialog>
-
-<TagEditDialog OnTagUpdate=TagUpdated @ref=tagEditDialog/>
-
-<TagSelectDialog
- OnSubmit=SetImplicitTags
- @ref=implicitTagDialog />
-
-@code {
- private TabContainer tabContainer;
- private Dialog deleteTagDialog;
- private TagEditDialog tagEditDialog;
- private TagSelectDialog implicitTagDialog;
-
- private TagDefinition? toDelete;
- private TagDefinition? toEditImplicit;
-
- private TagDefinition[] tagDefinitions;
-
- private string?[] tagNamespaces;
-
- protected override void OnInitialized() =>
- userService.UserSessionState.OnStateChange += ShowNsfwChanged;
-
- protected override void OnParametersSet() =>
- LoadTags();
-
- private void LoadTags() {
- int[] nsfwTags = Array.Empty<int>();
- if(!userService.UserSessionState.ShowNsfw)
- nsfwTags = tagService.TagsThatImply(HBContext.NsfwTag)
- .Select(td => td.ObjectId)
- .ToArray();
-
- tagDefinitions = dbFactory.CreateDbContext().TagDefinitions
- .Include(td => td.ImplicitTags)
- .Where(td => td.Source == TagSource.UserTag)
- .OrderBy(td => td.Namespace)
- .ThenBy(td => td.Name)
- .AsEnumerable()
- .Where(td => userService.UserSessionState.ShowNsfw || !td.ImplicitTags
- .IntersectBy(nsfwTags, td => td.ObjectId)
- .Any())
- .ToArray();
-
- tagNamespaces = tagDefinitions
- .Select(td => td.Namespace)
- .Order()
- .Distinct()
- .ToArray();
- }
-
- private void PromptToDelete(TagDefinition toDelete) {
- this.toDelete = toDelete;
- deleteTagDialog.Show();
- }
-
- private void DeleteTagDefinition() {
- if(toDelete is null)
- return;
-
- tagService.DeleteTagDefinition(toDelete);
- deleteTagDialog.Hide();
- LoadTags();
- StateHasChanged();
- }
-
- private void PromptTagCreate() {
- string? ns = tabContainer.ActivePane?.Title;
- if(ns == "Default")
- ns = null;
- tagEditDialog.Show(ns);
- }
-
- private void TagUpdated(object? sender, EventArgs e) {
- LoadTags();
- StateHasChanged();
- }
-
- private void PromptImplicitTags(TagDefinition toEditImplicit) {
- this.toEditImplicit = toEditImplicit;
- implicitTagDialog.SelectedTags =
- toEditImplicit.ImplicitTags.ToArray();
- implicitTagDialog.Show();
- }
-
- private void SetImplicitTags(TagDefinition[] tagDefs) {
- if(toEditImplicit is null)
- return;
-
- tagService.SetImplicitTags(toEditImplicit, tagDefs);
- LoadTags();
- StateHasChanged();
- }
-
- private void SetNsfw(TagDefinition tagDef, bool nsfw) {
- if(nsfw)
- tagService.AddImplicitTag(tagDef.Guid, HBContext.NsfwTag);
- else
- tagService.RemoveImplicitTag(tagDef.Guid, HBContext.NsfwTag);
- LoadTags();
- StateHasChanged();
- }
-
- private async void ShowNsfwChanged(UserSessionState userSessionState) =>
- await InvokeAsync(() => {
- LoadTags();
- StateHasChanged();
- });
-
- public void Dispose() =>
- userService.UserSessionState.OnStateChange -= ShowNsfwChanged;
-}
diff --git a/Pages/TagDefinitions.razor.css b/Pages/TagDefinitions.razor.css
deleted file mode 100644
index 409eacc..0000000
--- a/Pages/TagDefinitions.razor.css
+++ /dev/null
@@ -1,5 +0,0 @@
-@media (hover: none) and (pointer: coarse) {
- td, th {
- font-size: 6pt;
- }
-} \ No newline at end of file
diff --git a/Pages/Upload.razor b/Pages/Upload.razor
deleted file mode 100644
index 6d6e8bc..0000000
--- a/Pages/Upload.razor
+++ /dev/null
@@ -1,43 +0,0 @@
-@page "/Upload"
-@attribute [Authorize]
-
-<div id="dropzone">
- <p></p>
- <form id="uploadForm" action="/media" method="post" enctype="multipart/form-data">
- <input type="file" id="fileUpload" name="fileUpload" accept="image/*,video/*" multiple/>
- </form>
-</div>
-
-<script suppress-error="BL9992">
- var dropzone = document.getElementById('dropzone');
- var uploadForm = document.getElementById('uploadForm');
- var fileUpload = document.getElementById('fileUpload');
-
- dropzone.ondragover = function (e) {
- e.preventDefault();
- }
-
- dropzone.ondragenter = function(e) {
- e.preventDefault();
- dropzone.classList.toggle('hover', true);
- }
-
- dropzone.ondragleave = function(e) {
- e.preventDefault();
- dropzone.classList.toggle('hover', false);
- }
-
- dropzone.ondrop = function(e) {
- e.preventDefault();
- fileUpload.files = e.dataTransfer.files;
- uploadForm.submit();
- }
-
- dropzone.onclick = function(e) {
- fileUpload.click();
- }
-
- fileUpload.onchange = function(e) {
- uploadForm.submit();
- }
-</script>
diff --git a/Pages/Upload.razor.css b/Pages/Upload.razor.css
deleted file mode 100644
index d510bc6..0000000
--- a/Pages/Upload.razor.css
+++ /dev/null
@@ -1,48 +0,0 @@
-div#dropzone {
- border-radius: 10px;
- border: 3px dashed #aaa;
- cursor: pointer;
- height: 400px;
- left: 50%;
- position: relative;
- top: 50%;
- transform: translate(-50%, -50%);
- transition: border-color 0.1s linear;
- width: min(700px, 85%);
-}
-
-div#dropzone p {
- color: #aaa;
- display: inline-block;
- left: 50%;
- margin: 0;
- position: relative;
- text-align: center;
- top: 50%;
- transform: translate(-50%, -50%);
-}
-
-div#dropzone p::before {
- content: "Drag a file to upload it\Aor click to select one or more file(s)";
- white-space: pre;
-}
-
-@media (hover: none) and (pointer: coarse) {
- div#dropzone p::before {
- content: "Tap to select a file to upload";
- }
-}
-
-div#dropzone input {
- display: none;
-}
-
-@media (hover: hover) {
- div#dropzone.hover, div#dropzone:hover {
- border: 3px dashed white;
- }
-
- div#dropzone.hover p, div#dropzone:hover p {
- color: white;
- }
-} \ No newline at end of file
diff --git a/Pages/ViewMedia.razor b/Pages/ViewMedia.razor
deleted file mode 100644
index 46cbc45..0000000
--- a/Pages/ViewMedia.razor
+++ /dev/null
@@ -1,265 +0,0 @@
-@page "/ViewMedia"
-@using HyperBooru.Util
-@inject IJSRuntime jsRuntime
-@inject IDbContextFactory<HBContext> dbFactory
-@inject ITagService tagService
-@inject IMediaService mediaService
-@inject ISourceService sourceService
-@attribute [Authorize]
-
-<PageTitle>@title</PageTitle>
-
-<script suppress-warning="BL9992">
- function toggleSidebar() {
- document.getElementById("hcontainer").classList.toggle("hide-metadata");
- }
-
- function setMobilePane(pane) {
- var panes = Array.from(document.querySelectorAll('[class^="mobile-pane-"]'));
-
- panes.forEach(e => e.classList.remove('visible'));
- panes
- .filter(e => e.classList.contains(`mobile-pane-${pane}`))
- .forEach(e => e.classList.add('visible'));
- }
-
- function pageKeyDownHandler(e) {
- if(!e.ctrlKey && !e.metaKey && !e.altKey && !e.shiftKey && !e.isComposing)
- if(e.key == 's')
- toggleSidebar();
- }
-</script>
-
-<div id="vcontainer">
- <div id="hcontainer">
- <div id="image-container" class="mobile-pane-image visible">
- <img
- src="/media/@(media.Guid)"
- width=@media.CurrentUploadedFile.Width
- height=@media.CurrentUploadedFile.Height/>
- </div>
- <div id="metadata-show-button">
- <a href="javascript:toggleSidebar();" title="Toggle sidebar (S)"></a>
- </div>
- <div id="metadata" class="mobile-pane-metadata">
- <div id="metadata-container">
- <div id="metadata-fileinfo">
- @if(infoEditMode) {
- <form action="javascript:;" @onsubmit=@(() => ApplyInfoEdit(true))>
- <table id="edit-metadata">
- <tr>
- <td>Title:</td>
- <td><input type="text" @bind=shortDescription @ref=shortDescriptionInput/></td>
- </tr>
- <tr>
- <td>Description:</td>
- <td><textarea rows="4" @bind=longDescription/></td>
- </tr>
- </table>
- </form>
- } else {
- <p>Title: <i>@(media.ShortDescription ?? "None")</i></p>
- <p class="newlines">Description:<br/><i>@(media.LongDescription ?? "None")</i></p>
- }
- <p>Resolution: @(media.CurrentUploadedFile.Width)x@(media.CurrentUploadedFile.Height)</p>
- <p class="heading">Upload history</p>
- <hr/>
- <table id="uploaded-files" class="data-table">
- <tr>
- <th>Created On</th>
- <th>Last Write</th>
- <th>Uploaded On</th>
- <th>Filename</th>
- <th>Size</th>
- <th>Original Checksum</th>
- </tr>
- @foreach(var file in media.UploadedFiles.OrderByDescending(uf => uf.UploadTime)) {
- string? sourceUrl = null;
- if(file.Filename is not null)
- sourceUrl = sourceService.GetUrlFromFilename(file.Filename);
- <tr>
- <td title=@file.CreateTime?.ToString()>
- @(file.CreateTime?.ToString("d") ?? "N/A")
- </td>
- <td title=@file.LastWriteTime?.ToString()>
- @(file.LastWriteTime?.ToString("d") ?? "N/A")
- </td>
- <td title=@file.UploadTime>@(file.UploadTime.ToString("d"))</td>
- <td title=@(file.Path is not null ? $"{file.Path.Replace('\\', '/')}/{file.Filename}" : file.Filename)>
- @if(sourceUrl is not null) {
- <a class="nondecorated" target="_blank" href=@sourceUrl>@file.Filename</a>
- } else {
- @file.Filename
- }
- </td>
- <td title=@file.Length>@file.Length.ToBytesSI()</td>
- <td
- title=@(file.Checksum + (file.ChecksumVerified ? " (verified)" : ""))
- class=@(file.ChecksumVerified ? "verified" : null)>
-
- @file.Checksum.Substring(0, 8)
- </td>
- </tr>
- }
- </table>
- </div>
- <div id="metadata-tags">
- <p class="heading">Tags</p>
- <hr/>
- <MediaTagTable Media=media @ref=mediaTagTable/>
- </div>
- </div>
- <div id="button-container">
- <ButtonContainer>
- <button @onclick=@(() => deleteDialog.Show()) class="warning" data-keyboard-shortcut="d">
- <img src="/images/trash.svg"/>
- <p><u>D</u>elete</p>
- </button>
- <button @onclick=@(() => tagDialog.Show()) class="secondary" data-keyboard-shortcut="t">
- <img src="/images/tag.svg"/>
- <p>Add <u>T</u>ag</p>
- </button>
- <button @onclick=@(() => ocrDialog.Show()) class="secondary" data-keyboard-shortcut="o">
- <img src="/images/book.svg"/>
- <p>View <u>O</u>CR</p>
- </button>
- @if(infoEditMode) {
- <button @onclick=@(() => ApplyInfoEdit(false)) class="secondary">
- <img src="/images/cross.svg"/>
- <p>Cancel</p>
- </button>
- <button @onclick=@(() => ApplyInfoEdit(true))>
- <img src="/images/checkmark.svg"/>
- <p>Apply</p>
- </button>
- } else {
- <button @onclick=@(() => InfoEditMode = true) class="secondary" data-keyboard-shortcut="e">
- <img src="/images/edit.svg"/>
- <p><u>E</u>dit Info</p>
- </button>
- }
- @if(media.IsIngest) {
- <button @onclick=@(() => SetIngest(false)) data-keyboard-shortcut="c">
- <img src="/images/checkmark.svg"/>
- <p>Mark Tagging <u>C</u>omplete</p>
- </button>
- } else {
- <button class="secondary" @onclick=@(() => SetIngest(true)) data-keyboard-shortcut="c">
- <img src="/images/cross.svg"/>
- <p>Mark Tagging In<u>c</u>omplete</p>
- </button>
- }
- </ButtonContainer>
- </div>
- </div>
- </div>
- <div id="bottom-bar">
- <img onclick="setMobilePane('image');" src="/images/photo.svg" width="25" height="25"/>
- <img onclick="setMobilePane('metadata');" src="/images/info.svg" width="25" height="25"/>
- </div>
-</div>
-
-<Dialog Title="Delete this media?" @ref=deleteDialog>
- <ButtonContainer>
- <button @onclick=@(() => deleteDialog.Hide()) class="secondary">Cancel</button>
- <button @onclick=DeleteMedia class="warning">Confirm</button>
- </ButtonContainer>
-</Dialog>
-
-<Dialog Title="OCR Data" @ref=ocrDialog>
- @if(media.OcrData is null) {
- <p><center>This media item hasn't been scanned yet!</center></p>
- } else {
- <code style="max-height:400px;">@media.OcrData?.Text</code>
- }
- <ButtonContainer>
- <button @onclick=@(() => ocrDialog.Hide())>Close</button>
- </ButtonContainer>
-</Dialog>
-
-<TagSelectDialog
- Title="Select one or more tag(s) to add"
- OnSubmit=AddTags
- @ref=tagDialog/>
-
-@code {
- [Parameter]
- [SupplyParameterFromQuery(Name = "m")]
- public Guid MediaId { get; set; }
-
- private Media media;
-
- private string title;
-
- private bool infoEditMode = false;
- private string? shortDescription;
- private string? longDescription;
-
- private MediaTagTable mediaTagTable;
- private Dialog deleteDialog;
- private Dialog ocrDialog;
- private TagSelectDialog tagDialog;
-
- private ElementReference shortDescriptionInput;
-
- protected override void OnInitialized() =>
- LoadMedia();
-
- protected override async void OnAfterRender(bool firstRender) {
- if(infoEditMode)
- await shortDescriptionInput.FocusAsync();
- }
-
- private void LoadMedia() {
- using var db = dbFactory.CreateDbContext();
- media = db.Media
- .Include(m => m.Tags)
- .ThenInclude(t => t.TagDefinition)
- .Include(m => m.CurrentUploadedFile)
- .Include(m => m.UploadedFiles)
- .Include(m => m.OcrData)
- .First(m => m.Guid == MediaId);
-
- title = media.DisplayName ?? "Media View";
- }
-
- private void AddTags(TagDefinition[] tagDefs) {
- foreach(var tagDef in tagDefs)
- tagService.AddTag(media, tagDef);
- mediaTagTable.Refresh();
- }
-
- private async void SetIngest(bool ingest) {
- mediaService.SetIngest(media, ingest);
- LoadMedia();
-
- if(ingest)
- StateHasChanged();
- else
- await jsRuntime.InvokeVoidAsync("history.back");
- }
-
- private bool InfoEditMode {
- get => infoEditMode;
- set {
- shortDescription = media.ShortDescription;
- longDescription = media.LongDescription;
- infoEditMode = value;
- StateHasChanged();
- }
- }
-
- private void ApplyInfoEdit(bool apply) {
- if(apply) {
- mediaService.SetDescription(media, shortDescription, longDescription);
- LoadMedia();
- }
-
- infoEditMode = false;
- }
-
- private async void DeleteMedia() {
- mediaService.Delete(media);
- await jsRuntime.InvokeVoidAsync("history.back");
- }
-}
diff --git a/Pages/ViewMedia.razor.css b/Pages/ViewMedia.razor.css
deleted file mode 100644
index 1a856d3..0000000
--- a/Pages/ViewMedia.razor.css
+++ /dev/null
@@ -1,222 +0,0 @@
-div#vcontainer {
- align-items: start;
- display: flex;
- flex-direction: column;
- height: 100%;
- overflow: hidden;
- width: 100%;
-}
-
-div#hcontainer {
- align-items: start;
- display: flex;
- flex-direction: row;
- height: 100%;
- overflow: hidden;
- width: 100%;
-}
-
-div#image-container {
- box-sizing: border-box;
- flex: 1 0 0;
- height: 100%;
- overflow: auto;
- padding: var(--size-default-gap);
- width: 100%;
-}
-
-@media (hover: none) and (pointer: coarse) {
- div#image-container {
- padding: 0 !important;
- }
-}
-
-div#image-container > img {
- display: block;
- left: 50%;
- max-height: 100%;
- max-width: 100%;
- object-fit: contain;
- position: relative;
- top: 50%;
- transform: translate(-50%, -50%);
-}
-
-div#metadata-show-button {
- display: flex;
- flex-direction: column;
- height: 100%;
- justify-content: center;
- user-select: none;
- width: 20px;
-}
-
-div#metadata-show-button > a::before {
- content: "\25B6";
-}
-
-div#hcontainer.hide-metadata > div#metadata-show-button > a::before {
- content: "\25C0" !important;
-}
-
-@media (hover: none) and (pointer: coarse) {
- div#metadata-show-button {
- display: none !important;
- }
-}
-
-div#metadata-show-button > a {
- /* TODO: Use colours from global.css */
- background: #333;
- border-radius: 10px 0 0 10px;
- color: #fff;
- display: block;
- padding: 15px 0 15px 0;
- text-align: center;
-}
-
-div#metadata-show-button > a:hover {
- filter: brightness(1.5);
-}
-
-div#metadata-show-button > a:active {
- background: #fff;
-}
-
-div#metadata {
- background: #333;
- box-shadow: rgba(0, 0, 0, 0.25) -10px 0px 10px;
- box-sizing: border-box;
- display: flex;
- flex-direction: column;
- flex: 0 0 auto;
- height: 100%;
- margin-left: auto;
- padding: 30px;
- transition: margin-right 0.1s linear;
- width: 700px;
- z-index: 90;
-}
-
-@media (hover: hover) and (pointer: fine) {
- div#hcontainer.hide-metadata > div#metadata {
- box-shadow: none;
- margin-right: -700px;
- }
-}
-
-@media (hover: none) and (pointer: coarse) {
- [class^="mobile-pane-"] {
- width: 100% !important;
- }
-
- [class^="mobile-pane-"]:not(.visible) {
- display: none !important;
- }
-}
-
-div#button-container {
- margin-top: auto;
-}
-
-@media (hover: none) and (pointer: coarse) {
- div#button-container button {
- font-size: 8pt;
- }
-}
-
-div#metadata-container {
- overflow-x: hidden;
- overflow-y: auto;
-}
-
-table#edit-metadata {
- border-collapse: collapse;
- width: 100%;
-}
-
-table#edit-metadata tr:first-child {
- vertical-align: middle;
-}
-
-table#edit-metadata tr:last-child {
- vertical-align: top;
-}
-
-table#edit-metadata td:last-child {
- width: 100%;
-}
-
-table#edit-metadata td > input {
- width: 100%;
- margin: 0;
-}
-
-table#edit-metadata td > textarea {
- margin: 0;
- resize: none;
- width: 100%;
-}
-
-table#uploaded-files th {
- font-size: 8pt;
-}
-
-table#uploaded-files td {
- font-family: 'Lucida Console';
- font-size: 7pt;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-@media (hover: none) and (pointer: coarse) {
- table#uploaded-files th,
- table#uploaded-files td {
- font-size: 6pt;
- }
-}
-
-table#uploaded-files td:nth-child(4) {
- max-width: 170px;
-}
-
-table#uploaded-files td.verified {
- color: var(--col-checksum-verified-pri);
-}
-
-p.heading {
- margin-top: 30px;
-}
-
-p.newlines {
- white-space: pre-line;
-}
-
-div#bottom-bar {
- /* TODO: Use colours from global.css */
- align-items: center;
- background: #141414;
- box-shadow: rgba(0, 0, 0, 0.25) 0px -5px 5px;
- display: none;
- flex-direction: row;
- width: 100%;
-}
-
-@media (hover: none) and (pointer: coarse) {
- div#bottom-bar {
- display: flex;
- }
-}
-
-div#bottom-bar > img {
- color: white;
- margin: auto;
- padding: 10px;
-}
-
-div#bottom-bar > img:active {
- /* TODO: Use colours from global.css */
- background: white;
- color: #141414;
-}
diff --git a/Pages/_Host.cshtml b/Pages/_Host.cshtml
deleted file mode 100644
index 28ff24c..0000000
--- a/Pages/_Host.cshtml
+++ /dev/null
@@ -1,37 +0,0 @@
-@page "/"
-@using Microsoft.AspNetCore.Components.Web
-@namespace HyperBooru.Pages
-@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
-
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
- <base href="~/" />
- <link href="css/site.css" rel="stylesheet" />
- <link href="/styles/global.css" rel="stylesheet" />
- <link href="/favicon.ico" rel="icon" />
- <link href="/manifest.webmanifest" rel="manifest" />
- <script type="text/javascript" src="/js/dialog.js"></script>
- <script type="text/javascript" src="/js/keyboard.js"></script>
- <script type="text/javascript" src="/js/mobile.js"></script>
- <component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
-</head>
-<body>
- <component type="typeof(App)" render-mode="ServerPrerendered" />
-
- <div id="blazor-error-ui">
- <environment include="Staging,Production">
- An error has occurred. This application may no longer respond until reloaded.
- </environment>
- <environment include="Development">
- An unhandled exception has occurred. See browser dev tools for details.
- </environment>
- <a href="" class="reload">Reload</a>
- <a class="dismiss">🗙</a>
- </div>
-
- <script src="_framework/blazor.server.js"></script>
-</body>
-</html>
diff --git a/Program.cs b/Program.cs
index 5863368..d159d2d 100644
--- a/Program.cs
+++ b/Program.cs
@@ -1,9 +1,5 @@
-using HyperBooru.Services;
using Microsoft.AspNetCore.Authentication.Cookies;
-using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Http.Json;
-using Microsoft.EntityFrameworkCore;
-using System.Text.Json.Serialization;
namespace HyperBooru;
@@ -11,14 +7,9 @@ public class Program {
public static void Main(string[] args) {
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSession();
- builder.Services.AddHttpContextAccessor();
builder.Services.AddAuthentication(
CookieAuthenticationDefaults.AuthenticationScheme).AddCookie();
builder.Services.AddAuthorization();
- builder.Services.AddControllers().AddJsonOptions(o => {
- var converter = new JsonStringEnumConverter();
- o.JsonSerializerOptions.Converters.Add(converter);
- });
builder.Services.Configure<JsonOptions>(o => {
o.SerializerOptions.TypeInfoResolverChain.Insert(0, new ExceptionJsonResolver());
});
@@ -26,30 +17,9 @@ public class Program {
builder.Services.AddServerSideBlazor();
// Add our custom services
- builder.Services.AddSingleton<IConfigService, ConfigService>();
- builder.Services.AddDbContextFactory<HBContext>();
- builder.Services.AddScoped<IFeedService, FeedService>();
- builder.Services.AddScoped<ITagService, TagService>();
- builder.Services.AddScoped<IMediaService, MediaService>();
- builder.Services.AddSingleton<IGlobalUserService, GlobalUserService>();
- builder.Services.AddScoped<IUserService, UserService>();
- builder.Services.AddHostedService<OcrService>();
- builder.Services.AddSingleton<ISourceService, SourceService>();
-
- // Ensure session keys are stored in a persistent location on all platforms
- builder.Services.AddDataProtection()
- .PersistKeysToFileSystem(new(
- builder.Services.BuildServiceProvider()
- .GetRequiredService<IConfigService>()
- .KeyPath));
var app = builder.Build();
- // Ensure database is created and it's schema is up to date
- using var scope = app.Services.CreateScope();
- using var db = scope.ServiceProvider.GetRequiredService<HBContext>();
- db.Database.Migrate();
-
app.UseRouting();
app.UseSession();
app.UseAuthentication();
@@ -59,7 +29,6 @@ public class Program {
app.UseStaticFiles();
app.UseMiddleware<ExceptionMiddleware>();
app.MapBlazorHub();
- app.MapControllers();
app.MapFallbackToPage("/_Host");
app.Run();
diff --git a/Services/ConfigService.cs b/Services/ConfigService.cs
deleted file mode 100644
index ac1f155..0000000
--- a/Services/ConfigService.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-using HyperBooru.ApiModels;
-
-namespace HyperBooru.Services;
-
-public interface IConfigService {
- public string DataPath { get; }
- public string KeyPath { get; }
- public string DbConnectionString { get; }
- public string MediaBasePath { get; }
- public string ThumbnailBasePath { get; }
- public string ConvertedMediaBasePath { get; }
- public bool EnableOcr { get; }
-}
-
-public class ConfigService : IConfigService {
- private IConfiguration config;
-
- private const string AppName = "HyperBooru";
-
- public string DataPath {
- get {
- #if DEBUG
- return "Data";
- #else
- string? path = config["DataPath"];
- if(path is not null)
- return path;
-
- switch(Environment.OSVersion.Platform) {
- case PlatformID.Win32NT:
- return Path.Join(
- Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
- AppName);
- case PlatformID.Unix:
- return $"/var/lib/{AppName.ToLower()}";
- default:
- throw new NotImplementedException(
- $"Unknown Operating System: {Environment.OSVersion.Platform}");
- }
- #endif
- }
- }
-
- public string KeyPath =>
- Path.Join(DataPath, "keys");
-
- public string DbConnectionString =>
- config.GetConnectionString("DefaultConnection") ??
- throw new HBException("Unable to get default connection string");
-
- public string MediaBasePath =>
- Path.Join(DataPath, "media");
-
- public string ThumbnailBasePath =>
- Path.Join(DataPath, "thumb");
-
- public string ConvertedMediaBasePath =>
- Path.Join(DataPath, "converted");
-
- public bool EnableOcr =>
- bool.TryParse(config["DisableOcr"], out bool x) ? !x : true;
-
- public ConfigService(IConfiguration config) {
- this.config = config;
- InitDirectoryStructure();
- }
-
- private void InitDirectoryStructure() {
- Directory.CreateDirectory(DataPath);
- Directory.CreateDirectory(MediaBasePath);
- }
-} \ No newline at end of file
diff --git a/Services/FeedService.cs b/Services/FeedService.cs
deleted file mode 100644
index 3744e73..0000000
--- a/Services/FeedService.cs
+++ /dev/null
@@ -1,212 +0,0 @@
-using HyperBooru.ApiModels;
-using Microsoft.EntityFrameworkCore;
-
-namespace HyperBooru.Services;
-
-public interface IFeedService {
- public Media[] LoadChunk(
- bool selectIngest,
- bool includeNsfw,
- Media? key = null,
- int count = 50,
- SortOrder sortOrder = SortOrder.ObjectId);
-
- public Media[] LoadChunk(
- bool selectIngest,
- bool includeNsfw,
- string query,
- Media? key = null,
- int count = 50,
- SortOrder sortOrder = SortOrder.ObjectId);
-
- public Media[] LoadChunk(
- bool selectIngest,
- bool includeNsfw,
- Guid tagId,
- Media? key = null,
- int count = 50,
- SortOrder sortOrder = SortOrder.ObjectId);
-
- public Media[] LoadChunk(FeedRequest feedRequest);
-}
-
-public class FeedService : IFeedService {
- private IDbContextFactory<HBContext> dbFactory;
-
- public FeedService(IDbContextFactory<HBContext> dbFactory) =>
- this.dbFactory = dbFactory;
-
- public Media[] LoadChunk(
- bool selectIngest,
- bool includeNsfw,
- Media? continuationToken,
- int count,
- SortOrder sortOrder) => LoadChunkInternal(
- selectIngest, includeNsfw, null, null, continuationToken?.Guid, count, sortOrder);
-
- public Media[] LoadChunk(
- bool selectIngest,
- bool includeNsfw,
- string query,
- Media? continuationToken,
- int count,
- SortOrder sortOrder) => LoadChunkInternal(
- selectIngest, includeNsfw, query, null, continuationToken?.Guid, count, sortOrder);
-
- public Media[] LoadChunk(
- bool selectIngest,
- bool includeNsfw,
- Guid tagId,
- Media? continuationToken,
- int count,
- SortOrder sortOrder) => LoadChunkInternal(
- selectIngest, includeNsfw, null, tagId, continuationToken?.Guid, count, sortOrder);
-
- public Media[] LoadChunk(FeedRequest feedRequest) {
- switch(feedRequest) {
- case FeedSearchRequest searchRequest:
- return LoadChunkInternal(
- selectIngest: searchRequest.SelectIngest,
- includeNsfw: searchRequest.IncludeNsfw,
- query: searchRequest.Query,
- tagId: null,
- continuationToken: searchRequest.ContinuationToken,
- count: searchRequest.Count,
- sortOrder: searchRequest.SortOrder);
- case FeedTagRequest tagRequest:
- return LoadChunkInternal(
- selectIngest: tagRequest.SelectIngest,
- includeNsfw: tagRequest.IncludeNsfw,
- query: null,
- tagId: tagRequest.TagId,
- continuationToken: tagRequest.ContinuationToken,
- count: tagRequest.Count,
- sortOrder: tagRequest.SortOrder);
- default:
- return LoadChunkInternal(
- selectIngest: feedRequest.SelectIngest,
- includeNsfw: feedRequest.IncludeNsfw,
- query: null,
- tagId: null,
- continuationToken: feedRequest.ContinuationToken,
- count: feedRequest.Count,
- sortOrder: feedRequest.SortOrder);
- }
- }
-
- private Media[] LoadChunkInternal(
- bool selectIngest,
- bool includeNsfw,
- string? query,
- Guid? tagId,
- Guid? continuationToken,
- int count,
- SortOrder sortOrder) {
-
- if(selectIngest && !includeNsfw)
- return Array.Empty<Media>();
-
- using var db = dbFactory.CreateDbContext();
-
- IQueryable<Media> media = db.Media
- .AsSingleQuery()
- .AsNoTracking()
- .Include(m => m.Tags)
- .Include(m => m.CurrentUploadedFile);
-
- if(!includeNsfw)
- media = media
- .Where(m => !TagsThatImply(db, HBContext.NsfwTag)
- .Intersect(m.Tags.Select(t => t.TagDefinitionId))
- .Any());
-
- if(selectIngest) {
- media = media
- .Where(m => m.Tags
- .Select(t => t.TagDefinitionId)
- .Contains((int) HBObjectId.IngestTag));
- } else {
- media = media
- .Where(m => !m.Tags
- .Select(t => t.TagDefinitionId)
- .Contains((int) HBObjectId.IngestTag));
- }
-
- if(query is not null) {
- media = Search(media, query);
- } else if(tagId is not null) {
- media = media
- .Where(m => TagsThatImply(db, (Guid) tagId)
- .Intersect(m.Tags.Select(t => t.TagDefinitionId))
- .Any());
- }
-
- if(continuationToken is not null)
- media = media
- .Where(m => m.ObjectId > db.Media.First(m => m.Guid == continuationToken).ObjectId);
-
- switch(sortOrder) {
- case SortOrder.ObjectId:
- media = media.OrderBy(m => m.ObjectId);
- break;
- case SortOrder.LastWriteTime:
- media = media.OrderBy(m => m.CurrentUploadedFile!.LastWriteTime);
- break;
- case SortOrder.Random:
- media = media.OrderBy(m => EF.Functions.Random());
- break;
- }
-
- return media
- .Take(count)
- .ToArray();
- }
-
- private static IQueryable<Media> Search(IQueryable<Media> media, string query) {
- // TODO: search implicit tags as well
-
- query = query.ToLower().Trim();
-
- return media
- .Where(m =>
- (m.ShortDescription != null && m.ShortDescription.ToLower().Contains(query)) ||
- (m.LongDescription != null && m.LongDescription.ToLower().Contains(query)) ||
- (m.UploadedFiles.Any(uf => uf.Filename != null && uf.Filename.ToLower().Contains(query))) ||
- (m.OcrData != null && m.OcrData.SearchableText.ToLower().Contains(query)) ||
- (m.Tags.Any(t => t.TagDefinition.Name.ToLower().Contains(query))));
- }
-
- private static IQueryable<int> TagsThatImply(HBContext db, Guid tagId) =>
- db.Database.SqlQueryRaw<int>("""
- WITH RECURSIVE basetag AS (
- SELECT "ObjectId" FROM "Objects" WHERE "Guid" = {0}
- ),
- impliedtags AS (
- SELECT
- "TagDefinitionObjectId"
- FROM
- "TagDefinitionTagDefinition"
- INNER JOIN
- basetag
- ON
- "ImplicitTagsObjectId" = basetag."ObjectId"
- UNION
- SELECT
- "TagDefinitionTagDefinition"."TagDefinitionObjectId"
- FROM
- "TagDefinitionTagDefinition"
- INNER JOIN
- impliedtags
- ON
- impliedtags."TagDefinitionObjectId" = "TagDefinitionTagDefinition"."ImplicitTagsObjectId"
- )
- SELECT DISTINCT
- "TagDefinitionObjectId" AS "Value"
- FROM impliedtags
- UNION
- SELECT
- "ObjectId" AS "Value"
- FROM
- basetag
- """, tagId);
-}
diff --git a/Services/MediaService.cs b/Services/MediaService.cs
deleted file mode 100644
index e497570..0000000
--- a/Services/MediaService.cs
+++ /dev/null
@@ -1,400 +0,0 @@
-using HyperBooru.ApiModels;
-using ImageMagick;
-using Microsoft.EntityFrameworkCore;
-using MimeDetective;
-using MimeDetective.Definitions;
-using System.Security.Cryptography;
-using System.Text.RegularExpressions;
-
-namespace HyperBooru.Services;
-
-public interface IMediaService {
- public void SetDescription(
- Media media,
- string? shortDescription,
- string? longDescription);
-
- public void SetIngest(Media media, bool ingest);
-
- public Media Create(
- Stream fileData,
- string fileName,
- string? checksum = null,
- DateTime? lastAccessTime = null,
- DateTime? lastWriteTime = null,
- DateTime? createTime = null,
- string? path = null,
- PathType? pathType = null,
- Guid[]? tagIds = null);
-
- public void Delete(Guid media);
- public void Delete(Media media);
- public void DeleteThumbnails(Guid media);
- public void DeleteThumbnails(Media media);
- public Stream GetThumbnail(Guid media, int? width, int? height);
- public Stream GetThumbnail(Media media, int? width, int? height);
- public Stream GetConverted(Guid mediaId, string mimeType = "image/png");
- public Stream GetConverted(Media media, string mimeType = "image/png");
- public string GetPath(Guid media);
- public string GetPath(Media media);
-
-}
-
-public class MediaService : IMediaService {
- private readonly Dictionary<string,MagickFormat> FormatMap = new() {
- ["image/jpeg"] = MagickFormat.Jpeg,
- ["image/jpg"] = MagickFormat.Jpg,
- ["image/png"] = MagickFormat.Png,
- ["image/webp"] = MagickFormat.WebP
- };
-
- private IDbContextFactory<HBContext> dbFactory;
- private IConfigService config;
-
- private IContentInspector inspector;
-
- public MediaService(IDbContextFactory<HBContext> dbFactory,
- IConfigService config) {
-
- this.dbFactory = dbFactory;
- this.config = config;
-
- ContentInspectorBuilder inspectorBuilder = new() {
- Definitions =
- DefaultDefinitions.FileTypes.Images.All()
- .Union(DefaultDefinitions.FileTypes.Video.All())
- .ToList()
- };
-
- inspector = inspectorBuilder.Build();
- }
-
- public void SetIngest(Media media, bool ingest) {
- using var db = dbFactory.CreateDbContext();
- media = db.Media
- .Include(m => m.Tags)
- .ThenInclude(t => t.TagDefinition)
- .First(m => m.Guid == media.Guid);
- var ingestTag = db.TagDefinitions
- .First(td => td.Guid == HBContext.IngestTag);
-
- if(ingest) {
- if(!media.Tags.Select(t => t.TagDefinition.Guid).Contains(HBContext.IngestTag))
- media.Tags.Add(new(ingestTag));
- } else {
- media.Tags.RemoveAll(t => t.TagDefinition.Guid == HBContext.IngestTag);
- }
-
- db.SaveChanges();
- }
-
- public void SetDescription(
- Media media,
- string? shortDescription,
- string? longDescription) {
-
- using var db = dbFactory.CreateDbContext();
- var m = db.Media.First(m => m.Guid == media.Guid);
-
- shortDescription = shortDescription?.Trim();
- longDescription = longDescription?.Trim();
-
- if(string.IsNullOrEmpty(shortDescription))
- shortDescription = null;
- if(string.IsNullOrEmpty(longDescription))
- longDescription = null;
-
- m.ShortDescription = shortDescription;
- m.LongDescription = longDescription;
-
- db.SaveChanges();
- }
-
- public Media Create(
- Stream fileData,
- string fileName,
- string? checksum = null,
- DateTime? lastAccessTime = null,
- DateTime? lastWriteTime = null,
- DateTime? createTime = null,
- string? path = null,
- PathType? pathType = null,
- Guid[]? tagIds = null) {
-
- using var db = dbFactory.CreateDbContext();
- using var transaction = db.Database.BeginTransaction();
-
- if(fileData.Length == 0)
- throw new MediaCreateException("File is empty");
-
- // Calculate the checksum using the in-memory file contents
- var hash = BitConverter
- .ToString(MD5.Create().ComputeHash(fileData))
- .Replace("-", "")
- .ToLower();
-
- if(checksum is not null && hash != checksum.ToLower())
- throw new MediaCreateException("Checksum does not match");
-
- // Determine the MIME type
- fileData.Seek(0, SeekOrigin.Begin);
- var defs = inspector.Inspect(fileData);
- var mime = defs.ByMimeType().FirstOrDefault()?.MimeType;
- if(mime is null)
- throw new MediaCreateException("Unsupported file type");
-
- // Read the image with ImageMagick to determine the width and height
- fileData.Seek(0, SeekOrigin.Begin);
- using var magickImage = new MagickImage(fileData);
-
- var media = db.Media
- .Include(m => m.UploadedFiles)
- .Include(m => m.Tags)
- .FirstOrDefault(m => m.UploadedFiles.Any(uf => uf.Checksum == hash));
-
- var fileRecord = new UploadedFile() {
- Filename = fileName,
- Length = fileData.Length,
- Checksum = hash,
- ChecksumVerified = checksum is not null,
- MimeType = mime,
- Width = (int) magickImage.Width,
- Height = (int) magickImage.Height,
- UploadTime = DateTime.UtcNow,
- LastAccessTime = lastAccessTime,
- LastWriteTime = lastWriteTime,
- CreateTime = createTime,
- Path = pathType is null ? null : path,
- PathType = pathType
- };
-
- var tags = Array.Empty<TagDefinition>();
- if(tagIds is not null) {
- tagIds = tagIds.Distinct().ToArray();
-
- tags = db.TagDefinitions
- .Where(td => tagIds.Contains(td.Guid))
- .ToArray();
-
- if(tags.Count() < tagIds.Count()) {
- var badIds = tagIds
- .Where(x => !tags.Select(td => td.Guid).Contains(x))
- .Order();
-
- throw new MediaCreateException(
- $"Non-existent tags specified: {string.Join(", ", badIds)}");
- }
- }
-
- if(media is null) {
- var ingestTagDef = db.TagDefinitions
- .First(td => td.Guid == HBContext.IngestTag);
-
- media = new() {
- UploadedFiles = new() {
- fileRecord
- },
- Tags = tags is null ? [ new() { TagDefinition = ingestTagDef } ] : tags
- .Select(td => new Tag() { TagDefinition = td })
- .ToList()
- };
-
- using var newFile = File.Create(GetPath(media));
-
- fileData.Seek(0, SeekOrigin.Begin);
- fileData.CopyTo(newFile);
- newFile.Flush();
-
- db.Media.Add(media);
- db.SaveChanges();
- media.CurrentUploadedFile = fileRecord;
- db.SaveChanges();
- } else {
- var fileHashes = media.UploadedFiles
- .Select(uf => GetUploadedFileHash(uf));
- // Only add the uploaded file record if it contains new information
- if(!fileHashes.Contains(GetUploadedFileHash(fileRecord)))
- media.UploadedFiles.Add(fileRecord);
- // Add new tags if needed
- var missingTags = tags
- .Where(td => !media.Tags.Select(t => t.TagDefinition.Guid).Contains(td.Guid));
- media.Tags.AddRange(missingTags.Select(td => new Tag() { TagDefinition = td }));
- db.Update(media);
- db.SaveChanges();
- }
-
- transaction.Commit();
-
- return media;
- }
-
- public void Delete(Guid media) {
- using var db = dbFactory.CreateDbContext();
- var m = db.Media.First(m => m.Guid == media);
-
- var path = Path.Join(
- config.MediaBasePath,
- m.Guid.ToString().Substring(0, 2),
- m.Guid.ToString().Substring(2, 2),
- m.Guid.ToString());
-
- try {
- var fileInfo = new FileInfo(path);
- fileInfo.Delete();
- fileInfo.Directory?.Delete();
- fileInfo.Directory?.Parent?.Delete();
- } catch(IOException) {}
-
- try {
- DeleteThumbnails(media);
- } catch {}
-
- db.Media.Remove(m);
- db.SaveChanges();
- }
-
- public void Delete(Media media) =>
- Delete(media.Guid);
-
- public void DeleteThumbnails(Guid media) {
- var dir = new DirectoryInfo(Path.Join(
- config.ThumbnailBasePath,
- media.ToString().Substring(0, 2),
- media.ToString().Substring(2, 2)));
-
- var pattern = new Regex($"^{media}-[0-9]+-[0-9]+$");
- var toDelete = dir.GetFiles()
- .Where(f => pattern.IsMatch(f.Name))
- .ToList();
-
- List<Exception> exceptions = new();
-
- foreach(var file in toDelete) {
- try {
- file.Delete();
- } catch(Exception e) {
- exceptions.Add(e);
- }
- }
-
- try {
- dir.Delete();
- dir.Parent?.Delete();
- } catch(Exception e) {
- exceptions.Add(e);
- }
-
- // TODO: wrap the AggregateException in a ThumbnailException
- if(exceptions.Count() > 1)
- throw new AggregateException(exceptions);
- }
-
- public void DeleteThumbnails(Media media) =>
- DeleteThumbnails(media.Guid);
-
- public Stream GetThumbnail(Guid mediaId, int? width, int? height) {
- if(width is null && height is null)
- throw new ThumbnailException(
- "Both width and height cannot be null!",
- mediaId);
-
- var thumbPath = GetThumbnailPath(mediaId, width, height);
-
- if(File.Exists(thumbPath))
- return System.IO.File.OpenRead(thumbPath);
-
- if(!File.Exists(GetPath(mediaId)))
- throw new ObjectNotFoundException(mediaId);
-
- using var image = new MagickImage(GetPath(mediaId));
-
- if(width > image.Width || height > image.Height) {
- width = (int) image.Width;
- height = (int) image.Height;
- }
-
- image.Thumbnail((uint) (width ?? -1), (uint) (height ?? -1));
- image.Write(thumbPath, MagickFormat.Jpeg);
-
- return System.IO.File.OpenRead(thumbPath);
- }
-
- public Stream GetConverted(Guid mediaId, string mimeType) {
- if(!FormatMap.TryGetValue(mimeType, out var format))
- throw new MediaException($"Cannot convert to unknown format ({mimeType})", mediaId);
-
- var convertedPath = GetConvertedPath(mediaId, mimeType);
-
- if(File.Exists(convertedPath))
- return System.IO.File.OpenRead(convertedPath);
-
- if(!File.Exists(GetPath(mediaId)))
- throw new ObjectNotFoundException(mediaId);
-
- using var image = new MagickImage(GetPath(mediaId));
- image.Write(convertedPath, format);
-
- return System.IO.File.OpenRead(convertedPath);
- }
-
- public Stream GetThumbnail(Media media, int? width, int? height) =>
- GetThumbnail(media.Guid, width, height);
-
- public Stream GetConverted(Media media, string mimeType) =>
- GetConverted(media.Guid, mimeType);
-
- public string GetPath(Guid mediaId) {
- var fileInfo = new FileInfo(
- Path.Join(
- config.MediaBasePath,
- mediaId.ToString().Substring(0, 2),
- mediaId.ToString().Substring(2, 2),
- mediaId.ToString()));
-
- Directory.CreateDirectory(fileInfo.Directory!.FullName);
- return fileInfo.FullName;
- }
-
- public string GetThumbnailPath(Guid mediaId, int? width, int? height) {
- if(width is null && height is null)
- throw new ThumbnailException(
- "Both width and height cannot be null!",
- mediaId);
-
- var fileInfo = new FileInfo(Path.Join(
- config.ThumbnailBasePath,
- mediaId.ToString().Substring(0, 2),
- mediaId.ToString().Substring(2, 2),
- $"{mediaId.ToString()}-{(width ?? 0)}-{(height ?? 0)}"));
-
- Directory.CreateDirectory(fileInfo.Directory!.FullName);
- return fileInfo.FullName;
- }
-
- public string GetConvertedPath(Guid mediaId, string mimeType) {
- var fileInfo = new FileInfo(Path.Join(
- config.ConvertedMediaBasePath,
- mediaId.ToString().Substring(0, 2),
- mediaId.ToString().Substring(2, 2),
- $"{mediaId.ToString()}-{mimeType.Split('/')[1]}"));
-
- Directory.CreateDirectory(fileInfo.Directory!.FullName);
- return fileInfo.FullName;
- }
-
- public string GetPath(Media media) =>
- GetPath(media.Guid);
-
- public string GetThumbnailPath(Media media, int? width, int? height) =>
- GetThumbnailPath(media.Guid, width, height);
-
- public string GetConvertedPath(Media media, string mimeType) =>
- GetConvertedPath(media.Guid, mimeType);
-
- private int GetUploadedFileHash(UploadedFile uf) => (
- uf.CreateTime,
- uf.LastWriteTime,
- uf.Filename,
- uf.Length,
- uf.Checksum).GetHashCode();
-}
diff --git a/Services/OcrService.cs b/Services/OcrService.cs
deleted file mode 100644
index d43db2e..0000000
--- a/Services/OcrService.cs
+++ /dev/null
@@ -1,128 +0,0 @@
-using HyperBooru.Util;
-using Microsoft.EntityFrameworkCore;
-using System.Diagnostics;
-using System.Runtime.InteropServices;
-using System.Text.RegularExpressions;
-using Tesseract;
-
-namespace HyperBooru.Services;
-
-public class OcrService : IHostedService {
- private readonly string[] InvalidMimeTypes = [ "image/heic", "image/webp" ];
-
- private readonly TimeSpan ProcessInterval = TimeSpan.FromMinutes(30);
- private readonly TimeSpan StartupDelay = TimeSpan.FromSeconds(30);
-
- private readonly Regex SpaceRegex = new(@"[^0-9a-z]+", RegexOptions.Compiled);
-
- private Task? task;
- private CancellationTokenSource cts = new();
-
- private Timer timer;
-
- private IConfigService configService;
- private IServiceScopeFactory scopeFactory;
- private ILogger<OcrService> logger;
- private IDbContextFactory<HBContext> dbFactory;
-
- public OcrService(
- IConfigService configService,
- IServiceScopeFactory scopeFactory,
- ILogger<OcrService> logger,
- IDbContextFactory<HBContext> dbFactory) {
-
- this.configService = configService;
- this.scopeFactory = scopeFactory;
- this.logger = logger;
- this.dbFactory = dbFactory;
-
- timer = new((object? state) => {
- if(task is not null && !task.IsCompleted)
- return;
- cts = new();
- task = ProcessAllAsync(cts.Token);
- });
- }
-
- public Task StartAsync(CancellationToken ct) {
- if(configService.EnableOcr) {
- logger.LogInformation("Service starting...");
- timer.Change(StartupDelay, ProcessInterval);
- }
-
- return Task.CompletedTask;
- }
-
- public Task StopAsync(CancellationToken ct) {
- logger.LogInformation("Service stopping...");
- timer.Change(Timeout.Infinite, Timeout.Infinite);
- cts.Cancel();
- return Task.CompletedTask;
- }
-
- async Task ProcessAllAsync(CancellationToken ct) {
- using var scope = scopeFactory.CreateScope();
- var mediaService = scope.ServiceProvider
- .GetRequiredService<IMediaService>();
-
- using var db = dbFactory.CreateDbContext();
- Guid[] guids = db.Media
- .AsNoTracking()
- .Include(m => m.CurrentUploadedFile)
- .Include(m => m.OcrData)
- .Where(m => m.OcrData == null)
- .Where(m => m.CurrentUploadedFile!.MimeType.Contains("image/"))
- .Where(m => !InvalidMimeTypes.Contains(m.CurrentUploadedFile!.MimeType))
- .Select(m => m.Guid)
- .ToArray();
- db.Dispose();
-
- logger.LogInformation($"Performing OCR pass on {guids.Count()} media items");
-
- var factory = new TaskFactory(new LimitedConcurrencyTaskScheduler());
- var tasks = new List<Task>();
-
- var stopwatch = Stopwatch.StartNew();
-
- foreach(var guid in guids)
- tasks.Add(factory.StartNew(() => Process(guid, mediaService), ct));
-
- await Task.WhenAll(tasks);
- stopwatch.Stop();
-
- var time = stopwatch.Elapsed.ToStringHumanReadable();
- logger.LogInformation(
- $"Performed OCR pass on {guids.Count()} media items in {time}");
- }
-
- private void Process(Guid media, IMediaService mediaService) {
- logger.LogDebug($"Performing OCR on media item {media}");
-
- using var db = dbFactory.CreateDbContext();
- var m = db.Media
- .Include(m => m.OcrData)
- .First(m => m.Guid == media);
-
- OcrData o = m.OcrData ?? new();
-
- using var engine = new TesseractEngine("tessdata", "eng", EngineMode.Default);
- using var image = Pix.LoadFromFile(mediaService.GetPath(m));
- engine.SetVariable("debug_file", NullFile);
-
- o.Timestamp = DateTime.UtcNow;
- o.Text = engine.Process(image).GetText().Trim();
- o.SearchableText = SpaceRegex.Replace(o.Text.ToLower(), " ").Trim();
-
- m.OcrData = o;
- db.SaveChanges();
- }
-
- private string NullFile {
- get {
- if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
- return "NUL";
- else
- return "/dev/null";
- }
- }
-}
diff --git a/Services/SourceService.cs b/Services/SourceService.cs
deleted file mode 100644
index d145346..0000000
--- a/Services/SourceService.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System.Text.RegularExpressions;
-
-namespace HyperBooru.Services;
-
-public interface ISourceService {
- public string? GetUrlFromFilename(string filename);
-}
-
-public class SourceService : ISourceService {
- private Regex PixivRegex =
- new(@"^([0-9]+)_p[0-9]+(_master1200)?\.[^.]+$", RegexOptions.Compiled);
-
- public string? GetUrlFromFilename(string filename) {
- var pixivMatch = PixivRegex.Match(filename);
- if(pixivMatch.Success)
- return $"https://pixiv.net/en/artworks/{pixivMatch.Groups[1].Value}";
-
- return null;
- }
-}
diff --git a/Services/TagService.cs b/Services/TagService.cs
deleted file mode 100644
index f7b91dc..0000000
--- a/Services/TagService.cs
+++ /dev/null
@@ -1,305 +0,0 @@
-using HyperBooru.ApiModels;
-using Microsoft.EntityFrameworkCore;
-
-namespace HyperBooru.Services;
-
-public interface ITagService {
- public void AddTag(Guid obj, Guid tagDef);
- public void AddTag(HBObject obj, TagDefinition tagDef);
- public void RemoveTag(Guid obj, Guid tagDef);
- public void RemoveTag(HBObject obj, TagDefinition tagDef);
- public void SetImplicitTags(TagDefinition tagDef, TagDefinition[] implicitTagDefs);
- public void SetImplicitTags(Guid tagDef, Guid[] implicitTagDefs);
- public void AddImplicitTag(Guid tagDef, Guid implicitTagDef);
- public void AddImplicitTag(TagDefinition tagDef, TagDefinition implicitTagDef);
- public void RemoveImplicitTag(Guid tagDef, Guid implicitTagDef);
- public void RemoveImplicitTag(TagDefinition tagDef, TagDefinition implicitTagDef);
- public void CreateTagDefinition(string name, string? @namespace = null, string? alias = null);
- public void DeleteTagDefinition(Guid tagDef);
- public void DeleteTagDefinition(TagDefinition tagDef);
- public void UpdateTagDefinition(Guid tagDef, string name, string? @namespace = null, string? alias = null);
- public void UpdateTagDefinition(TagDefinition tagDef, string name, string? @namespace = null, string? alias = null);
- public (TagDefinition tagDefinition, bool isImplicit)[] GetAllTags(Guid obj);
- public (TagDefinition tagDefinition, bool isImplicit)[] GetAllTags(HBObject obj);
- public (TagDefinition tagDefinition, bool isImplicit)[] GetAllTags(TagDefinition tagDef);
- public TagDefinition[] TagsThatImply(Guid tagDef);
- public TagDefinition[] TagsThatImply(TagDefinition tagDef);
-}
-
-public class TagService : ITagService {
- private IDbContextFactory<HBContext> dbFactory;
-
- public TagService(IDbContextFactory<HBContext> dbFactory) =>
- this.dbFactory = dbFactory;
-
- public void AddTag(Guid obj, Guid tagDef) {
- using var db = dbFactory.CreateDbContext();
-
- var tag = db.TagDefinitions.First(td => td.Guid == tagDef);
-
- db.Objects
- .Include(o => o.Tags)
- .ThenInclude(t => t.TagDefinition)
- .Where(o => !o.Tags.Select(t => t.TagDefinition.Guid).Contains(tagDef))
- .FirstOrDefault(o => o.Guid == obj)?
- .Tags
- .Add(new(tag));
-
- db.SaveChanges();
- }
-
- public void AddTag(HBObject obj, TagDefinition tagDef) =>
- AddTag(obj.Guid, tagDef.Guid);
-
- public void RemoveTag(Guid obj, Guid tagDef) {
- using var db = dbFactory.CreateDbContext();
-
- db.Objects
- .Include(o => o.Tags)
- .ThenInclude(t => t.TagDefinition)
- .First(o => o.Guid == obj)
- .Tags
- .RemoveAll(t => t.TagDefinition.Guid == tagDef);
-
- db.SaveChanges();
- }
-
- public void RemoveTag(HBObject obj, TagDefinition tagDef) =>
- RemoveTag(obj.Guid, tagDef.Guid);
-
- public void SetImplicitTags(Guid tagDef, Guid[] implicitTagDefs) {
- using var db = dbFactory.CreateDbContext();
- using var transaction = db.Database.BeginTransaction();
-
- var tag = db.TagDefinitions
- .Include(td => td.ImplicitTags)
- .First(td => td.Guid == tagDef);
-
- tag.ImplicitTags.RemoveAll(td => !implicitTagDefs.Contains(td.Guid));
- tag.ImplicitTags.AddRange(
- db.TagDefinitions
- .Where(td => implicitTagDefs.Contains(td.Guid))
- .Where(td => !tag.ImplicitTags
- .Select(td => td.Guid)
- .Contains(td.Guid)));
-
- db.SaveChanges();
- transaction.Commit();
- }
-
- public void SetImplicitTags(TagDefinition tagDef, TagDefinition[] implicitTagDefs) =>
- SetImplicitTags(tagDef.Guid, implicitTagDefs.Select(td => td.Guid).ToArray());
-
- public void AddImplicitTag(Guid tagDef, Guid implicitTagDef) {
- using var db = dbFactory.CreateDbContext();
-
- var tag = db.TagDefinitions
- .Include(td => td.ImplicitTags)
- .First(td => td.Guid == tagDef);
- var implicitTag = db.TagDefinitions.First(td => td.Guid == implicitTagDef);
-
- tag.ImplicitTags.Add(implicitTag);
- db.SaveChanges();
- }
-
- public void AddImplicitTag(TagDefinition tagDef, TagDefinition implicitTagDef) =>
- AddImplicitTag(tagDef, implicitTagDef);
-
- public void RemoveImplicitTag(Guid tagDef, Guid implicitTagDef) {
- using var db = dbFactory.CreateDbContext();
-
- var tag = db.TagDefinitions
- .Include(td => td.ImplicitTags)
- .First(td => td.Guid == tagDef);
-
- tag.ImplicitTags.RemoveAll(td => td.Guid == implicitTagDef);
- db.SaveChanges();
- }
-
- public void RemoveImplicitTag(TagDefinition tagDef, TagDefinition implicitTagDef) =>
- RemoveImplicitTag(tagDef, implicitTagDef);
-
- public void CreateTagDefinition(string name, string? @namespace = null, string? alias = null) {
- using var db = dbFactory.CreateDbContext();
-
- if(string.IsNullOrEmpty(@namespace))
- @namespace = null;
- if(string.IsNullOrEmpty(alias))
- alias = null;
-
- // Remove leading and trailing whitespace
- name = name.Trim();
- @namespace = @namespace?.Trim();
- alias = alias?.Trim();
-
- TagDefinition tagDef = new() {
- Source = TagSource.UserTag,
- Namespace = @namespace,
- Name = name,
- Alias = alias
- };
-
- bool nameExists = db.TagDefinitions.Any(td => td.Name.ToLower() == name.ToLower());
- bool aliasExists = false;
- if(alias is not null)
- aliasExists = db.TagDefinitions
- .Where(td => td.Alias != null)
- .Any(td => td.Alias!.ToLower() == alias.ToLower());
- if(nameExists || aliasExists)
- throw new TagDuplicateException(nameExists, aliasExists);
-
- if(!db.TagDefinitions.Contains(tagDef))
- db.TagDefinitions.Add(tagDef);
- db.SaveChanges();
- }
-
- public void DeleteTagDefinition(Guid tagDef) {
- using var db = dbFactory.CreateDbContext();
-
- var tag = db.TagDefinitions.First(td => td.Guid == tagDef);
-
- using var transaction = db.Database.BeginTransaction();
-
- db.Tags.RemoveRange(
- db.Tags
- .Include(t => t.TagDefinition)
- .Where(t => t.TagDefinition.Guid == tagDef));
- db.TagDefinitions.Remove(tag);
- db.SaveChanges();
-
- transaction.Commit();
- }
-
- public void DeleteTagDefinition(TagDefinition tagDef) =>
- DeleteTagDefinition(tagDef.Guid);
-
- public void UpdateTagDefinition(Guid tagDef, string name, string? @namespace = null, string? alias = null) {
- using var db = dbFactory.CreateDbContext();
-
- if(string.IsNullOrEmpty(@namespace))
- @namespace = null;
- if(string.IsNullOrEmpty(alias))
- alias = null;
-
- // Remove leading and trailing whitespace
- name = name.Trim();
- @namespace = @namespace?.Trim();
- alias = alias?.Trim();
-
- var tag = db.TagDefinitions.First(td => td.Guid == tagDef);
-
- TagDefinition? nameExisting = db.TagDefinitions.FirstOrDefault(td => td.Name.ToLower() == name.ToLower());
- TagDefinition? aliasExisting = null;
- if(alias is not null)
- aliasExisting = db.TagDefinitions
- .Where(td => td.Alias != null)
- .FirstOrDefault(td => td.Alias!.ToLower() == alias.ToLower());
- bool nameExists = nameExisting is not null && nameExisting != tag;
- bool aliasExists = aliasExisting is not null && aliasExisting != tag;
- if(nameExists || aliasExists)
- throw new TagDuplicateException(nameExists, aliasExists);
-
- tag.Name = name;
- tag.Namespace = @namespace;
- tag.Alias = alias;
-
- db.SaveChanges();
- }
-
- public void UpdateTagDefinition(TagDefinition tagDef, string name, string? @namespace = null, string? alias = null) =>
- UpdateTagDefinition(tagDef.Guid, name, @namespace, alias);
-
- private (TagDefinition tagDefinition, bool isImplicit)[] GetAllTags(IEnumerable<TagDefinition> tagDefs) {
- using var db = dbFactory.CreateDbContext();
-
- var tagGuids = tagDefs
- .Select(td => td.Guid)
- .ToArray();
-
- // Query all tag definitions
- var allTags = db.TagDefinitions
- .Include(td => td.ImplicitTags)
- .ToArray();
-
- var tags = new List<TagDefinition>(
- allTags.IntersectBy(
- tagGuids,
- td => td.Guid));
-
- while(true) {
- var toAdd = tags
- .SelectMany(td => td.ImplicitTags)
- .ExceptBy(tags.Select(td => td.Guid), td => td.Guid)
- .ToArray();
-
- if(toAdd.Count() == 0)
- break;
-
- tags.AddRange(toAdd);
- }
-
- return tags
- .Select(td => new ValueTuple<TagDefinition, bool>(td, !tagGuids.Contains(td.Guid)))
- .ToArray();
- }
-
- public (TagDefinition tagDefinition, bool isImplicit)[] GetAllTags(Guid obj) {
- using var db = dbFactory.CreateDbContext();
-
- // Query a list of tag GUIDs for this object
- var tags = db.Objects
- .Include(o => o.Tags)
- .ThenInclude(t => t.TagDefinition)
- .First(o => o.Guid == obj)
- .Tags
- .Select(t => t.TagDefinition)
- .ToArray();
-
- return GetAllTags(tags);
- }
-
-
- public (TagDefinition tagDefinition, bool isImplicit)[] GetAllTags(HBObject obj) =>
- GetAllTags(obj.Guid);
-
- public (TagDefinition tagDefinition, bool isImplicit)[] GetAllTags(TagDefinition tagDef) {
- using var db = dbFactory.CreateDbContext();
-
- var tags = db.TagDefinitions
- .Include(td => td.ImplicitTags)
- .First(td => td.Guid == tagDef.Guid)
- .ImplicitTags
- .ToArray();
-
- return GetAllTags(tags);
- }
-
- public TagDefinition[] TagsThatImply(Guid tagDef) {
- using var db = dbFactory.CreateDbContext();
-
- var tagDefs = db.TagDefinitions
- .Include(td => td.ImplicitTags)
- .ToArray();
-
- var tags = new List<TagDefinition>() {
- db.TagDefinitions.First(td => td.Guid == tagDef)
- };
-
- while(true) {
- var toAdd = tagDefs
- .Where(td => td.ImplicitTags.Select(it => it.Guid).Intersect(tags.Select(td => td.Guid)).Any())
- .ExceptBy(tags.Select(td => td.Guid), td => td.Guid)
- .ToArray();
-
- if(toAdd.Count() == 0)
- break;
-
- tags.AddRange(toAdd);
- }
-
- return tags.ToArray();
- }
-
- public TagDefinition[] TagsThatImply(TagDefinition tagDef) =>
- TagsThatImply(tagDef.Guid);
-}
diff --git a/Services/UserService.cs b/Services/UserService.cs
deleted file mode 100644
index 9e79dc6..0000000
--- a/Services/UserService.cs
+++ /dev/null
@@ -1,76 +0,0 @@
-using Microsoft.AspNetCore.Cryptography.KeyDerivation;
-
-namespace HyperBooru.Services;
-
-public interface IUserService {
- public UserSessionState UserSessionState { get; }
-}
-
-public class UserService : IUserService {
- public UserSessionState UserSessionState =>
- globalUserService.GetSessionState(httpContext.Session.Id);
-
- private IHttpContextAccessor httpContextAccessor;
- private IGlobalUserService globalUserService;
-
- private HttpContext httpContext =>
- httpContextAccessor.HttpContext!;
-
- public UserService(
- IHttpContextAccessor httpContextAccessor,
- IGlobalUserService globalUserService) {
-
- this.httpContextAccessor = httpContextAccessor;
- this.globalUserService = globalUserService;
-
- // HTTP context session states are discarded if no values
- // are set. Set a dummy value so that the session state
- // will not be discarded later when we actually need it.
- httpContext.Session.SetInt32("Persist", 1);
- }
-
- public static string HashPassword(string password) =>
- Convert.ToBase64String(
- KeyDerivation.Pbkdf2(
- password,
- Array.Empty<byte>(),
- KeyDerivationPrf.HMACSHA512,
- 100_000,
- 512 / 8));
-}
-
-public interface IGlobalUserService {
- public UserSessionState GetSessionState(string id);
-}
-
-public class GlobalUserService : IGlobalUserService {
- // TODO: prune this list periodically
- private Dictionary<string, UserSessionState> sessionStates = new();
-
- public UserSessionState GetSessionState(string id) {
- sessionStates.TryGetValue(id, out var state);
-
- if(state is null) {
- state = new();
- sessionStates[id] = state;
- }
-
- return state;
- }
-}
-
-public record UserSessionState {
- public event UserSessionStateChange OnStateChange;
-
- public bool ShowNsfw {
- get => showNsfw;
- set {
- showNsfw = value;
- OnStateChange.Invoke(this);
- }
- }
-
- private bool showNsfw = false;
-}
-
-public delegate void UserSessionStateChange(UserSessionState sessionState);
diff --git a/Tag.cs b/Tag.cs
deleted file mode 100644
index c857c66..0000000
--- a/Tag.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using System.ComponentModel.DataAnnotations.Schema;
-
-namespace HyperBooru;
-
-public enum TagSource {
- Internal,
- UserTag
-}
-
-public class TagDefinition : HBObject {
- public TagSource Source { get; set; } = TagSource.Internal;
- public string? Namespace { get; set; }
- public string Name { get; set; }
- public string? Alias { get; set; }
- public virtual List<TagDefinition> ImplicitTags { get; set; } = new();
-
- public static explicit operator ApiModels.TagDefinition(TagDefinition tagDefinition) => new() {
- TagDefinitionId = tagDefinition.Guid,
- Namespace = tagDefinition.Namespace,
- Name = tagDefinition.Name,
- Alias = tagDefinition.Alias,
- ImplicitTags = tagDefinition.ImplicitTags.Select(td => td.Guid).ToArray()
- };
-}
-
-public class Tag : HBObject {
- [ForeignKey("ObjectId")]
- public int TagDefinitionId { get; set; }
- public virtual TagDefinition TagDefinition { get; set; }
- public DateTime CreateTime { get; set; } = DateTime.UtcNow;
- public virtual HBObject Target { get; set; }
-
- public Tag() {}
-
- public Tag(TagDefinition tagDef) =>
- this.TagDefinition = tagDef;
-}
diff --git a/Todo.md b/Todo.md
deleted file mode 100644
index 23c406d..0000000
--- a/Todo.md
+++ /dev/null
@@ -1,41 +0,0 @@
-# Bugs
- - [X] Images in the gallery on mobile can easily exceed screen width
- - [X] Images smaller than the requested thumbnail size aren't delivered
- - [X] Autocorrect needs to be disabled on inputs such as username, tag name, etc
- - [X] Mobile menu does not automatically hide upon page navigation
- - [X] Input not focused
- - [ ] Setting implicit tags removes builtin tags
- - [X] UserService listeners don't seem to be removed after disposal
- - [X] Cancelling tag creation creates the tag anyway
- - [ ] Prevent marking tagging complete unless there are actually user tags
- - [X] Media upload not deduping media
- - [ ] Can't delete media
-
-# Short-term Features
- - [ ] Ability to set password (at least via API)
- - [ ] PowerShell uploading with initial tagging
- - [ ] Proper thumbnail generation
- - [ ] Video support
- - [ ] User/security support
- - [X] Record in UploadedFiles whether the checksums was verified at upload time
- - [X] Record in Media which UploadedFile actually holds the current content
-
-# Long-term Features
- - [ ] Redirect to last page after login
- - [ ] Enlarge image view in ViewMedia
- - [ ] Periodic thumbnail scrubbing
- - [ ] Loading animations
- - [ ] Keyboard shortcuts
- - [ ] Find source
- - [ ] Collections
- - [ ] Search memes by audio (for some reason)
- - [ ] Jump into ingest feed at random point
- - [ ] Rating system
- - [ ] Instantaneous OCR processing when media is uploaded
- - [ ] OCR status reporting on admin page
- - [ ] Dynamically update OCR data on ViewMedia page
- - [ ] Image deduplication by visual similarity
- - [ ] Audit log
- - [ ] Journaled operations
- - [ ] Confirmation dialog before enabling NSFW mode
- - [ ] Upload progress bars
diff --git a/User.cs b/User.cs
deleted file mode 100644
index 87384d2..0000000
--- a/User.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using Microsoft.EntityFrameworkCore;
-
-namespace HyperBooru;
-
-[Index(nameof(Username))]
-public class User : HBObject {
- public string Username { get; set; }
- public string PasswordHash { get; set; }
-
- public static explicit operator ApiModels.User(User user) =>
- new() {
- UserId = user.Guid,
- Username = user.Username
- };
-}
diff --git a/Util.cs b/Util.cs
deleted file mode 100644
index 6af6c81..0000000
--- a/Util.cs
+++ /dev/null
@@ -1,120 +0,0 @@
-namespace HyperBooru.Util;
-
-public static class Extensions {
- public static readonly string[] MagnitudeOrders = new[] {
- "K", "M", "G", "T", "P", "E", "Z", "Y", "R", "Q"
- };
-
- public static DateTime? TryParseDateTimeUtc(this string s) {
- bool success = DateTime.TryParse(s, out var dateTime);
- return success ? DateTime.SpecifyKind(dateTime, DateTimeKind.Utc) : null;
- }
-
- public static string ToBytesSI(this long x) {
- var exp = (int) Math.Log10(x);
- var suffix = MagnitudeOrders.ElementAtOrDefault(exp / 3 - 1);
- if(suffix is null)
- return x.ToString();
- double n = x / Math.Pow(10, exp / 3 * 3);
- return $"{Math.Round(n, 2 - (exp % 3))} {suffix}B";
- }
-
- public static string ToStringHumanReadable(this TimeSpan t) {
- if(t.TotalMilliseconds < 1000)
- return string.Format("{0:0}ms", t.TotalMilliseconds);
- if(t.TotalSeconds < 60)
- return string.Format("{0:0.00}s", t.TotalSeconds);
- if(t.TotalMinutes < 60)
- return string.Format("{0:0}m{0:0}s", t.TotalMinutes, t.Seconds);
- if(t.TotalHours < 24)
- return string.Format("{0:0}h{0:0}m", t.TotalHours, t.Minutes);
- return string.Format("{0:0.00}d", t.TotalDays);
- }
-}
-
-public class LimitedConcurrencyTaskScheduler : TaskScheduler {
- public sealed override int MaximumConcurrencyLevel =>
- maxConcurrency;
-
- private int maxConcurrency;
-
- [ThreadStatic]
- private static bool threadIsProcessingItems;
-
- private readonly LinkedList<Task> tasks = new();
-
- private int delegatesQueuedOrRunning = 0;
-
- public LimitedConcurrencyTaskScheduler() {
- maxConcurrency = Environment.ProcessorCount;
- }
-
- public LimitedConcurrencyTaskScheduler(int maxConcurrency) {
- if(maxConcurrency < 1)
- throw new ArgumentOutOfRangeException("maxConcurrency must be greater than 0");
- this.maxConcurrency = (int) maxConcurrency;
- }
-
- protected sealed override void QueueTask(Task task) {
- lock(tasks) {
- tasks.AddLast(task);
- if(delegatesQueuedOrRunning < maxConcurrency) {
- delegatesQueuedOrRunning++;
- NotifyThreadPoolOfPendingWork();
- }
- }
- }
-
- private void NotifyThreadPoolOfPendingWork() {
- ThreadPool.UnsafeQueueUserWorkItem(_ => {
- threadIsProcessingItems = true;
- try {
- while(true) {
- Task item;
- lock(tasks) {
- if(tasks.Count == 0) {
- delegatesQueuedOrRunning--;
- break;
- } else {
- item = tasks.First.Value;
- tasks.RemoveFirst();
- }
- }
- TryExecuteTask(item);
- }
- } finally {
- threadIsProcessingItems = false;
- }
- }, null);
- }
-
- protected sealed override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued) {
- if(!threadIsProcessingItems)
- return false;
-
- if(taskWasPreviouslyQueued)
- return TryDequeue(task) ? TryExecuteTask(task) : false;
- else
- return TryExecuteTask(task);
- }
-
- protected sealed override bool TryDequeue(Task task) {
- lock(tasks) {
- return tasks.Remove(task);
- }
- }
-
- protected sealed override IEnumerable<Task> GetScheduledTasks() {
- bool lockTaken = false;
- try {
- Monitor.TryEnter(tasks, ref lockTaken);
- if(lockTaken)
- return tasks;
- else
- throw new NotSupportedException();
- } finally {
- if(lockTaken)
- Monitor.Exit(tasks);
- }
- }
-}
diff --git a/_Imports.razor b/_Imports.razor
deleted file mode 100644
index 4c5566b..0000000
--- a/_Imports.razor
+++ /dev/null
@@ -1,9 +0,0 @@
-@using HyperBooru
-@using HyperBooru.Pages.Component
-@using HyperBooru.Services
-@using Microsoft.AspNetCore.Authorization
-@using Microsoft.AspNetCore.Components.Authorization
-@using Microsoft.AspNetCore.Components.Routing
-@using Microsoft.AspNetCore.Components.Web
-@using Microsoft.EntityFrameworkCore
-@using Microsoft.JSInterop
diff --git a/appsettings.json b/appsettings.json
index 414e673..10f68b8 100644
--- a/appsettings.json
+++ b/appsettings.json
@@ -5,8 +5,5 @@
"Microsoft.AspNetCore": "Warning"
}
},
- "ConnectionStrings": {
- "DefaultConnection": "Host=127.0.0.1;Database=hyperbooru;Username=hyperbooru;Password=password"
- },
"AllowedHosts": "*"
}
diff --git a/tessdata/eng.traineddata b/tessdata/eng.traineddata
deleted file mode 100644
index 176dc32..0000000
--- a/tessdata/eng.traineddata
+++ /dev/null
Binary files differ
diff --git a/wwwroot/css/site.css b/wwwroot/css/site.css
deleted file mode 100644
index 21f9a94..0000000
--- a/wwwroot/css/site.css
+++ /dev/null
@@ -1,28 +0,0 @@
-#blazor-error-ui {
- background: #555;
- bottom: 0;
- box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
- display: none;
- left: 0;
- padding: 0.6rem 1.25rem 0.7rem 1.25rem;
- position: fixed;
- width: 100%;
- z-index: 1000;
-}
-
-#blazor-error-ui .dismiss {
- cursor: pointer;
- position: absolute;
- right: 3.5rem;
- top: 0.5rem;
-}
-
-.blazor-error-boundary {
- background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
- color: white;
- padding: 1rem 1rem 1rem 3.7rem;
-}
-
-.blazor-error-boundary::after {
- content: "An error has occurred."
-}
diff --git a/wwwroot/favicon.ico b/wwwroot/favicon.ico
deleted file mode 100644
index a1be4cc..0000000
--- a/wwwroot/favicon.ico
+++ /dev/null
Binary files differ
diff --git a/wwwroot/icon-192.png b/wwwroot/icon-192.png
deleted file mode 100644
index 28ce06d..0000000
--- a/wwwroot/icon-192.png
+++ /dev/null
Binary files differ
diff --git a/wwwroot/icon-512.png b/wwwroot/icon-512.png
deleted file mode 100644
index 8c28696..0000000
--- a/wwwroot/icon-512.png
+++ /dev/null
Binary files differ
diff --git a/wwwroot/images/book.svg b/wwwroot/images/book.svg
deleted file mode 100644
index 6cdfc79..0000000
--- a/wwwroot/images/book.svg
+++ /dev/null
@@ -1,7 +0,0 @@
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
-<!-- Uploaded to: SVG Repo, www.svgrepo.com, Transformed by: SVG Repo Mixer Tools -->
-<svg width="800px" height="800px" viewBox="0 0 24.00 24.00" fill="none" xmlns="http://www.w3.org/2000/svg">
- <g id="SVGRepo_bgCarrier" stroke-width="0"/>
- <g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round" stroke="#CCCCCC" stroke-width="0.096"/>
- <g id="SVGRepo_iconCarrier"> <path d="M22 16.7399V4.66994C22 3.46994 21.02 2.57994 19.83 2.67994H19.77C17.67 2.85994 14.48 3.92994 12.7 5.04994L12.53 5.15994C12.24 5.33994 11.76 5.33994 11.47 5.15994L11.22 5.00994C9.44 3.89994 6.26 2.83994 4.16 2.66994C2.97 2.56994 2 3.46994 2 4.65994V16.7399C2 17.6999 2.78 18.5999 3.74 18.7199L4.03 18.7599C6.2 19.0499 9.55 20.1499 11.47 21.1999L11.51 21.2199C11.78 21.3699 12.21 21.3699 12.47 21.2199C14.39 20.1599 17.75 19.0499 19.93 18.7599L20.26 18.7199C21.22 18.5999 22 17.6999 22 16.7399Z" stroke="#ffffff" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/> <path d="M12 5.48999V20.49" stroke="#ffffff" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/> <path d="M7.75 8.48999H5.5" stroke="#ffffff" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/> <path d="M8.5 11.49H5.5" stroke="#ffffff" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/> </g>
- </svg> \ No newline at end of file
diff --git a/wwwroot/images/checkmark.svg b/wwwroot/images/checkmark.svg
deleted file mode 100644
index 5e55d9e..0000000
--- a/wwwroot/images/checkmark.svg
+++ /dev/null
@@ -1,7 +0,0 @@
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
-<!-- Uploaded to: SVG Repo, www.svgrepo.com, Transformed by: SVG Repo Mixer Tools -->
-<svg width="800px" height="800px" viewBox="0 0 24.00 24.00" fill="none" xmlns="http://www.w3.org/2000/svg" stroke="#ffffff" stroke-width="0.00024000000000000003">
- <g id="SVGRepo_bgCarrier" stroke-width="0"/>
- <g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round" stroke="#CCCCCC" stroke-width="0.048"/>
- <g id="SVGRepo_iconCarrier"> <path d="M17.8086 9.70558C18.1983 9.31421 18.1969 8.68105 17.8056 8.29137C17.4142 7.90169 16.781 7.90305 16.3913 8.29442L10.6215 14.0892L7.30211 10.816C6.90886 10.4283 6.27571 10.4327 5.88793 10.8259C5.50015 11.2192 5.50459 11.8524 5.89784 12.2401L9.92581 16.212C10.3177 16.5985 10.9482 16.5956 11.3366 16.2056L17.8086 9.70558Z" fill="#ffffff"/> <path fill-rule="evenodd" clip-rule="evenodd" d="M12 1C5.92487 1 1 5.92487 1 12C1 18.0751 5.92487 23 12 23C18.0751 23 23 18.0751 23 12C23 5.92487 18.0751 1 12 1ZM3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12Z" fill="#ffffff"/> </g>
- </svg> \ No newline at end of file
diff --git a/wwwroot/images/cross.svg b/wwwroot/images/cross.svg
deleted file mode 100644
index 0c37363..0000000
--- a/wwwroot/images/cross.svg
+++ /dev/null
@@ -1,7 +0,0 @@
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
-<!-- Uploaded to: SVG Repo, www.svgrepo.com, Transformed by: SVG Repo Mixer Tools -->
-<svg width="800px" height="800px" viewBox="0 0 24.00 24.00" fill="none" xmlns="http://www.w3.org/2000/svg" stroke="#ffffff" stroke-width="0.00024000000000000003">
- <g id="SVGRepo_bgCarrier" stroke-width="0"/>
- <g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round" stroke="#CCCCCC" stroke-width="0.096"/>
- <g id="SVGRepo_iconCarrier"> <path d="M7.75716 7.75736C8.14768 7.36683 8.78084 7.36683 9.17137 7.75736L11.9998 10.5858L14.8283 7.75736C15.2188 7.36684 15.852 7.36684 16.2425 7.75736C16.6331 8.14789 16.6331 8.78105 16.2425 9.17158L13.4141 12L16.2424 14.8284C16.633 15.2189 16.633 15.8521 16.2424 16.2426C15.8519 16.6332 15.2187 16.6332 14.8282 16.2426L11.9998 13.4143L9.17146 16.2426C8.78094 16.6332 8.14777 16.6332 7.75725 16.2426C7.36672 15.8521 7.36672 15.219 7.75725 14.8284L10.5856 12L7.75716 9.17157C7.36663 8.78104 7.36663 8.14788 7.75716 7.75736Z" fill="#ffffff"/> <path fill-rule="evenodd" clip-rule="evenodd" d="M1 12C1 5.92487 5.92487 1 12 1C18.0751 1 23 5.92487 23 12C23 18.0751 18.0751 23 12 23C5.92487 23 1 18.0751 1 12ZM12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3Z" fill="#ffffff"/> </g>
- </svg> \ No newline at end of file
diff --git a/wwwroot/images/edit.svg b/wwwroot/images/edit.svg
deleted file mode 100644
index d4c6ec4..0000000
--- a/wwwroot/images/edit.svg
+++ /dev/null
@@ -1,7 +0,0 @@
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
-<!-- Uploaded to: SVG Repo, www.svgrepo.com, Transformed by: SVG Repo Mixer Tools -->
-<svg fill="#ffffff" width="800px" height="800px" viewBox="0 0 32.00 32.00" version="1.1" xmlns="http://www.w3.org/2000/svg" stroke="#ffffff" stroke-width="0.00032">
- <g id="SVGRepo_bgCarrier" stroke-width="0"/>
- <g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round" stroke="#CCCCCC" stroke-width="0.064"/>
- <g id="SVGRepo_iconCarrier"> <title>alt-square-pencil</title> <path d="M0 26.016v-20q0-2.496 1.76-4.256t4.256-1.76h14.688l-4.032 4h-10.656q-0.832 0-1.44 0.608t-0.576 1.408v20q0 0.832 0.576 1.408t1.44 0.576h20q0.8 0 1.408-0.576t0.576-1.408v-10.688l4-4v14.688q0 2.496-1.76 4.224t-4.224 1.76h-20q-2.496 0-4.256-1.76t-1.76-4.224zM6.016 26.016l2.112-7.84 12.256-12.192 5.728 5.568-12.32 12.288zM22.112 4.256l3.072-3.072q1.152-1.184 2.816-1.184t2.816 1.184 1.184 2.816-1.184 2.848l-2.976 2.976z"/> </g>
- </svg> \ No newline at end of file
diff --git a/wwwroot/images/info.svg b/wwwroot/images/info.svg
deleted file mode 100644
index b194f05..0000000
--- a/wwwroot/images/info.svg
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Uploaded to: SVG Repo, www.svgrepo.com, Transformed by: SVG Repo Mixer Tools -->
-
-<svg
- width="256"
- height="255.99988"
- viewBox="-2 -2 24 23.999989"
- fill="none"
- stroke="#ffffff"
- stroke-width="0.0002"
- version="1.1"
- id="svg7"
- sodipodi:docname="info-svgrepo-com.svg"
- inkscape:version="1.1 (c68e22c387, 2021-05-23)"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:svg="http://www.w3.org/2000/svg">
- <defs
- id="defs11" />
- <sodipodi:namedview
- id="namedview9"
- pagecolor="#505050"
- bordercolor="#ffffff"
- borderopacity="1"
- inkscape:pageshadow="0"
- inkscape:pageopacity="0"
- inkscape:pagecheckerboard="1"
- showgrid="false"
- fit-margin-top="0"
- fit-margin-left="0"
- fit-margin-right="0"
- fit-margin-bottom="0"
- inkscape:zoom="3.25"
- inkscape:cx="96"
- inkscape:cy="120.76923"
- inkscape:window-width="1920"
- inkscape:window-height="1017"
- inkscape:window-x="1272"
- inkscape:window-y="-8"
- inkscape:window-maximized="1"
- inkscape:current-layer="svg7" />
- <g
- id="SVGRepo_bgCarrier"
- stroke-width="0"
- transform="translate(-2.9999,-2.9999039)" />
- <g
- id="SVGRepo_tracerCarrier"
- stroke-linecap="round"
- stroke-linejoin="round"
- stroke="#cccccc"
- stroke-width="0.08"
- transform="translate(-2.9999,-2.9999039)" />
- <g
- id="SVGRepo_iconCarrier"
- transform="matrix(1.3333185,0,0,1.3333185,-3.3331852,-3.3331904)">
- <path
- fill="#ffffff"
- fill-rule="evenodd"
- d="M 10,3 A 7,7 0 1 0 10,17 7,7 0 0 0 10,3 Z M 1,10 A 9,9 0 1 1 19,10 9,9 0 0 1 1,10 Z M 9,6 a 1,1 0 0 1 1,-1 h 0.01 a 1,1 0 1 1 0,2 H 10 A 1,1 0 0 1 9,6 Z m 0.01,8 a 1,1 0 1 0 2,0 V 9 a 1,1 0 1 0 -2,0 z"
- id="path4" />
- </g>
-</svg>
diff --git a/wwwroot/images/loginbg.webp b/wwwroot/images/loginbg.webp
deleted file mode 100644
index 759e666..0000000
--- a/wwwroot/images/loginbg.webp
+++ /dev/null
Binary files differ
diff --git a/wwwroot/images/photo.svg b/wwwroot/images/photo.svg
deleted file mode 100644
index 486c360..0000000
--- a/wwwroot/images/photo.svg
+++ /dev/null
@@ -1,7 +0,0 @@
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
-<!-- Uploaded to: SVG Repo, www.svgrepo.com, Transformed by: SVG Repo Mixer Tools -->
-<svg fill="#ffffff" width="800px" height="800px" viewBox="0 0 32.00 32.00" version="1.1" xmlns="http://www.w3.org/2000/svg" stroke="#ffffff" stroke-width="0.00032">
- <g id="SVGRepo_bgCarrier" stroke-width="0"/>
- <g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round" stroke="#CCCCCC" stroke-width="0.128"/>
- <g id="SVGRepo_iconCarrier"> <title>image</title> <path d="M0 26.016q0 2.496 1.76 4.224t4.256 1.76h20q2.464 0 4.224-1.76t1.76-4.224v-20q0-2.496-1.76-4.256t-4.224-1.76h-20q-2.496 0-4.256 1.76t-1.76 4.256v20zM4 26.016v-20q0-0.832 0.576-1.408t1.44-0.608h20q0.8 0 1.408 0.608t0.576 1.408v20q0 0.832-0.576 1.408t-1.408 0.576h-20q-0.832 0-1.44-0.576t-0.576-1.408zM6.016 24q0 0.832 0.576 1.44t1.408 0.576h16q0.832 0 1.408-0.576t0.608-1.44v-0.928q-0.224-0.448-1.12-2.688t-1.6-3.584-1.28-2.112q-0.544-0.576-1.12-0.608t-1.152 0.384-1.152 1.12-1.184 1.568-1.152 1.696-1.152 1.6-1.088 1.184-1.088 0.448q-0.576 0-1.664-1.44-0.16-0.192-0.48-0.608-1.12-1.504-1.6-1.824-0.768-0.512-1.184 0.352-0.224 0.512-0.928 2.24t-1.056 2.56v0.64zM6.016 9.024q0 1.248 0.864 2.112t2.112 0.864 2.144-0.864 0.864-2.112-0.864-2.144-2.144-0.864-2.112 0.864-0.864 2.144z"/> </g>
- </svg> \ No newline at end of file
diff --git a/wwwroot/images/tag.svg b/wwwroot/images/tag.svg
deleted file mode 100644
index 3eb8843..0000000
--- a/wwwroot/images/tag.svg
+++ /dev/null
@@ -1,7 +0,0 @@
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
-<!-- Uploaded to: SVG Repo, www.svgrepo.com, Transformed by: SVG Repo Mixer Tools -->
-<svg width="800px" height="800px" viewBox="0 0 24.00 24.00" fill="none" xmlns="http://www.w3.org/2000/svg">
- <g id="SVGRepo_bgCarrier" stroke-width="0"/>
- <g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round" stroke="#CCCCCC" stroke-width="0.096"/>
- <g id="SVGRepo_iconCarrier"> <path d="M7.0498 7.0498H7.0598M10.5118 3H7.8C6.11984 3 5.27976 3 4.63803 3.32698C4.07354 3.6146 3.6146 4.07354 3.32698 4.63803C3 5.27976 3 6.11984 3 7.8V10.5118C3 11.2455 3 11.6124 3.08289 11.9577C3.15638 12.2638 3.27759 12.5564 3.44208 12.8249C3.6276 13.1276 3.88703 13.387 4.40589 13.9059L9.10589 18.6059C10.2939 19.7939 10.888 20.388 11.5729 20.6105C12.1755 20.8063 12.8245 20.8063 13.4271 20.6105C14.112 20.388 14.7061 19.7939 15.8941 18.6059L18.6059 15.8941C19.7939 14.7061 20.388 14.112 20.6105 13.4271C20.8063 12.8245 20.8063 12.1755 20.6105 11.5729C20.388 10.888 19.7939 10.2939 18.6059 9.10589L13.9059 4.40589C13.387 3.88703 13.1276 3.6276 12.8249 3.44208C12.5564 3.27759 12.2638 3.15638 11.9577 3.08289C11.6124 3 11.2455 3 10.5118 3ZM7.5498 7.0498C7.5498 7.32595 7.32595 7.5498 7.0498 7.5498C6.77366 7.5498 6.5498 7.32595 6.5498 7.0498C6.5498 6.77366 6.77366 6.5498 7.0498 6.5498C7.32595 6.5498 7.5498 6.77366 7.5498 7.0498Z" stroke="#ffffff" stroke-width="1.9200000000000004" stroke-linecap="round" stroke-linejoin="round"/> </g>
- </svg> \ No newline at end of file
diff --git a/wwwroot/images/trash.svg b/wwwroot/images/trash.svg
deleted file mode 100644
index 18ff9c1..0000000
--- a/wwwroot/images/trash.svg
+++ /dev/null
@@ -1,7 +0,0 @@
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
-<!-- Uploaded to: SVG Repo, www.svgrepo.com, Transformed by: SVG Repo Mixer Tools -->
-<svg width="800px" height="800px" viewBox="0 0 24.00 24.00" fill="none" xmlns="http://www.w3.org/2000/svg">
- <g id="SVGRepo_bgCarrier" stroke-width="0"/>
- <g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round" stroke="#CCCCCC" stroke-width="0.192"/>
- <g id="SVGRepo_iconCarrier"> <path d="M10 12L14 16M14 12L10 16M4 6H20M16 6L15.7294 5.18807C15.4671 4.40125 15.3359 4.00784 15.0927 3.71698C14.8779 3.46013 14.6021 3.26132 14.2905 3.13878C13.9376 3 13.523 3 12.6936 3H11.3064C10.477 3 10.0624 3 9.70951 3.13878C9.39792 3.26132 9.12208 3.46013 8.90729 3.71698C8.66405 4.00784 8.53292 4.40125 8.27064 5.18807L8 6M18 6V16.2C18 17.8802 18 18.7202 17.673 19.362C17.3854 19.9265 16.9265 20.3854 16.362 20.673C15.7202 21 14.8802 21 13.2 21H10.8C9.11984 21 8.27976 21 7.63803 20.673C7.07354 20.3854 6.6146 19.9265 6.32698 19.362C6 18.7202 6 17.8802 6 16.2V6" stroke="#ffffff" stroke-width="1.56" stroke-linecap="round" stroke-linejoin="round"/> </g>
- </svg> \ No newline at end of file
diff --git a/wwwroot/js/dialog.js b/wwwroot/js/dialog.js
deleted file mode 100644
index 418962f..0000000
--- a/wwwroot/js/dialog.js
+++ /dev/null
@@ -1,78 +0,0 @@
-function dialogMouseDown(e) {
- bumpDialog(e.currentTarget);
-}
-
-function dialogTitleMouseDown(e) {
- e = e || window.event;
- e.preventDefault();
- var element = e.currentTarget.parentElement;
- var ds = element.dataset;
- ds.lastX = e.clientX;
- ds.lastY = e.clientY;
-
- window.dragDialog = element;
- document.onmouseup = dragMouseUp;
- document.onmousemove = dragMouseMove;
-}
-
-function dragMouseUp() {
- window.dragDialog = null;
- document.onmouseup = null;
- document.onmousemove = null;
-}
-
-function dragMouseMove(e) {
- e = e || window.event;
- e.preventDefault();
- var element = window.dragDialog;
- var ds = element.dataset;
- deltaX = ds.lastX - e.clientX;
- deltaY = ds.lastY - e.clientY;
- ds.lastX = e.clientX;
- ds.lastY = e.clientY;
- element.style.left = (element.offsetLeft - deltaX) + 'px';
- element.style.top = (element.offsetTop - deltaY) + 'px';
-}
-
-function setDialogVisibility(element, visible) {
- if(visible) {
- element.style.left = null;
- element.style.top = null;
- element.style.opacity = 1;
- element.style.visibility = 'visible';
- bumpDialog(element);
-
- var input = element.querySelector('input[type="text"]');
- if(input) {
- setTimeout(() => input.focus(), 100);
- }
- } else {
- element.style.opacity = 0;
- element.style.visibility = 'hidden';
- }
-}
-
-function bumpDialog(element) {
- var dialogs = Array
- .from(document.querySelectorAll('div.dialog'))
- .map(e => ({ zIndex: parseInt(e.style.zIndex), element: e }))
- .sort((a, b) => a.zIndex - b.zIndex)
- .map(d => d.element)
- .filter(e => e != element);
-
- dialogs.push(element);
-
- var z = 900;
- for(var d of dialogs)
- d.style.zIndex = z++;
-}
-
-function dialogAddObjectReference(element, dialogObject) {
- if(!window.dialogObjects)
- window.dialogObjects = []
-
- window.dialogObjects.push({
- element: element,
- dialogObject: dialogObject
- });
-}
diff --git a/wwwroot/js/keyboard.js b/wwwroot/js/keyboard.js
deleted file mode 100644
index 8b46639..0000000
--- a/wwwroot/js/keyboard.js
+++ /dev/null
@@ -1,57 +0,0 @@
-async function keyDownHandler(e) {
- function isDialogChild(e) {
- while(e = e.parentElement)
- if(e.tagName == 'DIV' && e.classList.contains('dialog'))
- return true;
- return false;
- }
-
- var tag = document.activeElement.tagName;
- if((tag == 'INPUT' || (tag == 'TEXTAREA' && e.ctrlKey)) && e.key == 'Enter') {
- var element = document.activeElement;
- while(element = element.parentElement) {
- if(element.tagName == 'FORM') {
- element
- .querySelectorAll('input,textarea')
- .forEach(e => e.dispatchEvent(new Event('change')));
- element.requestSubmit();
- e.preventDefault();
- return;
- }
- }
- }
-
- if((tag == 'INPUT' || tag == 'TEXTAREA') && e.key != 'Escape')
- return;
-
- var element = Array.from(document.querySelectorAll('div.dialog'))
- .filter(e => e.style.visibility == 'visible')
- .map(e => ({ element: e, zIndex: parseInt(e.style.zIndex) }))
- .sort((a, b) => b.zIndex - a.zIndex)
- .map(e => e.element)[0];
-
- if(element) {
- await window.dialogObjects
- .find(d => d.element == element)
- .dialogObject
- .invokeMethodAsync('KeyHandler', e.key);
- e.preventDefault();
- return;
- }
-
- var button = Array.from(document.getElementsByTagName('button'))
- .filter(b => typeof(b.dataset.keyboardShortcut) == 'string')
- .filter(b => !isDialogChild(b))
- .find(b => b.dataset.keyboardShortcut == e.key);
-
- if(!e.ctrlKey && button) {
- button.click();
- e.preventDefault();
- return;
- }
-
- if(typeof pageKeyDownHandler == 'function')
- pageKeyDownHandler(e);
-}
-
-window.onload = () => document.onkeydown = keyDownHandler; \ No newline at end of file
diff --git a/wwwroot/js/mobile.js b/wwwroot/js/mobile.js
deleted file mode 100644
index 0af11cc..0000000
--- a/wwwroot/js/mobile.js
+++ /dev/null
@@ -1,7 +0,0 @@
-function hideMobileMenu() {
- document.getElementsByTagName('body')[0].classList.remove('mobile-menu-visible');
-}
-
-function toggleMobileMenu() {
- document.getElementsByTagName('body')[0].classList.toggle('mobile-menu-visible');
-}
diff --git a/wwwroot/loginbg.webm b/wwwroot/loginbg.webm
deleted file mode 100644
index 139ed0d..0000000
--- a/wwwroot/loginbg.webm
+++ /dev/null
Binary files differ
diff --git a/wwwroot/manifest.webmanifest b/wwwroot/manifest.webmanifest
deleted file mode 100644
index f150f98..0000000
--- a/wwwroot/manifest.webmanifest
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "icons": [
- { "src": "/icon-192.png", "type": "images/png", "sizes": "192x192" },
- { "src": "/icon-512.png", "type": "images/png", "sizes": "512x512" }
- ]
-} \ No newline at end of file
diff --git a/wwwroot/styles/data-table.css b/wwwroot/styles/data-table.css
deleted file mode 100644
index 994d625..0000000
--- a/wwwroot/styles/data-table.css
+++ /dev/null
@@ -1,21 +0,0 @@
-table.data-table {
- border-collapse: collapse;
- width: 100%;
-}
-
-table.data-table > tr > th {
- border-bottom: 1px solid white;
- padding: 4px;
-}
-
-table.data-table > tr > td {
- padding: 4px;
-}
-
-table.data-table > tr:nth-child(2n) {
- background: rgba(255, 255, 255, 0.1);
-}
-
-table.data-table > tr > td:not(:last-child) {
- border-right: 1px solid white;
-}
diff --git a/wwwroot/styles/global.css b/wwwroot/styles/global.css
deleted file mode 100644
index 9de9fc1..0000000
--- a/wwwroot/styles/global.css
+++ /dev/null
@@ -1,214 +0,0 @@
-@import url('data-table.css');
-
-:root {
- --col-accent-pri: #0aa;
- --col-accent-pri-hl: #0cc;
- --col-error-pri: #ffaa00;
- --col-checksum-verified-pri: #8dff76;
- --col-bg: #222;
- --col-dialog-bg: #333;
- --col-navbar-bg: var(--col-accent-pri);
- --col-button-pri: var(--col-accent-pri);
- --col-button-pri-hl: var(--col-accent-pri-hl);
- --col-button-disabled: #777;
- --col-button-disabled-bg: #444;
- --col-button-sec: #555;
- --col-button-sec-hl: #777;
- --col-button-sec-disabled: #555;
- --col-button-sec-disabled-bg: #000;
- --col-button-warning: #ff4848;
- --col-button-warning-hl: #ff9999;
- --col-hr: #888;
- --col-scrollbar: #666;
- --col-scrollbar-hover: #aaaaaa;
- --col-switch-bg: var(--col-bg);
- --col-switch-fg: #fff;
- --col-switch-bg-hl: var(--col-accent-pri);
- --col-progbar-fg: var(--col-accent-pri);
- --col-progbar-bg: #777;
-
- --size-default-gap: 30px;
-}
-
-::selection {
- background: var(--col-accent-pri);
-}
-
-body {
- background: var(--col-bg);
- color: white;
- display: flex;
- flex-direction: column;
- font-family: 'Trebuchet MS', 'Lucida Sans Unicode';
- height: 100dvh;
- margin: 0;
- overflow: hidden;
- width: 100dvw;
-}
-
-a {
- color: var(--col-accent-pri);
- text-decoration: none;
-}
-
-@media (hover: hover) {
- a:hover {
- filter: brightness(1.5);
- }
-}
-
-a::selection {
- background: var(--col-accent-pri);
- color: #fff;
-}
-
-a.nondecorated {
- color: #fff;
-}
-
-@media (hover: hover) {
- a.nondecorated:hover {
- color: #999;
- }
-}
-
-code {
- background: #222;
- border-radius: 10px;
- box-sizing: border-box;
- font-family: 'Lucida Console';
- font-size: 8pt;
- overflow-y: auto;
- padding: 20px;
- white-space: pre-line;
-}
-
-button, input[type=submit] {
- align-items: center;
- background: var(--col-button-pri);
- border-radius: 10px;
- border: none;
- box-sizing: border-box;
- color: white;
- cursor: pointer;
- display: flex;
- height: 30px;
- margin: 10px 5px 0 5px;
- padding: 0 9px 0 9px;
- user-select: none;
-}
-
-button:disabled {
- color: var(--col-button-disabled) !important;
- background: var(--col-button-disabled-bg) !important;
-}
-
-button.warning {
- background: var(--col-button-warning);
-}
-
-button > img {
- height: 15px;
- margin-right: 5px;
- width: 15px;
-}
-
-@media (hover: none) and (pointer: coarse) {
- button > :not(:first-child) {
- display: none;
- }
-
- button > img {
- height: 20px;
- margin-right: 0;
- padding: 8px;
- width: 20px;
- }
-}
-
-@media (hover: hover) {
- button.warning:hover {
- background: var(--col-button-warning-hl);
- }
-}
-
-button.warning:active {
- color: var(--col-button-warning);
- background: white;
-}
-
-button.secondary {
- background: var(--col-button-sec);
-}
-
-@media (hover: hover) {
- button.secondary:hover {
- background: var(--col-button-sec-hl);
- }
-}
-
-button.secondary:active {
- background: white;
- color: var(--col-button-sec);
-}
-
-button.secondary:disabled {
- color: var(--col-button-sec-disabled) !important;
- background: var(--col-button-sec-disabled-bg) !important;
-}
-
-@media (hover: hover) {
- button:hover, input[type=submit]:hover {
- background: var(--col-button-pri-hl);
- }
-}
-
-button:active, input[type=submit]:active {
- background: white;
- color: var(--col-button-pri);
-}
-
-input, textarea {
- background: rgba(0, 0, 0, 0);
- border-radius: 5px;
- border: 1px solid #aaa;
- box-sizing: border-box;
- color: white;
- margin-bottom: 10px;
-}
-
-input {
- height: 25px !important;
-}
-
-/* disable hotkey underlines on mobile devices */
-@media (hover: none) and (pointer: coarse) {
- button > u {
- text-decoration: none !important;
- }
-}
-
-/* necessary for use inside flex containers */
-hr {
- width: 100%;
-}
-
-::-webkit-scrollbar {
- width: 10px;
- height: 10px;
-}
-
-::-webkit-scrollbar-thumb {
- background: var(--col-scrollbar);
- border-radius: 10px;
-}
-
-@media (hover: hover) {
- ::-webkit-scrollbar-thumb:hover {
- background: var(--col-scrollbar-hover);
- }
-}
-
-::-webkit-scrollbar-corner {
- opacity: 0;
-}