Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Merged
merged 1 commit into from

2 participants

@deepakaravindr
Collaborator

...d 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

@deepakaravindr deepakaravindr 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
9ded810
@deepakaravindr deepakaravindr merged commit bcf6635 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 16, 2014
  1. @deepakaravindr

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

    deepakaravindr authored
    …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
This page is out of date. Refresh to see the latest.
View
1  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>
View
1  src/NuGetGallery/Constants.cs
@@ -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";
View
24 src/NuGetGallery/Controllers/ApiController.cs
@@ -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()
View
1  src/NuGetGallery/NuGetGallery.csproj
@@ -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" />
Something went wrong with that request. Please try again.