Adds book reading support with EPUB and PDF reader plugins

This commit is contained in:
BinaryAlley committed 2026-09-02 04:45:11 -07:00
1 parent 275fd83ff2
commit f7ccdf3d1c
271 files changed
+11501 -361

No files matched your search

@@ -0,0 +1,57 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.Plugins;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
#endregion
namespace Lumina.DataAccess.Common.Configuration;
/// <summary>
/// Configures the entity mapping for the <see cref="LibraryBookReaderConfigurationEntity"/> entity.
/// </summary>
public class LibraryBookReaderConfigurationConfiguration : IEntityTypeConfiguration<LibraryBookReaderConfigurationEntity>
{
/// <summary>
/// Configures the <see cref="LibraryBookReaderConfigurationEntity"/> entity.
/// </summary>
/// <param name="builder">The builder to be used to configure the entity.</param>
public void Configure(EntityTypeBuilder<LibraryBookReaderConfigurationEntity> builder)
{
builder.ToTable("LibraryBookReaderConfigurations");
builder.HasKey(configuration => configuration.Id);
builder.Property(configuration => configuration.Id)
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
.HasColumnOrder(0);
builder.Property(configuration => configuration.LibraryId)
.IsRequired()
.HasColumnOrder(1);
builder.Property(configuration => configuration.PluginId)
.IsRequired()
.HasColumnOrder(2);
builder.Property(configuration => configuration.IsEnabled)
.IsRequired()
.HasColumnOrder(3);
// audit
builder.Property(configuration => configuration.CreatedOnUtc)
.IsRequired()
.HasColumnOrder(4);
builder.Property(configuration => configuration.CreatedBy)
.IsRequired()
.HasColumnOrder(5);
builder.Property(configuration => configuration.UpdatedOnUtc)
.HasDefaultValue(null)
.HasColumnOrder(6);
builder.Property(configuration => configuration.UpdatedBy)
.HasDefaultValue(null)
.HasColumnOrder(7);
// A media library has at most one book reader configuration per plugin, so the pair is unique; the repository upserts on it, and
// the constraint guarantees that two concurrent upserts cannot insert duplicate rows.
builder.HasIndex(configuration => new { configuration.LibraryId, configuration.PluginId })
.IsUnique();
}
}
@@ -50,6 +50,14 @@ public class UserSettingsConfiguration : IEntityTypeConfiguration<UserSettingsEn
.IsRequired()
.HasColumnOrder(10);
builder.Property(settings => settings.ShouldRenderPdfAsImages)
.IsRequired()
.HasColumnOrder(11);
builder.Property(settings => settings.ShouldPreserveBookStyles)
.IsRequired()
.HasColumnOrder(12);
builder.Property(settings => settings.IsThemeCachingEnabled)
.IsRequired()
.HasColumnOrder(9);
@@ -7,7 +7,6 @@ using Lumina.DataAccess.Core.Seed;
using Lumina.DataAccess.Core.UoW;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Reflection;
@@ -16,13 +15,13 @@ using System.Reflection;
namespace Lumina.DataAccess.Common.DependencyInjection;
/// <summary>
/// Contains all services of the DataAccess layer.
/// Utility class for registering the services of the Data Access layer into the Dependency Injection container..
/// </summary>
[ExcludeFromCodeCoverage]
public static class DataAccessLayerServices
{
/// <summary>
/// Extension method for adding the DataAccess layer services to the DI container.
/// Registers the services of the Data Access layer into the Dependency Injection container.
/// </summary>
/// <param name="services">The service collection to add the services to.</param>
/// <returns>The updated <see cref="IServiceCollection"/>.</returns>
@@ -0,0 +1,70 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Lumina.DataAccess.Common.Migrations
{
/// <inheritdoc />
public partial class AddsLibraryBookReaderConfigurationsAndShouldRenderPdfAsImagesToUserSettings : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "ShouldRenderPdfAsImages",
table: "UserSettings",
type: "INTEGER",
nullable: false,
defaultValue: false)
.Annotation("Relational:ColumnOrder", 11);
migrationBuilder.AddColumn<bool>(
name: "ShouldPreserveBookStyles",
table: "UserSettings",
type: "INTEGER",
nullable: false,
defaultValue: true)
.Annotation("Relational:ColumnOrder", 12);
migrationBuilder.CreateTable(
name: "LibraryBookReaderConfigurations",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
LibraryId = table.Column<Guid>(type: "TEXT", nullable: false),
PluginId = table.Column<Guid>(type: "TEXT", nullable: false),
IsEnabled = table.Column<bool>(type: "INTEGER", nullable: false),
CreatedOnUtc = table.Column<DateTime>(type: "TEXT", nullable: false),
CreatedBy = table.Column<Guid>(type: "TEXT", nullable: false),
UpdatedOnUtc = table.Column<DateTime>(type: "TEXT", nullable: true),
UpdatedBy = table.Column<Guid>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_LibraryBookReaderConfigurations", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_LibraryBookReaderConfigurations_LibraryId_PluginId",
table: "LibraryBookReaderConfigurations",
columns: new[] { "LibraryId", "PluginId" },
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "LibraryBookReaderConfigurations");
migrationBuilder.DropColumn(
name: "ShouldRenderPdfAsImages",
table: "UserSettings");
migrationBuilder.DropColumn(
name: "ShouldPreserveBookStyles",
table: "UserSettings");
}
}
}
@@ -929,6 +929,48 @@ namespace Lumina.DataAccess.Common.Migrations
b.ToTable("LibraryArtworkProviderConfigurations", (string)null);
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Plugins.LibraryBookReaderConfigurationEntity", b =>
{
b.Property<Guid>("Id")
.HasColumnType("TEXT")
.HasColumnOrder(0);
b.Property<Guid>("CreatedBy")
.HasColumnType("TEXT")
.HasColumnOrder(5);
b.Property<DateTime>("CreatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(4);
b.Property<bool>("IsEnabled")
.HasColumnType("INTEGER")
.HasColumnOrder(3);
b.Property<Guid>("LibraryId")
.HasColumnType("TEXT")
.HasColumnOrder(1);
b.Property<Guid>("PluginId")
.HasColumnType("TEXT")
.HasColumnOrder(2);
b.Property<Guid?>("UpdatedBy")
.HasColumnType("TEXT")
.HasColumnOrder(7);
b.Property<DateTime?>("UpdatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(6);
b.HasKey("Id");
b.HasIndex("LibraryId", "PluginId")
.IsUnique();
b.ToTable("LibraryBookReaderConfigurations", (string)null);
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Plugins.LibraryMetadataProviderConfigurationEntity", b =>
{
b.Property<Guid>("Id")
@@ -1215,6 +1257,14 @@ namespace Lumina.DataAccess.Common.Migrations
.HasColumnType("INTEGER")
.HasColumnOrder(4);
b.Property<bool>("ShouldRenderPdfAsImages")
.HasColumnType("INTEGER")
.HasColumnOrder(11);
b.Property<bool>("ShouldPreserveBookStyles")
.HasColumnType("INTEGER")
.HasColumnOrder(12);
b.Property<Guid?>("UpdatedBy")
.HasColumnType("TEXT")
.HasColumnOrder(8);