Added DashboardSourcePath config setting for easier development
This commit is contained in:
parent
bdcb329b1d
commit
5e5302a796
|
@ -269,6 +269,13 @@ namespace MediaBrowser.Model.Configuration
|
|||
[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>
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user