Make portal and proxy settings configurable

This commit is contained in:
2026-08-27 09:29:22 +08:00
parent 6b5e9a991c
commit 70da7ffda6
6 changed files with 277 additions and 140 deletions
+9 -3
View File
@@ -10,6 +10,7 @@ internal static class WebPortal
private const string TemplateFileName = "index.template.html";
private const string OutputFileName = "index.html";
private const string ServiceCardsToken = "{{NGINXMAN_SERVICE_CARDS}}";
private const string TemplateVersionMarker = "<!-- NGINXMAN_TEMPLATE_VERSION:2 -->";
private static readonly UTF8Encoding Utf8WithoutBom = new(false);
public static void ExtractTo(string dataDirectory)
@@ -37,9 +38,14 @@ internal static class WebPortal
throw new InvalidOperationException("Invalid embedded web resource path.");
}
// Keep the extracted template editable. Future route changes only render
// index.html and never overwrite a customized index.template.html.
if (File.Exists(targetPath))
// Preserve editable templates after the current template format has been
// installed. Older bundled templates without the version marker are
// upgraded once so legacy branding and layout do not remain in data/www.
var isCurrentTemplate = relativePath.Equals(TemplateFileName, StringComparison.OrdinalIgnoreCase) &&
File.Exists(targetPath) &&
File.ReadAllText(targetPath, Encoding.UTF8).Contains(TemplateVersionMarker, StringComparison.Ordinal);
if (File.Exists(targetPath) &&
(!relativePath.Equals(TemplateFileName, StringComparison.OrdinalIgnoreCase) || isCurrentTemplate))
{
continue;
}