From 4bccc3a011254ccb4f0b50380ac6abe6f1440b09 Mon Sep 17 00:00:00 2001 From: neroduckale Date: Wed, 13 Dec 2023 02:51:54 +0500 Subject: [PATCH 01/14] Initial commit --- LICENSE | 9 +++++++++ README.md | 3 +++ 2 files changed, 12 insertions(+) create mode 100644 LICENSE create mode 100644 README.md diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..55cc528 --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2023 neroduckale + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..2573984 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# nrdkwebsite + +просто мой вебсайт \ No newline at end of file From b48b36ae12e61abe961acd6764560c093a933f7f Mon Sep 17 00:00:00 2001 From: neroduckale Date: Wed, 13 Dec 2023 03:17:50 +0500 Subject: [PATCH 02/14] =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=BC=D0=B8=D1=82=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=80=D1=83=D1=81=D1=81=D0=BA=D0=BE=D0=BC=20?= =?UTF-8?q?=D1=8F=D0=B7=D1=8B=D0=BA=D0=B5=20=D0=B2=20=D0=BA=D0=BE=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=BE=D0=BC=20=D1=8F=20=D0=BC=D0=BE=D0=B3=D1=83=20?= =?UTF-8?q?=D0=BF=D0=B8=D1=81=D0=B0=D1=82=D1=8C=20=D0=B2=D1=81=D0=B5=20?= =?UTF-8?q?=D1=87=D1=82=D0=BE=20=D1=85=D0=BE=D1=87=D1=83=20=D0=B8=20=D0=BC?= =?UTF-8?q?=D0=BD=D0=B5=20=D0=BD=D0=B8=D0=BA=D1=82=D0=BE=20=D0=BD=D0=B5=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=BF=D1=80=D0=B5=D1=82=D0=B8=D1=82.=20=D0=B2?= =?UTF-8?q?=D1=85=D0=BE=D0=B4=D0=BD=D1=8B=D0=B9=20=D0=BA=D0=BE=D0=BC=D0=BC?= =?UTF-8?q?=D0=B8=D1=82=20=E2=84=961?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nrdkwebsite/DatabaseHandler.cs | 32 + nrdkwebsite/Pages/_ViewImports.cshtml | 3 + nrdkwebsite/Pages/_ViewStart.cshtml | 4 + nrdkwebsite/Pages/about.cshtml | 7 + nrdkwebsite/Pages/about.cshtml.cs | 19 + nrdkwebsite/Pages/error.cshtml | 26 + nrdkwebsite/Pages/error.cshtml.cs | 26 + nrdkwebsite/Pages/errors/404.cshtml | 8 + nrdkwebsite/Pages/errors/404.cshtml.cs | 12 + nrdkwebsite/Pages/index.cshtml | 10 + nrdkwebsite/Pages/index.cshtml.cs | 20 + nrdkwebsite/Pages/layout.cshtml | 35 + nrdkwebsite/Pages/users.cshtml | 16 + nrdkwebsite/Pages/users.cshtml.cs | 11 + nrdkwebsite/Pages/ygolek.cshtml | 6 + nrdkwebsite/Pages/ygolek.cshtml.cs | 11 + nrdkwebsite/Program.cs | 60 + nrdkwebsite/User.cs | 15 + nrdkwebsite/wwwroot/css/style.css | 38 + nrdkwebsite/wwwroot/favicon.ico | Bin 0 -> 5430 bytes nrdkwebsite/wwwroot/js/site.js | 35 + .../jquery-validation-unobtrusive/LICENSE.txt | 23 + .../jquery.validate.unobtrusive.js | 435 + .../jquery.validate.unobtrusive.min.js | 8 + .../wwwroot/lib/jquery-validation/LICENSE.md | 22 + .../dist/additional-methods.js | 1158 ++ .../dist/additional-methods.min.js | 4 + .../jquery-validation/dist/jquery.validate.js | 1601 +++ .../dist/jquery.validate.min.js | 4 + nrdkwebsite/wwwroot/lib/jquery/LICENSE.txt | 21 + nrdkwebsite/wwwroot/lib/jquery/dist/jquery.js | 10881 ++++++++++++++++ .../wwwroot/lib/jquery/dist/jquery.min.js | 2 + .../wwwroot/lib/jquery/dist/jquery.min.map | 1 + nrdkwebsite/wwwroot/ygolek.jpg | Bin 0 -> 57938 bytes 34 files changed, 14554 insertions(+) create mode 100644 nrdkwebsite/DatabaseHandler.cs create mode 100644 nrdkwebsite/Pages/_ViewImports.cshtml create mode 100644 nrdkwebsite/Pages/_ViewStart.cshtml create mode 100644 nrdkwebsite/Pages/about.cshtml create mode 100644 nrdkwebsite/Pages/about.cshtml.cs create mode 100644 nrdkwebsite/Pages/error.cshtml create mode 100644 nrdkwebsite/Pages/error.cshtml.cs create mode 100644 nrdkwebsite/Pages/errors/404.cshtml create mode 100644 nrdkwebsite/Pages/errors/404.cshtml.cs create mode 100644 nrdkwebsite/Pages/index.cshtml create mode 100644 nrdkwebsite/Pages/index.cshtml.cs create mode 100644 nrdkwebsite/Pages/layout.cshtml create mode 100644 nrdkwebsite/Pages/users.cshtml create mode 100644 nrdkwebsite/Pages/users.cshtml.cs create mode 100644 nrdkwebsite/Pages/ygolek.cshtml create mode 100644 nrdkwebsite/Pages/ygolek.cshtml.cs create mode 100644 nrdkwebsite/Program.cs create mode 100644 nrdkwebsite/User.cs create mode 100644 nrdkwebsite/wwwroot/css/style.css create mode 100644 nrdkwebsite/wwwroot/favicon.ico create mode 100644 nrdkwebsite/wwwroot/js/site.js create mode 100644 nrdkwebsite/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt create mode 100644 nrdkwebsite/wwwroot/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js create mode 100644 nrdkwebsite/wwwroot/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js create mode 100644 nrdkwebsite/wwwroot/lib/jquery-validation/LICENSE.md create mode 100644 nrdkwebsite/wwwroot/lib/jquery-validation/dist/additional-methods.js create mode 100644 nrdkwebsite/wwwroot/lib/jquery-validation/dist/additional-methods.min.js create mode 100644 nrdkwebsite/wwwroot/lib/jquery-validation/dist/jquery.validate.js create mode 100644 nrdkwebsite/wwwroot/lib/jquery-validation/dist/jquery.validate.min.js create mode 100644 nrdkwebsite/wwwroot/lib/jquery/LICENSE.txt create mode 100644 nrdkwebsite/wwwroot/lib/jquery/dist/jquery.js create mode 100644 nrdkwebsite/wwwroot/lib/jquery/dist/jquery.min.js create mode 100644 nrdkwebsite/wwwroot/lib/jquery/dist/jquery.min.map create mode 100644 nrdkwebsite/wwwroot/ygolek.jpg diff --git a/nrdkwebsite/DatabaseHandler.cs b/nrdkwebsite/DatabaseHandler.cs new file mode 100644 index 0000000..d8f16d6 --- /dev/null +++ b/nrdkwebsite/DatabaseHandler.cs @@ -0,0 +1,32 @@ +using Microsoft.AspNetCore.Identity; +using Microsoft.EntityFrameworkCore; + +namespace nrdkwebsite; + +public sealed class DatabaseHandler : DbContext +{ + public DbSet users { get; set; } = null!; + public DatabaseHandler(DbContextOptions options) : base(options) + { + + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity(entity => + { + entity.Property(u => u.nickname) + .HasColumnName("nickname") + .HasColumnType("varchar(100)") + .ValueGeneratedOnAdd(); + entity.Property(u => u.id) + .HasColumnName("id") + .HasColumnType("int") + .ValueGeneratedOnAdd(); + entity.Property(u => u.mast) + .HasColumnName("mast") + .HasColumnType("varchar(20)") + .ValueGeneratedOnAdd(); + }); + } +} \ No newline at end of file diff --git a/nrdkwebsite/Pages/_ViewImports.cshtml b/nrdkwebsite/Pages/_ViewImports.cshtml new file mode 100644 index 0000000..f90b56a --- /dev/null +++ b/nrdkwebsite/Pages/_ViewImports.cshtml @@ -0,0 +1,3 @@ +@using nrdkwebsite +@namespace nrdkwebsite.Pages +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers \ No newline at end of file diff --git a/nrdkwebsite/Pages/_ViewStart.cshtml b/nrdkwebsite/Pages/_ViewStart.cshtml new file mode 100644 index 0000000..2157e73 --- /dev/null +++ b/nrdkwebsite/Pages/_ViewStart.cshtml @@ -0,0 +1,4 @@ +@using nrdkwebsite.Pages +@{ + Layout = "layout"; +} diff --git a/nrdkwebsite/Pages/about.cshtml b/nrdkwebsite/Pages/about.cshtml new file mode 100644 index 0000000..93561fb --- /dev/null +++ b/nrdkwebsite/Pages/about.cshtml @@ -0,0 +1,7 @@ +@page +@model About + + +
+ neroduckale. +
\ No newline at end of file diff --git a/nrdkwebsite/Pages/about.cshtml.cs b/nrdkwebsite/Pages/about.cshtml.cs new file mode 100644 index 0000000..3216551 --- /dev/null +++ b/nrdkwebsite/Pages/about.cshtml.cs @@ -0,0 +1,19 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace nrdkwebsite.Pages; + +public class About : PageModel +{ + private readonly ILogger _logger; + + public About(ILogger logger) + { + _logger = logger; + } + + public void OnGet() + { + + } +} \ No newline at end of file diff --git a/nrdkwebsite/Pages/error.cshtml b/nrdkwebsite/Pages/error.cshtml new file mode 100644 index 0000000..6f92b95 --- /dev/null +++ b/nrdkwebsite/Pages/error.cshtml @@ -0,0 +1,26 @@ +@page +@model ErrorModel +@{ + ViewData["Title"] = "Error"; +} + +

