starting to separate site.css

pull/702/head
Luke Pulverenti 12 years ago
parent 5adc63cf8c
commit f4bdee4a64

@ -260,6 +260,10 @@ namespace MediaBrowser.WebDashboard.Api
{ {
resourceStream = await GetAllJavascript().ConfigureAwait(false); resourceStream = await GetAllJavascript().ConfigureAwait(false);
} }
else if (path.Equals("css/all.css", StringComparison.OrdinalIgnoreCase))
{
resourceStream = await GetAllCss().ConfigureAwait(false);
}
else else
{ {
resourceStream = GetRawResourceStream(path); resourceStream = GetRawResourceStream(path);
@ -408,7 +412,7 @@ namespace MediaBrowser.WebDashboard.Api
"http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css", "http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css",
"thirdparty/jqm-icon-pack-3.0/font-awesome/jqm-icon-pack-3.0.0-fa.css", "thirdparty/jqm-icon-pack-3.0/font-awesome/jqm-icon-pack-3.0.0-fa.css",
"css/jplayer.css" + versionString, "css/jplayer.css" + versionString,
"css/site.css" + versionString "css/all.css" + versionString
}; };
var tags = files.Select(s => string.Format("<link rel=\"stylesheet\" href=\"{0}\" />", s)).ToArray(); var tags = files.Select(s => string.Format("<link rel=\"stylesheet\" href=\"{0}\" />", s)).ToArray();
@ -498,6 +502,33 @@ namespace MediaBrowser.WebDashboard.Api
return memoryStream; return memoryStream;
} }
/// <summary>
/// Gets all CSS.
/// </summary>
/// <returns>Task{Stream}.</returns>
private async Task<Stream> GetAllCss()
{
var files = new[]
{
"site.css",
"librarybrowser.css",
"pluginupdates.css",
"userimage.css"
};
var memoryStream = new MemoryStream();
var newLineBytes = Encoding.UTF8.GetBytes(Environment.NewLine);
foreach (var file in files)
{
await AppendResource(memoryStream, "css/" + file, newLineBytes).ConfigureAwait(false);
}
memoryStream.Position = 0;
return memoryStream;
}
/// <summary> /// <summary>
/// Appends the resource. /// Appends the resource.
/// </summary> /// </summary>
@ -525,13 +556,22 @@ namespace MediaBrowser.WebDashboard.Api
/// <returns>Task.</returns> /// <returns>Task.</returns>
private async Task AppendResource(Stream outputStream, string path, byte[] newLineBytes) private async Task AppendResource(Stream outputStream, string path, byte[] newLineBytes)
{ {
using (var stream = GetRawResourceStream(path)) var runningDirectory = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
path = Path.Combine(runningDirectory, "dashboard-ui", path.Replace('/', '\\'));
using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, StreamDefaults.DefaultFileStreamBufferSize, true))
{ {
await stream.CopyToAsync(outputStream).ConfigureAwait(false); using (var streamReader = new StreamReader(fs))
{
var text = await streamReader.ReadToEndAsync().ConfigureAwait(false);
var bytes = Encoding.UTF8.GetBytes(text);
await outputStream.WriteAsync(bytes, 0, bytes.Length).ConfigureAwait(false);
}
}
await outputStream.WriteAsync(newLineBytes, 0, newLineBytes.Length).ConfigureAwait(false); await outputStream.WriteAsync(newLineBytes, 0, newLineBytes.Length).ConfigureAwait(false);
} }
} }
}
} }

@ -141,6 +141,15 @@
<Content Include="dashboard-ui\css\jplayer.css"> <Content Include="dashboard-ui\css\jplayer.css">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="dashboard-ui\css\librarybrowser.css">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\css\pluginupdates.css">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\css\userimage.css">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\index.html"> <Content Include="dashboard-ui\index.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>

Loading…
Cancel
Save