diff options
Diffstat (limited to 'MediaBrowser.WebDashboard/Api')
| -rw-r--r-- | MediaBrowser.WebDashboard/Api/DashboardService.cs | 6 | ||||
| -rw-r--r-- | MediaBrowser.WebDashboard/Api/PackageCreator.cs | 23 |
2 files changed, 21 insertions, 8 deletions
diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs index a5bfebea9..ab9ff8e6f 100644 --- a/MediaBrowser.WebDashboard/Api/DashboardService.cs +++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs @@ -25,7 +25,6 @@ namespace MediaBrowser.WebDashboard.Api /// <summary> /// Class GetDashboardConfigurationPages /// </summary> - [Route("/dashboard/ConfigurationPages", "GET")] [Route("/web/ConfigurationPages", "GET")] public class GetDashboardConfigurationPages : IReturn<List<ConfigurationPageInfo>> { @@ -39,7 +38,6 @@ namespace MediaBrowser.WebDashboard.Api /// <summary> /// Class GetDashboardConfigurationPage /// </summary> - [Route("/dashboard/ConfigurationPage", "GET")] [Route("/web/ConfigurationPage", "GET")] public class GetDashboardConfigurationPage { @@ -51,7 +49,6 @@ namespace MediaBrowser.WebDashboard.Api } [Route("/web/Package", "GET")] - [Route("/dashboard/Package", "GET")] public class GetDashboardPackage { public string Mode { get; set; } @@ -66,7 +63,6 @@ namespace MediaBrowser.WebDashboard.Api /// Class GetDashboardResource /// </summary> [Route("/web/{ResourceName*}", "GET")] - [Route("/dashboard/{ResourceName*}", "GET")] public class GetDashboardResource { /// <summary> @@ -142,7 +138,7 @@ namespace MediaBrowser.WebDashboard.Api { var page = ServerEntryPoint.Instance.PluginConfigurationPages.First(p => p.Name.Equals(request.Name, StringComparison.OrdinalIgnoreCase)); - return ResultFactory.GetStaticResult(Request, page.Plugin.Version.ToString().GetMD5(), null, null, MimeTypes.GetMimeType("page.html"), () => GetPackageCreator().ModifyHtml(null, page.GetHtmlStream(), null, _appHost.ApplicationVersion.ToString(), null, false)); + return ResultFactory.GetStaticResult(Request, page.Plugin.Version.ToString().GetMD5(), null, null, MimeTypes.GetMimeType("page.html"), () => GetPackageCreator().ModifyHtml("dummy.html", page.GetHtmlStream(), null, _appHost.ApplicationVersion.ToString(), null, false)); } /// <summary> diff --git a/MediaBrowser.WebDashboard/Api/PackageCreator.cs b/MediaBrowser.WebDashboard/Api/PackageCreator.cs index 55f6ca7a4..726205671 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,6 +315,13 @@ namespace MediaBrowser.WebDashboard.Api html = html.Replace("<head>", "<head>" + GetMetaTags(mode) + GetCommonCss(mode, appVersion)); + // Disable embedded scripts from plugins. We'll run them later once resources have loaded + if (html.IndexOf("<script", StringComparison.OrdinalIgnoreCase) != -1) + { + html = html.Replace("<script", "<!--<script"); + html = html.Replace("</script>", "</script>-->"); + } + html = html.Replace("</body>", GetCommonJavascript(mode, appVersion) + "</body>"); var bytes = Encoding.UTF8.GetBytes(html); |
