diff --git a/src/NzbDrone.Api/Frontend/Mappers/RobotsTxtMapper.cs b/src/NzbDrone.Api/Frontend/Mappers/RobotsTxtMapper.cs new file mode 100644 index 000000000..75a169912 --- /dev/null +++ b/src/NzbDrone.Api/Frontend/Mappers/RobotsTxtMapper.cs @@ -0,0 +1,31 @@ +using System; +using System.IO; +using NLog; +using NzbDrone.Common.Disk; +using NzbDrone.Common.EnvironmentInfo; + +namespace NzbDrone.Api.Frontend.Mappers +{ + public class RobotsTxtMapper : StaticResourceMapperBase + { + private readonly IAppFolderInfo _appFolderInfo; + + public RobotsTxtMapper(IAppFolderInfo appFolderInfo, IDiskProvider diskProvider, Logger logger) + : base(diskProvider, logger) + { + _appFolderInfo = appFolderInfo; + } + + public override string Map(string resourceUrl) + { + var path = Path.Combine("Content", "robots.txt"); + + return Path.Combine(_appFolderInfo.StartUpFolder, "UI", path); + } + + public override bool CanHandle(string resourceUrl) + { + return resourceUrl.Equals("/robots.txt"); + } + } +} diff --git a/src/NzbDrone.Api/NzbDrone.Api.csproj b/src/NzbDrone.Api/NzbDrone.Api.csproj index fa76d6825..adb826917 100644 --- a/src/NzbDrone.Api/NzbDrone.Api.csproj +++ b/src/NzbDrone.Api/NzbDrone.Api.csproj @@ -100,6 +100,7 @@ + diff --git a/src/UI/Content/robots.txt b/src/UI/Content/robots.txt new file mode 100644 index 000000000..77470cb39 --- /dev/null +++ b/src/UI/Content/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: / \ No newline at end of file