Error.

+

An error occurred while processing your request.

+ +@if (Model.ShowRequestId) +{ +

+ Request ID: @Model.RequestId +

+} + +

Development Mode

+

+ Swapping to the Development environment displays detailed information about the error that occurred. +

+

+ The Development environment shouldn't be enabled for deployed applications. + It can result in displaying sensitive information from exceptions to end users. + For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development + and restarting the app. +

diff --git a/nrdkwebsite/Pages/error.cshtml.cs b/nrdkwebsite/Pages/error.cshtml.cs new file mode 100644 index 0000000..93b0804 --- /dev/null +++ b/nrdkwebsite/Pages/error.cshtml.cs @@ -0,0 +1,26 @@ +using System.Diagnostics; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace nrdkwebsite.Pages; + +[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] +[IgnoreAntiforgeryToken] +public class ErrorModel : PageModel +{ + public string? RequestId { get; set; } + + public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); + + private readonly ILogger _logger; + + public ErrorModel(ILogger logger) + { + _logger = logger; + } + + public void OnGet() + { + RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; + } +} \ No newline at end of file diff --git a/nrdkwebsite/Pages/errors/404.cshtml b/nrdkwebsite/Pages/errors/404.cshtml new file mode 100644 index 0000000..9e9dcec --- /dev/null +++ b/nrdkwebsite/Pages/errors/404.cshtml @@ -0,0 +1,8 @@ +@page +@model error404 + +@{ + ViewData["Title"] = "not found"; +} + +

