aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.WebDashboard/Api
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2015-06-15 00:28:29 -0400
committerLuke <luke.pulverenti@gmail.com>2015-06-15 00:28:29 -0400
commit7d9d57a36ecee8e8a74b92544166c8fe70a0f880 (patch)
treea7f8a6bdb038048449d45a1e8926843015886f97 /MediaBrowser.WebDashboard/Api
parent5aafbe3dd694813a4e68f21ee72e59d6c53e776a (diff)
parent55eb54cbc28e40254a50c5a25443e910798243dc (diff)
Merge pull request #1118 from MediaBrowser/dev
3.0.5641.4
Diffstat (limited to 'MediaBrowser.WebDashboard/Api')
-rw-r--r--MediaBrowser.WebDashboard/Api/DashboardService.cs74
-rw-r--r--MediaBrowser.WebDashboard/Api/PackageCreator.cs101
2 files changed, 81 insertions, 94 deletions
diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs
index 715f06055f..72744f249c 100644
--- a/MediaBrowser.WebDashboard/Api/DashboardService.cs
+++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs
@@ -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;
@@ -13,10 +14,10 @@ using ServiceStack;
using ServiceStack.Web;
using System;
using System.Collections.Generic;
-using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
+using WebMarkupMin.Core.Minifiers;
namespace MediaBrowser.WebDashboard.Api
{
@@ -282,7 +283,7 @@ namespace MediaBrowser.WebDashboard.Api
}
catch (IOException)
{
-
+
}
var creator = GetPackageCreator();
@@ -301,17 +302,82 @@ namespace MediaBrowser.WebDashboard.Api
var cordovaVersion = Path.Combine(path, "thirdparty", "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);
+
+ 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);
await DumpFile("scripts/all.js", Path.Combine(path, "scripts", "all.js"), mode, culture, appVersion).ConfigureAwait(false);
await DumpFile("css/all.css", Path.Combine(path, "css", "all.css"), mode, culture, appVersion).ConfigureAwait(false);
-
+
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))
diff --git a/MediaBrowser.WebDashboard/Api/PackageCreator.cs b/MediaBrowser.WebDashboard/Api/PackageCreator.cs
index f6601ce804..dd1eba9a56 100644
--- a/MediaBrowser.WebDashboard/Api/PackageCreator.cs
+++ b/MediaBrowser.WebDashboard/Api/PackageCreator.cs
@@ -61,10 +61,7 @@ namespace MediaBrowser.WebDashboard.Api
// jQuery ajax doesn't seem to handle if-modified-since correctly
if (IsFormat(path, "html"))
{
- if (path.IndexOf("cordovaindex.html", StringComparison.OrdinalIgnoreCase) == -1)
- {
- resourceStream = await ModifyHtml(resourceStream, mode, localizationCulture, enableMinification).ConfigureAwait(false);
- }
+ resourceStream = await ModifyHtml(resourceStream, mode, localizationCulture, enableMinification).ConfigureAwait(false);
}
else if (IsFormat(path, "js"))
{
@@ -277,7 +274,10 @@ namespace MediaBrowser.WebDashboard.Api
var version = GetType().Assembly.GetName().Version;
- html = html.Replace("<head>", "<head>" + GetMetaTags(mode) + GetCommonCss(mode, version) + GetCommonJavascript(mode, version));
+ var imports = "<link rel=\"import\" href=\"thirdparty/polymer/polymer.html\">";
+ imports = "";
+
+ html = html.Replace("<head>", "<head>" + GetMetaTags(mode) + GetCommonCss(mode, version) + GetCommonJavascript(mode, version) + imports);
var bytes = Encoding.UTF8.GetBytes(html);
@@ -339,7 +339,7 @@ namespace MediaBrowser.WebDashboard.Api
sb.Append("<meta http-equiv=\"X-UA-Compatibility\" content=\"IE=Edge\">");
sb.Append("<meta name=\"format-detection\" content=\"telephone=no\">");
sb.Append("<meta name=\"msapplication-tap-highlight\" content=\"no\">");
- sb.Append("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no\">");
+ sb.Append("<meta name=\"viewport\" content=\"user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, target-densitydpi=device-dpi\">");
sb.Append("<meta name=\"apple-mobile-web-app-capable\" content=\"yes\">");
sb.Append("<meta name=\"mobile-web-app-capable\" content=\"yes\">");
sb.Append("<meta name=\"application-name\" content=\"Emby\">");
@@ -373,6 +373,7 @@ namespace MediaBrowser.WebDashboard.Api
{
"thirdparty/jquerymobile-1.4.5/jquery.mobile-1.4.5.min.css",
"thirdparty/fontawesome/css/font-awesome.min.css" + versionString,
+ "thirdparty/materialicons/style.css" + versionString,
"css/all.css" + versionString
};
@@ -395,6 +396,7 @@ namespace MediaBrowser.WebDashboard.Api
var files = new List<string>
{
+ //"thirdparty/webcomponentsjs/webcomponents-lite.min.js",
"scripts/all.js" + versionString
};
@@ -460,24 +462,14 @@ namespace MediaBrowser.WebDashboard.Api
"thirdparty/apiclient/md5.js",
"thirdparty/apiclient/sha1.js",
"thirdparty/apiclient/store.js",
- "thirdparty/apiclient/network.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",
- "thirdparty/apiclient/connectservice.js"
+ "thirdparty/apiclient/apiclient.js"
}.ToList();
- if (string.Equals(mode, "cordova", StringComparison.OrdinalIgnoreCase))
- {
- apiClientFiles.Add("thirdparty/cordova/serverdiscovery.js");
- }
- else
- {
- apiClientFiles.Add("thirdparty/apiclient/serverdiscovery.js");
- }
apiClientFiles.Add("thirdparty/apiclient/connectionmanager.js");
foreach (var file in apiClientFiles)
@@ -545,93 +537,22 @@ namespace MediaBrowser.WebDashboard.Api
"site.js",
"librarybrowser.js",
"librarylist.js",
- "editorsidebar.js",
"librarymenu.js",
"mediacontroller.js",
"backdrops.js",
"sync.js",
- "syncjob.js",
- "appservices.js",
"playlistmanager.js",
-
+ "appsettings.js",
"mediaplayer.js",
"mediaplayer-video.js",
"nowplayingbar.js",
- "nowplayingpage.js",
- "taskbutton.js",
-
"alphapicker.js",
- "addpluginpage.js",
- "autoorganizetv.js",
- "autoorganizelog.js",
- "channelsettings.js",
- "dashboardgeneral.js",
- "dashboardpage.js",
- "devicesupload.js",
"directorybrowser.js",
- "dlnaprofile.js",
- "dlnaprofiles.js",
- "dlnasettings.js",
- "dlnaserversettings.js",
- "editcollectionitems.js",
- "edititemmetadata.js",
- "edititemsubtitles.js",
-
- "playbackconfiguration.js",
- "cinemamodeconfiguration.js",
- "encodingsettings.js",
-
- "forgotpassword.js",
- "forgotpasswordpin.js",
- "indexpage.js",
- "itembynamedetailpage.js",
- "itemdetailpage.js",
- "kids.js",
- "librarypathmapping.js",
- "librarysettings.js",
- "livetvrecording.js",
- "livetvtimer.js",
- "livetvseriestimer.js",
- "livetvsettings.js",
- "livetvstatus.js",
-
- "medialibrarypage.js",
- "metadataconfigurationpage.js",
- "metadataimagespage.js",
- "metadatasubtitles.js",
- "metadatanfo.js",
"moviecollections.js",
-
- "mypreferencesdisplay.js",
- "mypreferenceslanguages.js",
- "mypreferenceswebclient.js",
-
"notifications.js",
- "notificationlist.js",
- "notificationsetting.js",
- "notificationsettings.js",
- "playlists.js",
- "playlistedit.js",
-
- "plugincatalogpage.js",
- "pluginspage.js",
"remotecontrol.js",
- "scheduledtaskpage.js",
- "scheduledtaskspage.js",
"search.js",
- "syncactivity.js",
- "syncsettings.js",
- "thememediaplayer.js",
- "useredit.js",
- "myprofile.js",
- "userpassword.js",
- "userprofilespage.js",
- "userparentalcontrol.js",
- "userlibraryaccess.js",
- "wizardagreement.js",
- "wizardfinishpage.js",
- "wizardservice.js",
- "wizardstartpage.js"
+ "thememediaplayer.js"
};
}