mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-21 01:24:44 +01:00
refined app themes
This commit is contained in:
@@ -238,8 +238,19 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||
return hasOptions;
|
||||
}
|
||||
|
||||
// Otherwise wrap into an HttpResult
|
||||
var httpResult = new HttpResult(result, contentType ?? "text/html", HttpStatusCode.NotModified);
|
||||
IHasOptions httpResult;
|
||||
|
||||
var stream = result as Stream;
|
||||
|
||||
if (stream != null)
|
||||
{
|
||||
httpResult = new StreamWriter(stream, contentType, _logger);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise wrap into an HttpResult
|
||||
httpResult = new HttpResult(result, contentType ?? "text/html", HttpStatusCode.NotModified);
|
||||
}
|
||||
|
||||
AddResponseHeaders(httpResult, responseHeaders);
|
||||
|
||||
@@ -478,7 +489,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||
if (!SupportsCompression)
|
||||
{
|
||||
responseHeaders["Content-Length"] = originalContentLength.ToString(UsCulture);
|
||||
|
||||
|
||||
if (isHeadRequest)
|
||||
{
|
||||
return GetHttpResult(new byte[] { }, contentType);
|
||||
@@ -495,7 +506,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||
{
|
||||
return GetHttpResult(new byte[] { }, contentType);
|
||||
}
|
||||
|
||||
|
||||
return new CompressedResult(contents, requestedCompressionType, contentType);
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,11 @@ namespace MediaBrowser.Server.Implementations.Themes
|
||||
return Path.Combine(GetThemesPath(applicationName), name);
|
||||
}
|
||||
|
||||
private string GetImagesPath(string applicationName, string themeName)
|
||||
{
|
||||
return Path.Combine(GetThemePath(applicationName, themeName), "images");
|
||||
}
|
||||
|
||||
public IEnumerable<AppThemeInfo> GetThemes(string applicationName)
|
||||
{
|
||||
var path = GetThemesPath(applicationName);
|
||||
@@ -97,9 +102,11 @@ namespace MediaBrowser.Server.Implementations.Themes
|
||||
var themePath = GetThemePath(applicationName, name);
|
||||
var file = Path.Combine(themePath, "theme.json");
|
||||
|
||||
var imagesPath = GetImagesPath(applicationName, name);
|
||||
|
||||
var theme = _json.DeserializeFromFile<AppTheme>(file);
|
||||
|
||||
theme.Images = new DirectoryInfo(themePath)
|
||||
theme.Images = new DirectoryInfo(imagesPath)
|
||||
.EnumerateFiles("*", SearchOption.TopDirectoryOnly)
|
||||
.Where(i => _supportedImageExtensions.Contains(i.Extension, StringComparer.OrdinalIgnoreCase))
|
||||
.Select(GetThemeImage)
|
||||
@@ -123,7 +130,7 @@ namespace MediaBrowser.Server.Implementations.Themes
|
||||
|
||||
public void SaveTheme(AppTheme theme)
|
||||
{
|
||||
var themePath = GetThemePath(theme.ApplicationName, theme.Name);
|
||||
var themePath = GetThemePath(theme.AppName, theme.Name);
|
||||
var file = Path.Combine(themePath, "theme.json");
|
||||
|
||||
Directory.CreateDirectory(themePath);
|
||||
@@ -131,7 +138,7 @@ namespace MediaBrowser.Server.Implementations.Themes
|
||||
// Clone it so that we don't serialize all the images - they're always dynamic
|
||||
var clone = new AppTheme
|
||||
{
|
||||
ApplicationName = theme.ApplicationName,
|
||||
AppName = theme.AppName,
|
||||
Name = theme.Name,
|
||||
Options = theme.Options,
|
||||
Images = null
|
||||
@@ -142,12 +149,10 @@ namespace MediaBrowser.Server.Implementations.Themes
|
||||
|
||||
public InternalThemeImage GetImageImageInfo(string applicationName, string themeName, string imageName)
|
||||
{
|
||||
var themePath = GetThemePath(applicationName, themeName);
|
||||
var imagesPath = GetImagesPath(applicationName, themeName);
|
||||
|
||||
var fullPath = Path.Combine(themePath, imageName);
|
||||
|
||||
var file = new DirectoryInfo(themePath).EnumerateFiles("*", SearchOption.TopDirectoryOnly)
|
||||
.First(i => string.Equals(i.FullName, fullPath, StringComparison.OrdinalIgnoreCase));
|
||||
var file = new DirectoryInfo(imagesPath).EnumerateFiles("*", SearchOption.TopDirectoryOnly)
|
||||
.First(i => string.Equals(i.Name, imageName, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
var themeImage = GetThemeImage(file);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user