|
|
|
@ -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
|
|
|
|
|