aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Api/Controllers/BrandingController.cs
blob: d3ea41201515bcbf8d436c2668648d42dc53380c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Model.Branding;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Jellyfin.Api.Controllers
{
    /// <summary>
    /// Branding controller.
    /// </summary>
    public class BrandingController : BaseJellyfinApiController
    {
        private readonly IServerConfigurationManager _serverConfigurationManager;

        /// <summary>
        /// Initializes a new instance of the <see cref="BrandingController"/> class.
        /// </summary>
        /// <param name="serverConfigurationManager">Instance of the <see cref="IServerConfigurationManager"/> interface.</param>
        public BrandingController(IServerConfigurationManager serverConfigurationManager)
        {
            _serverConfigurationManager = serverConfigurationManager;
        }

        /// <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");
        }

        /// <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;
        }
    }
}