2013-05-17 03:03:52 +00:00
|
|
|
using System.IO;
|
2013-08-20 06:23:36 +00:00
|
|
|
using NLog;
|
|
|
|
using NzbDrone.Common;
|
2013-06-28 00:04:52 +00:00
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
2013-05-17 03:03:52 +00:00
|
|
|
|
2013-08-20 02:31:26 +00:00
|
|
|
namespace NzbDrone.Api.Frontend.Mappers
|
2013-05-17 03:03:52 +00:00
|
|
|
{
|
2013-08-20 06:23:36 +00:00
|
|
|
public class StaticResourceMapper : StaticResourceMapperBase
|
2013-05-17 03:03:52 +00:00
|
|
|
{
|
2013-07-05 04:43:28 +00:00
|
|
|
private readonly IAppFolderInfo _appFolderInfo;
|
2013-05-17 03:03:52 +00:00
|
|
|
|
2013-08-20 06:23:36 +00:00
|
|
|
public StaticResourceMapper(IAppFolderInfo appFolderInfo, IDiskProvider diskProvider, Logger logger)
|
|
|
|
: base(diskProvider, logger)
|
2013-05-17 03:03:52 +00:00
|
|
|
{
|
2013-07-05 04:43:28 +00:00
|
|
|
_appFolderInfo = appFolderInfo;
|
2013-05-17 03:03:52 +00:00
|
|
|
}
|
|
|
|
|
2013-08-20 06:23:36 +00:00
|
|
|
protected override string Map(string resourceUrl)
|
2013-05-17 03:03:52 +00:00
|
|
|
{
|
|
|
|
var path = resourceUrl.Replace('/', Path.DirectorySeparatorChar);
|
2013-07-24 06:26:10 +00:00
|
|
|
path = path.Trim(Path.DirectorySeparatorChar);
|
2013-05-17 03:03:52 +00:00
|
|
|
|
2013-08-20 02:31:26 +00:00
|
|
|
return Path.Combine(_appFolderInfo.StartUpFolder, "UI", path);
|
2013-05-17 03:03:52 +00:00
|
|
|
}
|
|
|
|
|
2013-08-20 06:23:36 +00:00
|
|
|
public override bool CanHandle(string resourceUrl)
|
2013-05-18 01:18:02 +00:00
|
|
|
{
|
2013-08-27 14:22:14 +00:00
|
|
|
return resourceUrl.StartsWith("/Content") || resourceUrl.EndsWith(".js") || resourceUrl.EndsWith(".css") || resourceUrl.EndsWith(".ico");
|
2013-05-18 01:18:02 +00:00
|
|
|
}
|
2013-05-17 03:03:52 +00:00
|
|
|
}
|
|
|
|
}
|