update components

This commit is contained in:
Luke Pulverenti 2016-03-16 14:09:58 -04:00
parent 67642b6f57
commit fee7cbdc4a
3 changed files with 21 additions and 4 deletions

View File

@ -49,7 +49,7 @@ namespace MediaBrowser.Server.Startup.Common.Browser
/// <param name="logger">The logger.</param>
public static void OpenDashboard(IServerApplicationHost appHost, ILogger logger)
{
OpenDashboardPage("index.html#!/dashboard.html", appHost, logger);
OpenDashboardPage("dashboard.html", appHost, logger);
}
/// <summary>

View File

@ -142,7 +142,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(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(null, page.GetHtmlStream(), null, _appHost.ApplicationVersion.ToString(), null, false));
}
/// <summary>

View File

@ -60,7 +60,7 @@ namespace MediaBrowser.WebDashboard.Api
{
if (IsCoreHtml(path))
{
resourceStream = await ModifyHtml(resourceStream, mode, appVersion, localizationCulture, enableMinification).ConfigureAwait(false);
resourceStream = await ModifyHtml(path, resourceStream, mode, appVersion, localizationCulture, enableMinification).ConfigureAwait(false);
}
}
else if (IsFormat(path, "js"))
@ -238,13 +238,14 @@ namespace MediaBrowser.WebDashboard.Api
/// <summary>
/// Modifies the HTML by adding common meta tags, css and js.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="sourceStream">The source stream.</param>
/// <param name="mode">The mode.</param>
/// <param name="appVersion">The application version.</param>
/// <param name="localizationCulture">The localization culture.</param>
/// <param name="enableMinification">if set to <c>true</c> [enable minification].</param>
/// <returns>Task{Stream}.</returns>
public async Task<Stream> ModifyHtml(Stream sourceStream, string mode, string appVersion, string localizationCulture, bool enableMinification)
public async Task<Stream> ModifyHtml(string path, Stream sourceStream, string mode, string appVersion, string localizationCulture, bool enableMinification)
{
using (sourceStream)
{
@ -260,6 +261,12 @@ 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)
{
var indexFile = File.ReadAllText(GetDashboardResourcePath("index.html"));
html = ReplaceFirst(indexFile, "<div class=\"mainAnimatedPage hide\"></div>", "<div class=\"mainAnimatedPage hide\">" + html + "</div>");
}
if (!string.IsNullOrWhiteSpace(localizationCulture))
{
@ -306,6 +313,16 @@ namespace MediaBrowser.WebDashboard.Api
}
}
public string ReplaceFirst(string text, string search, string replace)
{
int pos = text.IndexOf(search, StringComparison.OrdinalIgnoreCase);
if (pos < 0)
{
return text;
}
return text.Substring(0, pos) + replace + text.Substring(pos + search.Length);
}
private string ModifyForCordova(string html)
{
// Replace CORDOVA_REPLACE_SUPPORTER_SUBMIT_START