diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-11-26 15:57:16 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-11-26 15:57:16 -0500 |
| commit | 63a0d52fd115f3a4888acd53f9fd92defa9dc721 (patch) | |
| tree | cc934bda5db40dc773893f9d1f1a4e2304911af8 | |
| parent | 17081767da92369a29d5f324abebbcfabf4e8ab5 (diff) | |
allow separate configuration of app resources path
7 files changed, 25 insertions, 29 deletions
diff --git a/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs b/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs index 2940f921c..4ad63b2e3 100644 --- a/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs +++ b/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs @@ -14,24 +14,12 @@ namespace MediaBrowser.Common.Implementations /// </summary> protected BaseApplicationPaths(string programDataPath, string applicationPath) { - _programDataPath = programDataPath; + ProgramDataPath = programDataPath; ApplicationPath = applicationPath; } public string ApplicationPath { get; private set; } - - /// <summary> - /// The _program data path - /// </summary> - private readonly string _programDataPath; - /// <summary> - /// Gets the path to the program data folder - /// </summary> - /// <value>The program data path.</value> - public string ProgramDataPath - { - get { return _programDataPath; } - } + public string ProgramDataPath { get; private set; } /// <summary> /// Gets the path to the system folder diff --git a/MediaBrowser.Controller/IServerApplicationPaths.cs b/MediaBrowser.Controller/IServerApplicationPaths.cs index 34137088f..e3438c3d2 100644 --- a/MediaBrowser.Controller/IServerApplicationPaths.cs +++ b/MediaBrowser.Controller/IServerApplicationPaths.cs @@ -11,6 +11,13 @@ namespace MediaBrowser.Controller string RootFolderPath { get; } /// <summary> + /// Gets the application resources path. This is the path to the folder containing resources that are deployed as part of the application + /// For example, this folder contains dashboard-ui and swagger-ui + /// </summary> + /// <value>The application resources path.</value> + string ApplicationResourcesPath { get; } + + /// <summary> /// Gets the path to the default user view directory. Used if no specific user view is defined. /// </summary> /// <value>The default user views path.</value> diff --git a/MediaBrowser.Server.Implementations/HttpServer/SwaggerService.cs b/MediaBrowser.Server.Implementations/HttpServer/SwaggerService.cs index 3764697f1..aeaac80e8 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SwaggerService.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SwaggerService.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Common.Configuration; +using MediaBrowser.Controller; using MediaBrowser.Controller.Net; using ServiceStack.Web; using System.IO; @@ -7,9 +7,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer { public class SwaggerService : IHasResultFactory, IRestfulService { - private readonly IApplicationPaths _appPaths; + private readonly IServerApplicationPaths _appPaths; - public SwaggerService(IApplicationPaths appPaths) + public SwaggerService(IServerApplicationPaths appPaths) { _appPaths = appPaths; } @@ -21,9 +21,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// <returns>System.Object.</returns> public object Get(GetSwaggerResource request) { - var runningDirectory = Path.GetDirectoryName(_appPaths.ApplicationPath); - - var swaggerDirectory = Path.Combine(runningDirectory, "swagger-ui"); + var swaggerDirectory = Path.Combine(_appPaths.ApplicationResourcesPath, "swagger-ui"); var requestedFile = Path.Combine(swaggerDirectory, request.ResourceName.Replace('/', Path.DirectorySeparatorChar)); diff --git a/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs b/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs index 68956be18..d9973afe7 100644 --- a/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs +++ b/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs @@ -12,12 +12,14 @@ namespace MediaBrowser.Server.Implementations /// <summary> /// Initializes a new instance of the <see cref="BaseApplicationPaths" /> class. /// </summary> - public ServerApplicationPaths(string programDataPath, string applicationPath) + public ServerApplicationPaths(string programDataPath, string applicationPath, string applicationResourcesPath) : base(programDataPath, applicationPath) { - + ApplicationResourcesPath = applicationResourcesPath; } + public string ApplicationResourcesPath { get; private set; } + /// <summary> /// Gets the path to the base root media directory /// </summary> diff --git a/MediaBrowser.Server.Mono/Program.cs b/MediaBrowser.Server.Mono/Program.cs index 0df213d90..1cd0b5ae6 100644 --- a/MediaBrowser.Server.Mono/Program.cs +++ b/MediaBrowser.Server.Mono/Program.cs @@ -1,3 +1,4 @@ +using System.IO; using MediaBrowser.Common.Implementations.IO; using MediaBrowser.Common.Implementations.Logging; using MediaBrowser.Model.Logging; @@ -58,10 +59,10 @@ namespace MediaBrowser.Server.Mono { if (string.IsNullOrEmpty(programDataPath)) { - return new ServerApplicationPaths(ApplicationPathHelper.GetProgramDataPath(applicationPath), applicationPath); + programDataPath = ApplicationPathHelper.GetProgramDataPath(applicationPath); } - return new ServerApplicationPaths(programDataPath, applicationPath); + return new ServerApplicationPaths(programDataPath, applicationPath, Path.GetDirectoryName(applicationPath)); } private static readonly TaskCompletionSource<bool> ApplicationTaskCompletionSource = new TaskCompletionSource<bool>(); diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs index 36430e642..af0219bda 100644 --- a/MediaBrowser.ServerApplication/MainStartup.cs +++ b/MediaBrowser.ServerApplication/MainStartup.cs @@ -153,16 +153,18 @@ namespace MediaBrowser.ServerApplication /// <returns>ServerApplicationPaths.</returns> private static ServerApplicationPaths CreateApplicationPaths(string applicationPath, bool runAsService) { + var resourcesPath = Path.GetDirectoryName(applicationPath); + if (runAsService) { var systemPath = Path.GetDirectoryName(applicationPath); var programDataPath = Path.GetDirectoryName(systemPath); - return new ServerApplicationPaths(programDataPath, applicationPath); + return new ServerApplicationPaths(programDataPath, applicationPath, resourcesPath); } - return new ServerApplicationPaths(ApplicationPathHelper.GetProgramDataPath(applicationPath), applicationPath); + return new ServerApplicationPaths(ApplicationPathHelper.GetProgramDataPath(applicationPath), applicationPath, resourcesPath); } /// <summary> diff --git a/MediaBrowser.WebDashboard/Api/PackageCreator.cs b/MediaBrowser.WebDashboard/Api/PackageCreator.cs index ff61af0f3..39fcce57d 100644 --- a/MediaBrowser.WebDashboard/Api/PackageCreator.cs +++ b/MediaBrowser.WebDashboard/Api/PackageCreator.cs @@ -87,9 +87,7 @@ namespace MediaBrowser.WebDashboard.Api return _config.Configuration.DashboardSourcePath; } - var runningDirectory = Path.GetDirectoryName(_config.ApplicationPaths.ApplicationPath); - - return Path.Combine(runningDirectory, "dashboard-ui"); + return Path.Combine(_config.ApplicationPaths.ApplicationResourcesPath, "dashboard-ui"); } } |
