The Free Software Media System - Server Backend & API
Merge remote-tracking branch 'upstream/master' into support-running-without-web-content
Mark Monteiroe2685c51ec19
diff --cc MediaBrowser.WebDashboard/Api/DashboardService.csindex 0114f5d602,99d8d044f3..3e47ce6829--- a/MediaBrowser.WebDashboard/Api/DashboardService.cs+++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs@@@ -96,63 -101,46 +103,61 @@@ namespace MediaBrowser.WebDashboard.Ap/// </summary>/// <value>The HTTP result factory.</value>private readonly IHttpResultFactory _resultFactory;-- /// <summary>- /// Gets or sets the request context.- /// </summary>- /// <value>The request context.</value>- public IRequest Request { get; set; }-- /// <summary>- /// The _app host- /// </summary>private readonly IServerApplicationHost _appHost;-- /// <summary>- /// The _server configuration manager- /// </summary>++ private readonly IConfiguration _appConfig;private readonly IServerConfigurationManager _serverConfigurationManager;-private readonly IFileSystem _fileSystem;- private IResourceFileManager _resourceFileManager;- private readonly IConfiguration _appConfig;+ private readonly IResourceFileManager _resourceFileManager;/// <summary>/// Initializes a new instance of the <see cref="DashboardService" /> class./// </summary>+ /// <param name="logger">The logger.</param>+ /// <param name="appHost">The application host.</param>++ /// <param name="appConfig">The application configuration.</param>+ /// <param name="resourceFileManager">The resource file manager.</param>+ /// <param name="serverConfigurationManager">The server configuration manager.</param>+ /// <param name="fileSystem">The file system.</param>+ /// <param name="resultFactory">The result factory.</param>public DashboardService(+ ILogger<DashboardService> logger,IServerApplicationHost appHost,++ IConfiguration appConfig,IResourceFileManager resourceFileManager,IServerConfigurationManager serverConfigurationManager,IFileSystem fileSystem,- ILogger<DashboardService> logger,- IHttpResultFactory resultFactory,- IConfiguration appConfig)+ IHttpResultFactory resultFactory){+ _logger = logger;_appHost = appHost;++ _appConfig = appConfig;+ _resourceFileManager = resourceFileManager;_serverConfigurationManager = serverConfigurationManager;_fileSystem = fileSystem;- _logger = logger;_resultFactory = resultFactory;- _resourceFileManager = resourceFileManager;- _appConfig = appConfig;++ // Validate web content path+ string webContentPath = DashboardUIPath;+ bool webContentPathValid = appConfig.NoWebContent() || (Directory.Exists(webContentPath) && Directory.GetFiles(webContentPath).Any());+ if (!webContentPathValid)+ {+ throw new InvalidOperationException(+ "The server is expected to host web content, but the provided content directory is either " ++ $"invalid or empty: {webContentPath}. If you do not want to host web content with the server, " ++ $"you may set the '{Controller.Extensions.ConfigurationExtensions.NoWebContentKey}' flag.");+ }}+ /// <summary>+ /// Gets or sets the request context.+ /// </summary>+ /// <value>The request context.</value>+ public IRequest Request { get; set; }+/// <summary>- /// Gets the path for the web interface.+ /// Gets the path of the directory containing the static web interface content, or null if the server is not+ /// hosting the static web content./// </summary>- /// <value>The path for the web interface.</value>public string DashboardUIPath{getdiff --cc MediaBrowser.WebDashboard/Api/PackageCreator.csindex e8eb0389f9,ad996c5a9b..b7c15a840e--- a/MediaBrowser.WebDashboard/Api/PackageCreator.cs+++ b/MediaBrowser.WebDashboard/Api/PackageCreator.cs@@@ -45,15 -47,9 +48,20 @@@ namespace MediaBrowser.WebDashboard.Apreturn string.Equals(Path.GetExtension(path), ".html", StringComparison.OrdinalIgnoreCase);}- // Modifies the HTML by adding common meta tags, css and js.- public async Task<Stream> ModifyHtml(- string path,+ /// <summary>+ /// Modifies the source HTML stream by adding common meta tags, css and js.+ /// </summary>++ /// <param name="isMainIndexPage">True if the stream contains content for the main index page.</param>++ /// <param name="sourceStream">The stream whose content should be modified.</param>++ /// <param name="mode">The client mode ('cordova', 'android', etc).</param>++ /// <param name="appVersion">The application version.</param>++ /// <param name="localizationCulture">The localization culture.</param>+ /// <returns>+ /// A task that represents the async operation to read and modify the input stream.+ /// The task result contains a stream containing the modified HTML content.+ /// </returns>+ public static async Task<Stream> ModifyHtml(+ bool isMainIndexPage,Stream sourceStream,string mode,string appVersion,