update drawer

This commit is contained in:
Luke Pulverenti 2017-01-27 18:05:04 -05:00
parent 8649cbc0cb
commit 4ba2d73bf7
2 changed files with 5 additions and 167 deletions

View File

@ -323,43 +323,6 @@ namespace MediaBrowser.WebDashboard.Api
return new PackageCreator(_fileSystem, _logger, _serverConfigurationManager, _memoryStreamFactory);
}
private List<string> GetDeployIgnoreExtensions()
{
var list = new List<string>();
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<Tuple<string, bool>> GetDeployIgnoreFilenames()
{
var list = new List<Tuple<string, bool>>();
list.Add(new Tuple<string, bool>("copying", true));
list.Add(new Tuple<string, bool>("license", true));
list.Add(new Tuple<string, bool>("license-mit", true));
list.Add(new Tuple<string, bool>("gitignore", false));
list.Add(new Tuple<string, bool>("npmignore", false));
list.Add(new Tuple<string, bool>("jshintrc", false));
list.Add(new Tuple<string, bool>("gruntfile", false));
list.Add(new Tuple<string, bool>("bowerrc", false));
list.Add(new Tuple<string, bool>("jscsrc", false));
list.Add(new Tuple<string, bool>("hero.svg", false));
list.Add(new Tuple<string, bool>("travis.yml", false));
list.Add(new Tuple<string, bool>("build.js", false));
list.Add(new Tuple<string, bool>("editorconfig", false));
list.Add(new Tuple<string, bool>("gitattributes", false));
return list;
}
public async Task<object> 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)

View File

@ -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("<link rel=\"stylesheet\" href=\"{0}\" async />", s)).ToArray();
@ -318,48 +312,6 @@ namespace MediaBrowser.WebDashboard.Api
return builder.ToString();
}
/// <summary>
/// Gets all CSS.
/// </summary>
/// <returns>Task{Stream}.</returns>
private async Task<Stream> 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;
}
/// <summary>
/// Gets the raw resource stream.
/// </summary>