The Free Software Media System - Server Backend & API
adjust dependency loading
Luke Pulverentic6a3f6b5cce4
diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.csindex b9176afc03..d24a4a3de0 100644--- a/MediaBrowser.WebDashboard/Api/DashboardService.cs+++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs@@ -203,7 +203,7 @@ namespace MediaBrowser.WebDashboard.Apiif (!_serverConfigurationManager.Configuration.IsStartupWizardCompleted && path.IndexOf("wizard", StringComparison.OrdinalIgnoreCase) == -1 && GetPackageCreator().IsCoreHtml(path)){// But don't redirect if an html import is being requested.- if (path.IndexOf("vulcanize", StringComparison.OrdinalIgnoreCase) == -1 && path.IndexOf("bower_components", StringComparison.OrdinalIgnoreCase) == -1)+ if (path.IndexOf("bower_components", StringComparison.OrdinalIgnoreCase) == -1){Request.Response.Redirect("wizardstart.html");return null;@@ -303,36 +303,46 @@ namespace MediaBrowser.WebDashboard.Apivar mode = request.Mode;+ // Try to trim the output size a bit+ var bowerPath = Path.Combine(path, "bower_components");+ DeleteFilesByExtension(bowerPath, ".log");+ DeleteFilesByExtension(bowerPath, ".txt");+ DeleteFilesByExtension(bowerPath, ".map");+ DeleteFilesByExtension(bowerPath, ".md");+ DeleteFilesByExtension(bowerPath, ".json");+ DeleteFilesByExtension(bowerPath, ".gz");+ DeleteFilesByName(bowerPath, "copying", true);+ DeleteFilesByName(bowerPath, "license", true);+ DeleteFilesByName(bowerPath, "license-mit", true);+ DeleteFilesByName(bowerPath, "gitignore");+ DeleteFilesByName(bowerPath, "npmignore");+ DeleteFilesByName(bowerPath, "jshintrc");+ DeleteFilesByName(bowerPath, "gruntfile");+ DeleteFilesByName(bowerPath, "bowerrc");+ DeleteFilesByName(bowerPath, "jscsrc");+ DeleteFilesByName(bowerPath, "hero.svg");+ DeleteFilesByName(bowerPath, "travis.yml");+ DeleteFilesByName(bowerPath, "build.js");+ DeleteFilesByName(bowerPath, "editorconfig");+ DeleteFilesByName(bowerPath, "gitattributes");+ DeleteFoldersByName(bowerPath, "demo");+ DeleteFoldersByName(bowerPath, "test");+ DeleteFoldersByName(bowerPath, "guides");+ DeleteFoldersByName(bowerPath, "grunt");++ DeleteFoldersByName(Path.Combine(bowerPath, "jquery"), "src");+ DeleteFoldersByName(Path.Combine(bowerPath, "jstree"), "src");+ DeleteFoldersByName(Path.Combine(bowerPath, "Sortable"), "meteor");+ DeleteFoldersByName(Path.Combine(bowerPath, "Sortable"), "st");+ DeleteFoldersByName(Path.Combine(bowerPath, "swipebox"), "lib");+ DeleteFoldersByName(Path.Combine(bowerPath, "swipebox"), "scss");+if (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.DeleteFile(Path.Combine(path, "thirdparty", "jquerymobile-1.4.5", "jquery.mobile-1.4.5.min.map"));-- _fileSystem.DeleteDirectory(Path.Combine(path, "bower_components"), true);-- // But we do need this- CopyFile(Path.Combine(creator.DashboardUIPath, "bower_components", "webcomponentsjs", "webcomponents-lite.js"), Path.Combine(path, "bower_components", "webcomponentsjs", "webcomponents-lite.js"));- CopyFile(Path.Combine(creator.DashboardUIPath, "bower_components", "webcomponentsjs", "webcomponents-lite.min.js"), Path.Combine(path, "bower_components", "webcomponentsjs", "webcomponents-lite.min.js"));- CopyFile(Path.Combine(creator.DashboardUIPath, "bower_components", "velocity", "velocity.min.js"), Path.Combine(path, "bower_components", "velocity", "velocity.min.js"));- CopyFile(Path.Combine(creator.DashboardUIPath, "bower_components", "requirejs", "require.js"), Path.Combine(path, "bower_components", "requirejs", "require.js"));- CopyFile(Path.Combine(creator.DashboardUIPath, "bower_components", "fastclick", "lib", "fastclick.js"), Path.Combine(path, "bower_components", "fastclick", "lib", "fastclick.js"));- CopyFile(Path.Combine(creator.DashboardUIPath, "bower_components", "jquery", "dist", "jquery.min.js"), Path.Combine(path, "bower_components", "jquery", "dist", "jquery.min.js"));-- CopyFile(Path.Combine(creator.DashboardUIPath, "bower_components", "jstree", "dist", "jstree.min.js"), Path.Combine(path, "bower_components", "jstree", "dist", "jstree.min.js"));-- CopyDirectory(Path.Combine(creator.DashboardUIPath, "bower_components", "swipebox", "src", "css"), Path.Combine(path, "bower_components", "swipebox", "src", "css"));- CopyDirectory(Path.Combine(creator.DashboardUIPath, "bower_components", "swipebox", "src", "js"), Path.Combine(path, "bower_components", "swipebox", "src", "js"));- CopyDirectory(Path.Combine(creator.DashboardUIPath, "bower_components", "swipebox", "src", "img"), Path.Combine(path, "bower_components", "swipebox", "src", "img"));-- CopyFile(Path.Combine(creator.DashboardUIPath, "bower_components", "hammerjs", "hammer.min.js"), Path.Combine(path, "bower_components", "hammerjs", "hammer.min.js"));-- CopyFile(Path.Combine(creator.DashboardUIPath, "bower_components", "Sortable", "Sortable.min.js"), Path.Combine(path, "bower_components", "Sortable", "Sortable.min.js"));- CopyFile(Path.Combine(creator.DashboardUIPath, "bower_components", "fetch", "fetch.js"), Path.Combine(path, "bower_components", "fetch", "fetch.js"));- CopyFile(Path.Combine(creator.DashboardUIPath, "bower_components", "native-promise-only", "lib", "npo.src.js"), Path.Combine(path, "bower_components", "native-promise-only", "lib", "npo.src.js"));- CopyFile(Path.Combine(creator.DashboardUIPath, "bower_components", "headroom.js", "dist", "headroom.min.js"), Path.Combine(path, "bower_components", "headroom.js", "dist", "headroom.min.js"));- CopyFile(Path.Combine(creator.DashboardUIPath, "bower_components", "isMobile", "isMobile.min.js"), Path.Combine(path, "bower_components", "isMobile", "isMobile.min.js"));}else{@@ -347,6 +357,42 @@ namespace MediaBrowser.WebDashboard.Apireturn "";}+ private void DeleteFilesByExtension(string path, string extension)+ {+ var files = _fileSystem.GetFiles(path, true)+ .Where(i => string.Equals(i.Extension, extension, StringComparison.OrdinalIgnoreCase))+ .ToList();++ foreach (var file in files)+ {+ _fileSystem.DeleteFile(file.FullName);+ }+ }++ private void DeleteFilesByName(string path, string name, bool exact = false)+ {+ var files = _fileSystem.GetFiles(path, true)+ .Where(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase) || (!exact && i.Name.IndexOf(name, StringComparison.OrdinalIgnoreCase) != -1))+ .ToList();++ foreach (var file in files)+ {+ _fileSystem.DeleteFile(file.FullName);+ }+ }++ private void DeleteFoldersByName(string path, string name)+ {+ var directories = _fileSystem.GetDirectories(path, true)+ .Where(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase))+ .ToList();++ foreach (var directory in directories)+ {+ _fileSystem.DeleteDirectory(directory.FullName, true);+ }+ }+private void MinifyCssDirectory(string path){foreach (var file in Directory.GetFiles(path, "*.css", SearchOption.AllDirectories))diff --git a/MediaBrowser.WebDashboard/Api/PackageCreator.cs b/MediaBrowser.WebDashboard/Api/PackageCreator.csindex 56344d2990..aeba6965a3 100644--- a/MediaBrowser.WebDashboard/Api/PackageCreator.cs+++ b/MediaBrowser.WebDashboard/Api/PackageCreator.cs@@ -221,11 +221,6 @@ namespace MediaBrowser.WebDashboard.Apipublic bool IsCoreHtml(string path){- if (path.IndexOf("vulcanize", StringComparison.OrdinalIgnoreCase) != -1)- {- return false;- }-if (path.IndexOf(".template.html", StringComparison.OrdinalIgnoreCase) != -1){return false;diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csprojindex 572482798f..495c67eb2c 100644--- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj+++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj@@ -386,6 +386,9 @@<Content Include="dashboard-ui\scripts\supporterkeypage.js"><CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></Content>+ <Content Include="dashboard-ui\components\testermessage.js">+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>+ </Content><Content Include="dashboard-ui\scripts\wizardlivetvguide.js"><CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></Content>@@ -1798,12 +1801,6 @@<Content Include="dashboard-ui\userpassword.html"><CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></Content>- <Content Include="dashboard-ui\vulcanize-in.html">- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>- </Content>- <Content Include="dashboard-ui\vulcanize-out.html">- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>- </Content><Content Include="dashboard-ui\wizardagreement.html"><CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></Content>