Skip to content

Commit

Permalink
Merge pull request #2253 from NuGet/daravind/ReadOnlyAlert
Browse files Browse the repository at this point in the history
Added a ReadOnly.md which can be used as the service-alert if an Alert.m...
  • Loading branch information
deepakaravindr committed Jul 16, 2014
2 parents c82ac28 + 9ded810 commit bcf6635
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
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 Alert = "Alert";
public static readonly string ReadOnly = "ReadOnly";
public static readonly string TermsOfUse = "Terms-Of-Use";
public static readonly string PrivacyPolicy = "Privacy-Policy";
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.Filters;
using NuGetGallery.Packaging;
using NuGetGallery.Configuration;

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

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

public virtual async Task<ActionResult> ServiceAlert()
{
string alertString = null;
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()
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\CreateCuratedPackageRequest.cs" />
<Compile Include="RequestModels\VerifyPackageRequest.cs" />
<Content Include="App_Data\Files\Content\ReadOnly.md" />
<None Include="Scripts\jquery-1.11.0.intellisense.js" />
<Content Include="Scripts\jquery-1.11.0.js" />
<Content Include="Scripts\jquery-1.11.0.min.js" />
Expand Down

0 comments on commit bcf6635

Please sign in to comment.