Jelajahi Sumber

resolve script error

Luke Pulverenti 10 tahun lalu
induk
melakukan
3bedcbb4f5

+ 6 - 3
MediaBrowser.WebDashboard/Api/DashboardService.cs

@@ -200,9 +200,11 @@ namespace MediaBrowser.WebDashboard.Api
 
 
             var isHtml = IsHtml(path);
             var isHtml = IsHtml(path);
 
 
-            if (isHtml && !_serverConfigurationManager.Configuration.IsStartupWizardCompleted)
+            // Bounce them to the startup wizard if it hasn't been completed yet
+            if (isHtml && !_serverConfigurationManager.Configuration.IsStartupWizardCompleted && path.IndexOf("wizard", StringComparison.OrdinalIgnoreCase) == -1)
             {
             {
-                if (path.IndexOf("wizard", StringComparison.OrdinalIgnoreCase) == -1)
+                // 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)
                 {
                 {
                     Request.Response.Redirect("wizardstart.html");
                     Request.Response.Redirect("wizardstart.html");
                     return null;
                     return null;
@@ -317,8 +319,9 @@ namespace MediaBrowser.WebDashboard.Api
 
 
                 Directory.Delete(Path.Combine(path, "bower_components"), true);
                 Directory.Delete(Path.Combine(path, "bower_components"), true);
                 Directory.Delete(Path.Combine(path, "thirdparty", "viblast"), true);
                 Directory.Delete(Path.Combine(path, "thirdparty", "viblast"), true);
-                
+
                 // But we do need this
                 // 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", "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", "velocity", "velocity.min.js"), Path.Combine(path, "bower_components", "velocity", "velocity.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", "css"), Path.Combine(path, "bower_components", "swipebox", "src", "css"));

+ 30 - 2
MediaBrowser.WebDashboard/Api/PackageCreator.cs

@@ -315,7 +315,7 @@ namespace MediaBrowser.WebDashboard.Api
                 // In chrome it is causing the body to be hidden while loading, which leads to width-check methods to return 0 for everything
                 // In chrome it is causing the body to be hidden while loading, which leads to width-check methods to return 0 for everything
                 //imports = "";
                 //imports = "";
 
 
-                html = html.Replace("<head>", "<head>" + GetMetaTags(mode) + GetCommonCss(mode, version) + GetCommonJavascript(mode, version) + importsHtml);
+                html = html.Replace("<head>", "<head>" + GetMetaTags(mode) + GetCommonCss(mode, version) + GetInitialJavascript(mode, version) + importsHtml + GetCommonJavascript(mode, version));
 
 
                 var bytes = Encoding.UTF8.GetBytes(html);
                 var bytes = Encoding.UTF8.GetBytes(html);
 
 
@@ -426,6 +426,35 @@ namespace MediaBrowser.WebDashboard.Api
             return string.Join(string.Empty, tags);
             return string.Join(string.Empty, tags);
         }
         }
 
 
+        /// <summary>
+        /// Gets the common javascript.
+        /// </summary>
+        /// <param name="mode">The mode.</param>
+        /// <param name="version">The version.</param>
+        /// <returns>System.String.</returns>
+        private string GetInitialJavascript(string mode, Version version)
+        {
+            var builder = new StringBuilder();
+
+            var versionString = !string.Equals(mode, "cordova", StringComparison.OrdinalIgnoreCase) ? "?v=" + version : string.Empty;
+
+            var files = new List<string>
+            {
+                "bower_components/webcomponentsjs/webcomponents-lite.js" + versionString
+            };
+
+            if (string.Equals(mode, "cordova", StringComparison.OrdinalIgnoreCase))
+            {
+                files.Insert(0, "cordova.js");
+            }
+
+            var tags = files.Select(s => string.Format("<script src=\"{0}\"></script>", s)).ToArray();
+
+            builder.Append(string.Join(string.Empty, tags));
+
+            return builder.ToString();
+        }
+
         /// <summary>
         /// <summary>
         /// Gets the common javascript.
         /// Gets the common javascript.
         /// </summary>
         /// </summary>
@@ -440,7 +469,6 @@ namespace MediaBrowser.WebDashboard.Api
 
 
             var files = new List<string>
             var files = new List<string>
             {
             {
-                "bower_components/webcomponentsjs/webcomponents-lite.js" + versionString,
                 "scripts/all.js" + versionString
                 "scripts/all.js" + versionString
             };
             };
 
 

+ 1 - 1
SharedVersion.cs

@@ -1,4 +1,4 @@
 using System.Reflection;
 using System.Reflection;
 
 
 //[assembly: AssemblyVersion("3.0.*")]
 //[assembly: AssemblyVersion("3.0.*")]
-[assembly: AssemblyVersion("3.0.5666.9")]
+[assembly: AssemblyVersion("3.0.5667.5")]