diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-04-06 14:30:36 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-04-06 14:30:36 -0400 |
| commit | 5e5302a7962bc91f7d4a0db7388927fbcfa18453 (patch) | |
| tree | f30ccee63d9c1b2d53e80337c1fc45e4664d590b | |
| parent | bdcb329b1df625dc0fa8f20e73887f3610700569 (diff) | |
Added DashboardSourcePath config setting for easier development
| -rw-r--r-- | MediaBrowser.Model/Configuration/ServerConfiguration.cs | 9 | ||||
| -rw-r--r-- | MediaBrowser.WebDashboard/Api/DashboardService.cs | 39 |
2 files changed, 39 insertions, 9 deletions
diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index d125047f5..f4e1d84ac 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -268,7 +268,14 @@ namespace MediaBrowser.Model.Configuration /// <value><c>true</c> if [enable dashboard response caching]; otherwise, <c>false</c>.</value> [ProtoMember(61)] public bool EnableDashboardResponseCaching { get; set; } - + + /// <summary> + /// Allows the dashboard to be served from a custom path. + /// </summary> + /// <value>The dashboard source path.</value> + [ProtoMember(62)] + public string DashboardSourcePath { get; set; } + // Next Proto number ====> 62 /// <summary> diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs index 5a8e7a6ff..7c3de72fe 100644 --- a/MediaBrowser.WebDashboard/Api/DashboardService.cs +++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs @@ -141,6 +141,35 @@ namespace MediaBrowser.WebDashboard.Api } /// <summary> + /// Gets the dashboard UI path. + /// </summary> + /// <value>The dashboard UI path.</value> + public string DashboardUIPath + { + get + { + if (!string.IsNullOrEmpty(_serverConfigurationManager.Configuration.DashboardSourcePath)) + { + return _serverConfigurationManager.Configuration.DashboardSourcePath; + } + + var runningDirectory = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); + + return Path.Combine(runningDirectory, "dashboard-ui"); + } + } + + /// <summary> + /// Gets the dashboard resource path. + /// </summary> + /// <param name="virtualPath">The virtual path.</param> + /// <returns>System.String.</returns> + private string GetDashboardResourcePath(string virtualPath) + { + return Path.Combine(DashboardUIPath, virtualPath.Replace('/', '\\')); + } + + /// <summary> /// Gets the specified request. /// </summary> /// <param name="request">The request.</param> @@ -290,11 +319,7 @@ namespace MediaBrowser.WebDashboard.Api /// <returns>Task{Stream}.</returns> private Stream GetRawResourceStream(string path) { - var runningDirectory = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); - - path = Path.Combine(runningDirectory, "dashboard-ui", path.Replace('/', '\\')); - - return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, StreamDefaults.DefaultFileStreamBufferSize, true); + return new FileStream(GetDashboardResourcePath(path), FileMode.Open, FileAccess.Read, FileShare.ReadWrite, StreamDefaults.DefaultFileStreamBufferSize, true); // This code is used when the files are embedded resources //return GetType().Assembly.GetManifestResourceStream("MediaBrowser.WebDashboard.Html." + ConvertUrlToResourcePath(path)); @@ -564,9 +589,7 @@ namespace MediaBrowser.WebDashboard.Api /// <returns>Task.</returns> private async Task AppendResource(Stream outputStream, string path, byte[] newLineBytes) { - var runningDirectory = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); - - path = Path.Combine(runningDirectory, "dashboard-ui", path.Replace('/', '\\')); + path = GetDashboardResourcePath(path); using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, StreamDefaults.DefaultFileStreamBufferSize, true)) { |
