2
0
Luke Pulverenti 11 жил өмнө
parent
commit
fb51f1e6f0

+ 11 - 11
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.Api
 
         public 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.Api
 
         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);
 

+ 5 - 4
MediaBrowser.Api/Images/ImageService.cs

@@ -707,10 +707,11 @@ namespace MediaBrowser.Api.Images
             var 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
             {

+ 2 - 2
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.Themes
 
     public class AppThemeInfo
     {
-        public string ApplicationName { get; set; }
+        public string AppName { get; set; }
         
         public string Name { get; set; }
     }

+ 15 - 4
MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs

@@ -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);
         }
 

+ 13 - 8
MediaBrowser.Server.Implementations/Themes/AppThemeManager.cs

@@ -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 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);