Ver Fonte

Added DashboardSourcePath config setting for easier development

Luke Pulverenti há 12 anos atrás
pai
commit
5e5302a796

+ 8 - 1
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>

+ 31 - 8
MediaBrowser.WebDashboard/Api/DashboardService.cs

@@ -140,6 +140,35 @@ namespace MediaBrowser.WebDashboard.Api
             _serverConfigurationManager = serverConfigurationManager;
         }
 
+        /// <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>
@@ -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))
             {