mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-02 21:11:10 +00:00
Renders every page through the themed shell with a themed navigation menu
This commit is contained in:
1 parent
e37bb3ecc6
commit
4ef8570854
19 files changed
+707
-104
No files matched your search
@@ -0,0 +1,30 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.DTO.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for the model available to the themed layout template while rendering the shell of a page.
|
||||
/// </summary>
|
||||
/// <param name="Title">The title of the page, rendered by the theme.</param>
|
||||
/// <param name="AssetBase">The base URL of the theme assets.</param>
|
||||
/// <param name="AppHead">The application head links, such as its global stylesheets.</param>
|
||||
/// <param name="Nav">The rendered navigation menu of the page.</param>
|
||||
/// <param name="Content">The rendered content section of the page.</param>
|
||||
/// <param name="AudioPlayer">The rendered audio player, when the current user is authenticated.</param>
|
||||
/// <param name="AppScripts">The application global scripts, such as its client libraries and configuration.</param>
|
||||
/// <param name="Scripts">The rendered script section of the page.</param>
|
||||
/// <param name="MainStyle">The inline style of the main content area, used to fill the viewport when the user is not authenticated.</param>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
public sealed record ThemeLayoutModelDto(
|
||||
string Title,
|
||||
string AssetBase,
|
||||
string AppHead,
|
||||
string Nav,
|
||||
string Content,
|
||||
string AudioPlayer,
|
||||
string AppScripts,
|
||||
string Scripts,
|
||||
string MainStyle
|
||||
);
|
||||
@@ -0,0 +1,18 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.DTO.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for the page content handed to the layout renderer, which wraps it in the themed shell.
|
||||
/// </summary>
|
||||
/// <param name="Title">The title of the page, displayed by the themed shell.</param>
|
||||
/// <param name="Content">The rendered HTML content of the page section.</param>
|
||||
/// <param name="Script">The rendered script element of the page section, when the template defines one.</param>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
public sealed record ThemeLayoutPageDto(
|
||||
string Title,
|
||||
string Content,
|
||||
string Script
|
||||
);
|
||||
@@ -0,0 +1,21 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.DTO.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for a menu entry of the themed navigation menu, either a link or a submenu.
|
||||
/// </summary>
|
||||
/// <param name="Label">The localized label of the menu entry.</param>
|
||||
/// <param name="Url">The URL of the link, or <see langword="null"/> for a submenu.</param>
|
||||
/// <param name="CssClass">The CSS classes of the link, such as <c>nav-link</c> for AJAX navigation.</param>
|
||||
/// <param name="Children">The child links of a submenu, empty for a plain link.</param>
|
||||
[DebuggerDisplay("Label: {Label}")]
|
||||
public sealed record ThemeNavEntryDto(
|
||||
string Label,
|
||||
string? Url,
|
||||
string? CssClass,
|
||||
IReadOnlyList<ThemeNavEntryDto> Children
|
||||
);
|
||||
@@ -0,0 +1,19 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.DTO.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for the model available to the themed navigation menu template.
|
||||
/// </summary>
|
||||
/// <param name="SiteName">The name of the site displayed by the navigation menu.</param>
|
||||
/// <param name="MobileSections">The menu sections of the mobile navigation menu.</param>
|
||||
/// <param name="MenubarSections">The menu sections of the desktop navigation menu bar.</param>
|
||||
[DebuggerDisplay("SiteName: {SiteName}")]
|
||||
public sealed record ThemeNavMenuDto(
|
||||
string SiteName,
|
||||
IReadOnlyList<ThemeNavSectionDto> MobileSections,
|
||||
IReadOnlyList<ThemeNavSectionDto> MenubarSections
|
||||
);
|
||||
@@ -0,0 +1,17 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.DTO.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for a menu section of the themed navigation menu.
|
||||
/// </summary>
|
||||
/// <param name="Label">The localized label of the menu section.</param>
|
||||
/// <param name="Items">The menu entries of the section, visible to the current user.</param>
|
||||
[DebuggerDisplay("Label: {Label}")]
|
||||
public sealed record ThemeNavSectionDto(
|
||||
string Label,
|
||||
IReadOnlyList<ThemeNavEntryDto> Items
|
||||
);
|
||||
@@ -9,10 +9,8 @@ namespace Lumina.Presentation.Web.Common.DTO.Themes;
|
||||
/// </summary>
|
||||
/// <param name="Content">The rendered HTML content of the page section.</param>
|
||||
/// <param name="Script">The rendered script element of the page section, when the template defines one.</param>
|
||||
/// <param name="AssetBase">The base URL of the theme assets, used to load the theme stylesheet of the page.</param>
|
||||
[DebuggerDisplay("Content length: {Content.Length}, Script length: {Script.Length}")]
|
||||
public sealed record ThemeViewDto(
|
||||
string Content,
|
||||
string Script,
|
||||
string AssetBase
|
||||
string Script
|
||||
);
|
||||
@@ -304,6 +304,9 @@ public static class PresentationWebLayerServices
|
||||
services.AddScoped<ThemeService>();
|
||||
services.AddSingleton<ThemeTemplateEngine>();
|
||||
services.AddScoped<ThemePageRenderer>();
|
||||
services.AddScoped<RazorViewToStringRenderer>();
|
||||
services.AddScoped<ThemeNavBuilder>();
|
||||
services.AddScoped<ThemeLayoutRenderer>();
|
||||
|
||||
services.AddScoped<IAuthorizationHandler, InitializationHandler>();
|
||||
services.AddScoped<IAuthorizationHandler, RoleAuthorizationHandler>();
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Themes;
|
||||
using Lumina.Presentation.Web.Common.Primitives;
|
||||
using Lumina.Presentation.Web.Common.Routes;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Common;
|
||||
using Lumina.Presentation.Web.Core.Themes;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
@@ -15,6 +20,26 @@ namespace Lumina.Presentation.Web.Core.Endpoints.Home;
|
||||
/// </summary>
|
||||
public class HomeNotFoundViewEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
// the resource base name deliberately excludes the "Core.Resources" segment: the localization factory re-roots it with the configured ResourcesPath
|
||||
private const string VIEW_RESOURCE_BASE_NAME = "Lumina.Presentation.Web.Views.Shared.NotFound";
|
||||
private const string VIEW_RESOURCE_LOCATION = "Lumina.Presentation.Web";
|
||||
// the page key mirrors the path of the Razor view under Core/Views, so that theme templates can override it at the page, section or default scope
|
||||
private const string VIEW_PAGE_KEY = "shared/not-found";
|
||||
|
||||
private readonly ThemePageRenderer _themePageRenderer;
|
||||
private readonly IStringLocalizer _localizer;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="HomeNotFoundViewEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="themePageRenderer">Injected service for rendering themed pages.</param>
|
||||
/// <param name="stringLocalizerFactory">Injected factory used to create the localizer of the view resources.</param>
|
||||
public HomeNotFoundViewEndpoint(ThemePageRenderer themePageRenderer, IStringLocalizerFactory stringLocalizerFactory)
|
||||
{
|
||||
_themePageRenderer = themePageRenderer;
|
||||
_localizer = stringLocalizerFactory.Create(VIEW_RESOURCE_BASE_NAME, VIEW_RESOURCE_LOCATION);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
@@ -28,12 +53,30 @@ public class HomeNotFoundViewEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays the not-found page.
|
||||
/// Displays the not-found page, rendered by the active theme with a fallback to the Razor view.
|
||||
/// </summary>
|
||||
/// <param name="request">The request object.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override Task<IResult> ExecuteAsync(EmptyRequest request, CancellationToken cancellationToken)
|
||||
public override async Task<IResult> ExecuteAsync(EmptyRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult(View("/Core/Views/Shared/NotFound.cshtml"));
|
||||
ThemePageDto pageModel = new()
|
||||
{
|
||||
PageKey = VIEW_PAGE_KEY,
|
||||
Title = _localizer["PageNotFound"].Value,
|
||||
Description = _localizer["ThereIsNoPage"].Value,
|
||||
PageData = new Dictionary<string, object?>
|
||||
{
|
||||
["strings"] = ThemePageDataFactory.CreateLocalizedStrings(_localizer)
|
||||
}
|
||||
};
|
||||
|
||||
Result<ThemePageRenderResultDto> sectionResult = await _themePageRenderer.RenderAsync(pageModel, requestedThemeId: null, cancellationToken).ConfigureAwait(false);
|
||||
if (sectionResult.IsFailure)
|
||||
return View("/Core/Views/Shared/NotFound.cshtml");
|
||||
|
||||
return View(
|
||||
"/Core/Views/Shared/_ThemedView.cshtml",
|
||||
new ThemeViewDto(sectionResult.Value.Content, sectionResult.Value.Script),
|
||||
new Dictionary<string, object?> { ["Title"] = pageModel.Title });
|
||||
}
|
||||
}
|
||||
+6
-3
@@ -89,10 +89,13 @@ public class BooksIndexViewEndpoint : BaseEndpoint<GetBooksViewRequest, IResult>
|
||||
}
|
||||
};
|
||||
|
||||
Result<ThemePageRenderResultDto> renderResult = await _themePageRenderer.RenderAsync(pageModel, requestedThemeId: null, cancellationToken).ConfigureAwait(false);
|
||||
if (renderResult.IsFailure)
|
||||
Result<ThemePageRenderResultDto> sectionResult = await _themePageRenderer.RenderAsync(pageModel, requestedThemeId: null, cancellationToken).ConfigureAwait(false);
|
||||
if (sectionResult.IsFailure)
|
||||
return View("/Core/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.cshtml", library);
|
||||
|
||||
return View("/Core/Views/Shared/_ThemedView.cshtml", new ThemeViewDto(renderResult.Value.Content, renderResult.Value.Script, pageModel.AssetBase));
|
||||
return View(
|
||||
"/Core/Views/Shared/_ThemedView.cshtml",
|
||||
new ThemeViewDto(sectionResult.Value.Content, sectionResult.Value.Script),
|
||||
new Dictionary<string, object?> { ["Title"] = pageModel.Title });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Abstractions;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.ViewEngines;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Renders a Razor partial to a string, so that the application chrome can be reused by the themed layout renderer.
|
||||
/// </summary>
|
||||
public sealed class RazorViewToStringRenderer
|
||||
{
|
||||
private readonly ICompositeViewEngine _viewEngine;
|
||||
private readonly ITempDataProvider _tempDataProvider;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RazorViewToStringRenderer"/> class.
|
||||
/// </summary>
|
||||
/// <param name="viewEngine">Injected engine used to resolve the partial to render.</param>
|
||||
/// <param name="tempDataProvider">Injected provider used to create the temp data dictionary of the view context.</param>
|
||||
/// <param name="serviceProvider">Injected service provider used to resolve the model metadata provider.</param>
|
||||
/// <param name="httpContextAccessor">Injected accessor for the current HTTP context.</param>
|
||||
public RazorViewToStringRenderer(ICompositeViewEngine viewEngine, ITempDataProvider tempDataProvider, IServiceProvider serviceProvider, IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_viewEngine = viewEngine;
|
||||
_tempDataProvider = tempDataProvider;
|
||||
_serviceProvider = serviceProvider;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the partial with the specified name to a string.
|
||||
/// </summary>
|
||||
/// <param name="partialName">The name of the partial to render.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>The rendered HTML of the partial.</returns>
|
||||
public async Task<string> RenderPartialAsync(string partialName, CancellationToken cancellationToken = default)
|
||||
{
|
||||
HttpContext httpContext = _httpContextAccessor.HttpContext ?? throw new InvalidOperationException("The current HTTP context is unavailable.");
|
||||
ActionContext actionContext = new(httpContext, httpContext.GetRouteData() ?? new RouteData(), new ActionDescriptor());
|
||||
IView view = _viewEngine.FindView(actionContext, partialName, isMainPage: false).View
|
||||
?? throw new InvalidOperationException($"The partial '{partialName}' could not be found.");
|
||||
|
||||
IModelMetadataProvider metadataProvider = _serviceProvider.GetRequiredService<IModelMetadataProvider>();
|
||||
ViewDataDictionary viewData = new(metadataProvider, new ModelStateDictionary());
|
||||
using StringWriter writer = new();
|
||||
ViewContext viewContext = new(actionContext, view, viewData, new TempDataDictionary(httpContext, _tempDataProvider), writer, new HtmlHelperOptions());
|
||||
await view.RenderAsync(viewContext).ConfigureAwait(false);
|
||||
return writer.ToString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.Themes;
|
||||
using Lumina.Presentation.Web.Common.Primitives;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Renders the themed shell of a page, wrapping the page section in the layout and navigation templates of the active theme.
|
||||
/// </summary>
|
||||
public class ThemeLayoutRenderer
|
||||
{
|
||||
// the page keys mirror the paths of the corresponding Razor views under Core/Views, so that theme templates can override them at the page, section or default scope
|
||||
private const string LAYOUT_PAGE_KEY = "shared/layout";
|
||||
private const string NAV_PAGE_KEY = "shared/nav-menu";
|
||||
|
||||
private readonly ThemeService _themeService;
|
||||
private readonly ThemeTemplateEngine _templateEngine;
|
||||
private readonly RazorViewToStringRenderer _viewRenderer;
|
||||
private readonly ThemeNavBuilder _navBuilder;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ThemeLayoutRenderer"/> class.
|
||||
/// </summary>
|
||||
/// <param name="themeService">The service that resolves the render documents.</param>
|
||||
/// <param name="templateEngine">The template engine used to render the documents.</param>
|
||||
/// <param name="viewRenderer">The renderer used to produce the application chrome fragments.</param>
|
||||
/// <param name="navBuilder">The builder used to produce the navigation menu model.</param>
|
||||
/// <param name="httpContextAccessor">Injected accessor for the current HTTP context.</param>
|
||||
public ThemeLayoutRenderer(ThemeService themeService, ThemeTemplateEngine templateEngine, RazorViewToStringRenderer viewRenderer, ThemeNavBuilder navBuilder, IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_themeService = themeService;
|
||||
_templateEngine = templateEngine;
|
||||
_viewRenderer = viewRenderer;
|
||||
_navBuilder = navBuilder;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the themed shell of the page, wrapping the page section in the layout template of the active theme.
|
||||
/// </summary>
|
||||
/// <param name="page">The rendered page section to wrap.</param>
|
||||
/// <param name="requestedThemeId">The optional unique identifier of the theme to render with, falling back to the current theme when <see langword="null"/>.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> containing either the full page HTML, or an error.</returns>
|
||||
public virtual async Task<Result<string>> RenderAsync(ThemeLayoutPageDto page, string? requestedThemeId = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
ThemeRenderDocumentDto layoutDocument = await _themeService.GetRenderDocumentAsync(LAYOUT_PAGE_KEY, requestedThemeId, cancellationToken);
|
||||
string themeId = layoutDocument.Theme.Id;
|
||||
bool isAuthenticated = _httpContextAccessor.HttpContext?.User.Identity?.IsAuthenticated == true;
|
||||
|
||||
string appHead = await _viewRenderer.RenderPartialAsync("_ThemeLayoutHead", cancellationToken);
|
||||
string nav = await RenderNavAsync(themeId, cancellationToken);
|
||||
string audioPlayer = isAuthenticated ? await _viewRenderer.RenderPartialAsync("_AudioPlayer", cancellationToken) : string.Empty;
|
||||
string appScripts = await _viewRenderer.RenderPartialAsync("_ThemeLayoutScripts", cancellationToken);
|
||||
|
||||
ThemeLayoutModelDto layoutModel = new(
|
||||
page.Title,
|
||||
$"/theme-assets/{themeId}/assets",
|
||||
appHead,
|
||||
nav,
|
||||
page.Content,
|
||||
audioPlayer,
|
||||
appScripts,
|
||||
page.Script,
|
||||
isAuthenticated ? string.Empty : "bottom: 0px;");
|
||||
|
||||
Result<ThemePageRenderResultDto> renderResult = _templateEngine.RenderPage(layoutDocument.Template, layoutModel);
|
||||
if (renderResult.IsFailure)
|
||||
return renderResult.Errors;
|
||||
|
||||
return renderResult.Value.Content;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the navigation menu of the active theme, falling back to the application Razor menu when the theme template cannot be rendered.
|
||||
/// </summary>
|
||||
/// <param name="themeId">The manifest id of the active theme.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>The rendered navigation menu HTML.</returns>
|
||||
private async Task<string> RenderNavAsync(string themeId, CancellationToken cancellationToken)
|
||||
{
|
||||
ThemeNavMenuDto navModel = await _navBuilder.BuildAsync(cancellationToken);
|
||||
ThemeRenderDocumentDto navDocument = await _themeService.GetRenderDocumentAsync(NAV_PAGE_KEY, themeId, cancellationToken);
|
||||
Result<ThemePageRenderResultDto> navRenderResult = _templateEngine.RenderPage(navDocument.Template, navModel);
|
||||
if (navRenderResult.IsSuccess)
|
||||
return navRenderResult.Value.Content;
|
||||
|
||||
return await _viewRenderer.RenderPartialAsync("_NavMenu", cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,251 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.Authorization;
|
||||
using Lumina.Presentation.Web.Common.DTO.Themes;
|
||||
using Lumina.Presentation.Web.Common.Enums.Authorization;
|
||||
using Lumina.Presentation.Web.Common.Routes;
|
||||
using Lumina.Presentation.Web.Common.Services;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Claims;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Builds the navigation menu model for the themed navigation template, resolving the authorization conditions and localized labels server side.
|
||||
/// </summary>
|
||||
public sealed class ThemeNavBuilder
|
||||
{
|
||||
// the resource base name deliberately excludes the "Core.Resources" segment: the localization factory re-roots it with the configured ResourcesPath
|
||||
private const string VIEW_RESOURCE_BASE_NAME = "Lumina.Presentation.Web.Views.Shared._NavMenu";
|
||||
private const string VIEW_RESOURCE_LOCATION = "Lumina.Presentation.Web";
|
||||
|
||||
private readonly IUrlService _urlService;
|
||||
private readonly IStringLocalizerFactory _stringLocalizerFactory;
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IStringLocalizer _localizer;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ThemeNavBuilder"/> class.
|
||||
/// </summary>
|
||||
/// <param name="urlService">Injected service for generating URLs from action and controller names, with localization.</param>
|
||||
/// <param name="stringLocalizerFactory">Injected factory used to create the localizer of the navigation resources.</param>
|
||||
/// <param name="authorizationService">Injected service used to resolve the roles and permissions of the current user.</param>
|
||||
/// <param name="httpContextAccessor">Injected accessor for the current HTTP context.</param>
|
||||
public ThemeNavBuilder(IUrlService urlService, IStringLocalizerFactory stringLocalizerFactory, IAuthorizationService authorizationService, IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_urlService = urlService;
|
||||
_stringLocalizerFactory = stringLocalizerFactory;
|
||||
_authorizationService = authorizationService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_localizer = stringLocalizerFactory.Create(VIEW_RESOURCE_BASE_NAME, VIEW_RESOURCE_LOCATION);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds the navigation menu model for the current user and request.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>The navigation menu model, with the sections visible to the current user.</returns>
|
||||
public async Task<ThemeNavMenuDto> BuildAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
ClaimsPrincipal user = _httpContextAccessor.HttpContext?.User ?? new ClaimsPrincipal();
|
||||
bool isAuthenticated = user.Identity?.IsAuthenticated == true;
|
||||
bool isAdmin = isAuthenticated && await _authorizationService.IsInRoleAsync("Admin", cancellationToken).ConfigureAwait(false);
|
||||
bool canCreateLibraries = isAuthenticated && (isAdmin || await _authorizationService.HasPermissionAsync(AuthorizationPermission.CanCreateLibraries, cancellationToken).ConfigureAwait(false));
|
||||
string returnUrl = Uri.EscapeDataString(GetCurrentRequestUrl());
|
||||
ThemeNavEntryDto[] languages = CreateLanguageEntries(returnUrl);
|
||||
|
||||
List<ThemeNavSectionDto> mobileSections = [];
|
||||
mobileSections.Add(CreateSiteSection());
|
||||
mobileSections.Add(CreateAccountSection(isAuthenticated));
|
||||
if (isAdmin)
|
||||
mobileSections.Add(CreateAdministratorSection());
|
||||
if (isAuthenticated)
|
||||
mobileSections.Add(CreateLibrarySection(canCreateLibraries));
|
||||
mobileSections.Add(new ThemeNavSectionDto(Localize("Language"), languages));
|
||||
if (isAuthenticated)
|
||||
mobileSections.Add(CreateToolsSection(isAuthenticated, languages: []));
|
||||
mobileSections.Add(CreateHelpSection());
|
||||
|
||||
List<ThemeNavSectionDto> menubarSections = [];
|
||||
menubarSections.Add(CreateSiteSection());
|
||||
menubarSections.Add(CreateAccountSection(isAuthenticated));
|
||||
if (isAdmin)
|
||||
menubarSections.Add(CreateAdministratorSection());
|
||||
if (isAuthenticated)
|
||||
menubarSections.Add(CreateLibrarySection(canCreateLibraries));
|
||||
menubarSections.Add(CreateToolsSection(isAuthenticated, languages));
|
||||
menubarSections.Add(CreateHelpSection());
|
||||
|
||||
return new ThemeNavMenuDto("Lumina", mobileSections, menubarSections);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the site section, which links to the home page.
|
||||
/// </summary>
|
||||
/// <returns>The site section of the navigation menu.</returns>
|
||||
private ThemeNavSectionDto CreateSiteSection()
|
||||
{
|
||||
return new ThemeNavSectionDto(
|
||||
"Lumina",
|
||||
[new ThemeNavEntryDto(Localize("Home"), _urlService.GetAbsoluteUrl(WebRoutes.Home.INDEX_CULTURED), "nav-link", [])]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the account section, whose entries depend on the authentication state of the user.
|
||||
/// </summary>
|
||||
/// <param name="isAuthenticated">Whether the current user is authenticated.</param>
|
||||
/// <returns>The account section of the navigation menu.</returns>
|
||||
private ThemeNavSectionDto CreateAccountSection(bool isAuthenticated)
|
||||
{
|
||||
List<ThemeNavEntryDto> items = [];
|
||||
if (isAuthenticated)
|
||||
{
|
||||
items.Add(new ThemeNavEntryDto(Localize("Logout"), _urlService.GetAbsoluteUrl(WebRoutes.Authentication.LOGOUT), CssClass: null, Children: []));
|
||||
items.Add(new ThemeNavEntryDto(Localize("Register"), _urlService.GetAbsoluteUrl(WebRoutes.Authentication.REGISTER_VIEW), "nav-link", []));
|
||||
items.Add(new ThemeNavEntryDto(Localize("ChangePassword"), _urlService.GetAbsoluteUrl(WebRoutes.Authentication.CHANGE_PASSWORD_VIEW), "nav-link", []));
|
||||
items.Add(new ThemeNavEntryDto(Localize("Profile"), _urlService.GetAbsoluteUrl(WebRoutes.Authentication.PROFILE_VIEW), "nav-link", []));
|
||||
}
|
||||
else
|
||||
{
|
||||
items.Add(new ThemeNavEntryDto(Localize("Login"), _urlService.GetAbsoluteUrl(WebRoutes.Authentication.LOGIN_VIEW), CssClass: null, Children: []));
|
||||
items.Add(new ThemeNavEntryDto(Localize("RecoverPassword"), _urlService.GetAbsoluteUrl(WebRoutes.Authentication.RECOVER_PASSWORD_VIEW), CssClass: null, Children: []));
|
||||
}
|
||||
|
||||
return new ThemeNavSectionDto(Localize("Account"), items);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the administrator section, shown only to administrators.
|
||||
/// </summary>
|
||||
/// <returns>The administrator section of the navigation menu.</returns>
|
||||
private ThemeNavSectionDto CreateAdministratorSection()
|
||||
{
|
||||
return new ThemeNavSectionDto(
|
||||
Localize("Administrator"),
|
||||
[
|
||||
new ThemeNavEntryDto(Localize("ManageRoles"), _urlService.GetAbsoluteUrl(WebRoutes.Admin.MANAGE_ROLES), "nav-link", []),
|
||||
new ThemeNavEntryDto(Localize("ManagePermissions"), _urlService.GetAbsoluteUrl(WebRoutes.Admin.MANAGE_PERMISSIONS), "nav-link", []),
|
||||
new ThemeNavEntryDto(Localize("Plugins"), _urlService.GetAbsoluteUrl(WebRoutes.Plugins.INDEX), "nav-link", [])
|
||||
]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the library section, shown only to authenticated users.
|
||||
/// </summary>
|
||||
/// <param name="canCreateLibraries">Whether the current user can create media libraries.</param>
|
||||
/// <returns>The library section of the navigation menu.</returns>
|
||||
private ThemeNavSectionDto CreateLibrarySection(bool canCreateLibraries)
|
||||
{
|
||||
List<ThemeNavEntryDto> items =
|
||||
[
|
||||
new ThemeNavEntryDto(Localize("ManageLibraries"), _urlService.GetAbsoluteUrl(WebRoutes.LibraryManagement.INDEX), "nav-link", [])
|
||||
];
|
||||
if (canCreateLibraries)
|
||||
items.Add(new ThemeNavEntryDto(Localize("AddNewLibrary"), _urlService.GetAbsoluteUrl(WebRoutes.LibraryManagement.ADD_LIBRARY), "nav-link", []));
|
||||
items.Add(new ThemeNavEntryDto(Localize("WrittenContent"), Url: null, CssClass: null,
|
||||
[
|
||||
new ThemeNavEntryDto(Localize("Books"), "library/written-content-library/books-library/books", "nav-link", []),
|
||||
new ThemeNavEntryDto(Localize("Magazines"), "library/written-content/magazines", "nav-link", [])
|
||||
]));
|
||||
items.Add(new ThemeNavEntryDto(Localize("Audio"), Url: null, CssClass: null,
|
||||
[
|
||||
new ThemeNavEntryDto(Localize("Music"), "library/audio/music", "nav-link", []),
|
||||
new ThemeNavEntryDto(Localize("Interviews"), "library/audio/interviews", "nav-link", [])
|
||||
]));
|
||||
items.Add(new ThemeNavEntryDto(Localize("Video"), Url: null, CssClass: null,
|
||||
[
|
||||
new ThemeNavEntryDto(Localize("Movies"), "library/video/movies", "nav-link", []),
|
||||
new ThemeNavEntryDto(Localize("TvShows"), "library/video/tvshows", "nav-link", [])
|
||||
]));
|
||||
|
||||
return new ThemeNavSectionDto(Localize("Library"), items);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the tools section, with the language submenu and the settings entry.
|
||||
/// </summary>
|
||||
/// <param name="isAuthenticated">Whether the current user is authenticated.</param>
|
||||
/// <param name="languages">The language entries of the submenu.</param>
|
||||
/// <returns>The tools section of the navigation menu.</returns>
|
||||
private ThemeNavSectionDto CreateToolsSection(bool isAuthenticated, IReadOnlyList<ThemeNavEntryDto> languages)
|
||||
{
|
||||
List<ThemeNavEntryDto> items = [];
|
||||
if (languages.Count > 0)
|
||||
items.Add(new ThemeNavEntryDto(Localize("Language"), Url: null, CssClass: null, Children: languages));
|
||||
if (isAuthenticated)
|
||||
items.Add(new ThemeNavEntryDto(Localize("Settings"), _urlService.GetAbsoluteUrl(WebRoutes.Settings.INDEX), "nav-link", []));
|
||||
|
||||
return new ThemeNavSectionDto(Localize("Tools"), items);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the help section.
|
||||
/// </summary>
|
||||
/// <returns>The help section of the navigation menu.</returns>
|
||||
private ThemeNavSectionDto CreateHelpSection()
|
||||
{
|
||||
return new ThemeNavSectionDto(
|
||||
Localize("Help"),
|
||||
[
|
||||
new ThemeNavEntryDto(Localize("Documentation"), "help/documentation", "nav-link", []),
|
||||
new ThemeNavEntryDto(Localize("About"), "help/about", "nav-link", [])
|
||||
]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the language entries of the navigation menu, each keeping the current request URL as the return URL.
|
||||
/// </summary>
|
||||
/// <param name="returnUrl">The encoded current request URL used as the return URL.</param>
|
||||
/// <returns>The language entries of the navigation menu.</returns>
|
||||
private ThemeNavEntryDto[] CreateLanguageEntries(string returnUrl)
|
||||
{
|
||||
string baseUrl = _urlService.GetAbsoluteUrl(WebRoutes.Language.SET_LANGUAGE) ?? string.Empty;
|
||||
(string Culture, string DisplayName)[] cultures =
|
||||
[
|
||||
("zh-cn", "简体中文"),
|
||||
("de-de", "Deutsch"),
|
||||
("en-us", "English"),
|
||||
("es-es", "Español"),
|
||||
("fr-fr", "Français"),
|
||||
("it-it", "Italiano"),
|
||||
("ja-jp", "日本語"),
|
||||
("ro-ro", "Română"),
|
||||
("ru-ru", "Русский")
|
||||
];
|
||||
|
||||
ThemeNavEntryDto[] entries = new ThemeNavEntryDto[cultures.Length];
|
||||
for (int index = 0; index < cultures.Length; index++)
|
||||
{
|
||||
(string culture, string displayName) = cultures[index];
|
||||
entries[index] = new ThemeNavEntryDto(displayName, $"{baseUrl}?newCulture={culture}&returnUrl={returnUrl}", "lang-set", []);
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path and query string of the current request.
|
||||
/// </summary>
|
||||
/// <returns>The path and query string of the current request.</returns>
|
||||
private string GetCurrentRequestUrl()
|
||||
{
|
||||
HttpRequest request = _httpContextAccessor.HttpContext?.Request ?? throw new InvalidOperationException("The current HTTP context is unavailable.");
|
||||
return $"{request.Path}{request.QueryString}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves a localized navigation label.
|
||||
/// </summary>
|
||||
/// <param name="key">The resource key of the label.</param>
|
||||
/// <returns>The localized label.</returns>
|
||||
private string Localize(string key)
|
||||
{
|
||||
return _localizer[key].Value;
|
||||
}
|
||||
}
|
||||
@@ -259,7 +259,7 @@
|
||||
<div class="action-icons">
|
||||
<img src="/images/ui/stop.svg" alt="@_localizer["CancelScan"]" title="@_localizer["CancelScan"]" class="hidden action-icon" />
|
||||
<img src="/images/ui/trigger.svg" alt="@_localizer["Scan"]" title="@_localizer["Scan"]" class="action-icon" />
|
||||
<a href="${editUrl}">
|
||||
<a href="${editUrl}" class="nav-link">
|
||||
<img src="/images/ui/edit.svg" alt="@_localizer["Edit"]" title="@_localizer["Edit"]" class="action-icon" />
|
||||
</a>
|
||||
<img src="/images/ui/delete.svg" alt="@_localizer["Remove"]" title="@_localizer["Remove"]" class="mr-5 action-icon" />
|
||||
@@ -269,6 +269,7 @@
|
||||
</tr>
|
||||
`;
|
||||
}).join('');
|
||||
bindNavigationLinks(); // bind the dynamically created edit links, so that editing keeps the persistent chrome running
|
||||
} else {
|
||||
btnScanAllLibraries.style.display = 'none';
|
||||
table.style.display = 'none';
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
@using Microsoft.Extensions.Localization
|
||||
|
||||
@inject IStringLocalizerFactory _stringLocalizerFactory
|
||||
|
||||
@{
|
||||
IStringLocalizer localizer = _stringLocalizerFactory.Create("Lumina.Presentation.Web.Views.Shared._Layout", "Lumina.Presentation.Web");
|
||||
}
|
||||
|
||||
<div class="audio-player-container">
|
||||
<video controls
|
||||
preload="auto"
|
||||
height="50" width="600">
|
||||
<source src="https://samplelib.com/lib/preview/mp4/sample-5s.mp4" type="video/mp4">
|
||||
</video>
|
||||
<a id="audio-player-full-height-toggle">@localizer["ToggleFullHeight"]</a>
|
||||
<a id="audio-player-close">@localizer["ToggleVisibility"]</a>
|
||||
</div>
|
||||
@@ -1,89 +1,71 @@
|
||||
@using Lumina.Presentation.Web.Common.DTO.Configuration
|
||||
@using Microsoft.AspNetCore.Mvc.Localization
|
||||
@using Microsoft.Extensions.Options
|
||||
@using Lumina.Presentation.Web.Common.DTO.Themes
|
||||
@using Lumina.Presentation.Web.Common.Primitives
|
||||
@using Lumina.Presentation.Web.Core.Themes
|
||||
@using Microsoft.AspNetCore.Html
|
||||
@using System.IO
|
||||
@using System.Text.Encodings.Web
|
||||
|
||||
@inject IViewLocalizer _localizer
|
||||
@inject IOptions<ServerConfigurationDto> _serverConfigurationModel
|
||||
@inject ThemeLayoutRenderer _themeLayoutRenderer
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"] - Lumina</title>
|
||||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/css/button.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/css/checkbox.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/css/combobox.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/css/file-system-browser.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/css/file-system-tree-view-node.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/css/navigation-menu.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/css/notification.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/css/dialog.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/css/textbox.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/Lumina.Presentation.Web.styles.css" asp-append-version="true" />
|
||||
@await RenderSectionAsync("Head", required: false) <!--needed for themes templates css files-->
|
||||
</head>
|
||||
<body>
|
||||
<div id="page">
|
||||
<header>
|
||||
@await Html.PartialAsync("_NavMenu")
|
||||
</header>
|
||||
<main role="main" style="@(User?.Identity?.IsAuthenticated == false ? "bottom: 0px;" : string.Empty)">
|
||||
<article class="h-100"> <!--needs to be 100% height so that child pages that require full height as well, can stretch-->
|
||||
@RenderBody()
|
||||
<div id="modal-background-article"></div>
|
||||
<div class="dialog-container"></div>
|
||||
</article>
|
||||
</main>
|
||||
@if (User?.Identity?.IsAuthenticated == true)
|
||||
{
|
||||
<!--Audio player-->
|
||||
<div class="audio-player-container">
|
||||
<video controls
|
||||
preload="auto"
|
||||
height="50" width="600">
|
||||
<source src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" type="video/mp4">
|
||||
</video>
|
||||
<a id="audio-player-full-height-toggle">@_localizer["ToggleFullHeight"]</a>
|
||||
<a id="audio-player-close">@_localizer["ToggleVisibility"]</a>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<!--Modal grid background-->
|
||||
<div id="modal-background-menu"></div>
|
||||
@{
|
||||
string bodyHtml;
|
||||
using (StringWriter bodyWriter = new())
|
||||
{
|
||||
IHtmlContent bodyContent = RenderBody();
|
||||
bodyContent.WriteTo(bodyWriter, HtmlEncoder.Default);
|
||||
bodyHtml = bodyWriter.ToString();
|
||||
}
|
||||
|
||||
<script>
|
||||
var globalConfiguration = {
|
||||
serverBasePath: '@(_serverConfigurationModel.Value.BaseAddress):@(_serverConfigurationModel.Value.Port)',
|
||||
apiBasePath: '@(_serverConfigurationModel.Value.BaseAddress):@(_serverConfigurationModel.Value.Port)/api/v@(_serverConfigurationModel.Value.ApiVersion)',
|
||||
};
|
||||
var jsLocalizedMessages = {
|
||||
navigationFailed: '@_localizer["NavigationFailed"]',
|
||||
};
|
||||
var jsLocalizedDialogs = {
|
||||
// button texts
|
||||
ok: '@_localizer["Ok"]',
|
||||
cancel: '@_localizer["Cancel"]',
|
||||
yes: '@_localizer["Yes"]',
|
||||
no: '@_localizer["No"]',
|
||||
retry: '@_localizer["Retry"]',
|
||||
abort: '@_localizer["Abort"]',
|
||||
ignore: '@_localizer["Ignore"]',
|
||||
// default titles
|
||||
confirmation: '@_localizer["Confirmation"]',
|
||||
warning: '@_localizer["Warning"]',
|
||||
error: '@_localizer["Error"]',
|
||||
information: '@_localizer["Information"]'
|
||||
};
|
||||
string scriptsHtml;
|
||||
using (StringWriter scriptsWriter = new())
|
||||
{
|
||||
TextWriter originalWriter = ViewContext.Writer;
|
||||
ViewContext.Writer = scriptsWriter;
|
||||
await RenderSectionAsync("Scripts", required: false);
|
||||
ViewContext.Writer = originalWriter;
|
||||
scriptsHtml = scriptsWriter.ToString();
|
||||
}
|
||||
|
||||
</script>
|
||||
<script src="~/libs/microsoft-signalr/signalr.min.js" asp-append-version="true"></script>
|
||||
<script defer src="~/js/notifications.js" asp-append-version="true"></script>
|
||||
<script defer src="~/js/dialogs.js" asp-append-version="true"></script>
|
||||
<script defer src="~/js/site.js" asp-append-version="true"></script>
|
||||
<div data-section="scripts">
|
||||
@await RenderSectionAsync("Scripts", required: false)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
string title = ViewData["Title"]?.ToString() ?? string.Empty;
|
||||
Result<string> themedResult = await _themeLayoutRenderer.RenderAsync(new ThemeLayoutPageDto(title, bodyHtml, scriptsHtml), cancellationToken: ViewContext.HttpContext.RequestAborted);
|
||||
}
|
||||
|
||||
@if (themedResult.IsSuccess)
|
||||
{
|
||||
@Html.Raw(themedResult.Value)
|
||||
}
|
||||
else
|
||||
{
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"] - Lumina</title>
|
||||
@await Html.PartialAsync("_ThemeLayoutHead")
|
||||
</head>
|
||||
<body>
|
||||
<div id="page">
|
||||
<header>
|
||||
@await Html.PartialAsync("_NavMenu")
|
||||
</header>
|
||||
<main role="main" style="@(User?.Identity?.IsAuthenticated == false ? "bottom: 0px;" : string.Empty)">
|
||||
<article class="h-100">
|
||||
@Html.Raw(bodyHtml)
|
||||
<div id="modal-background-article"></div>
|
||||
<div class="dialog-container"></div>
|
||||
</article>
|
||||
</main>
|
||||
@if (User?.Identity?.IsAuthenticated == true)
|
||||
{
|
||||
@await Html.PartialAsync("_AudioPlayer")
|
||||
}
|
||||
</div>
|
||||
<div id="modal-background-menu"></div>
|
||||
@await Html.PartialAsync("_ThemeLayoutScripts")
|
||||
<div data-section="scripts">
|
||||
@Html.Raw(scriptsHtml)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
}
|
||||
@@ -19,7 +19,7 @@
|
||||
Lumina
|
||||
</div>
|
||||
<ul>
|
||||
<li><a href="@_urlService.GetAbsoluteUrl(WebRoutes.Home.INDEX_CULTURED)"><span>@_localizer["Home"]</span></a></li>
|
||||
<li><a href="@_urlService.GetAbsoluteUrl(WebRoutes.Home.INDEX_CULTURED)" class="nav-link"><span>@_localizer["Home"]</span></a></li>
|
||||
</ul>
|
||||
<div class="mobile-menu-heading">
|
||||
@_localizer["Account"]
|
||||
@@ -124,7 +124,7 @@
|
||||
<li tabindex="0" class="top-level-menuitem">
|
||||
<label for="account-menu">Lumina</label>
|
||||
<ul>
|
||||
<li><a href="@_urlService.GetAbsoluteUrl(WebRoutes.Home.INDEX_CULTURED)">@_localizer["Home"]</a></li>
|
||||
<li><a href="@_urlService.GetAbsoluteUrl(WebRoutes.Home.INDEX_CULTURED)" class="nav-link">@_localizer["Home"]</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li tabindex="0" class="top-level-menuitem">
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/css/button.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/css/checkbox.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/css/combobox.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/css/file-system-browser.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/css/file-system-tree-view-node.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/css/navigation-menu.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/css/notification.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/css/dialog.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/css/textbox.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/Lumina.Presentation.Web.styles.css" asp-append-version="true" />
|
||||
@@ -0,0 +1,37 @@
|
||||
@using Lumina.Presentation.Web.Common.DTO.Configuration
|
||||
@using Microsoft.Extensions.Localization
|
||||
@using Microsoft.Extensions.Options
|
||||
|
||||
@inject IStringLocalizerFactory _stringLocalizerFactory
|
||||
@inject IOptions<ServerConfigurationDto> _serverConfigurationModel
|
||||
|
||||
@{
|
||||
IStringLocalizer localizer = _stringLocalizerFactory.Create("Lumina.Presentation.Web.Views.Shared._Layout", "Lumina.Presentation.Web");
|
||||
}
|
||||
|
||||
<script>
|
||||
var globalConfiguration = {
|
||||
serverBasePath: '@(_serverConfigurationModel.Value.BaseAddress):@(_serverConfigurationModel.Value.Port)',
|
||||
apiBasePath: '@(_serverConfigurationModel.Value.BaseAddress):@(_serverConfigurationModel.Value.Port)/api/v@(_serverConfigurationModel.Value.ApiVersion)',
|
||||
};
|
||||
var jsLocalizedMessages = {
|
||||
navigationFailed: '@localizer["NavigationFailed"]',
|
||||
};
|
||||
var jsLocalizedDialogs = {
|
||||
ok: '@localizer["Ok"]',
|
||||
cancel: '@localizer["Cancel"]',
|
||||
yes: '@localizer["Yes"]',
|
||||
no: '@localizer["No"]',
|
||||
retry: '@localizer["Retry"]',
|
||||
abort: '@localizer["Abort"]',
|
||||
ignore: '@localizer["Ignore"]',
|
||||
confirmation: '@localizer["Confirmation"]',
|
||||
warning: '@localizer["Warning"]',
|
||||
error: '@localizer["Error"]',
|
||||
information: '@localizer["Information"]'
|
||||
};
|
||||
</script>
|
||||
<script src="~/libs/microsoft-signalr/signalr.min.js" asp-append-version="true"></script>
|
||||
<script defer src="~/js/notifications.js" asp-append-version="true"></script>
|
||||
<script defer src="~/js/dialogs.js" asp-append-version="true"></script>
|
||||
<script defer src="~/js/site.js" asp-append-version="true"></script>
|
||||
@@ -1,12 +1,5 @@
|
||||
@model Lumina.Presentation.Web.Common.DTO.Themes.ThemeViewDto
|
||||
|
||||
@section Head {
|
||||
@if (!string.IsNullOrEmpty(Model.AssetBase))
|
||||
{
|
||||
<link rel="stylesheet" href="@Model.AssetBase/theme.css" />
|
||||
}
|
||||
}
|
||||
|
||||
@Html.Raw(Model.Content)
|
||||
|
||||
@section Scripts {
|
||||
|
||||
Reference in new issue
Block a user