BrandingController.cs 2.2 KB

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