Adds comments.

This commit is contained in:
BinaryAlley committed 2026-08-20 23:38:50 -07:00
1 parent 4ef8570854
commit fd64cbd6ba
13 files changed
+17

No files matched your search

@@ -51,6 +51,7 @@ public class ThemeAssetsEndpoint : BaseEndpoint<GetThemeAssetRequest, IResult>
if (string.IsNullOrWhiteSpace(request.ThemeId) || string.IsNullOrWhiteSpace(request.Path))
return Results.Problem(statusCode: StatusCodes.Status400BadRequest, detail: "The theme id and the asset path are required.");
// the API route token is a catch-all ("{*assetPath}"), so the replace target must include the star to match it
BlobDataDto blob = await _apiHttpClient.GetBlobAsync(
ApiRoutes.Themes.GET_THEME_ASSET.Replace("{themeId}", request.ThemeId).Replace("{*assetPath}", request.Path), cancellationToken).ConfigureAwait(false);
return Results.File(blob.Data, blob.ContentType);
@@ -49,6 +49,7 @@ public sealed class RazorViewToStringRenderer
/// <returns>The rendered HTML of the partial.</returns>
public async Task<string> RenderPartialAsync(string partialName, CancellationToken cancellationToken = default)
{
// the theme shell reuses the application's Razor chrome as strings, so the same markup stays in one place
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
@@ -60,6 +60,8 @@ public sealed class ThemeNavBuilder
string returnUrl = Uri.EscapeDataString(GetCurrentRequestUrl());
ThemeNavEntryDto[] languages = CreateLanguageEntries(returnUrl);
// the mobile and desktop menus arrange the same sections differently, notably the language switcher, which is
// its own mobile heading but a submenu under Tools on the desktop, so each menu gets its own section list
List<ThemeNavSectionDto> mobileSections = [];
mobileSections.Add(CreateSiteSection());
mobileSections.Add(CreateAccountSection(isAuthenticated));
@@ -17,6 +17,7 @@ public static class ThemePageDataFactory
/// <returns>The localized strings keyed by their resource names.</returns>
public static Dictionary<string, object?> CreateLocalizedStrings(IStringLocalizer localizer)
{
// expose the page's full resource set, so templates can pull any localized string without the page enumerating keys
Dictionary<string, object?> strings = [];
foreach (LocalizedString localizedString in localizer.GetAllStrings(includeParentCultures: true))
strings[localizedString.Name] = localizedString.Value;
@@ -40,6 +40,7 @@ public class ThemePageRenderer
model.ThemeId = document.Theme.Id;
model.AssetBase = $"/theme-assets/{document.Theme.Id}/assets";
// a fresh script id per render lets the AJAX navigator unload this view's script when navigating away
model.ScriptId = ScriptIdentifierHelper.GenerateScriptId();
return _templateEngine.RenderPage(document.Template, model);
@@ -18,6 +18,7 @@ namespace Lumina.Presentation.Web.Core.Themes;
/// </summary>
public sealed class ThemeTemplateEngine
{
// bound template nesting and rendered output, so a single theme cannot exhaust the server memory
private const int MAX_NESTING_DEPTH = 32;
private const int MAX_RENDERED_CHARACTERS = 4 * 1024 * 1024;
@@ -8,6 +8,7 @@
@inject ThemeLayoutRenderer _themeLayoutRenderer
@{
// capture the page body and its scripts, so the themed shell can wrap them instead of rendering them directly
string bodyHtml;
using (StringWriter bodyWriter = new())
{
@@ -19,6 +20,7 @@
string scriptsHtml;
using (StringWriter scriptsWriter = new())
{
// RenderSectionAsync writes to ViewContext.Writer, so swap it to capture the section content
TextWriter originalWriter = ViewContext.Writer;
ViewContext.Writer = scriptsWriter;
await RenderSectionAsync("Scripts", required: false);