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