From 35368f4d7c1df2afd22c8d93266fdad82008267e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=A8=D0=B8?= =?UTF-8?q?=D0=BC=D0=B0=D0=BD=D1=81=D0=BA=D0=B8=D0=B9?= Date: Sun, 22 Oct 2023 17:02:30 +0300 Subject: [PATCH] Make 500 Error page --- .editorconfig | 4 + Controllers/HomeController.cs | 36 +- Pages/IternalErrorPage.cshtml | 247 +++++++++ Pages/{ErrorPage.cshtml => NotFound.cshtml} | 3 +- ...ErrorPage.cshtml.cs => NotFound.cshtml.cs} | 0 Startup.cs | 15 +- wwwroot/css/500.css | 469 ++++++++++++++++++ yaflay.ru.sln | 5 + 8 files changed, 758 insertions(+), 21 deletions(-) create mode 100644 .editorconfig create mode 100644 Pages/IternalErrorPage.cshtml rename Pages/{ErrorPage.cshtml => NotFound.cshtml} (96%) rename Pages/{ErrorPage.cshtml.cs => NotFound.cshtml.cs} (100%) create mode 100644 wwwroot/css/500.css diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b2ad626 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +[*.cs] + +# CS8602: Разыменование вероятной пустой ссылки. +dotnet_diagnostic.CS8602.severity = none diff --git a/Controllers/HomeController.cs b/Controllers/HomeController.cs index b4bb9e7..9f4f624 100644 --- a/Controllers/HomeController.cs +++ b/Controllers/HomeController.cs @@ -1,6 +1,8 @@ using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.ModelBinding; using System.Text.Json; using System.Text.Json.Nodes; +using yaflay.ru.Pages; namespace yaflay.ru.Новая_папка { @@ -9,17 +11,21 @@ namespace yaflay.ru.Новая_папка { // GET: HomeController - private async Task getUrlFromGit(string baseUrl) + private async Task getUrlFromGit(string baseUrl) { try { HttpClient client = new(); HttpResponseMessage getter = await client.GetAsync("https://raw.githubusercontent.com/YaFlay/yaflay.ru/master/redirect_uris.json"); - await Console.Out.WriteLineAsync(await getter.Content.ReadAsStringAsync()); JsonNodeOptions jsonNodeOptions = new (); - JsonDocumentOptions jsonDocumentOptions = new(); - jsonDocumentOptions.AllowTrailingCommas = true; - JsonNode allFile = JsonNode.Parse(await getter.Content.ReadAsStringAsync(), jsonNodeOptions, jsonDocumentOptions); + JsonDocumentOptions jsonDocumentOptions = new() + { + AllowTrailingCommas = true + }; + JsonNode? allFile = JsonNode.Parse(await getter.Content.ReadAsStringAsync(), + nodeOptions: jsonNodeOptions, + documentOptions: jsonDocumentOptions); + ; return (string?)allFile[baseUrl]; } catch (Exception except) @@ -29,19 +35,21 @@ namespace yaflay.ru.Новая_папка } } - // GET: HomeController/Details/5 [HttpGet("{uri}")] - public async Task fromGitHub(string? uri) + public async Task FromGitHub(string uri) { - if (uri == "Robots.txt") { return Ok("User-Agent: * \n Disallow: /*"); } - - string? url = await getUrlFromGit(uri); - await Console.Out.WriteLineAsync(url == null ? "Null" : $"notNull {url}"); - return Redirect(url ?? "https://yaflay.ru/404"); + await Console.Out.WriteLineAsync($"New connected user: {HttpContext.Connection.RemoteIpAddress}"); + if (url != null) + { + return Redirect(url); + } + else + { + return Redirect("/404"); + } + } - - // GET: HomeController/Create } } diff --git a/Pages/IternalErrorPage.cshtml b/Pages/IternalErrorPage.cshtml new file mode 100644 index 0000000..284436c --- /dev/null +++ b/Pages/IternalErrorPage.cshtml @@ -0,0 +1,247 @@ +@page +@{ + ViewData["Title"] = "500 Error"; + Layout = null; +} + + + + + + Page not found + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ Woops!
Something went wrong :( +

+

+ Have you tried turning it off and on again? +

+ + +
+ + \ No newline at end of file diff --git a/Pages/ErrorPage.cshtml b/Pages/NotFound.cshtml similarity index 96% rename from Pages/ErrorPage.cshtml rename to Pages/NotFound.cshtml index e35da0d..e12fd6b 100644 --- a/Pages/ErrorPage.cshtml +++ b/Pages/NotFound.cshtml @@ -1,6 +1,5 @@ @page - - + diff --git a/Pages/ErrorPage.cshtml.cs b/Pages/NotFound.cshtml.cs similarity index 100% rename from Pages/ErrorPage.cshtml.cs rename to Pages/NotFound.cshtml.cs diff --git a/Startup.cs b/Startup.cs index fcfc50f..e54044a 100644 --- a/Startup.cs +++ b/Startup.cs @@ -18,7 +18,8 @@ namespace yaflay.ru .AddRazorPagesOptions(options => { options.Conventions.AddPageRoute("/RobotsTxt", "/Robots.txt"); - options.Conventions.AddPageRoute("/ErrorPage", "/404"); + options.Conventions.AddPageRoute("/NotFound", "/404"); + options.Conventions.AddPageRoute("/IternalErrorPage", "/500"); }); services.AddRouting(); services.AddRazorPages(); @@ -26,7 +27,8 @@ namespace yaflay.ru .AddRazorPagesOptions(options => { options.Conventions.AddPageRoute("/RobotsTxt", "/Robots.txt"); - options.Conventions.AddPageRoute("/ErrorPage", "/404"); + options.Conventions.AddPageRoute("/NotFound", "/404"); + options.Conventions.AddPageRoute("/IternalErrorPage", "/500"); }); //services.AddDirectoryBrowser(); @@ -38,15 +40,18 @@ namespace yaflay.ru { // Add services to the container. // app.Services.AddRazorPages(); - + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + //app.UseHsts(); + } // Configure the HTTP request pipeline. - app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); - + app.UseEndpoints(endpoints => { endpoints.MapRazorPages(); diff --git a/wwwroot/css/500.css b/wwwroot/css/500.css new file mode 100644 index 0000000..1988fc7 --- /dev/null +++ b/wwwroot/css/500.css @@ -0,0 +1,469 @@ +@import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap'); + +.main-error-page { + min-height: 600px; + margin: 0px auto; + width: auto; + max-width: 560px; + display: flex; + align-items: center; + justify-content: center; + flex-direction: column; +} + +.error-title { + max-width: 529px; + font-family: Roboto; + font-size: 38px; + font-weight: bold; + font-stretch: normal; + font-style: normal; + line-height: normal; + letter-spacing: normal; + text-align: center; + color: #4b4b62; + margin-bottom: 16px; +} + +.error-subtitle { + max-width: 568px; + font-family: Roboto; + font-size: 16px; + font-weight: normal; + font-stretch: normal; + font-style: normal; + line-height: 1.31; + letter-spacing: normal; + text-align: center; + color: #4b4b62; + margin-bottom: 24px; +} + +svg { + margin-bottom: 16px; +} + + +.full-torradeira { +} + +.torradeira { +} + +.pao-atras { + animation: leftright 1s alternate infinite; + transform-origin: center; +} + +.pao-frente { + animation: leftright 1s 0.3s alternate infinite; + transform-origin: center; +} + +.olho-esq { + animation: sad 2s alternate infinite; + transform-origin: center; +} + +.olho-dir { + animation: sad 2s alternate infinite; + transform-origin: center; +} + +.boca { + animation: sad 2s alternate infinite; + transform-origin: center; +} + +.raios { + -webkit-animation: flicker-4 4s linear infinite both; + animation: flicker-4 4s linear infinite both; +} + +.tomada { + -webkit-animation: vibrate-1 3s linear infinite both; + animation: vibrate-1 3s linear infinite both; +} + +.fio-500 { + -webkit-animation: vibrate-1 3s linear infinite both; + animation: vibrate-1 3s linear infinite both; +} + +.fio { + -webkit-animation: vibrate-1 3s linear infinite both; + animation: vibrate-1 3s linear infinite both; +} + +@keyframes scales { + from { + transform: scale(0.98); + } + + to { + transform: scale(1); + } +} + +/* ---------------------------------------------- + * Generated by Animista on 2020-4-1 14:58:16 + * Licensed under FreeBSD License. + * See http://animista.net/license for more info. + * w: http://animista.net, t: @cssanimista + * ---------------------------------------------- */ + +/** + * ---------------------------------------- + * animation flicker-4 + * ---------------------------------------- + */ +@-webkit-keyframes flicker-4 { + 0%, 100% { + opacity: 1; + } + + 31.98% { + opacity: 1; + } + + 32% { + opacity: 0; + } + + 32.8% { + opacity: 0; + } + + 32.82% { + opacity: 1; + } + + 34.98% { + opacity: 1; + } + + 35% { + opacity: 0; + } + + 35.7% { + opacity: 0; + } + + 35.72% { + opacity: 1; + } + + 36.98% { + opacity: 1; + } + + 37% { + opacity: 0; + } + + 37.6% { + opacity: 0; + } + + 37.62% { + opacity: 1; + } + + 67.98% { + opacity: 1; + } + + 68% { + opacity: 0; + } + + 68.4% { + opacity: 0; + } + + 68.42% { + opacity: 1; + } + + 95.98% { + opacity: 1; + } + + 96% { + opacity: 0; + } + + 96.7% { + opacity: 0; + } + + 96.72% { + opacity: 1; + } + + 98.98% { + opacity: 1; + } + + 99% { + opacity: 0; + } + + 99.6% { + opacity: 0; + } + + 99.62% { + opacity: 1; + } +} + +@keyframes flicker-4 { + 0%, 100% { + opacity: 1; + } + + 31.98% { + opacity: 1; + } + + 32% { + opacity: 0; + } + + 32.8% { + opacity: 0; + } + + 32.82% { + opacity: 1; + } + + 34.98% { + opacity: 1; + } + + 35% { + opacity: 0; + } + + 35.7% { + opacity: 0; + } + + 35.72% { + opacity: 1; + } + + 36.98% { + opacity: 1; + } + + 37% { + opacity: 0; + } + + 37.6% { + opacity: 0; + } + + 37.62% { + opacity: 1; + } + + 67.98% { + opacity: 1; + } + + 68% { + opacity: 0; + } + + 68.4% { + opacity: 0; + } + + 68.42% { + opacity: 1; + } + + 95.98% { + opacity: 1; + } + + 96% { + opacity: 0; + } + + 96.7% { + opacity: 0; + } + + 96.72% { + opacity: 1; + } + + 98.98% { + opacity: 1; + } + + 99% { + opacity: 0; + } + + 99.6% { + opacity: 0; + } + + 99.62% { + opacity: 1; + } +} + + +/* ---------------------------------------------- + * Generated by Animista on 2020-4-1 15:17:57 + * Licensed under FreeBSD License. + * See http://animista.net/license for more info. + * w: http://animista.net, t: @cssanimista + * ---------------------------------------------- */ + +/** + * ---------------------------------------- + * animation vibrate-1 + * ---------------------------------------- + */ +@-webkit-keyframes vibrate-1 { + 0% { + -webkit-transform: translate(0); + transform: translate(0); + } + + 20% { + -webkit-transform: translate(-2px, 2px); + transform: translate(-2px, 2px); + } + + 40% { + -webkit-transform: translate(-2px, -2px); + transform: translate(-2px, -2px); + } + + 60% { + -webkit-transform: translate(2px, 2px); + transform: translate(2px, 2px); + } + + 80% { + -webkit-transform: translate(2px, -2px); + transform: translate(2px, -2px); + } + + 100% { + -webkit-transform: translate(0); + transform: translate(0); + } +} + +@keyframes vibrate-1 { + 0% { + -webkit-transform: translate(0); + transform: translate(0); + } + + 20% { + -webkit-transform: translate(-2px, 2px); + transform: translate(-2px, 2px); + } + + 40% { + -webkit-transform: translate(-2px, -2px); + transform: translate(-2px, -2px); + } + + 60% { + -webkit-transform: translate(2px, 2px); + transform: translate(2px, 2px); + } + + 80% { + -webkit-transform: translate(2px, -2px); + transform: translate(2px, -2px); + } + + 100% { + -webkit-transform: translate(0); + transform: translate(0); + } +} + + + +/* ---------------------------------------------- + * Generated by Animista on 2020-4-1 15:42:45 + * Licensed under FreeBSD License. + * See http://animista.net/license for more info. + * w: http://animista.net, t: @cssanimista + * ---------------------------------------------- */ + +/** + * ---------------------------------------- + * animation wobble-ver-right + * ---------------------------------------- + */ +@-webkit-keyframes wobble-ver-right { + 0%, 100% { + -webkit-transform: translateY(0) rotate(0); + transform: translateY(0) rotate(0); + -webkit-transform-origin: 50% 50%; + transform-origin: 50% 50%; + } + + 15% { + -webkit-transform: translateY(-30px) rotate(6deg); + transform: translateY(-30px) rotate(6deg); + } + + 30% { + -webkit-transform: translateY(15px) rotate(-6deg); + transform: translateY(15px) rotate(-6deg); + } + + 45% { + -webkit-transform: translateY(-15px) rotate(3.6deg); + transform: translateY(-15px) rotate(3.6deg); + } + + 60% { + -webkit-transform: translateY(9px) rotate(-2.4deg); + transform: translateY(9px) rotate(-2.4deg); + } + + 75% { + -webkit-transform: translateY(-6px) rotate(1.2deg); + transform: translateY(-6px) rotate(1.2deg); + } +} + + +@keyframes sad { + 0% { + transform: rotateX(0deg) rotateY(0deg); + } + + 100% { + transform: rotateX(10deg) rotateY(5deg); + } +} + +@keyframes leftright { + + 0% { + transform: rotateZ( 0deg) + } + + 100% { + transform: rotateZ( -15deg) + } +} diff --git a/yaflay.ru.sln b/yaflay.ru.sln index 1b84d45..6d36628 100644 --- a/yaflay.ru.sln +++ b/yaflay.ru.sln @@ -5,6 +5,11 @@ VisualStudioVersion = 17.6.33723.286 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "yaflay.ru", "yaflay.ru.csproj", "{3AA2FE9B-D1AF-4B12-B090-7E4529BA40E0}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{82D95147-E21B-45B6-B636-A145A498D56E}" + ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU