2020-11-21 13:26:03 +00:00
|
|
|
using MediaBrowser.Common.Configuration;
|
2020-06-22 13:37:29 +00:00
|
|
|
using MediaBrowser.Controller.Configuration;
|
|
|
|
using MediaBrowser.Model.Branding;
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
2023-01-31 11:18:10 +00:00
|
|
|
namespace Jellyfin.Api.Controllers;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Branding controller.
|
|
|
|
/// </summary>
|
|
|
|
public class BrandingController : BaseJellyfinApiController
|
2020-06-22 13:37:29 +00:00
|
|
|
{
|
2023-01-31 11:18:10 +00:00
|
|
|
private readonly IServerConfigurationManager _serverConfigurationManager;
|
|
|
|
|
2020-06-22 13:37:29 +00:00
|
|
|
/// <summary>
|
2023-01-31 11:18:10 +00:00
|
|
|
/// Initializes a new instance of the <see cref="BrandingController"/> class.
|
2020-06-22 13:37:29 +00:00
|
|
|
/// </summary>
|
2023-01-31 11:18:10 +00:00
|
|
|
/// <param name="serverConfigurationManager">Instance of the <see cref="IServerConfigurationManager"/> interface.</param>
|
|
|
|
public BrandingController(IServerConfigurationManager serverConfigurationManager)
|
2020-06-22 13:37:29 +00:00
|
|
|
{
|
2023-01-31 11:18:10 +00:00
|
|
|
_serverConfigurationManager = serverConfigurationManager;
|
|
|
|
}
|
2020-06-22 13:37:29 +00:00
|
|
|
|
2023-01-31 11:18:10 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Gets branding configuration.
|
|
|
|
/// </summary>
|
|
|
|
/// <response code="200">Branding configuration returned.</response>
|
|
|
|
/// <returns>An <see cref="OkResult"/> containing the branding configuration.</returns>
|
|
|
|
[HttpGet("Configuration")]
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
public ActionResult<BrandingOptions> GetBrandingOptions()
|
|
|
|
{
|
|
|
|
return _serverConfigurationManager.GetConfiguration<BrandingOptions>("branding");
|
|
|
|
}
|
2020-06-22 13:37:29 +00:00
|
|
|
|
2023-01-31 11:18:10 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Gets branding css.
|
|
|
|
/// </summary>
|
|
|
|
/// <response code="200">Branding css returned.</response>
|
|
|
|
/// <response code="204">No branding css configured.</response>
|
|
|
|
/// <returns>
|
|
|
|
/// An <see cref="OkResult"/> containing the branding css if exist,
|
|
|
|
/// or a <see cref="NoContentResult"/> if the css is not configured.
|
|
|
|
/// </returns>
|
|
|
|
[HttpGet("Css")]
|
|
|
|
[HttpGet("Css.css", Name = "GetBrandingCss_2")]
|
|
|
|
[Produces("text/css")]
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
|
|
public ActionResult<string> GetBrandingCss()
|
|
|
|
{
|
|
|
|
var options = _serverConfigurationManager.GetConfiguration<BrandingOptions>("branding");
|
|
|
|
return options.CustomCss ?? string.Empty;
|
2020-06-22 13:37:29 +00:00
|
|
|
}
|
|
|
|
}
|