The Free Software Media System - Server Backend & API
support dynamic bower path
Luke Pulverenti33dffd2943ec
diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.csindex 957d73c2d3..7122c8fc12 100644--- a/MediaBrowser.Api/Images/ImageService.cs+++ b/MediaBrowser.Api/Images/ImageService.cs@@ -637,7 +637,11 @@ namespace MediaBrowser.Api.ImagesResponseHeaders = headers,ContentType = imageResult.Item2,IsHeadRequest = isHeadRequest,- Path = imageResult.Item1+ Path = imageResult.Item1,++ // Sometimes imagemagick keeps a hold on the file briefly even after it's done writing to it.+ // I'd rather do this than add a delay after saving the file+ FileShare = FileShare.ReadWrite});}diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.csindex c16c635786..ec40fe4b19 100644--- a/MediaBrowser.WebDashboard/Api/DashboardService.cs+++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs@@ -197,6 +197,8 @@ namespace MediaBrowser.WebDashboard.Api{var path = request.ResourceName;+ path = path.Replace("bower_components" + _appHost.ApplicationVersion, "bower_components", StringComparison.OrdinalIgnoreCase);+var contentType = MimeTypes.GetMimeType(path);// Bounce them to the startup wizard if it hasn't been completed yet@@ -263,22 +265,6 @@ namespace MediaBrowser.WebDashboard.Apireturn new PackageCreator(_fileSystem, _localization, Logger, _serverConfigurationManager, _jsonSerializer);}- /// <summary>- /// Determines whether the specified path is HTML.- /// </summary>- /// <param name="path">The path.</param>- /// <returns><c>true</c> if the specified path is HTML; otherwise, <c>false</c>.</returns>- private bool IsHtml(string path)- {- return Path.GetExtension(path).EndsWith("html", StringComparison.OrdinalIgnoreCase);- }-- private void CopyFile(string src, string dst)- {- _fileSystem.CreateDirectory(Path.GetDirectoryName(dst));- _fileSystem.CopyFile(src, dst, true);- }-public async Task<object> Get(GetDashboardPackage request){var path = Path.Combine(_serverConfigurationManager.ApplicationPaths.ProgramDataPath,@@ -307,9 +293,17 @@ namespace MediaBrowser.WebDashboard.Api{_fileSystem.DeleteFile(Path.Combine(path, "scripts", "registrationservices.js"));}-+// Try to trim the output size a bitvar bowerPath = Path.Combine(path, "bower_components");++ if (!string.Equals(mode, "cordova", StringComparison.OrdinalIgnoreCase))+ {+ var versionedBowerPath = Path.Combine(Path.GetDirectoryName(bowerPath), "bower_components" + _appHost.ApplicationVersion);+ Directory.Move(bowerPath, versionedBowerPath);+ bowerPath = versionedBowerPath;+ }+DeleteFilesByExtension(bowerPath, ".log");DeleteFilesByExtension(bowerPath, ".txt");DeleteFilesByExtension(bowerPath, ".map");@@ -345,9 +339,9 @@ namespace MediaBrowser.WebDashboard.Apiif (string.Equals(mode, "cordova", StringComparison.OrdinalIgnoreCase)){// Delete things that are unneeded in an attempt to keep the output as trim as possible- _fileSystem.DeleteDirectory(Path.Combine(path, "css", "images", "tour"), true);+ _fileSystem.DeleteDirectory(Path.Combine(path, "css", "images", "tour"), true);- _fileSystem.DeleteFile(Path.Combine(path, "thirdparty", "jquerymobile-1.4.5", "jquery.mobile-1.4.5.min.map"));+ _fileSystem.DeleteFile(Path.Combine(path, "thirdparty", "jquerymobile-1.4.5", "jquery.mobile-1.4.5.min.map"));}else{@@ -413,7 +407,7 @@ namespace MediaBrowser.WebDashboard.Apitry{- var text = _fileSystem.ReadAllText(file, Encoding.UTF8);+ var text = _fileSystem.ReadAllText(file, Encoding.UTF8);var result = new KristensenCssMinifier().Minify(text, false, Encoding.UTF8);@@ -424,7 +418,7 @@ namespace MediaBrowser.WebDashboard.Apielse{text = result.MinifiedContent;- _fileSystem.WriteAllText(file, text, Encoding.UTF8);+ _fileSystem.WriteAllText(file, text, Encoding.UTF8);}}catch (Exception ex)@@ -449,7 +443,7 @@ namespace MediaBrowser.WebDashboard.Apitry{- var text = _fileSystem.ReadAllText(file, Encoding.UTF8);+ var text = _fileSystem.ReadAllText(file, Encoding.UTF8);var result = new CrockfordJsMinifier().Minify(text, false, Encoding.UTF8);@@ -460,7 +454,7 @@ namespace MediaBrowser.WebDashboard.Apielse{text = result.MinifiedContent;- _fileSystem.WriteAllText(file, text, Encoding.UTF8);+ _fileSystem.WriteAllText(file, text, Encoding.UTF8);}}catch (Exception ex)@@ -488,7 +482,7 @@ namespace MediaBrowser.WebDashboard.Apiforeach (var file in excludeFiles){- _fileSystem.DeleteFile(Path.Combine(destination, file));+ _fileSystem.DeleteFile(Path.Combine(destination, file));}}@@ -505,17 +499,17 @@ namespace MediaBrowser.WebDashboard.Apiprivate void CopyDirectory(string source, string destination){- _fileSystem.CreateDirectory(destination);+ _fileSystem.CreateDirectory(destination);//Now Create all of the directoriesforeach (string dirPath in Directory.GetDirectories(source, "*",SearchOption.AllDirectories))- _fileSystem.CreateDirectory(dirPath.Replace(source, destination));+ _fileSystem.CreateDirectory(dirPath.Replace(source, destination));//Copy all the files & Replaces any files with the same nameforeach (string newPath in Directory.GetFiles(source, "*.*",SearchOption.AllDirectories))- _fileSystem.CopyFile(newPath, newPath.Replace(source, destination), true);+ _fileSystem.CopyFile(newPath, newPath.Replace(source, destination), true);}}diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csprojindex f32bd8ad1c..e0de8846be 100644--- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj+++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj@@ -368,7 +368,7 @@<Content Include="dashboard-ui\apiclient\wakeonlan.js"><CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></Content>- <Content Include="dashboard-ui\thirdparty\emby-icons.html">+ <Content Include="dashboard-ui\bower_components\emby-icons\emby-icons.html"><CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></Content><Content Include="dashboard-ui\thirdparty\hls.min.js">