mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 13:11:10 +00:00
Adds book reading support with EPUB and PDF reader plugins
This commit is contained in:
1 parent
275fd83ff2
commit
f7ccdf3d1c
271 files changed
+11501
-361
No files matched your search
+54
@@ -0,0 +1,54 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Repository entity for the configuration of a book reader of a media library.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("LibraryId: {LibraryId}, PluginId: {PluginId}")]
|
||||
public class LibraryBookReaderConfigurationEntity : IStorageEntity, IAuditableEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the configuration.
|
||||
/// </summary>
|
||||
public required Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the media library the configuration belongs to.
|
||||
/// </summary>
|
||||
public required Guid LibraryId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the plugin providing the book reader.
|
||||
/// </summary>
|
||||
public required Guid PluginId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the book reader is enabled for the media library.
|
||||
/// </summary>
|
||||
public required bool IsEnabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
/// </summary>
|
||||
public DateTime? UpdatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+13
@@ -47,6 +47,19 @@ public class UserSettingsEntity : IStorageEntity, IAuditableEntity
|
||||
/// </summary>
|
||||
public bool ShouldAggregateMetadataWhenMissing { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether PDF books are rendered as page images for the user, or not. Rendering PDFs as images preserves the
|
||||
/// original layout, but the pages are not selectable or searchable, unlike their text layer.
|
||||
/// </summary>
|
||||
public bool ShouldRenderPdfAsImages { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the styles of the book content are preserved when it is rendered for the user, or not. Preserving them
|
||||
/// keeps the original look of a book (its fonts, colors, and alignment), but the styles of a book can load resources from
|
||||
/// external servers, which those servers could observe; stripping them removes that possibility, at the cost of the look of the book.
|
||||
/// </summary>
|
||||
public bool ShouldPreserveBookStyles { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Plugins;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Repositories.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for the repository for the book reader configurations of media libraries.
|
||||
/// </summary>
|
||||
public interface ILibraryBookReaderConfigurationRepository : IRepository<LibraryBookReaderConfigurationEntity>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets all the book reader configurations of the media library identified by <paramref name="libraryId"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">The Id of the media library whose book reader configurations are retrieved.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> containing either a collection of <see cref="LibraryBookReaderConfigurationEntity"/>, or an error.</returns>
|
||||
Task<Result<IReadOnlyList<LibraryBookReaderConfigurationEntity>>> GetByLibraryIdAsync(Guid libraryId, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the book reader configuration of the media library identified by <paramref name="libraryId"/> for the plugin identified by <paramref name="pluginId"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">The Id of the media library whose book reader configuration is retrieved.</param>
|
||||
/// <param name="pluginId">The Id of the plugin whose book reader configuration is retrieved.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> containing either the <see cref="LibraryBookReaderConfigurationEntity"/>, or an error.</returns>
|
||||
Task<Result<LibraryBookReaderConfigurationEntity?>> GetByLibraryAndPluginIdAsync(Guid libraryId, Guid pluginId, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Inserts the provided <paramref name="configuration"/> into the storage medium, or updates it when it already exists.
|
||||
/// </summary>
|
||||
/// <param name="configuration">The book reader configuration to insert or update.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
Task<Result<Updated>> UpsertAsync(LibraryBookReaderConfigurationEntity configuration, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes all the book reader configurations of the media library identified by <paramref name="libraryId"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">The Id of the media library whose book reader configurations are deleted.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
Task<Result<Deleted>> DeleteByLibraryIdAsync(Guid libraryId, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes all the book reader configurations referencing the plugin identified by <paramref name="pluginId"/>.
|
||||
/// </summary>
|
||||
/// <param name="pluginId">The Id of the plugin whose book reader configurations are deleted.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
Task<Result<Deleted>> DeleteByPluginIdAsync(Guid pluginId, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the book reader configurations of the media library identified by <paramref name="libraryId"/> that reference
|
||||
/// one of the plugins identified by <paramref name="pluginIds"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">The Id of the media library whose book reader configurations are deleted.</param>
|
||||
/// <param name="pluginIds">The Ids of the plugins whose configurations of the media library are deleted.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
Task<Result<Deleted>> DeleteByLibraryIdAndPluginIdsAsync(Guid libraryId, IEnumerable<Guid> pluginIds, CancellationToken cancellationToken);
|
||||
}
|
||||
@@ -82,6 +82,11 @@ public interface IUnitOfWork
|
||||
/// </summary>
|
||||
IArtworkProviderConfigurationRepository ArtworkProviderConfigurationRepository { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the library book reader configuration repository.
|
||||
/// </summary>
|
||||
ILibraryBookReaderConfigurationRepository LibraryBookReaderConfigurationRepository { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin repository.
|
||||
/// </summary>
|
||||
|
||||
@@ -12,13 +12,13 @@ using System.Reflection;
|
||||
namespace Lumina.Application.Common.DependencyInjection;
|
||||
|
||||
/// <summary>
|
||||
/// Contains all services of the Application layer.
|
||||
/// Utility class for registering the services of the Application layer into the Dependency Injection container.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public static class ApplicationLayerServices
|
||||
{
|
||||
/// <summary>
|
||||
/// Registers the services of the Application layer into the dependency injection container.
|
||||
/// Registers the services of the Application 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>
|
||||
@@ -52,7 +52,7 @@ public static class ApplicationLayerServices
|
||||
continue;
|
||||
}
|
||||
|
||||
// wrap query, command, and domain event handlers in their telemetry decorator, so that every invocation emits traces, metrics, and structured logs
|
||||
// Wrap query, command, and domain event handlers in their telemetry decorator, so that every invocation emits traces, metrics, and structured logs.
|
||||
services.AddScoped(registration.Contract, serviceProvider =>
|
||||
{
|
||||
object handler = ActivatorUtilities.GetServiceOrCreateInstance(serviceProvider, registration.Implementation);
|
||||
|
||||
+34
@@ -58,4 +58,38 @@ public interface IMediaLibraryProviderConfigurationStore
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
Task<Result<Deleted>> RemoveProviderConfigurationsAsync(Guid pluginId, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a disabled book reader configuration for every loaded plugin that supports the provided library type and has no configuration yet, for the media library identified by <paramref name="libraryId"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">The Id of the media library whose book reader configurations are ensured.</param>
|
||||
/// <param name="libraryType">The type of the media library, used to determine the plugins whose book readers apply.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
Task<Result<Success>> EnsureBookReaderConfigurationsAsync(Guid libraryId, LibraryType libraryType, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Replaces the book reader configurations of the media library identified by <paramref name="libraryId"/> so that they match the plugins supporting the provided library type.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">The Id of the media library whose book reader configurations are reconciled.</param>
|
||||
/// <param name="libraryType">The type of the media library, used to determine the plugins whose book readers apply.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
Task<Result<Success>> ReconcileBookReaderConfigurationsAsync(Guid libraryId, LibraryType libraryType, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes all the book reader configurations of the media library identified by <paramref name="libraryId"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">The Id of the media library whose book reader configurations are deleted.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
Task<Result<Deleted>> RemoveBookReaderConfigurationsForLibraryAsync(Guid libraryId, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes all the book reader configurations referencing the plugin identified by <paramref name="pluginId"/>.
|
||||
/// </summary>
|
||||
/// <param name="pluginId">The Id of the plugin whose book reader configurations are deleted.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
Task<Result<Deleted>> RemoveBookReaderConfigurationsAsync(Guid pluginId, CancellationToken cancellationToken);
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Infrastructure.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Cache of whether the book reader of a plugin is enabled for a media library. The enablement is read from the database on its first
|
||||
/// use and cached afterwards, because it is consulted on every section and resource request, and it only changes when the user toggles
|
||||
/// a reader or a plugin is uninstalled; those operations invalidate the affected entries.
|
||||
/// </summary>
|
||||
public interface IBookReaderEnablementCache
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the cached enablement of the book reader of the plugin identified by <paramref name="pluginId"/> for the media library identified by <paramref name="libraryId"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">The Id of the media library whose book reader enablement is retrieved.</param>
|
||||
/// <param name="pluginId">The Id of the plugin providing the book reader.</param>
|
||||
/// <returns>The cached enablement, or <see langword="null"/> when it is not cached yet.</returns>
|
||||
bool? Get(Guid libraryId, Guid pluginId);
|
||||
|
||||
/// <summary>
|
||||
/// Caches the enablement of the book reader of the plugin identified by <paramref name="pluginId"/> for the media library identified by <paramref name="libraryId"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">The Id of the media library whose book reader enablement is cached.</param>
|
||||
/// <param name="pluginId">The Id of the plugin providing the book reader.</param>
|
||||
/// <param name="isEnabled">Whether the book reader is enabled for the media library.</param>
|
||||
void Set(Guid libraryId, Guid pluginId, bool isEnabled);
|
||||
|
||||
/// <summary>
|
||||
/// Removes the cached enablement of the book reader of the plugin identified by <paramref name="pluginId"/> for the media library identified by <paramref name="libraryId"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">The Id of the media library whose book reader enablement is invalidated.</param>
|
||||
/// <param name="pluginId">The Id of the plugin providing the book reader.</param>
|
||||
void Invalidate(Guid libraryId, Guid pluginId);
|
||||
|
||||
/// <summary>
|
||||
/// Removes every cached enablement of the media library identified by <paramref name="libraryId"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">The Id of the media library whose book reader enablements are invalidated.</param>
|
||||
void InvalidateLibrary(Guid libraryId);
|
||||
|
||||
/// <summary>
|
||||
/// Removes every cached enablement of the plugin identified by <paramref name="pluginId"/>.
|
||||
/// </summary>
|
||||
/// <param name="pluginId">The Id of the plugin whose book reader enablements are invalidated.</param>
|
||||
void InvalidatePlugin(Guid pluginId);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Infrastructure.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Registry of the book readers provided by the loaded plugins.
|
||||
/// </summary>
|
||||
public interface IBookReaderRegistry
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the file extensions supported by the book readers of each loaded plugin, keyed by the Id of the plugin.
|
||||
/// </summary>
|
||||
/// <returns>The supported extensions of the book readers, keyed by the Id of the plugin providing them.</returns>
|
||||
IReadOnlyDictionary<Guid, IReadOnlyList<string>> GetSupportedExtensionsByPluginId();
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Commands.AddBook;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
|
||||
#endregion
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooksLite;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Queries.GetBooksLite;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
#endregion
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooks;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Queries.GetBooks;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
#endregion
|
||||
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading.Queries.GetReadingAvailability;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetReadingAvailabilityRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetReadingAvailabilityRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetReadingAvailabilityQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetReadingAvailabilityQuery ToQuery(this GetReadingAvailabilityRequest request)
|
||||
{
|
||||
return new GetReadingAvailabilityQuery(
|
||||
request.BookId
|
||||
);
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading.Queries.GetReadingManifest;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetReadingManifestRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetReadingManifestRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetReadingManifestQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetReadingManifestQuery ToQuery(this GetReadingManifestRequest request)
|
||||
{
|
||||
return new GetReadingManifestQuery(
|
||||
request.BookId
|
||||
);
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading.Queries.GetReadingResource;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetReadingResourceRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetReadingResourceRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetReadingResourceQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetReadingResourceQuery ToQuery(this GetReadingResourceRequest request)
|
||||
{
|
||||
return new GetReadingResourceQuery(
|
||||
request.BookId,
|
||||
request.ResourceKey
|
||||
);
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading.Queries.GetReadingSection;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetReadingSectionRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetReadingSectionRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetReadingSectionQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetReadingSectionQuery ToQuery(this GetReadingSectionRequest request)
|
||||
{
|
||||
return new GetReadingSectionQuery(
|
||||
request.BookId,
|
||||
request.LocationRef
|
||||
);
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="ReadingDocumentDto"/>.
|
||||
/// </summary>
|
||||
public static class ReadingDocumentDtoMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="document"/> to <see cref="ReadingManifestResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="document">The reading document to be converted.</param>
|
||||
/// <returns>The converted reading manifest response.</returns>
|
||||
public static ReadingManifestResponse ToResponse(this ReadingDocumentDto document)
|
||||
{
|
||||
return new ReadingManifestResponse(
|
||||
document.Title,
|
||||
document.Author,
|
||||
document.CoverResourceKey,
|
||||
[.. document.TableOfContents.Select(entry => entry.ToResponse())],
|
||||
[.. document.Spine.Select(spineItem => new ReadingSpineItemResponse(spineItem.LocationRef, spineItem.Title))],
|
||||
[.. document.Resources.Keys],
|
||||
document.HasTextContent
|
||||
);
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="ReadingTocEntryDto"/>.
|
||||
/// </summary>
|
||||
public static class ReadingTocEntryDtoMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="entry"/> to <see cref="ReadingTocEntryResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="entry">The table of contents entry to be converted.</param>
|
||||
/// <returns>The converted table of contents entry response.</returns>
|
||||
public static ReadingTocEntryResponse ToResponse(this ReadingTocEntryDto entry)
|
||||
{
|
||||
return new ReadingTocEntryResponse(
|
||||
entry.Label,
|
||||
entry.LocationRef,
|
||||
[.. entry.Children.Select(child => child.ToResponse())]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.Plugins.Queries.GetLibraryBookReaders;
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetLibraryBookReadersRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetLibraryBookReadersRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetLibraryBookReadersQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetLibraryBookReadersQuery ToQuery(this GetLibraryBookReadersRequest request)
|
||||
{
|
||||
return new GetLibraryBookReadersQuery(
|
||||
request.LibraryId
|
||||
);
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Plugins;
|
||||
using Lumina.Contracts.Responses.Plugins;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="LibraryBookReaderConfigurationEntity"/>.
|
||||
/// </summary>
|
||||
public static class LibraryBookReaderConfigurationEntityMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="configuration"/> to <see cref="LibraryBookReaderResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="configuration">The repository entity to be converted.</param>
|
||||
/// <param name="readerName">The display name of the book reader.</param>
|
||||
/// <param name="supportedExtensions">The file extensions supported by the book reader.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static LibraryBookReaderResponse ToResponse(this LibraryBookReaderConfigurationEntity configuration, string readerName, IReadOnlyList<string> supportedExtensions)
|
||||
{
|
||||
return new LibraryBookReaderResponse(
|
||||
configuration.PluginId,
|
||||
readerName,
|
||||
supportedExtensions,
|
||||
configuration.IsEnabled
|
||||
);
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.Plugins.Commands.SetLibraryBookReaderEnabled;
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="SetLibraryBookReaderEnabledRequest"/>.
|
||||
/// </summary>
|
||||
public static class SetLibraryBookReaderEnabledRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="SetLibraryBookReaderEnabledCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted command.</returns>
|
||||
public static SetLibraryBookReaderEnabledCommand ToCommand(this SetLibraryBookReaderEnabledRequest request)
|
||||
{
|
||||
return new SetLibraryBookReaderEnabledCommand(
|
||||
request.LibraryId,
|
||||
request.PluginId,
|
||||
request.IsEnabled
|
||||
);
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -22,7 +22,9 @@ public static class UpdateUserSettingsRequestMapping
|
||||
request.ItemsPerPage,
|
||||
request.ShouldIgnoreThePrefixForAlphaPicker,
|
||||
request.IsThemeCachingEnabled,
|
||||
request.ShouldAggregateMetadataWhenMissing
|
||||
request.ShouldAggregateMetadataWhenMissing,
|
||||
request.ShouldRenderPdfAsImages,
|
||||
request.ShouldPreserveBookStyles
|
||||
);
|
||||
}
|
||||
}
|
||||
+6
-2
@@ -30,7 +30,9 @@ public static class UserSettingsEntityMapping
|
||||
repositoryEntity.ItemsPerPage,
|
||||
repositoryEntity.ShouldIgnoreThePrefixForAlphaPicker,
|
||||
repositoryEntity.IsThemeCachingEnabled,
|
||||
repositoryEntity.ShouldAggregateMetadataWhenMissing
|
||||
repositoryEntity.ShouldAggregateMetadataWhenMissing,
|
||||
repositoryEntity.ShouldRenderPdfAsImages,
|
||||
repositoryEntity.ShouldPreserveBookStyles
|
||||
);
|
||||
}
|
||||
|
||||
@@ -47,7 +49,9 @@ public static class UserSettingsEntityMapping
|
||||
repositoryEntity.ItemsPerPage,
|
||||
repositoryEntity.ShouldIgnoreThePrefixForAlphaPicker,
|
||||
repositoryEntity.IsThemeCachingEnabled,
|
||||
repositoryEntity.ShouldAggregateMetadataWhenMissing
|
||||
repositoryEntity.ShouldAggregateMetadataWhenMissing,
|
||||
repositoryEntity.ShouldRenderPdfAsImages,
|
||||
repositoryEntity.ShouldPreserveBookStyles
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,9 @@ public static class UserSettingsMapping
|
||||
ItemsPerPage = domainEntity.ItemsPerPage,
|
||||
ShouldIgnoreThePrefixForAlphaPicker = domainEntity.ShouldIgnoreThePrefixForAlphaPicker,
|
||||
IsThemeCachingEnabled = domainEntity.IsThemeCachingEnabled,
|
||||
ShouldAggregateMetadataWhenMissing = domainEntity.ShouldAggregateMetadataWhenMissing
|
||||
ShouldAggregateMetadataWhenMissing = domainEntity.ShouldAggregateMetadataWhenMissing,
|
||||
ShouldRenderPdfAsImages = domainEntity.ShouldRenderPdfAsImages,
|
||||
ShouldPreserveBookStyles = domainEntity.ShouldPreserveBookStyles
|
||||
};
|
||||
}
|
||||
|
||||
@@ -43,7 +45,9 @@ public static class UserSettingsMapping
|
||||
domainEntity.ItemsPerPage,
|
||||
domainEntity.ShouldIgnoreThePrefixForAlphaPicker,
|
||||
domainEntity.IsThemeCachingEnabled,
|
||||
domainEntity.ShouldAggregateMetadataWhenMissing
|
||||
domainEntity.ShouldAggregateMetadataWhenMissing,
|
||||
domainEntity.ShouldRenderPdfAsImages,
|
||||
domainEntity.ShouldPreserveBookStyles
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user