aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.WebDashboard
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2016-03-18 02:36:58 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2016-03-18 02:36:58 -0400
commitb84f178467e347e1d6d977e84259c713c06001f5 (patch)
treee6ff106d73d615971e2579eb43b8360502da9a25 /MediaBrowser.WebDashboard
parent79dc9f29d9bffae50a1fb24d8650d0ea73a73a45 (diff)
update plugin pages
Diffstat (limited to 'MediaBrowser.WebDashboard')
-rw-r--r--MediaBrowser.WebDashboard/Api/PackageCreator.cs35
1 files changed, 29 insertions, 6 deletions
diff --git a/MediaBrowser.WebDashboard/Api/PackageCreator.cs b/MediaBrowser.WebDashboard/Api/PackageCreator.cs
index 55f6ca7a43..753946ac4d 100644
--- a/MediaBrowser.WebDashboard/Api/PackageCreator.cs
+++ b/MediaBrowser.WebDashboard/Api/PackageCreator.cs
@@ -261,11 +261,21 @@ namespace MediaBrowser.WebDashboard.Api
{
html = ModifyForCordova(html);
}
- else if (!string.IsNullOrWhiteSpace(path) && !string.Equals(path, "index.html", StringComparison.OrdinalIgnoreCase) && html.IndexOf("<html", StringComparison.OrdinalIgnoreCase) == -1)
+ else if (!string.IsNullOrWhiteSpace(path) && !string.Equals(path, "index.html", StringComparison.OrdinalIgnoreCase))
{
- var indexFile = File.ReadAllText(GetDashboardResourcePath("index.html"));
+ var index = html.IndexOf("<body", StringComparison.OrdinalIgnoreCase);
+ if (index != -1)
+ {
+ html = html.Substring(index);
+ index = html.IndexOf("</body>", StringComparison.OrdinalIgnoreCase);
+ if (index != -1)
+ {
+ html = html.Substring(0, index+7);
+ }
+ }
+ var mainFile = File.ReadAllText(GetDashboardResourcePath("index.html"));
- html = ReplaceFirst(indexFile, "<div class=\"mainAnimatedPage hide\"></div>", "<div class=\"mainAnimatedPage hide\">" + html + "</div>");
+ html = ReplaceFirst(mainFile, "<div class=\"mainAnimatedPage hide\"></div>", "<div class=\"mainAnimatedPage hide\">" + html + "</div>");
}
if (!string.IsNullOrWhiteSpace(localizationCulture))
@@ -305,7 +315,15 @@ namespace MediaBrowser.WebDashboard.Api
html = html.Replace("<head>", "<head>" + GetMetaTags(mode) + GetCommonCss(mode, appVersion));
- html = html.Replace("</body>", GetCommonJavascript(mode, appVersion) + "</body>");
+ // Inject sripts before any embedded scripts
+ if (html.IndexOf("<script", StringComparison.OrdinalIgnoreCase) != -1)
+ {
+ html = ReplaceFirst(html, "<script", GetCommonJavascript(mode, appVersion, false) + "<script");
+ }
+ else
+ {
+ html = html.Replace("</body>", GetCommonJavascript(mode, appVersion, true) + "</body>");
+ }
var bytes = Encoding.UTF8.GetBytes(html);
@@ -428,8 +446,9 @@ namespace MediaBrowser.WebDashboard.Api
/// </summary>
/// <param name="mode">The mode.</param>
/// <param name="version">The version.</param>
+ /// <param name="async">if set to <c>true</c> [asynchronous].</param>
/// <returns>System.String.</returns>
- private string GetCommonJavascript(string mode, string version)
+ private string GetCommonJavascript(string mode, string version, bool async)
{
var builder = new StringBuilder();
@@ -463,7 +482,11 @@ namespace MediaBrowser.WebDashboard.Api
{
if (s.IndexOf("require", StringComparison.OrdinalIgnoreCase) == -1)
{
- return string.Format("<script src=\"{0}\" async></script>", s);
+ if (async)
+ {
+ return string.Format("<script src=\"{0}\" async></script>", s);
+ }
+ return string.Format("<script src=\"{0}\"></script>", s);
}
return string.Format("<script src=\"{0}\"></script>", s);