From b368df8f00c12596f78704008635fa30329c3736 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Fri, 5 Nov 2021 09:16:50 +0330 Subject: [PATCH] #238 maintenance page --- GanjooRazor/Pages/Index.cshtml.cs | 10 +++++--- GanjooRazor/Pages/errors/503.cshtml | 38 +++++++++++++++++++++++++++++ GanjooRazor/appsettings.json | 3 ++- 3 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 GanjooRazor/Pages/errors/503.cshtml diff --git a/GanjooRazor/Pages/Index.cshtml.cs b/GanjooRazor/Pages/Index.cshtml.cs index ea530f03..59796b11 100644 --- a/GanjooRazor/Pages/Index.cshtml.cs +++ b/GanjooRazor/Pages/Index.cshtml.cs @@ -30,7 +30,7 @@ namespace GanjooRazor.Pages /// /// configration file reader (appsettings.json) /// - private readonly IConfiguration _configuration; + private readonly IConfiguration Configuration; /// /// HttpClient instance @@ -53,7 +53,7 @@ namespace GanjooRazor.Pages IMemoryCache memoryCache ) { - _configuration = configuration; + Configuration = configuration; _httpClient = httpClient; _memoryCache = memoryCache; } @@ -511,6 +511,10 @@ namespace GanjooRazor.Pages /// public async Task OnGetAsync() { + if(bool.Parse(Configuration["MaintenanceMode"])) + { + return StatusCode(503); + } LastError = ""; LoggedIn = !string.IsNullOrEmpty(Request.Cookies["Token"]); CanEdit = Request.Cookies["CanEdit"] == "True"; @@ -519,7 +523,7 @@ namespace GanjooRazor.Pages IsPoemPage = false; IsHomePage = Request.Path == "/"; PinterestUrl = Request.Query["pinterest_url"]; - ViewData["GoogleAnalyticsCode"] = _configuration["GoogleAnalyticsCode"]; + ViewData["GoogleAnalyticsCode"] = Configuration["GoogleAnalyticsCode"]; GoogleBreadCrumbList breadCrumbList = new GoogleBreadCrumbList(); Banner = null; diff --git a/GanjooRazor/Pages/errors/503.cshtml b/GanjooRazor/Pages/errors/503.cshtml new file mode 100644 index 00000000..7ddc9243 --- /dev/null +++ b/GanjooRazor/Pages/errors/503.cshtml @@ -0,0 +1,38 @@ +@page + +@{ + Layout = null; + ViewData["Title"] = "در حال به‌روز رسانی ..."; +} + + + + + + + + + @ViewData["Title"] + + + + + + + + + +
+

گنجور

+
+ +

گنجور در حال به روزرسانی است

+ + +

+ گنجور در حال به‌روزرسانی است. لطفاً لحظاتی دیگر مجدداً تلاش کنید. +

+ + + + diff --git a/GanjooRazor/appsettings.json b/GanjooRazor/appsettings.json index 367a6d76..1565f251 100644 --- a/GanjooRazor/appsettings.json +++ b/GanjooRazor/appsettings.json @@ -11,5 +11,6 @@ "APIRoot": "http://localhost:3439", "GlobalAPIRoot": "http://localhost:3439", "SiteUrl": "http://localhost:33081", - "ReadOnlyMode": "False" + "ReadOnlyMode": "False", + "MaintenanceMode": "False" }