This commit is contained in:
CodeDevMLH
2025-12-15 11:27:06 +01:00
parent c867c892de
commit d88c967023
15 changed files with 215 additions and 130 deletions

View File

@@ -6,10 +6,17 @@ using Microsoft.AspNetCore.Mvc;
namespace Jellyfin.Plugin.Seasonals.Api;
/// <summary>
/// Controller for serving seasonal resources and configuration.
/// </summary>
[ApiController]
[Route("Seasonals")]
public class SeasonalsController : ControllerBase
{
/// <summary>
/// Gets the current plugin configuration.
/// </summary>
/// <returns>The configuration object.</returns>
[HttpGet("Config")]
[Produces("application/json")]
public ActionResult<object> GetConfig()
@@ -22,11 +29,16 @@ public class SeasonalsController : ControllerBase
};
}
/// <summary>
/// Serves embedded resources.
/// </summary>
/// <param name="path">The path to the resource.</param>
/// <returns>The resource file.</returns>
[HttpGet("Resources/{*path}")]
public ActionResult GetResource(string path)
{
// Sanitize path
if (string.IsNullOrWhiteSpace(path) || path.Contains(".."))
if (string.IsNullOrWhiteSpace(path) || path.Contains("..", StringComparison.Ordinal))
{
return BadRequest();
}
@@ -47,7 +59,7 @@ public class SeasonalsController : ControllerBase
return File(stream, contentType);
}
private string GetContentType(string path)
private static string GetContentType(string path)
{
if (path.EndsWith(".js", StringComparison.OrdinalIgnoreCase)) return "application/javascript";
if (path.EndsWith(".css", StringComparison.OrdinalIgnoreCase)) return "text/css";