mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 07: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
+21
-12
@@ -6,12 +6,14 @@ using Lumina.Application.Common.Infrastructure.Authorization.Policies.LibraryOwn
|
||||
using Lumina.Application.Common.Infrastructure.Authorization.Policies.Over18;
|
||||
using Lumina.Application.Common.Infrastructure.Models.DTO.Configuration;
|
||||
using Lumina.Application.Common.Infrastructure.Plugins;
|
||||
using Lumina.Application.Common.Infrastructure.Reading;
|
||||
using Lumina.Application.Common.Infrastructure.Security;
|
||||
using Lumina.Application.Common.Infrastructure.Themes;
|
||||
using Lumina.Application.Common.Infrastructure.Time;
|
||||
using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Progress;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Artwork;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Artwork;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
using Lumina.Domain.Common.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Cancellation;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
||||
@@ -29,7 +31,8 @@ using Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Jobs.Common;
|
||||
using Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Jobs.WrittenContent.Books;
|
||||
using Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Progress;
|
||||
using Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Queue;
|
||||
using Lumina.Infrastructure.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Artwork;
|
||||
using Lumina.Infrastructure.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Artwork;
|
||||
using Lumina.Infrastructure.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
using Lumina.Infrastructure.Core.Plugins;
|
||||
using Lumina.Infrastructure.Core.Security;
|
||||
using Lumina.Infrastructure.Core.Themes;
|
||||
@@ -49,20 +52,20 @@ using System.Reflection;
|
||||
namespace Lumina.Infrastructure.Common.DependencyInjection;
|
||||
|
||||
/// <summary>
|
||||
/// Contains all services of the Infrastructure layer.
|
||||
/// Utility class for registering the services of the Infrastructure layer into the Dependency Injection container.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public static class InfrastructureLayerServices
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension method for adding the Infrastructure layer services to the DI container.
|
||||
/// Registers the services of the Infrastucture layer into the Dependency Injection container.
|
||||
/// </summary>
|
||||
/// <param name="services">The service collection to add the services to.</param>
|
||||
/// <param name="configuration">The configuration manager used to read the application configuration.</param>
|
||||
/// <param name="configuration">The configuration used to read the application configuration.</param>
|
||||
/// <returns>The updated <see cref="IServiceCollection"/>.</returns>
|
||||
public static IServiceCollection AddInfrastructureLayerServices(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
// scan the current assembly for validators and add them to the DI container
|
||||
// Scan the current assembly for validators and add them to the DI container.
|
||||
IEnumerable<Type> concreteTypes = Assembly.GetExecutingAssembly()
|
||||
.GetTypes()
|
||||
.Where(type => !type.IsInterface && !type.IsAbstract && !type.IsGenericTypeDefinition);
|
||||
@@ -84,13 +87,13 @@ public static class InfrastructureLayerServices
|
||||
services.AddScoped<IDomainEventsQueue, DomainEventsQueue>();
|
||||
services.AddScoped<IDomainEventPublisher, DomainEventPublisher>();
|
||||
|
||||
// authorization
|
||||
// Authorization.
|
||||
services.AddScoped<IOver18Policy, Over18Policy>();
|
||||
services.AddScoped<ILibraryOwnershipPolicy, LibraryOwnershipPolicy>();
|
||||
services.AddScoped<IAuthorizationPolicyFactory, AuthorizationPolicyFactory>();
|
||||
services.AddScoped<IAuthorizationService, AuthorizationService>();
|
||||
|
||||
// media library scanning
|
||||
// Media library scanning.
|
||||
services.AddSingleton<IMediaLibrariesScanQueue, MediaLibrariesScanQueue>();
|
||||
services.AddSingleton<IMediaLibrariesScanCancellationTracker, MediaLibrariesScanCancellationTracker>();
|
||||
services.AddHostedService<MediaLibraryScanJobProcessorJob>();
|
||||
@@ -106,15 +109,21 @@ public static class InfrastructureLayerServices
|
||||
|
||||
services.AddSingleton<IMediaLibraryScanProgressNotifier, DebouncedMediaLibraryScanProgressNotifier>();
|
||||
|
||||
// book artwork: stores the artwork of the books into the internal media directory
|
||||
// Book artwork: stores the artwork of the books into the internal media directory.
|
||||
services.AddHttpClient();
|
||||
services.AddScoped<IBookArtworkService, BookArtworkService>();
|
||||
|
||||
// plugins: load the plugin assemblies from the plugins directory, register their services and provide the plugin manager
|
||||
// Book reading: resolves the book reader plugins, extracts the books into a temporary directory, and serves their contents;
|
||||
// the enablement cache lets the reading service skip the per-request database read of the reader configurations.
|
||||
services.AddSingleton<IBookReaderEnablementCache, BookReaderEnablementCache>();
|
||||
services.AddSingleton<IBookReaderRegistry, BookReaderRegistry>();
|
||||
services.AddSingleton<IBookReadingService, BookReadingService>();
|
||||
|
||||
// Plugins: load the plugin assemblies from the plugins directory, register their services and provide the plugin manager.
|
||||
string pluginsDirectorySetting = configuration.GetSection(PluginsSettingsDto.SECTION_NAME)["Directory"] ?? "plugins";
|
||||
string pluginsDirectory = Path.Combine(AppContext.BaseDirectory, pluginsDirectorySetting);
|
||||
PluginLoadResultDto pluginLoadResult = PluginLoader.LoadPlugins(pluginsDirectory, services);
|
||||
services.AddSingleton<IPluginManager>(new PluginManager(pluginLoadResult.Plugins));
|
||||
services.AddSingleton<IPluginManager>(new PluginManager(pluginLoadResult.Plugins, pluginLoadResult.LoadContexts));
|
||||
services.AddScoped<IPluginSettingsStore, PluginSettingsStore>();
|
||||
services.AddScoped<IPluginInstaller, PluginInstaller>();
|
||||
services.AddScoped<IMediaLibraryProviderConfigurationStore, MediaLibraryProviderConfigurationStore>();
|
||||
@@ -125,7 +134,7 @@ public static class InfrastructureLayerServices
|
||||
serviceProvider.GetRequiredService<ILogger<PluginDetectionSyncJob>>()));
|
||||
services.AddHostedService(serviceProvider => serviceProvider.GetRequiredService<PluginDetectionSyncJob>());
|
||||
|
||||
// themes: the theme service stores and serves theme packs, and the detection job seeds the bundled themes at startup
|
||||
// Themes: the theme service stores and serves theme packs, and the detection job seeds the bundled themes at startup.
|
||||
services.AddSingleton<IThemeService, ThemeService>();
|
||||
services.AddHostedService<ThemeDetectionSyncJob>();
|
||||
|
||||
|
||||
Reference in new issue
Block a user