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
@@ -0,0 +1,34 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.DTO.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for a book reader configured for a media library.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("Name: {Name}")]
|
||||
public class LibraryBookReaderDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the unique identifier of the plugin providing the book reader.
|
||||
/// </summary>
|
||||
public Guid PluginId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the display name of the book reader.
|
||||
/// </summary>
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the file extensions supported by the book reader.
|
||||
/// </summary>
|
||||
public List<string> SupportedExtensions { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the book reader is enabled for the media library.
|
||||
/// </summary>
|
||||
public bool IsEnabled { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.DTO.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for the reading availability of a book.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("BookId: {BookId}, IsAvailable: {IsAvailable}")]
|
||||
public class ReadingAvailabilityDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the book whose reading availability is reported.
|
||||
/// </summary>
|
||||
public Guid BookId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the media library the book belongs to.
|
||||
/// </summary>
|
||||
public Guid LibraryId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the book can be opened for reading.
|
||||
/// </summary>
|
||||
public bool IsAvailable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the code of the error preventing the book from being read, when it cannot be read. Can be <see langword="null"/> when the book is available.
|
||||
/// </summary>
|
||||
public string? ErrorCode { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.DTO.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for the reading manifest of a book.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
public class ReadingManifestDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the title of the book.
|
||||
/// </summary>
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the author of the book, if known.
|
||||
/// </summary>
|
||||
public string? Author { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the resource key of the cover image of the book, if applicable.
|
||||
/// </summary>
|
||||
public string? CoverResourceKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the hierarchical table of contents of the book.
|
||||
/// </summary>
|
||||
public List<ReadingTocEntryDto> TableOfContents { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ordered spine of the reading sections of the book.
|
||||
/// </summary>
|
||||
public List<ReadingSpineItemDto> Spine { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the resource keys of the resources of the book.
|
||||
/// </summary>
|
||||
public List<string> ResourceKeys { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the book has extractable text content. A scanned book, whose pages are only images, has no text content.
|
||||
/// </summary>
|
||||
public bool HasTextContent { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.DTO.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for the content of a reading section of a book.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("LocationRef: {LocationRef}")]
|
||||
public class ReadingSectionDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the opaque location reference of the reading section.
|
||||
/// </summary>
|
||||
public string LocationRef { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the title of the reading section, if known.
|
||||
/// </summary>
|
||||
public string? Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the sanitized HTML content of the reading section, ready to be rendered by the client.
|
||||
/// </summary>
|
||||
public string ContentHtml { get; set; } = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.DTO.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for an item of the spine of the reading manifest of a book.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("LocationRef: {LocationRef}")]
|
||||
public class ReadingSpineItemDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the opaque location reference of the reading section.
|
||||
/// </summary>
|
||||
public string LocationRef { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the title of the reading section, if known.
|
||||
/// </summary>
|
||||
public string? Title { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.DTO.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for an entry of the table of contents of the reading manifest of a book.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("Label: {Label}")]
|
||||
public class ReadingTocEntryDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the label of the table of contents entry.
|
||||
/// </summary>
|
||||
public string Label { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the opaque location reference of the reading section the entry points to.
|
||||
/// </summary>
|
||||
public string LocationRef { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the child entries of the table of contents entry.
|
||||
/// </summary>
|
||||
public List<ReadingTocEntryDto> Children { get; set; } = [];
|
||||
}
|
||||
@@ -40,4 +40,17 @@ public class UserSettingsDto
|
||||
/// Gets or sets whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.
|
||||
/// </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; }
|
||||
}
|
||||
+40
-42
@@ -9,7 +9,6 @@ using Lumina.Presentation.Web.Common.Http;
|
||||
using Lumina.Presentation.Web.Common.Localization;
|
||||
using Lumina.Presentation.Web.Common.Security;
|
||||
using Lumina.Presentation.Web.Common.Services;
|
||||
using Lumina.Presentation.Web.Common.Validation;
|
||||
using Lumina.Presentation.Web.Core.Themes;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
@@ -19,7 +18,6 @@ using Microsoft.AspNetCore.Http.Features;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using Microsoft.AspNetCore.Localization.Routing;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Localization;
|
||||
using Microsoft.AspNetCore.Mvc.Razor;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@@ -40,13 +38,13 @@ using System.Threading.Tasks;
|
||||
namespace Lumina.Presentation.Web.Common.DependencyInjection;
|
||||
|
||||
/// <summary>
|
||||
/// Contains all services of the Presentation Web layer.
|
||||
/// Utility class for registering the services of the Presentation Web layer into the Dependency Injection container.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public static class PresentationWebLayerServices
|
||||
{
|
||||
/// <summary>
|
||||
/// Registers the services of the Presentation Web layer into the dependency injection container.
|
||||
/// Registers the services of the Presentation Web 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>
|
||||
@@ -58,11 +56,11 @@ public static class PresentationWebLayerServices
|
||||
.AddJsonOptions(jsonOptions =>
|
||||
{
|
||||
jsonOptions.JsonSerializerOptions.MaxDepth = 256;
|
||||
jsonOptions.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles; // needed because file system API responses can have very nested structures
|
||||
jsonOptions.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles; // Needed because file system API responses can have very nested structures.
|
||||
jsonOptions.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
|
||||
});
|
||||
|
||||
// configure the locations where the Razor view engine looks for views and layouts, since the views live under the Core directory
|
||||
// Configure the locations where the Razor view engine looks for views and layouts, since the views live under the Core directory.
|
||||
services.Configure<RazorViewEngineOptions>(razorViewEngineOptions =>
|
||||
{
|
||||
razorViewEngineOptions.ViewLocationFormats.Clear();
|
||||
@@ -70,17 +68,17 @@ public static class PresentationWebLayerServices
|
||||
razorViewEngineOptions.ViewLocationFormats.Add("/Core/Views/Shared/{0}.cshtml");
|
||||
});
|
||||
|
||||
// configure the JSON serialization settings used by Results.Json, so that the JSON responses of the endpoints match the MVC responses they replace
|
||||
// Configure the JSON serialization settings used by Results.Json, so that the JSON responses of the endpoints match the MVC responses they replace.
|
||||
services.Configure<Microsoft.AspNetCore.Http.Json.JsonOptions>(jsonOptions =>
|
||||
{
|
||||
jsonOptions.SerializerOptions.MaxDepth = 256;
|
||||
jsonOptions.SerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles; // needed because file system API responses can have very nested structures
|
||||
jsonOptions.SerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles; // Needed because file system API responses can have very nested structures.
|
||||
jsonOptions.SerializerOptions.Converters.Add(new JsonStringEnumConverter());
|
||||
});
|
||||
|
||||
// register the FastEndpoints library, which replaces the MVC controllers for handling the application routes
|
||||
// Register the FastEndpoints library, which replaces the MVC controllers for handling the application routes.
|
||||
services.AddFastEndpoints();
|
||||
// add OpenAPI document generation, so that the endpoints exposed by the web application are discoverable and their contracts are visible
|
||||
// Add OpenAPI document generation, so that the endpoints exposed by the web application are discoverable and their contracts are visible.
|
||||
services.AddOpenApi();
|
||||
services.SwaggerDocument(documentOptions =>
|
||||
{
|
||||
@@ -98,9 +96,9 @@ public static class PresentationWebLayerServices
|
||||
documentOptions.RemoveEmptyRequestSchema = true;
|
||||
documentOptions.ShortSchemaNames = true;
|
||||
});
|
||||
// configure URL-based localization
|
||||
// Configure URL-based localization.
|
||||
services.AddLocalization(localizationOptions => localizationOptions.ResourcesPath = "Core/Resources");
|
||||
// resolve the resources of the views that live under the Core/Views directory
|
||||
// Resolve the resources of the views that live under the Core/Views directory.
|
||||
services.AddSingleton<IHtmlLocalizerFactory, CoreHtmlLocalizerFactory>();
|
||||
|
||||
services.Configure<RequestLocalizationOptions>(requestLocalizationOptions =>
|
||||
@@ -122,57 +120,57 @@ public static class PresentationWebLayerServices
|
||||
requestLocalizationOptions.SupportedCultures = supportedCultures;
|
||||
requestLocalizationOptions.SupportedUICultures = supportedCultures;
|
||||
|
||||
// configure route-based culture provider
|
||||
// Configure route-based culture provider.
|
||||
RouteDataRequestCultureProvider routeDataRequestCultureProvider = new()
|
||||
{
|
||||
RouteDataStringKey = "culture",
|
||||
UIRouteDataStringKey = "culture",
|
||||
Options = requestLocalizationOptions
|
||||
};
|
||||
// make the route culture provider the first one to be evaluated
|
||||
// Make the route culture provider the first one to be evaluated.
|
||||
requestLocalizationOptions.RequestCultureProviders =
|
||||
[
|
||||
routeDataRequestCultureProvider, // keep route-based culture handling
|
||||
new CookieRequestCultureProvider(), // but also add cookie option, so the application "remembers" the last used language the next time it's opened
|
||||
routeDataRequestCultureProvider, // Keep route-based culture handling,
|
||||
new CookieRequestCultureProvider(), // but also add cookie option, so the application "remembers" the last used language the next time it's opened.
|
||||
new AcceptLanguageHeaderRequestCultureProvider()
|
||||
];
|
||||
});
|
||||
|
||||
// configure cookie-based authentication
|
||||
// Configure cookie-based authentication.
|
||||
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
|
||||
.AddCookie(cookieAuthenticationOptions =>
|
||||
{
|
||||
// basic path configuration
|
||||
// Basic path configuration.
|
||||
cookieAuthenticationOptions.LoginPath = "/auth/login";
|
||||
cookieAuthenticationOptions.LogoutPath = "/auth/logout";
|
||||
cookieAuthenticationOptions.AccessDeniedPath = "/auth/access-denied";
|
||||
|
||||
// cookie configuration
|
||||
// Cookie configuration.
|
||||
cookieAuthenticationOptions.Cookie = new CookieBuilder
|
||||
{
|
||||
Name = ".Lumina.Auth", // unique name to avoid conflicts
|
||||
HttpOnly = true, // prevent JavaScript access
|
||||
Name = ".Lumina.Auth", // Unique name to avoid conflicts.
|
||||
HttpOnly = true, // Prevent JavaScript access.
|
||||
SameSite = SameSiteMode.Strict,
|
||||
SecurePolicy = CookieSecurePolicy.Always, // require HTTPS
|
||||
Path = "/", // make cookie available for all paths
|
||||
IsEssential = true // mark as essential for GDPR
|
||||
SecurePolicy = CookieSecurePolicy.Always, // Require HTTPS.
|
||||
Path = "/", // Make cookie available for all paths.
|
||||
IsEssential = true // Mark as essential for GDPR.
|
||||
};
|
||||
|
||||
// security settings
|
||||
// Security settings.
|
||||
cookieAuthenticationOptions.ExpireTimeSpan = TimeSpan.FromHours(24); // TODO: perhaps make it configurable by user?
|
||||
cookieAuthenticationOptions.SlidingExpiration = true;
|
||||
|
||||
// handle validation to support various deployment scenarios
|
||||
// Handle validation to support various deployment scenarios.
|
||||
cookieAuthenticationOptions.Events = new CookieAuthenticationEvents
|
||||
{
|
||||
// handle redirects to work with different base paths
|
||||
// Handle redirects to work with different base paths.
|
||||
OnRedirectToLogin = redirectContext =>
|
||||
{
|
||||
HttpContext httpContext = redirectContext.HttpContext;
|
||||
string culture = httpContext.Request.RouteValues["culture"]?.ToString()?.ToLower() ?? "en-us";
|
||||
string? lastDisplayedView = httpContext.Session.GetString(HttpContextItemKeys.LAST_DISPLAYED_VIEW);
|
||||
|
||||
// build the login path considering reverse proxy and subfolder scenarios
|
||||
// Build the login path considering reverse proxy and subfolder scenarios.
|
||||
string? originalHost = httpContext.Request.Headers["X-Forwarded-Host"].FirstOrDefault() ?? httpContext.Request.Host.Value;
|
||||
string? originalScheme = httpContext.Request.Headers["X-Forwarded-Proto"].FirstOrDefault() ?? httpContext.Request.Scheme;
|
||||
string? originalPathBase = httpContext.Request.Headers["X-Forwarded-Prefix"].FirstOrDefault() ?? httpContext.Request.PathBase.Value;
|
||||
@@ -226,8 +224,8 @@ public static class PresentationWebLayerServices
|
||||
};
|
||||
});
|
||||
|
||||
// add authorization policies that ensure the application is initialized with the super admin account before allowing access,
|
||||
// and that restrict access based on the roles and permissions retrieved from the remote API
|
||||
// Add authorization policies that ensure the application is initialized with the super admin account before allowing access,
|
||||
// and that restrict access based on the roles and permissions retrieved from the remote API.
|
||||
services.AddAuthorizationBuilder()
|
||||
.AddPolicy(AuthorizationPolicies.REQUIRE_INITIALIZATION, authorizationPolicyBuilder => authorizationPolicyBuilder.Requirements.Add(new InitializationRequirement()))
|
||||
.AddPolicy(AuthorizationPolicies.REQUIRE_ADMIN_ROLE, authorizationPolicyBuilder =>
|
||||
@@ -241,7 +239,7 @@ public static class PresentationWebLayerServices
|
||||
authorizationPolicyBuilder.RequireAuthenticatedUser();
|
||||
});
|
||||
|
||||
// add forwarded headers middleware to handle reverse proxy scenarios
|
||||
// Add forwarded headers middleware to handle reverse proxy scenarios.
|
||||
services.Configure<ForwardedHeadersOptions>(forwardedHeadersOptions =>
|
||||
{
|
||||
forwardedHeadersOptions.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto | ForwardedHeaders.XForwardedHost;
|
||||
@@ -249,15 +247,15 @@ public static class PresentationWebLayerServices
|
||||
forwardedHeadersOptions.KnownProxies.Clear();
|
||||
});
|
||||
|
||||
// configure session management to maintain user-specific data across requests
|
||||
// Configure session management to maintain user-specific data across requests.
|
||||
services.AddSession(sessionOptions =>
|
||||
{
|
||||
sessionOptions.IdleTimeout = TimeSpan.FromMinutes(30); // session expires after 30 minutes of inactivity
|
||||
sessionOptions.Cookie.HttpOnly = true; // prevent JavaScript access to session cookie, for security
|
||||
sessionOptions.Cookie.IsEssential = true; // mark session cookie as essential, for GDPR compliance
|
||||
sessionOptions.IdleTimeout = TimeSpan.FromMinutes(30); // Session expires after 30 minutes of inactivity.
|
||||
sessionOptions.Cookie.HttpOnly = true; // Prevent JavaScript access to session cookie, for security.
|
||||
sessionOptions.Cookie.IsEssential = true; // Mark session cookie as essential, for GDPR compliance.
|
||||
});
|
||||
|
||||
// scan the current assembly for validators and register them as singletons in the DI container
|
||||
// Scan the current assembly for validators and register them as singletons in the DI container.
|
||||
foreach (Type validatorType in typeof(Program).Assembly.GetTypes())
|
||||
{
|
||||
if (validatorType.IsInterface || validatorType.IsAbstract || validatorType.IsGenericTypeDefinition)
|
||||
@@ -273,16 +271,16 @@ public static class PresentationWebLayerServices
|
||||
}
|
||||
}
|
||||
|
||||
// handle transient errors like network timeouts or intermittent failures
|
||||
// Handle transient errors like network timeouts or intermittent failures.
|
||||
AsyncRetryPolicy<HttpResponseMessage> retryPolicy = Policy<HttpResponseMessage>
|
||||
.Handle<HttpRequestException>()
|
||||
.OrInner<ApiException>(apiException =>
|
||||
apiException.HttpStatusCode != HttpStatusCode.BadRequest && // do not retry Bad Request and Forbidden responses, it's pointless
|
||||
apiException.HttpStatusCode != HttpStatusCode.BadRequest && // Do not retry Bad Request and Forbidden responses, it's pointless.
|
||||
apiException.HttpStatusCode != HttpStatusCode.Forbidden)
|
||||
.WaitAndRetryAsync(3, retryAttempt =>
|
||||
TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)));
|
||||
|
||||
// use a circuit breaker to prevent repeatedly calling a failing service
|
||||
// Use a circuit breaker to prevent repeatedly calling a failing service.
|
||||
AsyncCircuitBreakerPolicy<HttpResponseMessage> circuitBreakerPolicy = Policy<HttpResponseMessage>
|
||||
.Handle<HttpRequestException>()
|
||||
.OrInner<ApiException>(apiException => apiException.HttpStatusCode == HttpStatusCode.InternalServerError)
|
||||
@@ -290,7 +288,7 @@ public static class PresentationWebLayerServices
|
||||
|
||||
AsyncPolicyWrap<HttpResponseMessage> policy = Policy.WrapAsync(retryPolicy, circuitBreakerPolicy);
|
||||
|
||||
// register the HTTP typed client used for the API interaction
|
||||
// Register the HTTP typed client used for the API interaction.
|
||||
services.AddHttpClient<IApiHttpClient, ApiHttpClient>()
|
||||
.AddHttpMessageHandler<CachedAuthorizationHandler>()
|
||||
.AddHttpMessageHandler<CachedThemeHandler>()
|
||||
@@ -301,7 +299,7 @@ public static class PresentationWebLayerServices
|
||||
services.AddScoped<CachedThemeHandler>();
|
||||
services.AddScoped<ThemeCachePreferenceService>();
|
||||
|
||||
// enable access to the current HTTP context in non-controller classes
|
||||
// Enable access to the current HTTP context in non-controller classes.
|
||||
services.AddHttpContextAccessor();
|
||||
services.Configure<FormOptions>(options => options.MultipartBodyLengthLimit = 10 * 1024 * 1024);
|
||||
|
||||
@@ -320,7 +318,7 @@ public static class PresentationWebLayerServices
|
||||
services.AddScoped<Authorization.IAuthorizationService, AuthorizationService>();
|
||||
services.AddSingleton<ICryptographyService, CryptographyService>();
|
||||
services.AddSingleton<IUrlService, UrlService>();
|
||||
services.AddHybridCache(); // used for caching authorization roles, permissions, policies and theme data
|
||||
services.AddHybridCache(); // Used for caching authorization roles, permissions, policies and theme data.
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
+5
-5
@@ -16,7 +16,7 @@ using System.Diagnostics.CodeAnalysis;
|
||||
namespace Lumina.Presentation.Web.Common.DependencyInjection;
|
||||
|
||||
/// <summary>
|
||||
/// Contains the OpenTelemetry services of the Presentation Web layer.
|
||||
/// Utility class for registering the OpenTelemetry services of the Presentation Web layer into the Dependency Injection container.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public static class PresentationWebTelemetryServices
|
||||
@@ -24,10 +24,10 @@ public static class PresentationWebTelemetryServices
|
||||
private const string SERVICE_NAME = "Lumina.Web";
|
||||
|
||||
/// <summary>
|
||||
/// Registers the OpenTelemetry tracing and metrics pipelines into the dependency injection container.
|
||||
/// Registers the OpenTelemetry services of the Presentation Web layer into the Dependency Injection container.
|
||||
/// </summary>
|
||||
/// <param name="services">The service collection to add the services to.</param>
|
||||
/// <param name="configuration">Application configuration properties.</param>
|
||||
/// <param name="configuration">The configuration used to read the application configuration.</param>
|
||||
/// <param name="environment">The hosting environment of the application.</param>
|
||||
/// <returns>The updated <see cref="IServiceCollection"/>.</returns>
|
||||
public static IServiceCollection AddPresentationWebTelemetryServices(this IServiceCollection services, IConfiguration configuration, IWebHostEnvironment environment)
|
||||
@@ -54,8 +54,8 @@ public static class PresentationWebTelemetryServices
|
||||
tracingBuilder.SetSampler(CreateSampler(traceSampleRatio));
|
||||
tracingBuilder.AddSource(WebTelemetry.SOURCE_NAME);
|
||||
tracingBuilder.AddAspNetCoreInstrumentation();
|
||||
// the HTTP client instrumentation emits spans and metrics for the calls to the API, and injects the W3C trace context
|
||||
// into their headers, so that the API continues the same trace across the two separately deployed applications
|
||||
// The HTTP client instrumentation emits spans and metrics for the calls to the API, and injects the W3C trace context
|
||||
// into their headers, so that the API continues the same trace across the two separately deployed applications.
|
||||
tracingBuilder.AddHttpClientInstrumentation();
|
||||
if (isConsoleExporterEnabled)
|
||||
tracingBuilder.AddConsoleExporter();
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ namespace Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Path;
|
||||
/// <summary>
|
||||
/// Represents the request for retrieving the parent path of a file system path.
|
||||
/// </summary>
|
||||
/// <param name="Path">The path for which the parent path is retrieved.</param>
|
||||
/// <param name="Path">The path for which the parent path is retrieved. Required.</param>
|
||||
[DebuggerDisplay("Path: {Path}")]
|
||||
public record GetPathParentRequest(
|
||||
string? Path
|
||||
|
||||
+2
-2
@@ -7,8 +7,8 @@ namespace Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Thumbnail
|
||||
/// <summary>
|
||||
/// Represents a request for retrieving the thumbnail of a file system file.
|
||||
/// </summary>
|
||||
/// <param name="Path">The path of the file for which the thumbnail is retrieved.</param>
|
||||
/// <param name="Quality">The quality to use for the thumbnail.</param>
|
||||
/// <param name="Path">The path of the file for which the thumbnail is retrieved. Required.</param>
|
||||
/// <param name="Quality">The quality to use for the thumbnail. Required.</param>
|
||||
[DebuggerDisplay("Path: {Path}")]
|
||||
public record GetThumbnailRequest(
|
||||
string? Path,
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ namespace Lumina.Presentation.Web.Common.Requests.Library.Management;
|
||||
/// <summary>
|
||||
/// Represents the request for displaying the media library editing view.
|
||||
/// </summary>
|
||||
/// <param name="Id">The unique identifier of the media library to edit.</param>
|
||||
/// <param name="Id">The unique identifier of the media library to edit. Required.</param>
|
||||
[DebuggerDisplay("Id: {Id}")]
|
||||
public record EditLibraryRequest(
|
||||
Guid Id
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ namespace Lumina.Presentation.Web.Common.Requests.Library.Management;
|
||||
/// <summary>
|
||||
/// Represents the request for retrieving the artwork providers of a media library.
|
||||
/// </summary>
|
||||
/// <param name="LibraryId">The unique identifier of the media library whose artwork providers are retrieved.</param>
|
||||
/// <param name="LibraryId">The unique identifier of the media library whose artwork providers are retrieved. Required.</param>
|
||||
[DebuggerDisplay("LibraryId: {LibraryId}")]
|
||||
public record GetArtworkProvidersRequest(
|
||||
Guid LibraryId
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.Requests.Library.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the request for retrieving the book readers of a media library.
|
||||
/// </summary>
|
||||
/// <param name="LibraryId">The unique identifier of the media library whose book readers are retrieved. Required.</param>
|
||||
[DebuggerDisplay("LibraryId: {LibraryId}")]
|
||||
public record GetBookReadersRequest(
|
||||
Guid LibraryId
|
||||
);
|
||||
+1
-1
@@ -8,7 +8,7 @@ namespace Lumina.Presentation.Web.Common.Requests.Library.Management;
|
||||
/// <summary>
|
||||
/// Represents the request for retrieving the metadata providers of a media library.
|
||||
/// </summary>
|
||||
/// <param name="LibraryId">The unique identifier of the media library whose metadata providers are retrieved.</param>
|
||||
/// <param name="LibraryId">The unique identifier of the media library whose metadata providers are retrieved. Required.</param>
|
||||
[DebuggerDisplay("LibraryId: {LibraryId}")]
|
||||
public record GetMetadataProvidersRequest(
|
||||
Guid LibraryId
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ namespace Lumina.Presentation.Web.Common.Requests.Library.WrittenContentLibrary.
|
||||
/// <summary>
|
||||
/// Represents a request to get a book by the specified Id.
|
||||
/// </summary>
|
||||
/// <param name="Id">The unique identifier of the book to retrieve.</param>
|
||||
/// <param name="Id">The unique identifier of the book to retrieve. Required.</param>
|
||||
[DebuggerDisplay("Id: {Id}")]
|
||||
public record GetBookRequest(
|
||||
Guid Id
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ namespace Lumina.Presentation.Web.Common.Requests.Library.WrittenContentLibrary.
|
||||
/// <summary>
|
||||
/// Represents the request for displaying the books browsing view.
|
||||
/// </summary>
|
||||
/// <param name="LibraryId">The unique identifier of the media library whose books are browsed.</param>
|
||||
/// <param name="LibraryId">The unique identifier of the media library whose books are browsed. Optional.</param>
|
||||
[DebuggerDisplay("LibraryId: {LibraryId}")]
|
||||
public record GetBooksViewRequest(
|
||||
Guid? LibraryId
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.Requests.Library.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a request to check the reading availability of a book.
|
||||
/// </summary>
|
||||
/// <param name="BookId">The unique identifier of the book whose reading availability is checked. Required.</param>
|
||||
[DebuggerDisplay("BookId: {BookId}")]
|
||||
public record GetBookReadingAvailabilityRequest(
|
||||
Guid BookId
|
||||
);
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.Requests.Library.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a request to get the reading manifest of a book.
|
||||
/// </summary>
|
||||
/// <param name="BookId">The unique identifier of the book whose reading manifest is retrieved. Required.</param>
|
||||
[DebuggerDisplay("BookId: {BookId}")]
|
||||
public record GetBookReadingManifestRequest(
|
||||
Guid BookId
|
||||
);
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.Requests.Library.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a request to get a resource of a book, for reading.
|
||||
/// </summary>
|
||||
/// <param name="BookId">The unique identifier of the book whose resource is retrieved. Required.</param>
|
||||
/// <param name="ResourceKey">The opaque resource key of the resource. Required.</param>
|
||||
[DebuggerDisplay("BookId: {BookId}, ResourceKey: {ResourceKey}")]
|
||||
public record GetBookReadingResourceRequest(
|
||||
Guid BookId,
|
||||
string ResourceKey
|
||||
);
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.Requests.Library.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a request to get the content of a reading section of a book.
|
||||
/// </summary>
|
||||
/// <param name="BookId">The unique identifier of the book whose reading section is retrieved. Required.</param>
|
||||
/// <param name="LocationRef">The opaque location reference of the reading section. Required.</param>
|
||||
[DebuggerDisplay("BookId: {BookId}, LocationRef: {LocationRef}")]
|
||||
public record GetBookReadingSectionRequest(
|
||||
Guid BookId,
|
||||
string LocationRef
|
||||
);
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.Requests.Library.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the request for displaying the reading view of a book.
|
||||
/// </summary>
|
||||
/// <param name="BookId">The unique identifier of the book to read. Required.</param>
|
||||
[DebuggerDisplay("BookId: {BookId}")]
|
||||
public record ReadBookViewRequest(
|
||||
Guid BookId
|
||||
);
|
||||
@@ -0,0 +1,28 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.Requests.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a request to enable or disable a book reader for a media library.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("LibraryId: {LibraryId}, PluginId: {PluginId}")]
|
||||
public class SetBookReaderEnabledRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the media library whose book reader is enabled or disabled. Required.
|
||||
/// </summary>
|
||||
public Guid LibraryId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the unique identifier of the plugin providing the book reader. Required.
|
||||
/// </summary>
|
||||
public Guid PluginId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the book reader should be enabled for the media library. Required.
|
||||
/// </summary>
|
||||
public bool IsEnabled { get; set; }
|
||||
}
|
||||
@@ -7,7 +7,7 @@ namespace Lumina.Presentation.Web.Common.Requests.Themes;
|
||||
/// <summary>
|
||||
/// Represents a request to delete a theme.
|
||||
/// </summary>
|
||||
/// <param name="ThemeId">The manifest id of the theme to delete.</param>
|
||||
/// <param name="ThemeId">The manifest id of the theme to delete. Required.</param>
|
||||
[DebuggerDisplay("ThemeId: {ThemeId}")]
|
||||
public record DeleteThemeRequest(
|
||||
string? ThemeId
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Lumina.Presentation.Web.Common.Requests.Themes;
|
||||
/// <summary>
|
||||
/// Represents a request to download the archive of a theme.
|
||||
/// </summary>
|
||||
/// <param name="ThemeId">The manifest id of the theme to download.</param>
|
||||
/// <param name="ThemeId">The manifest id of the theme to download. Required.</param>
|
||||
[DebuggerDisplay("ThemeId: {ThemeId}")]
|
||||
public record GetThemeArchiveRequest(
|
||||
string? ThemeId
|
||||
|
||||
@@ -7,8 +7,8 @@ namespace Lumina.Presentation.Web.Common.Requests.Themes;
|
||||
/// <summary>
|
||||
/// Represents a request to get an asset file of a theme.
|
||||
/// </summary>
|
||||
/// <param name="ThemeId">The manifest id of the theme.</param>
|
||||
/// <param name="Path">The asset path relative to the theme pack root.</param>
|
||||
/// <param name="ThemeId">The manifest id of the theme. Required.</param>
|
||||
/// <param name="Path">The asset path relative to the theme pack root. Required.</param>
|
||||
[DebuggerDisplay("ThemeId: {ThemeId}, Path: {Path}")]
|
||||
public record GetThemeAssetRequest(
|
||||
string? ThemeId,
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Lumina.Presentation.Web.Common.Requests.Themes;
|
||||
/// <summary>
|
||||
/// Represents a request to restore a soft deleted bundled theme.
|
||||
/// </summary>
|
||||
/// <param name="ThemeId">The manifest id of the bundled theme to restore.</param>
|
||||
/// <param name="ThemeId">The manifest id of the bundled theme to restore. Required.</param>
|
||||
[DebuggerDisplay("ThemeId: {ThemeId}")]
|
||||
public record RestoreThemeRequest(
|
||||
string? ThemeId
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Lumina.Presentation.Web.Common.Requests.Themes;
|
||||
/// <summary>
|
||||
/// Represents a request to set the currently active theme.
|
||||
/// </summary>
|
||||
/// <param name="ThemeId">The manifest id of the theme to activate.</param>
|
||||
/// <param name="ThemeId">The manifest id of the theme to activate. Required.</param>
|
||||
[DebuggerDisplay("ThemeId: {ThemeId}")]
|
||||
public record SetCurrentThemeRequest(
|
||||
string? ThemeId
|
||||
|
||||
@@ -7,8 +7,8 @@ namespace Lumina.Presentation.Web.Common.Requests.Tools;
|
||||
/// <summary>
|
||||
/// Represents the request for setting the culture used by the application.
|
||||
/// </summary>
|
||||
/// <param name="NewCulture">The new culture to set.</param>
|
||||
/// <param name="ReturnUrl">The URL to return to, after setting the new culture.</param>
|
||||
/// <param name="NewCulture">The new culture to set. Required.</param>
|
||||
/// <param name="ReturnUrl">The URL to return to, after setting the new culture. Optional.</param>
|
||||
[DebuggerDisplay("NewCulture: {NewCulture}, ReturnUrl: {ReturnUrl}")]
|
||||
public record SetLanguageRequest(
|
||||
string? NewCulture,
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ namespace Lumina.Presentation.Web.Common.Requests.UsersManagement.Authentication
|
||||
/// <summary>
|
||||
/// Represents the request for displaying the account login view.
|
||||
/// </summary>
|
||||
/// <param name="ReturnUrl">The URL to return to, after login.</param>
|
||||
/// <param name="ReturnUrl">The URL to return to, after login. Optional.</param>
|
||||
[DebuggerDisplay("ReturnUrl: {ReturnUrl}")]
|
||||
public record LoginViewRequest(
|
||||
string? ReturnUrl = null
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Lumina.Presentation.Web.Common.Requests.UsersManagement;
|
||||
/// <param name="Username">The username of the account to authenticate. Required.</param>
|
||||
/// <param name="Password">The password of the account to authenticate. Required.</param>
|
||||
/// <param name="TotpCode">The TOTP (Time-Based One-Time Password) of the account to authenticate. Optional.</param>
|
||||
/// <param name="ReturnUrl">The URL to return to, after login.</param>
|
||||
/// <param name="ReturnUrl">The URL to return to, after login. Optional.</param>
|
||||
[DebuggerDisplay("Username: {Username}")]
|
||||
public record LoginRequest(
|
||||
string? Username = null,
|
||||
|
||||
@@ -11,5 +11,9 @@ public static partial class ApiRoutes
|
||||
public static class Books
|
||||
{
|
||||
public const string GET_BOOKS_LITE = "books/lite";
|
||||
public const string GET_BOOK_READING_MANIFEST = "books/{bookId}/reading/manifest";
|
||||
public const string GET_BOOK_READING_AVAILABILITY = "books/{bookId}/reading/availability";
|
||||
public const string GET_BOOK_READING_SECTION = "books/{bookId}/reading/sections/{locationRef}";
|
||||
public const string GET_BOOK_READING_RESOURCE = "books/{bookId}/reading/resources/{resourceKey}";
|
||||
}
|
||||
}
|
||||
@@ -27,5 +27,7 @@ public static partial class ApiRoutes
|
||||
public const string GET_LIBRARY_ARTWORK_PROVIDERS = "libraries/{libraryId}/artwork-providers";
|
||||
public const string SET_LIBRARY_ARTWORK_PROVIDER_ENABLED = "libraries/{libraryId}/artwork-providers/{pluginId}/enabled";
|
||||
public const string REORDER_LIBRARY_ARTWORK_PROVIDERS = "libraries/{libraryId}/artwork-providers/reorder";
|
||||
public const string GET_LIBRARY_BOOK_READERS = "libraries/{libraryId}/book-readers";
|
||||
public const string SET_LIBRARY_BOOK_READER_ENABLED = "libraries/{libraryId}/book-readers/{pluginId}/enabled";
|
||||
}
|
||||
}
|
||||
@@ -13,5 +13,10 @@ public static partial class WebRoutes
|
||||
public const string INDEX = "{culture}/library/written-content-library/books-library/books";
|
||||
public const string GET_LIBRARY_ITEMS = "{culture}/library/written-content-library/books-library/books/api-get-library-items";
|
||||
public const string EDIT_BOOK = "{culture}/library/written-content-library/books-library/books/{id}";
|
||||
public const string READ = "{culture}/library/written-content-library/books-library/books/{bookId}/read";
|
||||
public const string GET_READING_MANIFEST = "{culture}/library/written-content-library/books-library/books/{bookId}/api-get-reading-manifest";
|
||||
public const string GET_READING_AVAILABILITY = "{culture}/library/written-content-library/books-library/books/{bookId}/api-get-reading-availability";
|
||||
public const string GET_READING_SECTION = "{culture}/library/written-content-library/books-library/books/{bookId}/api-get-reading-section";
|
||||
public const string GET_READING_RESOURCE = "{culture}/library/written-content-library/books-library/books/{bookId}/api-get-reading-resource";
|
||||
}
|
||||
}
|
||||
@@ -28,5 +28,7 @@ public static partial class WebRoutes
|
||||
public const string GET_ARTWORK_PROVIDERS = "{culture}/libraries/manage/api-get-artwork-providers/{libraryId}";
|
||||
public const string SET_ARTWORK_PROVIDER_ENABLED = "{culture}/libraries/manage/api-set-artwork-provider-enabled";
|
||||
public const string REORDER_ARTWORK_PROVIDERS = "{culture}/libraries/manage/api-reorder-artwork-providers";
|
||||
public const string GET_BOOK_READERS = "{culture}/libraries/manage/api-get-book-readers/{libraryId}";
|
||||
public const string SET_BOOK_READER_ENABLED = "{culture}/libraries/manage/api-set-book-reader-enabled";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user