diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-03-31 20:22:38 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-03-31 20:22:38 -0400 |
| commit | f4bdee4a64fe5a28716dce39a67cb929debb3642 (patch) | |
| tree | d38136f9dde8bf7a2aa156cf4110a20d75102b91 | |
| parent | 5adc63cf8c3516d2e3441a3aef7b54e80d20670d (diff) | |
starting to separate site.css
| -rw-r--r-- | MediaBrowser.WebDashboard/Api/DashboardService.cs | 50 | ||||
| -rw-r--r-- | MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj | 9 |
2 files changed, 54 insertions, 5 deletions
diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs index 8ceafd349..e6a59e0ee 100644 --- a/MediaBrowser.WebDashboard/Api/DashboardService.cs +++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs @@ -260,6 +260,10 @@ namespace MediaBrowser.WebDashboard.Api { resourceStream = await GetAllJavascript().ConfigureAwait(false); } + else if (path.Equals("css/all.css", StringComparison.OrdinalIgnoreCase)) + { + resourceStream = await GetAllCss().ConfigureAwait(false); + } else { 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", "thirdparty/jqm-icon-pack-3.0/font-awesome/jqm-icon-pack-3.0.0-fa.css", "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(); @@ -499,6 +503,33 @@ namespace MediaBrowser.WebDashboard.Api } /// <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> /// Appends the resource. /// </summary> /// <param name="assembly">The assembly.</param> @@ -525,12 +556,21 @@ namespace MediaBrowser.WebDashboard.Api /// <returns>Task.</returns> private async Task AppendResource(Stream outputStream, string path, byte[] newLineBytes) { - using (var stream = GetRawResourceStream(path)) - { - await stream.CopyToAsync(outputStream).ConfigureAwait(false); + var runningDirectory = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); - await outputStream.WriteAsync(newLineBytes, 0, newLineBytes.Length).ConfigureAwait(false); + path = Path.Combine(runningDirectory, "dashboard-ui", path.Replace('/', '\\')); + + using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, StreamDefaults.DefaultFileStreamBufferSize, true)) + { + 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); } } diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index 135f0bed8..2bbf41391 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -141,6 +141,15 @@ <Content Include="dashboard-ui\css\jplayer.css">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</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">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
|
