Permalink
Browse files

Added a ReadOnly.md which can be used as the service-alert if an Aler…

…t.md is not present AND if the gallery is in Read-Only Mode

1) Tested that if Alert.md is not present, and it is not read-only, no banner is shown
2) Tested that if Alert.md is not present, and it is in Read-Only mode, Read-Only mode banner is shown
3) Tested that if Alert.md is present, and it is not Read-Only mode, Alert banner is shown
4) Tested that if Alert.md is present, and it is Read-Only mode, still Alert banner is shown
  • Loading branch information...
1 parent c82ac28 commit 9ded8101718389b57a86060316e88580d64005a8 @deepakaravindr deepakaravindr committed Jul 16, 2014
@@ -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>
@@ -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";
@@ -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; }
@@ -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;
@@ -57,6 +60,7 @@ public partial class ApiController : AppController
SearchService = searchService;
AutoCuratePackage = autoCuratePackage;
StatusService = statusService;
+ _config = config;
}
public ApiController(
@@ -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;
}
@@ -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()
@@ -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" />

0 comments on commit 9ded810

Please sign in to comment.