The Free Software Media System - Server Backend & API
refined app themes
Luke Pulverentifb51f1e6f012
diff --git a/MediaBrowser.Api/AppThemeService.cs b/MediaBrowser.Api/AppThemeService.csindex d1819cce41..54141b3e22 100644--- a/MediaBrowser.Api/AppThemeService.cs+++ b/MediaBrowser.Api/AppThemeService.cs@@ -13,16 +13,16 @@ namespace MediaBrowser.Api[Api(Description = "Gets a list of available themes for an app")]public class GetAppThemes : IReturn<List<AppThemeInfo>>{- [ApiMember(Name = "ApplicationName", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]- public string ApplicationName { get; set; }+ [ApiMember(Name = "App", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]+ public string App { get; set; }}[Route("/Themes/Info", "GET")][Api(Description = "Gets an app theme")]public class GetAppTheme : IReturn<AppTheme>{- [ApiMember(Name = "ApplicationName", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]- public string ApplicationName { get; set; }+ [ApiMember(Name = "App", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]+ public string App { get; set; }[ApiMember(Name = "Name", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]public string Name { get; set; }@@ -32,11 +32,11 @@ namespace MediaBrowser.Api[Api(Description = "Gets an app theme")]public class GetAppThemeImage{- [ApiMember(Name = "ApplicationName", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]- public string ApplicationName { get; set; }+ [ApiMember(Name = "App", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]+ public string App { get; set; }- [ApiMember(Name = "ThemeName", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]- public string ThemeName { get; set; }+ [ApiMember(Name = "Theme", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]+ public string Theme { get; set; }[ApiMember(Name = "Name", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]public string Name { get; set; }@@ -64,14 +64,14 @@ namespace MediaBrowser.Apipublic object Get(GetAppThemes request){- var result = _themeManager.GetThemes(request.ApplicationName).ToList();+ var result = _themeManager.GetThemes(request.App).ToList();return ToOptimizedResult(result);}public object Get(GetAppTheme request){- var result = _themeManager.GetTheme(request.ApplicationName, request.Name);+ var result = _themeManager.GetTheme(request.App, request.Name);return ToOptimizedResult(result);}@@ -83,7 +83,7 @@ namespace MediaBrowser.Apipublic 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);diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.csindex daa52f5a01..2cdaef1ed8 100644--- a/MediaBrowser.Api/Images/ImageService.cs+++ b/MediaBrowser.Api/Images/ImageService.cs@@ -707,10 +707,11 @@ namespace MediaBrowser.Api.Imagesvar currentItem = item;var currentRequest = request;- var responseHeaders = new Dictionary<string, string>();-- responseHeaders.Add("transferMode.dlna.org", "Interactive");- responseHeaders.Add("realTimeInfo.dlna.org", "DLNA.ORG_TLAG=*");+ var responseHeaders = new Dictionary<string, string>+ {+ {"transferMode.dlna.org", "Interactive"},+ {"realTimeInfo.dlna.org", "DLNA.ORG_TLAG=*"}+ };return ToCachedResult(cacheGuid, originalFileImageDateModified, cacheDuration, () => new ImageWriter{diff --git a/MediaBrowser.Model/Themes/AppTheme.cs b/MediaBrowser.Model/Themes/AppTheme.csindex a0532854dc..a814fec336 100644--- a/MediaBrowser.Model/Themes/AppTheme.cs+++ b/MediaBrowser.Model/Themes/AppTheme.cs@@ -5,7 +5,7 @@ namespace MediaBrowser.Model.Themes{public class AppTheme{- public string ApplicationName { get; set; }+ public string AppName { get; set; }public string Name { get; set; }@@ -23,7 +23,7 @@ namespace MediaBrowser.Model.Themespublic class AppThemeInfo{- public string ApplicationName { get; set; }+ public string AppName { get; set; }public string Name { get; set; }}diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.csindex 4c21d2eb7a..8455d9f581 100644--- a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs+++ b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs@@ -238,8 +238,19 @@ namespace MediaBrowser.Server.Implementations.HttpServerreturn 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.HttpServerif (!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);}diff --git a/MediaBrowser.Server.Implementations/Themes/AppThemeManager.cs b/MediaBrowser.Server.Implementations/Themes/AppThemeManager.csindex ca792bcd34..9845f38674 100644--- a/MediaBrowser.Server.Implementations/Themes/AppThemeManager.cs+++ b/MediaBrowser.Server.Implementations/Themes/AppThemeManager.cs@@ -63,6 +63,11 @@ namespace MediaBrowser.Server.Implementations.Themesreturn 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.Themesvar 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.Themespublic 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 dynamicvar 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.Themespublic InternalThemeImage GetImageImageInfo(string applicationName, string themeName, string imageName){- var themePath = GetThemePath(applicationName, themeName);-- var fullPath = Path.Combine(themePath, imageName);+ var imagesPath = GetImagesPath(applicationName, themeName);- 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);