2012-07-12 06:55:27 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Reactive.Linq;
|
2012-07-13 03:50:50 +00:00
|
|
|
|
using MediaBrowser.Common.Net.Handlers;
|
2012-07-12 06:55:27 +00:00
|
|
|
|
using MediaBrowser.Common.Plugins;
|
|
|
|
|
using MediaBrowser.Controller;
|
2012-07-14 20:45:11 +00:00
|
|
|
|
using MediaBrowser.HtmlBrowser.Handlers;
|
2012-07-12 06:55:27 +00:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.HtmlBrowser
|
|
|
|
|
{
|
|
|
|
|
public class Plugin : BasePlugin<BasePluginConfiguration>
|
|
|
|
|
{
|
|
|
|
|
protected override void InitInternal()
|
|
|
|
|
{
|
2012-07-13 03:50:50 +00:00
|
|
|
|
var httpServer = Kernel.Instance.HttpServer;
|
|
|
|
|
|
2012-07-14 20:45:11 +00:00
|
|
|
|
httpServer.Where(ctx => ctx.LocalPath.IndexOf("/browser/", StringComparison.OrdinalIgnoreCase) != -1).Subscribe(ctx =>
|
|
|
|
|
{
|
|
|
|
|
string localPath = ctx.LocalPath;
|
|
|
|
|
string srch = "/browser/";
|
2012-07-13 03:50:50 +00:00
|
|
|
|
|
2012-07-14 20:45:11 +00:00
|
|
|
|
int index = localPath.IndexOf(srch, StringComparison.OrdinalIgnoreCase);
|
2012-07-13 03:50:50 +00:00
|
|
|
|
|
2012-07-14 20:45:11 +00:00
|
|
|
|
string resource = localPath.Substring(index + srch.Length);
|
|
|
|
|
|
|
|
|
|
ctx.Respond(new EmbeddedResourceHandler(ctx, resource));
|
|
|
|
|
|
|
|
|
|
});
|
2012-07-12 06:55:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|