mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
refined app themes
This commit is contained in:
parent
c177de9407
commit
fb51f1e6f0
@ -13,16 +13,16 @@ namespace MediaBrowser.Api
|
|||||||
[Api(Description = "Gets a list of available themes for an app")]
|
[Api(Description = "Gets a list of available themes for an app")]
|
||||||
public class GetAppThemes : IReturn<List<AppThemeInfo>>
|
public class GetAppThemes : IReturn<List<AppThemeInfo>>
|
||||||
{
|
{
|
||||||
[ApiMember(Name = "ApplicationName", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
[ApiMember(Name = "App", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||||
public string ApplicationName { get; set; }
|
public string App { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Route("/Themes/Info", "GET")]
|
[Route("/Themes/Info", "GET")]
|
||||||
[Api(Description = "Gets an app theme")]
|
[Api(Description = "Gets an app theme")]
|
||||||
public class GetAppTheme : IReturn<AppTheme>
|
public class GetAppTheme : IReturn<AppTheme>
|
||||||
{
|
{
|
||||||
[ApiMember(Name = "ApplicationName", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
[ApiMember(Name = "App", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||||
public string ApplicationName { get; set; }
|
public string App { get; set; }
|
||||||
|
|
||||||
[ApiMember(Name = "Name", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
[ApiMember(Name = "Name", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
@ -32,11 +32,11 @@ namespace MediaBrowser.Api
|
|||||||
[Api(Description = "Gets an app theme")]
|
[Api(Description = "Gets an app theme")]
|
||||||
public class GetAppThemeImage
|
public class GetAppThemeImage
|
||||||
{
|
{
|
||||||
[ApiMember(Name = "ApplicationName", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
[ApiMember(Name = "App", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||||
public string ApplicationName { get; set; }
|
public string App { get; set; }
|
||||||
|
|
||||||
[ApiMember(Name = "ThemeName", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
[ApiMember(Name = "Theme", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||||
public string ThemeName { get; set; }
|
public string Theme { get; set; }
|
||||||
|
|
||||||
[ApiMember(Name = "Name", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
[ApiMember(Name = "Name", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
@ -64,14 +64,14 @@ namespace MediaBrowser.Api
|
|||||||
|
|
||||||
public object Get(GetAppThemes request)
|
public object Get(GetAppThemes request)
|
||||||
{
|
{
|
||||||
var result = _themeManager.GetThemes(request.ApplicationName).ToList();
|
var result = _themeManager.GetThemes(request.App).ToList();
|
||||||
|
|
||||||
return ToOptimizedResult(result);
|
return ToOptimizedResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object Get(GetAppTheme request)
|
public object Get(GetAppTheme request)
|
||||||
{
|
{
|
||||||
var result = _themeManager.GetTheme(request.ApplicationName, request.Name);
|
var result = _themeManager.GetTheme(request.App, request.Name);
|
||||||
|
|
||||||
return ToOptimizedResult(result);
|
return ToOptimizedResult(result);
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ namespace MediaBrowser.Api
|
|||||||
|
|
||||||
public object Get(GetAppThemeImage request)
|
public object Get(GetAppThemeImage request)
|
||||||
{
|
{
|
||||||
var info = _themeManager.GetImageImageInfo(request.ApplicationName, request.ThemeName, request.Name);
|
var info = _themeManager.GetImageImageInfo(request.App, request.Theme, request.Name);
|
||||||
|
|
||||||
var cacheGuid = new Guid(info.CacheTag);
|
var cacheGuid = new Guid(info.CacheTag);
|
||||||
|
|
||||||
|
@ -707,10 +707,11 @@ namespace MediaBrowser.Api.Images
|
|||||||
var currentItem = item;
|
var currentItem = item;
|
||||||
var currentRequest = request;
|
var currentRequest = request;
|
||||||
|
|
||||||
var responseHeaders = new Dictionary<string, string>();
|
var responseHeaders = new Dictionary<string, string>
|
||||||
|
{
|
||||||
responseHeaders.Add("transferMode.dlna.org", "Interactive");
|
{"transferMode.dlna.org", "Interactive"},
|
||||||
responseHeaders.Add("realTimeInfo.dlna.org", "DLNA.ORG_TLAG=*");
|
{"realTimeInfo.dlna.org", "DLNA.ORG_TLAG=*"}
|
||||||
|
};
|
||||||
|
|
||||||
return ToCachedResult(cacheGuid, originalFileImageDateModified, cacheDuration, () => new ImageWriter
|
return ToCachedResult(cacheGuid, originalFileImageDateModified, cacheDuration, () => new ImageWriter
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@ namespace MediaBrowser.Model.Themes
|
|||||||
{
|
{
|
||||||
public class AppTheme
|
public class AppTheme
|
||||||
{
|
{
|
||||||
public string ApplicationName { get; set; }
|
public string AppName { get; set; }
|
||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ namespace MediaBrowser.Model.Themes
|
|||||||
|
|
||||||
public class AppThemeInfo
|
public class AppThemeInfo
|
||||||
{
|
{
|
||||||
public string ApplicationName { get; set; }
|
public string AppName { get; set; }
|
||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -238,8 +238,19 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
|||||||
return hasOptions;
|
return hasOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IHasOptions httpResult;
|
||||||
|
|
||||||
|
var stream = result as Stream;
|
||||||
|
|
||||||
|
if (stream != null)
|
||||||
|
{
|
||||||
|
httpResult = new StreamWriter(stream, contentType, _logger);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// Otherwise wrap into an HttpResult
|
// Otherwise wrap into an HttpResult
|
||||||
var httpResult = new HttpResult(result, contentType ?? "text/html", HttpStatusCode.NotModified);
|
httpResult = new HttpResult(result, contentType ?? "text/html", HttpStatusCode.NotModified);
|
||||||
|
}
|
||||||
|
|
||||||
AddResponseHeaders(httpResult, responseHeaders);
|
AddResponseHeaders(httpResult, responseHeaders);
|
||||||
|
|
||||||
|
@ -63,6 +63,11 @@ namespace MediaBrowser.Server.Implementations.Themes
|
|||||||
return Path.Combine(GetThemesPath(applicationName), name);
|
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)
|
public IEnumerable<AppThemeInfo> GetThemes(string applicationName)
|
||||||
{
|
{
|
||||||
var path = GetThemesPath(applicationName);
|
var path = GetThemesPath(applicationName);
|
||||||
@ -97,9 +102,11 @@ namespace MediaBrowser.Server.Implementations.Themes
|
|||||||
var themePath = GetThemePath(applicationName, name);
|
var themePath = GetThemePath(applicationName, name);
|
||||||
var file = Path.Combine(themePath, "theme.json");
|
var file = Path.Combine(themePath, "theme.json");
|
||||||
|
|
||||||
|
var imagesPath = GetImagesPath(applicationName, name);
|
||||||
|
|
||||||
var theme = _json.DeserializeFromFile<AppTheme>(file);
|
var theme = _json.DeserializeFromFile<AppTheme>(file);
|
||||||
|
|
||||||
theme.Images = new DirectoryInfo(themePath)
|
theme.Images = new DirectoryInfo(imagesPath)
|
||||||
.EnumerateFiles("*", SearchOption.TopDirectoryOnly)
|
.EnumerateFiles("*", SearchOption.TopDirectoryOnly)
|
||||||
.Where(i => _supportedImageExtensions.Contains(i.Extension, StringComparer.OrdinalIgnoreCase))
|
.Where(i => _supportedImageExtensions.Contains(i.Extension, StringComparer.OrdinalIgnoreCase))
|
||||||
.Select(GetThemeImage)
|
.Select(GetThemeImage)
|
||||||
@ -123,7 +130,7 @@ namespace MediaBrowser.Server.Implementations.Themes
|
|||||||
|
|
||||||
public void SaveTheme(AppTheme theme)
|
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");
|
var file = Path.Combine(themePath, "theme.json");
|
||||||
|
|
||||||
Directory.CreateDirectory(themePath);
|
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
|
// Clone it so that we don't serialize all the images - they're always dynamic
|
||||||
var clone = new AppTheme
|
var clone = new AppTheme
|
||||||
{
|
{
|
||||||
ApplicationName = theme.ApplicationName,
|
AppName = theme.AppName,
|
||||||
Name = theme.Name,
|
Name = theme.Name,
|
||||||
Options = theme.Options,
|
Options = theme.Options,
|
||||||
Images = null
|
Images = null
|
||||||
@ -142,12 +149,10 @@ namespace MediaBrowser.Server.Implementations.Themes
|
|||||||
|
|
||||||
public InternalThemeImage GetImageImageInfo(string applicationName, string themeName, string imageName)
|
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(imagesPath).EnumerateFiles("*", SearchOption.TopDirectoryOnly)
|
||||||
|
.First(i => string.Equals(i.Name, imageName, StringComparison.OrdinalIgnoreCase));
|
||||||
var file = new DirectoryInfo(themePath).EnumerateFiles("*", SearchOption.TopDirectoryOnly)
|
|
||||||
.First(i => string.Equals(i.FullName, fullPath, StringComparison.OrdinalIgnoreCase));
|
|
||||||
|
|
||||||
var themeImage = GetThemeImage(file);
|
var themeImage = GetThemeImage(file);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user