|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
using MediaBrowser.Common.Extensions;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using MediaBrowser.Common.Extensions;
|
|
|
|
|
using MediaBrowser.Common.IO;
|
|
|
|
|
using MediaBrowser.Controller;
|
|
|
|
|
using MediaBrowser.Controller.Configuration;
|
|
|
|
@ -16,6 +17,7 @@ using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using WebMarkupMin.Core.Minifiers;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.WebDashboard.Api
|
|
|
|
|
{
|
|
|
|
@ -308,6 +310,11 @@ namespace MediaBrowser.WebDashboard.Api
|
|
|
|
|
File.Delete(Path.Combine(path, "thirdparty", "jquerymobile-1.4.5", "jquery.mobile-1.4.5.min.map"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MinifyCssDirectory(Path.Combine(path, "css"));
|
|
|
|
|
MinifyJsDirectory(Path.Combine(path, "scripts"));
|
|
|
|
|
MinifyJsDirectory(Path.Combine(path, "thirdparty", "apiclient"));
|
|
|
|
|
MinifyJsDirectory(Path.Combine(path, "voice"));
|
|
|
|
|
|
|
|
|
|
await DumpHtml(creator.DashboardUIPath, path, mode, culture, appVersion);
|
|
|
|
|
await DumpJs(creator.DashboardUIPath, path, mode, culture, appVersion);
|
|
|
|
|
|
|
|
|
@ -317,6 +324,60 @@ namespace MediaBrowser.WebDashboard.Api
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MinifyCssDirectory(string path)
|
|
|
|
|
{
|
|
|
|
|
foreach (var file in Directory.GetFiles(path, "*.css", SearchOption.AllDirectories))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var text = File.ReadAllText(file, Encoding.UTF8);
|
|
|
|
|
|
|
|
|
|
var result = new KristensenCssMinifier().Minify(text, false, Encoding.UTF8);
|
|
|
|
|
|
|
|
|
|
if (result.Errors.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
Logger.Error("Error minifying css: " + result.Errors[0].Message);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
text = result.MinifiedContent;
|
|
|
|
|
File.WriteAllText(file, text, Encoding.UTF8);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Logger.ErrorException("Error minifying css", ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MinifyJsDirectory(string path)
|
|
|
|
|
{
|
|
|
|
|
foreach (var file in Directory.GetFiles(path, "*.js", SearchOption.AllDirectories))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var text = File.ReadAllText(file, Encoding.UTF8);
|
|
|
|
|
|
|
|
|
|
var result = new CrockfordJsMinifier().Minify(text, false, Encoding.UTF8);
|
|
|
|
|
|
|
|
|
|
if (result.Errors.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
Logger.Error("Error minifying javascript: " + result.Errors[0].Message);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
text = result.MinifiedContent;
|
|
|
|
|
File.WriteAllText(file, text, Encoding.UTF8);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Logger.ErrorException("Error minifying css", ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task DumpHtml(string source, string destination, string mode, string culture, string appVersion)
|
|
|
|
|
{
|
|
|
|
|
foreach (var file in Directory.GetFiles(source, "*.html", SearchOption.TopDirectoryOnly))
|
|
|
|
|