BrandingController.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using MediaBrowser.Common.Configuration;
  2. using MediaBrowser.Controller.Configuration;
  3. using MediaBrowser.Model.Branding;
  4. using Microsoft.AspNetCore.Http;
  5. using Microsoft.AspNetCore.Mvc;
  6. namespace Jellyfin.Api.Controllers;
  7. /// <summary>
  8. /// Branding controller.
  9. /// </summary>
  10. public class BrandingController : BaseJellyfinApiController
  11. {
  12. private readonly IServerConfigurationManager _serverConfigurationManager;
  13. /// <summary>
  14. /// Initializes a new instance of the <see cref="BrandingController"/> class.
  15. /// </summary>
  16. /// <param name="serverConfigurationManager">Instance of the <see cref="IServerConfigurationManager"/> interface.</param>
  17. public BrandingController(IServerConfigurationManager serverConfigurationManager)
  18. {
  19. _serverConfigurationManager = serverConfigurationManager;
  20. }
  21. /// <summary>
  22. /// Gets branding configuration.
  23. /// </summary>
  24. /// <response code="200">Branding configuration returned.</response>
  25. /// <returns>An <see cref="OkResult"/> containing the branding configuration.</returns>
  26. [HttpGet("Configuration")]
  27. [ProducesResponseType(StatusCodes.Status200OK)]
  28. public ActionResult<BrandingOptions> GetBrandingOptions()
  29. {
  30. return _serverConfigurationManager.GetConfiguration<BrandingOptions>("branding");
  31. }
  32. /// <summary>
  33. /// Gets branding css.
  34. /// </summary>
  35. /// <response code="200">Branding css returned.</response>
  36. /// <response code="204">No branding css configured.</response>
  37. /// <returns>
  38. /// An <see cref="OkResult"/> containing the branding css if exist,
  39. /// or a <see cref="NoContentResult"/> if the css is not configured.
  40. /// </returns>
  41. [HttpGet("Css")]
  42. [HttpGet("Css.css", Name = "GetBrandingCss_2")]
  43. [Produces("text/css")]
  44. [ProducesResponseType(StatusCodes.Status200OK)]
  45. [ProducesResponseType(StatusCodes.Status204NoContent)]
  46. public ActionResult<string> GetBrandingCss()
  47. {
  48. var options = _serverConfigurationManager.GetConfiguration<BrandingOptions>("branding");
  49. return options.CustomCss ?? string.Empty;
  50. }
  51. }