Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a ReadOnly.md which can be used as the service-alert if an Alert.m... #2253

Merged
merged 1 commit into from Jul 16, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/NuGetGallery/App_Data/Files/Content/ReadOnly.md
@@ -0,0 +1 @@
<div class="banner-warning">The site is undergoing maintenance and is in read-only mode. Follow <a href="http://twitter.com/nuget">@nuget</a> on Twitter for updates.</div>
1 change: 1 addition & 0 deletions src/NuGetGallery/Constants.cs
Expand Up @@ -44,6 +44,7 @@ public static class ContentNames
{ {
public static readonly string Home = "Home"; public static readonly string Home = "Home";
public static readonly string Alert = "Alert"; public static readonly string Alert = "Alert";
public static readonly string ReadOnly = "ReadOnly";
public static readonly string TermsOfUse = "Terms-Of-Use"; public static readonly string TermsOfUse = "Terms-Of-Use";
public static readonly string PrivacyPolicy = "Privacy-Policy"; public static readonly string PrivacyPolicy = "Privacy-Policy";
public static readonly string Team = "Team"; public static readonly string Team = "Team";
Expand Down
24 changes: 20 additions & 4 deletions src/NuGetGallery/Controllers/ApiController.cs
Expand Up @@ -15,11 +15,13 @@
using NuGetGallery.Authentication; using NuGetGallery.Authentication;
using NuGetGallery.Filters; using NuGetGallery.Filters;
using NuGetGallery.Packaging; using NuGetGallery.Packaging;
using NuGetGallery.Configuration;


namespace NuGetGallery namespace NuGetGallery
{ {
public partial class ApiController : AppController public partial class ApiController : AppController
{ {
private readonly IAppConfiguration _config;
public IEntitiesContext EntitiesContext { get; set; } public IEntitiesContext EntitiesContext { get; set; }
public INuGetExeDownloaderService NugetExeDownloaderService { get; set; } public INuGetExeDownloaderService NugetExeDownloaderService { get; set; }
public IPackageFileService PackageFileService { get; set; } public IPackageFileService PackageFileService { get; set; }
Expand All @@ -44,7 +46,8 @@ public partial class ApiController : AppController
IIndexingService indexingService, IIndexingService indexingService,
ISearchService searchService, ISearchService searchService,
IAutomaticallyCuratePackageCommand autoCuratePackage, IAutomaticallyCuratePackageCommand autoCuratePackage,
IStatusService statusService) IStatusService statusService,
IAppConfiguration config)
{ {
EntitiesContext = entitiesContext; EntitiesContext = entitiesContext;
PackageService = packageService; PackageService = packageService;
Expand All @@ -57,6 +60,7 @@ public partial class ApiController : AppController
SearchService = searchService; SearchService = searchService;
AutoCuratePackage = autoCuratePackage; AutoCuratePackage = autoCuratePackage;
StatusService = statusService; StatusService = statusService;
_config = config;
} }


public ApiController( public ApiController(
Expand All @@ -70,8 +74,9 @@ public partial class ApiController : AppController
ISearchService searchService, ISearchService searchService,
IAutomaticallyCuratePackageCommand autoCuratePackage, IAutomaticallyCuratePackageCommand autoCuratePackage,
IStatusService statusService, IStatusService statusService,
IStatisticsService statisticsService) IStatisticsService statisticsService,
: this(entitiesContext, packageService, packageFileService, userService, nugetExeDownloaderService, contentService, indexingService, searchService, autoCuratePackage, statusService) IAppConfiguration config)
: this(entitiesContext, packageService, packageFileService, userService, nugetExeDownloaderService, contentService, indexingService, searchService, autoCuratePackage, statusService, config)
{ {
StatisticsService = statisticsService; StatisticsService = statisticsService;
} }
Expand Down Expand Up @@ -336,8 +341,19 @@ public virtual ActionResult PublishPackage(string id, string version)


public virtual async Task<ActionResult> ServiceAlert() public virtual async Task<ActionResult> ServiceAlert()
{ {
string alertString = null;
var alert = await ContentService.GetContentItemAsync(Constants.ContentNames.Alert, TimeSpan.Zero); var alert = await ContentService.GetContentItemAsync(Constants.ContentNames.Alert, TimeSpan.Zero);
return Content(alert == null ? (string)null : alert.ToString(), "text/html"); if (alert != null)
{
alertString = alert.ToString();
}

if (String.IsNullOrEmpty(alertString) && _config.ReadOnlyMode)
{
var readOnly = await ContentService.GetContentItemAsync(Constants.ContentNames.ReadOnly, TimeSpan.Zero);
alertString = (readOnly == null) ? (string)null : readOnly.ToString();
}
return Content(alertString, "text/html");
} }


public virtual async Task<ActionResult> Team() public virtual async Task<ActionResult> Team()
Expand Down
1 change: 1 addition & 0 deletions src/NuGetGallery/NuGetGallery.csproj
Expand Up @@ -963,6 +963,7 @@
<Compile Include="RequestModels\ModifyCuratedPackageRequest.cs" /> <Compile Include="RequestModels\ModifyCuratedPackageRequest.cs" />
<Compile Include="RequestModels\CreateCuratedPackageRequest.cs" /> <Compile Include="RequestModels\CreateCuratedPackageRequest.cs" />
<Compile Include="RequestModels\VerifyPackageRequest.cs" /> <Compile Include="RequestModels\VerifyPackageRequest.cs" />
<Content Include="App_Data\Files\Content\ReadOnly.md" />
<None Include="Scripts\jquery-1.11.0.intellisense.js" /> <None Include="Scripts\jquery-1.11.0.intellisense.js" />
<Content Include="Scripts\jquery-1.11.0.js" /> <Content Include="Scripts\jquery-1.11.0.js" />
<Content Include="Scripts\jquery-1.11.0.min.js" /> <Content Include="Scripts\jquery-1.11.0.min.js" />
Expand Down