diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs index 72744f249c..f197914a53 100644 --- a/MediaBrowser.WebDashboard/Api/DashboardService.cs +++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs @@ -272,6 +272,12 @@ namespace MediaBrowser.WebDashboard.Api return Path.GetExtension(path).EndsWith("html", StringComparison.OrdinalIgnoreCase); } + private void CopyFile(string src, string dst) + { + Directory.CreateDirectory(Path.GetDirectoryName(dst)); + File.Copy(src, dst, true); + } + public async Task Get(GetDashboardPackage request) { var path = Path.Combine(_serverConfigurationManager.ApplicationPaths.ProgramDataPath, @@ -299,20 +305,24 @@ namespace MediaBrowser.WebDashboard.Api if (string.Equals(mode, "cordova", StringComparison.OrdinalIgnoreCase)) { // Overwrite certain files with cordova specific versions - var cordovaVersion = Path.Combine(path, "thirdparty", "cordova", "registrationservices.js"); + var cordovaVersion = Path.Combine(path, "cordova", "registrationservices.js"); File.Copy(cordovaVersion, Path.Combine(path, "scripts", "registrationservices.js"), true); File.Delete(cordovaVersion); // Delete things that are unneeded in an attempt to keep the output as trim as possible Directory.Delete(Path.Combine(path, "css", "images", "tour"), true); - Directory.Delete(Path.Combine(path, "thirdparty", "apiclient", "alt"), true); + Directory.Delete(Path.Combine(path, "apiclient", "alt"), true); File.Delete(Path.Combine(path, "thirdparty", "jquerymobile-1.4.5", "jquery.mobile-1.4.5.min.map")); + + Directory.Delete(Path.Combine(path, "bower_components"), true); + // But we do need this + CopyFile(Path.Combine(creator.DashboardUIPath, "bower_components", "webcomponentsjs", "webcomponents-lite.min.js"), Path.Combine(path, "bower_components", "webcomponentsjs", "webcomponents-lite.min.js")); } MinifyCssDirectory(Path.Combine(path, "css")); MinifyJsDirectory(Path.Combine(path, "scripts")); - MinifyJsDirectory(Path.Combine(path, "thirdparty", "apiclient")); + MinifyJsDirectory(Path.Combine(path, "apiclient")); MinifyJsDirectory(Path.Combine(path, "voice")); await DumpHtml(creator.DashboardUIPath, path, mode, culture, appVersion); diff --git a/MediaBrowser.WebDashboard/Api/PackageCreator.cs b/MediaBrowser.WebDashboard/Api/PackageCreator.cs index 44e5d7cbdb..623eab73b3 100644 --- a/MediaBrowser.WebDashboard/Api/PackageCreator.cs +++ b/MediaBrowser.WebDashboard/Api/PackageCreator.cs @@ -61,7 +61,10 @@ namespace MediaBrowser.WebDashboard.Api // jQuery ajax doesn't seem to handle if-modified-since correctly if (IsFormat(path, "html")) { - resourceStream = await ModifyHtml(resourceStream, mode, localizationCulture, enableMinification).ConfigureAwait(false); + if (IsCoreHtml(path)) + { + resourceStream = await ModifyHtml(resourceStream, mode, localizationCulture, enableMinification).ConfigureAwait(false); + } } else if (IsFormat(path, "js")) { @@ -210,6 +213,22 @@ namespace MediaBrowser.WebDashboard.Api } } + private bool IsCoreHtml(string path) + { + if (path.IndexOf("vulcanize", StringComparison.OrdinalIgnoreCase) != -1) + { + return false; + } + + path = GetDashboardResourcePath(path); + var parent = Path.GetDirectoryName(path); + + var basePath = DashboardUIPath; + + return string.Equals(basePath, parent, StringComparison.OrdinalIgnoreCase) || + string.Equals(Path.Combine(basePath, "voice"), parent, StringComparison.OrdinalIgnoreCase); + } + /// /// Modifies the HTML by adding common meta tags, css and js. /// @@ -276,17 +295,7 @@ namespace MediaBrowser.WebDashboard.Api var imports = new string[] { - "bower_components/paper-button/paper-button.html", - "bower_components/paper-toast/paper-toast.html", - "bower_components/paper-spinner/paper-spinner.html", - "bower_components/paper-fab/paper-fab.html", - "bower_components/paper-dialog/paper-dialog.html", - "bower_components/paper-dialog-scrollable/paper-dialog-scrollable.html", - "bower_components/neon-animation/animations/scale-up-animation.html", - "bower_components/neon-animation/animations/fade-out-animation.html", - "bower_components/neon-animation/animations/fade-in-animation.html", - "bower_components/paper-icon-button/paper-icon-button.html", - "thirdparty/emby-icons.html" + "vulcanize-out.html" }; var importsHtml = string.Join("", imports.Select(i => "").ToArray()); @@ -412,7 +421,6 @@ namespace MediaBrowser.WebDashboard.Api var files = new List { - "bower_components/webcomponentsjs/webcomponents-lite.min.js", "scripts/all.js" + versionString }; @@ -437,6 +445,8 @@ namespace MediaBrowser.WebDashboard.Api var memoryStream = new MemoryStream(); var newLineBytes = Encoding.UTF8.GetBytes(Environment.NewLine); + await AppendResource(memoryStream, "bower_components/webcomponentsjs/webcomponents-lite.min.js", newLineBytes).ConfigureAwait(false); + // jQuery + jQuery mobile await AppendResource(memoryStream, "thirdparty/jquery-2.1.1.min.js", newLineBytes).ConfigureAwait(false); await AppendResource(memoryStream, "thirdparty/jquerymobile-1.4.5/jquery.mobile-1.4.5.min.js", newLineBytes).ConfigureAwait(false); @@ -474,19 +484,19 @@ namespace MediaBrowser.WebDashboard.Api var apiClientFiles = new[] { - "thirdparty/apiclient/logger.js", - "thirdparty/apiclient/md5.js", - "thirdparty/apiclient/sha1.js", - "thirdparty/apiclient/store.js", - "thirdparty/apiclient/device.js", - "thirdparty/apiclient/credentials.js", - "thirdparty/apiclient/ajax.js", - "thirdparty/apiclient/events.js", - "thirdparty/apiclient/deferred.js", - "thirdparty/apiclient/apiclient.js" + "apiclient/logger.js", + "apiclient/md5.js", + "apiclient/sha1.js", + "apiclient/store.js", + "apiclient/device.js", + "apiclient/credentials.js", + "apiclient/ajax.js", + "apiclient/events.js", + "apiclient/deferred.js", + "apiclient/apiclient.js" }.ToList(); - apiClientFiles.Add("thirdparty/apiclient/connectionmanager.js"); + apiClientFiles.Add("apiclient/connectionmanager.js"); foreach (var file in apiClientFiles) { diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index fff0032ccc..9481789243 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -558,40 +558,40 @@ PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest @@ -729,75 +729,75 @@ PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - - + + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - - + + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest @@ -1412,19 +1412,19 @@ PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest @@ -2069,7 +2069,7 @@ PreserveNewest - + PreserveNewest @@ -2132,6 +2132,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest