TLC Admin Portal
This commit is contained in:
@@ -281,12 +281,33 @@
|
||||
<script>
|
||||
const cdnBase = '@Model.CdnBaseUrl';
|
||||
let tw = @Model.Tile.Width, th = @Model.Tile.Height;
|
||||
let sheet = null;
|
||||
let currentSheetId = null; // Currently selected sheet for painting
|
||||
let selected = null;
|
||||
let templateData = {}; // { "x,y": { sheetId, frameIndex, tileDefId } }
|
||||
let primarySet = false;
|
||||
|
||||
// All loaded sheets (by ID) for rendering tiles from any sheet
|
||||
const loadedSheets = {};
|
||||
|
||||
// Pre-load all sheet data from the dropdown
|
||||
function preloadSheets() {
|
||||
document.querySelectorAll('#sheetSelect option').forEach(opt => {
|
||||
if (opt.value) {
|
||||
loadedSheets[+opt.value] = {
|
||||
id: +opt.value,
|
||||
cdn: opt.dataset.cdn,
|
||||
cols: +opt.dataset.cols,
|
||||
tw: +opt.dataset.tw,
|
||||
th: +opt.dataset.th,
|
||||
sw: +opt.dataset.sw,
|
||||
sh: +opt.dataset.sh
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
preloadSheets();
|
||||
loadExisting();
|
||||
buildTemplateGrid();
|
||||
});
|
||||
@@ -305,9 +326,21 @@ function loadExisting() {
|
||||
|
||||
function buildTemplateGrid() {
|
||||
const grid = document.getElementById('templateGrid');
|
||||
// Use sheet tile dimensions if available, fallback to 32px
|
||||
const cellW = sheet?.tw || 32;
|
||||
const cellH = sheet?.th || 32;
|
||||
|
||||
// Use current sheet dimensions, or try to get from existing tile data, or fallback to 32px
|
||||
let cellW = 32, cellH = 32;
|
||||
if (currentSheetId && loadedSheets[currentSheetId]) {
|
||||
cellW = loadedSheets[currentSheetId].tw;
|
||||
cellH = loadedSheets[currentSheetId].th;
|
||||
} else {
|
||||
// Try to get dimensions from existing template data
|
||||
const firstTile = Object.values(templateData)[0];
|
||||
if (firstTile && loadedSheets[firstTile.sheetId]) {
|
||||
cellW = loadedSheets[firstTile.sheetId].tw;
|
||||
cellH = loadedSheets[firstTile.sheetId].th;
|
||||
}
|
||||
}
|
||||
|
||||
grid.style.gridTemplateColumns = `repeat(${tw}, ${cellW}px)`;
|
||||
grid.innerHTML = '';
|
||||
|
||||
@@ -331,7 +364,8 @@ function renderCell(x, y) {
|
||||
if (!cell) return;
|
||||
|
||||
const data = templateData[`${x},${y}`];
|
||||
if (data && sheet && data.sheetId == sheet.id) {
|
||||
if (data && data.sheetId && loadedSheets[data.sheetId]) {
|
||||
const sheet = loadedSheets[data.sheetId];
|
||||
const col = data.frameIndex % sheet.cols;
|
||||
const row = Math.floor(data.frameIndex / sheet.cols);
|
||||
cell.style.background = `url('${cdnBase}/${sheet.cdn}') ${-col * sheet.tw}px ${-row * sheet.th}px no-repeat`;
|
||||
@@ -362,23 +396,21 @@ function paintCell(x, y) {
|
||||
function loadSheet() {
|
||||
const opt = document.getElementById('sheetSelect').selectedOptions[0];
|
||||
if (!opt?.value) {
|
||||
sheet = null;
|
||||
currentSheetId = null;
|
||||
document.getElementById('palette').innerHTML = '<div class="text-gray-500 text-xs p-2">Select a sprite sheet</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
sheet = {
|
||||
id: +opt.value,
|
||||
cdn: opt.dataset.cdn,
|
||||
cols: +opt.dataset.cols,
|
||||
tw: +opt.dataset.tw,
|
||||
th: +opt.dataset.th,
|
||||
sw: +opt.dataset.sw,
|
||||
sh: +opt.dataset.sh
|
||||
};
|
||||
currentSheetId = +opt.value;
|
||||
const sheet = loadedSheets[currentSheetId];
|
||||
|
||||
// Rebuild template grid with correct tile dimensions
|
||||
buildTemplateGrid();
|
||||
// Don't rebuild template grid - just re-render to keep existing tiles visible
|
||||
// Only rebuild if dimensions might need to change
|
||||
for (let y = 0; y < th; y++) {
|
||||
for (let x = 0; x < tw; x++) {
|
||||
renderCell(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
const total = sheet.cols * Math.ceil(sheet.sh / sheet.th);
|
||||
let html = '';
|
||||
@@ -397,7 +429,8 @@ function selectTile(frameIndex) {
|
||||
document.querySelectorAll('.palette-tile').forEach(t => t.classList.remove('active'));
|
||||
document.querySelector(`.palette-tile[data-frame="${frameIndex}"]`)?.classList.add('active');
|
||||
|
||||
selected = { sheetId: sheet.id, frameIndex };
|
||||
const sheet = loadedSheets[currentSheetId];
|
||||
selected = { sheetId: currentSheetId, frameIndex };
|
||||
|
||||
document.getElementById('selectedInfo').textContent = `Frame ${frameIndex}`;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-6">
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold text-white">Tile Templates</h1>
|
||||
<p class="text-gray-400 text-sm mt-1">Reusable floor, wall, and door patterns</p>
|
||||
<p class="text-gray-400 text-sm mt-1">Reusable floor, wall, and door patterns (@Model.TotalCount total)</p>
|
||||
</div>
|
||||
<a href="/admin/dungeonbuilder/tiles/edit" class="btn btn-primary">+ New Template</a>
|
||||
</div>
|
||||
@@ -30,7 +30,7 @@
|
||||
<form method="get" class="flex flex-wrap gap-3">
|
||||
<div class="flex-1 min-w-[150px]">
|
||||
<input type="text" name="search" value="@Model.Search"
|
||||
class="input w-full text-sm" placeholder="Search by name..." />
|
||||
class="input w-full text-sm" placeholder="Search by name or tags..." />
|
||||
</div>
|
||||
<select name="category" class="input text-sm">
|
||||
<option value="">All Categories</option>
|
||||
@@ -46,6 +46,13 @@
|
||||
<option value="@b" selected="@(Model.BiomeFilter == b)">@b</option>
|
||||
}
|
||||
</select>
|
||||
<select name="sheetId" class="input text-sm">
|
||||
<option value="">All Sheets</option>
|
||||
@foreach (var s in Model.TileSheets)
|
||||
{
|
||||
<option value="@s.Id" selected="@(Model.SheetFilter == s.Id)">@s.Name</option>
|
||||
}
|
||||
</select>
|
||||
<button type="submit" class="btn btn-secondary text-sm">Filter</button>
|
||||
<a href="/admin/dungeonbuilder/tiles" class="btn btn-ghost text-sm">Clear</a>
|
||||
</form>
|
||||
@@ -55,23 +62,16 @@
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">
|
||||
@foreach (var tile in Model.Tiles)
|
||||
{
|
||||
var tileInfo = Model.GetTileDisplayInfo(tile);
|
||||
<div class="card p-4 hover:border-blue-500/50 transition-colors">
|
||||
<div class="flex items-start gap-3">
|
||||
<!-- Preview -->
|
||||
<div class="w-16 h-16 bg-gray-900 rounded flex items-center justify-center flex-shrink-0">
|
||||
@if (tile.PrimaryTileDefinition?.TileMapSheet != null)
|
||||
<!-- Preview - Using TilesJson data -->
|
||||
<div class="w-16 h-16 bg-gray-900 rounded flex items-center justify-center flex-shrink-0" style="image-rendering: pixelated;">
|
||||
@if (tileInfo != null)
|
||||
{
|
||||
var sheet = tile.PrimaryTileDefinition.TileMapSheet;
|
||||
var cols = sheet.TileWidth > 0 ? sheet.SheetWidth / sheet.TileWidth : 1;
|
||||
var row = tile.PrimaryTileDefinition.FrameIndex / cols;
|
||||
var col = tile.PrimaryTileDefinition.FrameIndex % cols;
|
||||
var bgX = -col * sheet.TileWidth;
|
||||
var bgY = -row * sheet.TileHeight;
|
||||
var imgUrl = Model.GetCdnUrl(sheet.CdnPath);
|
||||
|
||||
<div style="width: @(sheet.TileWidth)px; height: @(sheet.TileHeight)px;
|
||||
background: url('@imgUrl') @(bgX)px @(bgY)px no-repeat;
|
||||
background-size: @(sheet.SheetWidth)px @(sheet.SheetHeight)px;
|
||||
<div style="width: @(tileInfo.TileWidth * 2)px; height: @(tileInfo.TileHeight * 2)px;
|
||||
background: url('@tileInfo.ImageUrl') @(tileInfo.BgX * 2)px @(tileInfo.BgY * 2)px no-repeat;
|
||||
background-size: @(tileInfo.SheetWidth * 2)px @(tileInfo.SheetHeight * 2)px;
|
||||
image-rendering: pixelated;"></div>
|
||||
}
|
||||
else
|
||||
@@ -91,6 +91,12 @@
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- Tags -->
|
||||
@if (!string.IsNullOrEmpty(tile.Tags))
|
||||
{
|
||||
<div class="text-xs text-gray-500 mt-1 truncate">@tile.Tags</div>
|
||||
}
|
||||
|
||||
<!-- Size & Flags -->
|
||||
<div class="flex flex-wrap gap-1 mt-2">
|
||||
@if (tile.Width > 1 || tile.Height > 1)
|
||||
@@ -130,6 +136,31 @@
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- Pagination -->
|
||||
@if (Model.TotalPages > 1)
|
||||
{
|
||||
<div class="flex items-center justify-center gap-2 mt-6">
|
||||
@if (Model.Page > 1)
|
||||
{
|
||||
<a href="@Model.GetPageUrl(1)" class="btn btn-ghost text-sm">First</a>
|
||||
<a href="@Model.GetPageUrl(Model.Page - 1)" class="btn btn-ghost text-sm">← Prev</a>
|
||||
}
|
||||
|
||||
@for (int i = Math.Max(1, Model.Page - 2); i <= Math.Min(Model.TotalPages, Model.Page + 2); i++)
|
||||
{
|
||||
<a href="@Model.GetPageUrl(i)" class="btn @(i == Model.Page ? "btn-primary" : "btn-ghost") text-sm">@i</a>
|
||||
}
|
||||
|
||||
@if (Model.Page < Model.TotalPages)
|
||||
{
|
||||
<a href="@Model.GetPageUrl(Model.Page + 1)" class="btn btn-ghost text-sm">Next →</a>
|
||||
<a href="@Model.GetPageUrl(Model.TotalPages)" class="btn btn-ghost text-sm">Last</a>
|
||||
}
|
||||
|
||||
<span class="text-gray-500 text-sm ml-4">Page @Model.Page of @Model.TotalPages</span>
|
||||
</div>
|
||||
}
|
||||
|
||||
@functions {
|
||||
string GetCategoryColor(TileTemplateCategory category)
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@ using DataServer.Data;
|
||||
using DataServer.Data.Entities;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Server.Services.Admin.Pages.DungeonBuilder;
|
||||
|
||||
@@ -18,19 +19,40 @@ public class TilesModel : AdminPageModel
|
||||
|
||||
public List<TileTemplate> Tiles { get; set; } = new();
|
||||
public List<string> Biomes { get; set; } = new();
|
||||
public List<TileMapSheet> TileSheets { get; set; } = new();
|
||||
|
||||
// Pagination
|
||||
public int Page { get; set; } = 1;
|
||||
public int PageSize { get; set; } = 24;
|
||||
public int TotalCount { get; set; }
|
||||
public int TotalPages => (int)Math.Ceiling((double)TotalCount / PageSize);
|
||||
|
||||
// Filters
|
||||
public string? Search { get; set; }
|
||||
public int? CategoryFilter { get; set; }
|
||||
public string? BiomeFilter { get; set; }
|
||||
public int? SheetFilter { get; set; }
|
||||
|
||||
public string? Message { get; set; }
|
||||
public bool IsError { get; set; }
|
||||
|
||||
// Cache for sheet lookups
|
||||
private Dictionary<int, TileMapSheet> _sheetCache = new();
|
||||
|
||||
public async Task OnGetAsync(string? search, int? category, string? biome)
|
||||
public async Task OnGetAsync(string? search, int? category, string? biome, int? sheetId, int page = 1)
|
||||
{
|
||||
Search = search;
|
||||
CategoryFilter = category;
|
||||
BiomeFilter = biome;
|
||||
SheetFilter = sheetId;
|
||||
Page = Math.Max(1, page);
|
||||
|
||||
// Load tile sheets for filter dropdown and display
|
||||
TileSheets = await _db.TileMapSheets
|
||||
.Where(s => s.IsEnabled)
|
||||
.OrderBy(s => s.Name)
|
||||
.ToListAsync();
|
||||
_sheetCache = TileSheets.ToDictionary(s => s.Id);
|
||||
|
||||
// Get unique biomes
|
||||
Biomes = await _db.TileTemplates
|
||||
@@ -41,10 +63,7 @@ public class TilesModel : AdminPageModel
|
||||
.ToListAsync();
|
||||
|
||||
// Build query
|
||||
var query = _db.TileTemplates
|
||||
.Include(t => t.PrimaryTileDefinition)
|
||||
.ThenInclude(td => td!.TileMapSheet)
|
||||
.AsQueryable();
|
||||
var query = _db.TileTemplates.AsQueryable();
|
||||
|
||||
if (!string.IsNullOrEmpty(search))
|
||||
{
|
||||
@@ -61,9 +80,24 @@ public class TilesModel : AdminPageModel
|
||||
query = query.Where(t => t.Biome == biome);
|
||||
}
|
||||
|
||||
if (sheetId.HasValue)
|
||||
{
|
||||
// Filter by sheet - tiles that use this sheet in TilesJson
|
||||
var sheetIdStr = $"\"sheetId\":{sheetId.Value}";
|
||||
var sheetIdStr2 = $"\"sheetId\": {sheetId.Value}";
|
||||
query = query.Where(t => t.TilesJson != null &&
|
||||
(t.TilesJson.Contains(sheetIdStr) || t.TilesJson.Contains(sheetIdStr2)));
|
||||
}
|
||||
|
||||
// Get total count for pagination
|
||||
TotalCount = await query.CountAsync();
|
||||
|
||||
// Get page of results
|
||||
Tiles = await query
|
||||
.OrderBy(t => t.Category)
|
||||
.ThenBy(t => t.Name)
|
||||
.Skip((Page - 1) * PageSize)
|
||||
.Take(PageSize)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
@@ -92,4 +126,71 @@ public class TilesModel : AdminPageModel
|
||||
|
||||
return $"{baseUrl}/{path.TrimStart('/')}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get display info for a tile template by parsing its TilesJson
|
||||
/// </summary>
|
||||
public TileDisplayInfo? GetTileDisplayInfo(TileTemplate tile)
|
||||
{
|
||||
if (string.IsNullOrEmpty(tile.TilesJson)) return null;
|
||||
|
||||
try
|
||||
{
|
||||
var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true };
|
||||
var tiles = JsonSerializer.Deserialize<List<TilePlacement>>(tile.TilesJson, options);
|
||||
var first = tiles?.FirstOrDefault();
|
||||
|
||||
if (first == null || !_sheetCache.TryGetValue(first.SheetId, out var sheet))
|
||||
return null;
|
||||
|
||||
var cols = sheet.Columns > 0 ? sheet.Columns : (sheet.TileWidth > 0 ? sheet.SheetWidth / sheet.TileWidth : 1);
|
||||
var col = first.FrameIndex % cols;
|
||||
var row = first.FrameIndex / cols;
|
||||
|
||||
return new TileDisplayInfo
|
||||
{
|
||||
ImageUrl = GetCdnUrl(sheet.CdnPath),
|
||||
TileWidth = sheet.TileWidth,
|
||||
TileHeight = sheet.TileHeight,
|
||||
SheetWidth = sheet.SheetWidth,
|
||||
SheetHeight = sheet.SheetHeight,
|
||||
BgX = -col * sheet.TileWidth,
|
||||
BgY = -row * sheet.TileHeight
|
||||
};
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Build URL for pagination with current filters preserved
|
||||
/// </summary>
|
||||
public string GetPageUrl(int page)
|
||||
{
|
||||
var query = new List<string> { $"page={page}" };
|
||||
if (!string.IsNullOrEmpty(Search)) query.Add($"search={Uri.EscapeDataString(Search)}");
|
||||
if (CategoryFilter.HasValue) query.Add($"category={CategoryFilter}");
|
||||
if (!string.IsNullOrEmpty(BiomeFilter)) query.Add($"biome={Uri.EscapeDataString(BiomeFilter)}");
|
||||
if (SheetFilter.HasValue) query.Add($"sheetId={SheetFilter}");
|
||||
return $"/admin/dungeonbuilder/tiles?{string.Join("&", query)}";
|
||||
}
|
||||
|
||||
private class TilePlacement
|
||||
{
|
||||
public int SheetId { get; set; }
|
||||
public int FrameIndex { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
public class TileDisplayInfo
|
||||
{
|
||||
public string ImageUrl { get; set; } = "";
|
||||
public int TileWidth { get; set; }
|
||||
public int TileHeight { get; set; }
|
||||
public int SheetWidth { get; set; }
|
||||
public int SheetHeight { get; set; }
|
||||
public int BgX { get; set; }
|
||||
public int BgY { get; set; }
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 class="text-3xl font-bold text-white">Sprite Sheets</h1>
|
||||
<p class="text-gray-400 mt-1">Manage sprite sheets and animations for mobs</p>
|
||||
<p class="text-gray-400 mt-1">Manage sprite sheets and animations for mobs (@Model.TotalCount total)</p>
|
||||
</div>
|
||||
<a href="/admin/spritesheets/edit" class="btn btn-primary">+ New Sprite Sheet</a>
|
||||
</div>
|
||||
@@ -26,6 +26,23 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Search/Filter -->
|
||||
<div class="card p-4">
|
||||
<form method="get" class="flex flex-wrap gap-3">
|
||||
<div class="flex-1 min-w-[200px]">
|
||||
<input type="text" name="search" value="@Model.Search"
|
||||
class="input w-full text-sm" placeholder="Search by name or path..." />
|
||||
</div>
|
||||
<select name="enabled" class="input text-sm">
|
||||
<option value="">All Status</option>
|
||||
<option value="true" selected="@(Model.EnabledFilter == true)">Enabled Only</option>
|
||||
<option value="false" selected="@(Model.EnabledFilter == false)">Disabled Only</option>
|
||||
</select>
|
||||
<button type="submit" class="btn btn-secondary text-sm">Search</button>
|
||||
<a href="/admin/spritesheets" class="btn btn-ghost text-sm">Clear</a>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
@foreach (var sheet in Model.SpriteSheets)
|
||||
{
|
||||
@@ -33,7 +50,7 @@
|
||||
<div class="flex items-start justify-between mb-3">
|
||||
<div>
|
||||
<h3 class="text-lg font-semibold text-white">@sheet.Name</h3>
|
||||
<p class="text-sm text-gray-400 font-mono">@sheet.CdnPath</p>
|
||||
<p class="text-sm text-gray-400 font-mono truncate max-w-[200px]" title="@sheet.CdnPath">@sheet.CdnPath</p>
|
||||
</div>
|
||||
@if (sheet.IsEnabled)
|
||||
{
|
||||
@@ -45,6 +62,17 @@
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- Preview -->
|
||||
@if (!string.IsNullOrEmpty(sheet.CdnPath))
|
||||
{
|
||||
<div class="mb-3 bg-gray-900 rounded p-2 flex justify-center overflow-hidden" style="max-height: 80px;">
|
||||
<img src="@Model.GetCdnUrl(sheet.CdnPath)"
|
||||
alt="@sheet.Name"
|
||||
style="max-height: 76px; image-rendering: pixelated;"
|
||||
onerror="this.style.display='none'" />
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="grid grid-cols-2 gap-2 text-sm mb-3">
|
||||
<div class="text-gray-400">Sheet Size:</div>
|
||||
<div class="text-white">@sheet.SheetWidth x @sheet.SheetHeight</div>
|
||||
@@ -71,7 +99,15 @@
|
||||
@if (Model.SpriteSheets.Count == 0)
|
||||
{
|
||||
<div class="card p-8 text-center text-gray-400">
|
||||
No sprite sheets found. <a href="/admin/spritesheets/edit" class="text-indigo-400 hover:underline">Create one</a>
|
||||
@if (!string.IsNullOrEmpty(Model.Search))
|
||||
{
|
||||
<span>No sprite sheets found matching "@Model.Search". </span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>No sprite sheets found. </span>
|
||||
}
|
||||
<a href="/admin/spritesheets/edit" class="text-indigo-400 hover:underline">Create one</a>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -8,18 +8,43 @@ namespace Server.Services.Admin.Pages.SpriteSheets;
|
||||
public class IndexModel : AdminPageModel
|
||||
{
|
||||
private readonly GameDbContext _db;
|
||||
private readonly IConfiguration _config;
|
||||
|
||||
public IndexModel(GameDbContext db)
|
||||
public IndexModel(GameDbContext db, IConfiguration config)
|
||||
{
|
||||
_db = db;
|
||||
_config = config;
|
||||
}
|
||||
|
||||
public List<MobSpriteSheet> SpriteSheets { get; set; } = new();
|
||||
public string? Search { get; set; }
|
||||
public bool? EnabledFilter { get; set; }
|
||||
public int TotalCount { get; set; }
|
||||
|
||||
public async Task OnGetAsync()
|
||||
public async Task OnGetAsync(string? search, bool? enabled)
|
||||
{
|
||||
SpriteSheets = await _db.MobSpriteSheets
|
||||
Search = search;
|
||||
EnabledFilter = enabled;
|
||||
|
||||
var query = _db.MobSpriteSheets
|
||||
.Include(s => s.Animations)
|
||||
.AsQueryable();
|
||||
|
||||
if (!string.IsNullOrEmpty(search))
|
||||
{
|
||||
query = query.Where(s =>
|
||||
s.Name.Contains(search) ||
|
||||
(s.CdnPath != null && s.CdnPath.Contains(search)));
|
||||
}
|
||||
|
||||
if (enabled.HasValue)
|
||||
{
|
||||
query = query.Where(s => s.IsEnabled == enabled.Value);
|
||||
}
|
||||
|
||||
TotalCount = await query.CountAsync();
|
||||
|
||||
SpriteSheets = await query
|
||||
.OrderBy(s => s.Name)
|
||||
.ToListAsync();
|
||||
}
|
||||
@@ -51,4 +76,17 @@ public class IndexModel : AdminPageModel
|
||||
}
|
||||
return RedirectToPage();
|
||||
}
|
||||
|
||||
public string GetCdnUrl(string? path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path)) return "";
|
||||
|
||||
var baseUrl = _config["Cdn:BaseUrl"]?.TrimEnd('/') ?? "https://assets.aeternalisgames.com";
|
||||
if (!baseUrl.EndsWith("/downloads", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
baseUrl += "/downloads";
|
||||
}
|
||||
|
||||
return $"{baseUrl}/{path.TrimStart('/')}";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user