forked from MediaBrowser/Emby.Plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
130 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using MediaBrowser.Controller.Net; | ||
using MediaBrowser.Model.Logging; | ||
using MediaBrowser.Model.Services; | ||
using System.IO; | ||
using System; | ||
using System.Threading.Tasks; | ||
using MediaBrowser.Model.Net; | ||
|
||
namespace MovieOrganizer.Html | ||
{ | ||
[Route("/web/components/fileorganizer/fileorganizer.js", "GET")] | ||
[Route("/web/components/fileorganizer/fileorganizer.template.html", "GET")] | ||
public class GetStaticResource | ||
{ | ||
} | ||
|
||
public class StaticFileServer : IService, IRequiresRequest | ||
{ | ||
private readonly ILogger _logger; | ||
|
||
/// <summary> | ||
/// Gets or sets the HTTP result factory. | ||
/// </summary> | ||
/// <value>The HTTP result factory.</value> | ||
private readonly IHttpResultFactory _resultFactory; | ||
|
||
/// <summary> | ||
/// Gets or sets the request context. | ||
/// </summary> | ||
/// <value>The request context.</value> | ||
public IRequest Request { get; set; } | ||
|
||
public StaticFileServer(ILogManager logManager, IHttpResultFactory resultFactory) | ||
{ | ||
_logger = logManager.GetLogger(GetType().Name); | ||
_resultFactory = resultFactory; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the specified request. | ||
/// </summary> | ||
/// <param name="request">The request.</param> | ||
/// <returns>System.Object.</returns> | ||
public async Task<object> Get(GetStaticResource request) | ||
{ | ||
var path = Request.PathInfo; | ||
|
||
var contentType = MimeTypes.GetMimeType(path); | ||
|
||
MemoryStream resultStream = null; | ||
|
||
if (path.Contains("/components/fileorganizer/fileorganizer.js")) | ||
{ | ||
resultStream = HtmlHelper.OrganizerScript; | ||
} | ||
else if (path.Contains("/components/fileorganizer/fileorganizer.template.html")) | ||
{ | ||
resultStream = HtmlHelper.OrganizerTemplate; | ||
} | ||
|
||
if (resultStream != null) | ||
{ | ||
resultStream = new MemoryStream(resultStream.GetBuffer()); | ||
} | ||
|
||
return _resultFactory.GetResult(resultStream, contentType); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters