Renders themed pages as swappable sections with path-mirrored template scopes and a Razor fallback

This commit is contained in:
BinaryAlley committed 2026-08-20 06:50:17 -07:00
1 parent f17e685239
commit e37bb3ecc6
24 files changed
+351 -187

No files matched your search

@@ -1,28 +0,0 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Themes;
/// <summary>
/// Data transfer object for a content entry rendered by a theme.
/// </summary>
/// <param name="Number">The ordering number of the content entry.</param>
/// <param name="Title">The title of the content entry.</param>
/// <param name="Description">The description of the content entry.</param>
/// <param name="Meta">The metadata line of the content entry.</param>
/// <param name="Badge">The badge text of the content entry.</param>
/// <param name="Accent">The accent color of the content entry.</param>
/// <param name="Glyph">The glyph or icon of the content entry.</param>
/// <param name="Url">The URL the content entry links to.</param>
[DebuggerDisplay("Number: {Number}, Title: {Title}")]
public sealed record ContentItemDto(
string Number,
string Title,
string Description,
string Meta,
string Badge,
string Accent,
string Glyph,
string Url
);
@@ -1,20 +0,0 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Themes;
/// <summary>
/// Data transfer object for a navigation entry rendered by a theme.
/// </summary>
/// <param name="Key">The unique key of the navigation entry.</param>
/// <param name="Label">The display label of the navigation entry.</param>
/// <param name="Url">The URL the navigation entry links to.</param>
/// <param name="IsCurrent">Whether the navigation entry represents the currently displayed page.</param>
[DebuggerDisplay("Key: {Key}, Label: {Label}")]
public sealed record NavigationItemDto(
string Key,
string Label,
string Url,
bool IsCurrent
);
@@ -1,18 +0,0 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Themes;
/// <summary>
/// Data transfer object for a statistic rendered by a theme.
/// </summary>
/// <param name="Value">The numeric or textual value of the statistic.</param>
/// <param name="Label">The label of the statistic.</param>
/// <param name="Detail">The additional detail of the statistic.</param>
[DebuggerDisplay("Value: {Value}, Label: {Label}")]
public sealed record StatItemDto(
string Value,
string Label,
string Detail
);
@@ -6,7 +6,7 @@ using System.Diagnostics;
namespace Lumina.Presentation.Web.Common.DTO.Themes;
/// <summary>
/// Data transfer object for the full model available to a theme template while rendering a page.
/// Data transfer object for the model available to a theme template while rendering a page.
/// </summary>
[DebuggerDisplay("Title: {Title}")]
public sealed class ThemePageDto
@@ -16,11 +16,6 @@ public sealed class ThemePageDto
/// </summary>
public required string PageKey { get; init; }
/// <summary>
/// Gets or sets the name of the site displayed by the theme.
/// </summary>
public required string SiteName { get; init; }
/// <summary>
/// Gets or sets the title of the page.
/// </summary>
@@ -32,72 +27,23 @@ public sealed class ThemePageDto
public required string Description { get; init; }
/// <summary>
/// Gets or sets the eyebrow text shown above the page title.
/// Gets or sets the resolved values exposed to the theme template and its scripts. Each page populates the entries its
/// template needs, such as resolved URLs, identifiers and server paths, and the localized strings of the page under the <c>strings</c> key.
/// </summary>
public required string Eyebrow { get; init; }
public required IReadOnlyDictionary<string, object?> PageData { get; init; } = new Dictionary<string, object?>();
/// <summary>
/// Gets or sets the label of the primary call to action.
/// Gets or sets the identifier of the script section of the page. Populated immediately before rendering.
/// </summary>
public required string PrimaryActionLabel { get; init; }
/// <summary>
/// Gets or sets the URL of the primary call to action.
/// </summary>
public required string PrimaryActionUrl { get; init; }
/// <summary>
/// Gets or sets the label of the secondary call to action.
/// </summary>
public required string SecondaryActionLabel { get; init; }
/// <summary>
/// Gets or sets the URL of the secondary call to action.
/// </summary>
public required string SecondaryActionUrl { get; init; }
/// <summary>
/// Gets or sets the navigation entries rendered by the theme.
/// </summary>
public required IReadOnlyList<NavigationItemDto> Navigation { get; init; }
/// <summary>
/// Gets or sets the content entries rendered by the theme.
/// </summary>
public required IReadOnlyList<ContentItemDto> Items { get; init; }
/// <summary>
/// Gets or sets the statistics rendered by the theme.
/// </summary>
public required IReadOnlyList<StatItemDto> Stats { get; init; }
/// <summary>
/// Gets or sets a value indicating whether the page is a theme preview.
/// </summary>
public bool IsPreview { get; init; }
public string ScriptId { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the identifier of the theme rendering the page. Populated immediately before rendering.
/// </summary>
public string ThemeId { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the name of the theme rendering the page. Populated immediately before rendering.
/// </summary>
public string ThemeName { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the version of the theme rendering the page. Populated immediately before rendering.
/// </summary>
public string ThemeVersion { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the base URL of the theme assets. Populated immediately before rendering.
/// </summary>
public string AssetBase { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the current year. Populated immediately before rendering.
/// </summary>
public int CurrentYear { get; set; }
}
@@ -0,0 +1,16 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Themes;
/// <summary>
/// Data transfer object for the rendered content and script of a themed page section.
/// </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>
[DebuggerDisplay("Content length: {Content.Length}, Script length: {Script.Length}")]
public sealed record ThemePageRenderResultDto(
string Content,
string Script
);
@@ -0,0 +1,18 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Themes;
/// <summary>
/// Data transfer object for the rendered sections of a themed page, served through the shared themed view.
/// </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
);
@@ -15,7 +15,7 @@ public static partial class ApiRoutes
public const string GET_THEME_SETTINGS = "themes/settings";
public const string GET_CURRENT_THEME = "themes/current";
public const string SET_CURRENT_THEME = "themes/current";
public const string GET_THEME_TEMPLATE = "themes/{themeId}/templates/{pageKey}";
public const string GET_THEME_TEMPLATE = "themes/{themeId}/templates/{*pageKey}";
public const string GET_THEME_ASSET = "themes/{themeId}/assets/{*assetPath}";
public const string GET_THEME_ARCHIVE = "themes/{themeId}/archive";
public const string DELETE_THEME = "themes/{themeId}";