From 4ba2d73bf7355f11df408529f770a26b311c1e95 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 27 Jan 2017 18:05:04 -0500 Subject: [PATCH] update drawer --- .../Api/DashboardService.cs | 114 ------------------ .../Api/PackageCreator.cs | 58 +-------- 2 files changed, 5 insertions(+), 167 deletions(-) diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs index 0b45090f3..dfdcdf2de 100644 --- a/MediaBrowser.WebDashboard/Api/DashboardService.cs +++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs @@ -323,43 +323,6 @@ namespace MediaBrowser.WebDashboard.Api return new PackageCreator(_fileSystem, _logger, _serverConfigurationManager, _memoryStreamFactory); } - private List GetDeployIgnoreExtensions() - { - var list = new List(); - - list.Add(".log"); - list.Add(".txt"); - list.Add(".map"); - list.Add(".md"); - list.Add(".gz"); - list.Add(".bat"); - list.Add(".sh"); - - return list; - } - - private List> GetDeployIgnoreFilenames() - { - var list = new List>(); - - list.Add(new Tuple("copying", true)); - list.Add(new Tuple("license", true)); - list.Add(new Tuple("license-mit", true)); - list.Add(new Tuple("gitignore", false)); - list.Add(new Tuple("npmignore", false)); - list.Add(new Tuple("jshintrc", false)); - list.Add(new Tuple("gruntfile", false)); - list.Add(new Tuple("bowerrc", false)); - list.Add(new Tuple("jscsrc", false)); - list.Add(new Tuple("hero.svg", false)); - list.Add(new Tuple("travis.yml", false)); - list.Add(new Tuple("build.js", false)); - list.Add(new Tuple("editorconfig", false)); - list.Add(new Tuple("gitattributes", false)); - - return list; - } - public async Task Get(GetDashboardPackage request) { var mode = request.Mode; @@ -388,39 +351,11 @@ namespace MediaBrowser.WebDashboard.Api // Try to trim the output size a bit var bowerPath = Path.Combine(path, "bower_components"); - foreach (var ext in GetDeployIgnoreExtensions()) - { - DeleteFilesByExtension(bowerPath, ext); - } - - DeleteFilesByExtension(bowerPath, ".json", "strings\\"); - - foreach (var ignore in GetDeployIgnoreFilenames()) - { - DeleteFilesByName(bowerPath, ignore.Item1, ignore.Item2); - } - - DeleteFoldersByName(bowerPath, "demo"); - DeleteFoldersByName(bowerPath, "test"); - DeleteFoldersByName(bowerPath, "guides"); - DeleteFoldersByName(bowerPath, "grunt"); - DeleteFoldersByName(bowerPath, "rollups"); - if (string.Equals(mode, "cordova", StringComparison.OrdinalIgnoreCase)) { DeleteFoldersByName(Path.Combine(bowerPath, "emby-webcomponents", "fonts"), "roboto"); } - _fileSystem.DeleteDirectory(Path.Combine(bowerPath, "jquery", "src"), true); - - DeleteCryptoFiles(Path.Combine(bowerPath, "cryptojslib", "components")); - - 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, "Swiper"), "src"); - if (string.Equals(mode, "cordova", StringComparison.OrdinalIgnoreCase)) { // Delete things that are unneeded in an attempt to keep the output as trim as possible @@ -429,58 +364,9 @@ namespace MediaBrowser.WebDashboard.Api await DumpHtml(creator.DashboardUIPath, path, mode, culture, appVersion); - await DumpFile("css/all.css", Path.Combine(path, "css", "all.css"), mode, culture, appVersion).ConfigureAwait(false); - return ""; } - private void DeleteCryptoFiles(string path) - { - var files = _fileSystem.GetFiles(path) - .ToList(); - - var keepFiles = new[] { "core-min.js", "md5-min.js", "sha1-min.js" }; - - foreach (var file in files) - { - if (!keepFiles.Contains(file.Name, StringComparer.OrdinalIgnoreCase)) - { - _fileSystem.DeleteFile(file.FullName); - } - } - } - - private void DeleteFilesByExtension(string path, string extension, string exclude = null) - { - var files = _fileSystem.GetFiles(path, true) - .Where(i => string.Equals(i.Extension, extension, StringComparison.OrdinalIgnoreCase)) - .ToList(); - - foreach (var file in files) - { - if (!string.IsNullOrWhiteSpace(exclude)) - { - if (file.FullName.IndexOf(exclude, StringComparison.OrdinalIgnoreCase) != -1) - { - continue; - } - } - _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) diff --git a/MediaBrowser.WebDashboard/Api/PackageCreator.cs b/MediaBrowser.WebDashboard/Api/PackageCreator.cs index f2df01976..7a788f6f0 100644 --- a/MediaBrowser.WebDashboard/Api/PackageCreator.cs +++ b/MediaBrowser.WebDashboard/Api/PackageCreator.cs @@ -33,16 +33,7 @@ namespace MediaBrowser.WebDashboard.Api string localizationCulture, string appVersion) { - Stream resourceStream; - - if (path.Equals("css/all.css", StringComparison.OrdinalIgnoreCase)) - { - resourceStream = await GetAllCss().ConfigureAwait(false); - } - else - { - resourceStream = GetRawResourceStream(path); - } + var resourceStream = GetRawResourceStream(path); if (resourceStream != null) { @@ -267,7 +258,10 @@ namespace MediaBrowser.WebDashboard.Api var files = new[] { - "css/all.css" + versionString + "css/site.css" + versionString, + "css/librarymenu.css" + versionString, + "css/librarybrowser.css" + versionString, + "thirdparty/paper-button-style.css" + versionString }; var tags = files.Select(s => string.Format("", s)).ToArray(); @@ -318,48 +312,6 @@ namespace MediaBrowser.WebDashboard.Api return builder.ToString(); } - /// - /// Gets all CSS. - /// - /// Task{Stream}. - private async Task GetAllCss() - { - var memoryStream = _memoryStreamFactory.CreateNew(); - - var files = new[] - { - "css/site.css", - "css/librarymenu.css", - "css/librarybrowser.css", - "thirdparty/paper-button-style.css" - }; - - var builder = new StringBuilder(); - - foreach (var file in files) - { - var path = GetDashboardResourcePath(file); - - using (var fs = _fileSystem.GetFileStream(path, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.ReadWrite, true)) - { - using (var streamReader = new StreamReader(fs)) - { - var text = await streamReader.ReadToEndAsync().ConfigureAwait(false); - builder.Append(text); - builder.Append(Environment.NewLine); - } - } - } - - var css = builder.ToString(); - - var bytes = Encoding.UTF8.GetBytes(css); - memoryStream.Write(bytes, 0, bytes.Length); - - memoryStream.Position = 0; - return memoryStream; - } - /// /// Gets the raw resource stream. ///