404! Страница не найдена

\ No newline at end of file diff --git a/nrdkwebsite/Pages/errors/404.cshtml.cs b/nrdkwebsite/Pages/errors/404.cshtml.cs new file mode 100644 index 0000000..8bbfb3f --- /dev/null +++ b/nrdkwebsite/Pages/errors/404.cshtml.cs @@ -0,0 +1,12 @@ +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace nrdkwebsite.Pages.errors; + +public class error404 : PageModel +{ + public void OnGet() + { + + } + +} \ No newline at end of file diff --git a/nrdkwebsite/Pages/index.cshtml b/nrdkwebsite/Pages/index.cshtml new file mode 100644 index 0000000..e4de078 --- /dev/null +++ b/nrdkwebsite/Pages/index.cshtml @@ -0,0 +1,10 @@ +@page +@model IndexModel +@{ + ViewData["Title"] = "Home page"; +} + + +

Привет, это сайт neroduckale

+

Мой никнейм читается по разному - неродакля, неродукель, неродакале, но одно в нем остается неизменным - неро.

+спасибо мактайлорс за помощь с созданием сайта. version: 0.3 diff --git a/nrdkwebsite/Pages/index.cshtml.cs b/nrdkwebsite/Pages/index.cshtml.cs new file mode 100644 index 0000000..511dbb9 --- /dev/null +++ b/nrdkwebsite/Pages/index.cshtml.cs @@ -0,0 +1,20 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace nrdkwebsite.Pages; + +public class IndexModel : PageModel +{ + private readonly ILogger _logger; + + public IndexModel(ILogger logger) + { + _logger = logger; + } + + + public void OnGet() + { + + } +} \ No newline at end of file diff --git a/nrdkwebsite/Pages/layout.cshtml b/nrdkwebsite/Pages/layout.cshtml new file mode 100644 index 0000000..4050af7 --- /dev/null +++ b/nrdkwebsite/Pages/layout.cshtml @@ -0,0 +1,35 @@ +@{ + if (ViewBag.Title == null) ViewBag.Title = "unknown"; +} + + + + + neroduckale's @ViewBag.Title + + + + @* *@ + + + + + +
+ + + +
+ +
+ @RenderBody() +
+ + + \ No newline at end of file diff --git a/nrdkwebsite/Pages/users.cshtml b/nrdkwebsite/Pages/users.cshtml new file mode 100644 index 0000000..3ddda27 --- /dev/null +++ b/nrdkwebsite/Pages/users.cshtml @@ -0,0 +1,16 @@ +@page +@using System.Collections +@model Users + + + + + + +
текст заголовкатекст заголовка
данныеданные
+ + \ No newline at end of file diff --git a/nrdkwebsite/Pages/users.cshtml.cs b/nrdkwebsite/Pages/users.cshtml.cs new file mode 100644 index 0000000..01bcfde --- /dev/null +++ b/nrdkwebsite/Pages/users.cshtml.cs @@ -0,0 +1,11 @@ +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace nrdkwebsite.Pages; + +public class Users : PageModel +{ + public void OnGet() + { + + } +} \ No newline at end of file diff --git a/nrdkwebsite/Pages/ygolek.cshtml b/nrdkwebsite/Pages/ygolek.cshtml new file mode 100644 index 0000000..95ca1ba --- /dev/null +++ b/nrdkwebsite/Pages/ygolek.cshtml @@ -0,0 +1,6 @@ +@page +@model nrdkwebsite.Pages.Ygolek + + + + \ No newline at end of file diff --git a/nrdkwebsite/Pages/ygolek.cshtml.cs b/nrdkwebsite/Pages/ygolek.cshtml.cs new file mode 100644 index 0000000..8dd5150 --- /dev/null +++ b/nrdkwebsite/Pages/ygolek.cshtml.cs @@ -0,0 +1,11 @@ +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace nrdkwebsite.Pages; + +public class Ygolek : PageModel +{ + public void OnGet() + { + + } +} \ No newline at end of file diff --git a/nrdkwebsite/Program.cs b/nrdkwebsite/Program.cs new file mode 100644 index 0000000..214ab99 --- /dev/null +++ b/nrdkwebsite/Program.cs @@ -0,0 +1,60 @@ +using Microsoft.EntityFrameworkCore; +using nrdkwebsite; +using Pomelo.EntityFrameworkCore.MySql.Infrastructure; + +var builder = WebApplication.CreateBuilder(args); +#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type. +var connection = builder.Configuration.GetConnectionString("DefaultConnection"); +#pragma warning restore CS8600 // Converting null literal or possible null value to non-nullable type. +builder.Services.AddDbContext(options => options.UseMySql(connection, ServerVersion.Create(new Version(8, 0, 35), ServerType.MySql))); +builder.Services.AddRazorPages(); +var app = builder.Build(); +if (!app.Environment.IsDevelopment()) +{ + app.UseExceptionHandler("/Error"); + // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. + app.UseHsts(); +} +app.UseStatusCodePagesWithReExecute("/errors/{0}"); +app.UseHttpsRedirection(); +app.UseStaticFiles(); + +app.MapGet("/api/users", (DatabaseHandler db) => db.users.ToList()); //WORKS +app.MapGet("/api/users/{id:int}", (int id, DatabaseHandler db) => { + var users = db.users.ToList(); + User? user = users.FirstOrDefault(u => u.id == id); + // если не найден, отправляем статусный код и сообщение об ошибке + if (user == null) return Results.NotFound(new { message = "Пользователь не найден" }); + + // если пользователь найден, отправляем его + return Results.Json(user); +}); //WORKS +app.MapGet("/api/users/nickname/{name}", (string name, DatabaseHandler db) => { + var users = db.users.ToList(); + User? user = users.FirstOrDefault(u => u.nickname == name); + // если не найден, отправляем статусный код и сообщение об ошибке + if (user == null) return Results.NotFound(new { message = "Пользователь не найден" }); + + // если пользователь найден, отправляем его + return Results.Json(user); +}); //WORKS +app.MapDelete("/api/users/{id:int}", async (int id, DatabaseHandler db) => { + User? user = db.users.FirstOrDefault(u => u.id == id); + if (user == null) return Results.NotFound(new { message = "Пользователь не найден" }); + db.users.Remove(user); + await db.SaveChangesAsync(); + return Results.Json(user); +}); //WORKS +app.MapPost("/api/users", async (User user, DatabaseHandler db)=> +{ + user.id = db.users.Count() + 1; + await db.users.AddAsync(user); + await db.SaveChangesAsync(); + return user; +}); //WORKS + +app.UseRouting(); +app.UseAuthorization(); +app.MapRazorPages(); +app.Run(); + diff --git a/nrdkwebsite/User.cs b/nrdkwebsite/User.cs new file mode 100644 index 0000000..7354bb5 --- /dev/null +++ b/nrdkwebsite/User.cs @@ -0,0 +1,15 @@ +namespace nrdkwebsite; + +public class User +{ + public string nickname { get; set; } + public int id { get; set; } + public string mast { get; set; } + + public User(string nickname, int id, string mast) + { + this.nickname = nickname; + this.id = id; + this.mast = mast; + } +} \ No newline at end of file diff --git a/nrdkwebsite/wwwroot/css/style.css b/nrdkwebsite/wwwroot/css/style.css new file mode 100644 index 0000000..03cd81f --- /dev/null +++ b/nrdkwebsite/wwwroot/css/style.css @@ -0,0 +1,38 @@ +body { + font-family: 'Raleway', sans-serif; + color: white; + margin: 0; + background: #2c2c2c; +} +a { + text-decoration: none; +} +.content { + text-align: center; + padding-top: 20px; +} + +.header-links { /*