mirror of
https://github.com/yawaflua/yaflay.ru.git
synced 2026-04-25 09:10:38 +03:00
Compare commits
74 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 810f9b353e | |||
| 7d2ee22c24 | |||
| e6f56938c1 | |||
| 1075225001 | |||
| 83c7fc1723 | |||
| 5e966809b0 | |||
| dd4a2798c4 | |||
| 152b5d8812 | |||
| 87e1f51e08 | |||
| ab6180b0d2 | |||
| 89f1ab0b85 | |||
| 75c8f58544 | |||
| eded562b7e | |||
| c8e877402c | |||
| f1f635a520 | |||
| 62e030436a | |||
| a83b2169f7 | |||
| e2800cfc2e | |||
| 05d5f8291c | |||
| b9036e2165 | |||
| 38c12ca246 | |||
| 153979cbbd | |||
| 8df7e26494 | |||
| 8c88eea1d7 | |||
| 01cd487a0d | |||
| 799e435afc | |||
| 0dc93500c8 | |||
| 782dea8c9d | |||
| f79e10f148 | |||
| ba514f8bca | |||
| d410c11f6f | |||
| a91de6921f | |||
| b91582a374 | |||
| ede506cb5d | |||
| 6b4f63c376 | |||
| 9000b9c372 | |||
| 408f7525f1 | |||
| f7f5723b2d | |||
| 921b8f3db3 | |||
| 8a73f597cf | |||
| 8a879b69f0 | |||
| a1d06708f0 | |||
| fa82a26828 | |||
| 5c9f9fc1c8 | |||
| 4d665665c1 | |||
| 1593ea8d5e | |||
| 25308408f9 | |||
| ed292bfe21 | |||
| 93220d9d79 | |||
| 09bcf505cb | |||
| a690cd5b40 | |||
| d3aac3ccbf | |||
| 964326ec3b | |||
| 179584620f | |||
| 967e08c57a | |||
| 3413c74bb3 | |||
| 2d705ce601 | |||
| 43520544ed | |||
| 4d086ae1e4 | |||
| aaefcea154 | |||
| 36d4b07e0e | |||
| f8ff067789 | |||
| 3743e3f1af | |||
| 3c055d5fb4 | |||
| 7de7a23024 | |||
| 5759241313 | |||
| 0f6c637e3e | |||
| a5d39384ac | |||
| 4e43b1631b | |||
| 14d045107f | |||
| d2fe5665b7 | |||
| ac77c00a7f | |||
| 634dde37a2 | |||
| e6d084f78c |
@@ -22,4 +22,3 @@
|
|||||||
**/secrets.dev.yaml
|
**/secrets.dev.yaml
|
||||||
**/values.dev.yaml
|
**/values.dev.yaml
|
||||||
LICENSE
|
LICENSE
|
||||||
README.md
|
|
||||||
@@ -36,7 +36,6 @@ jobs:
|
|||||||
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
|
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
yaflay/yaflay.ru
|
|
||||||
ghcr.io/${{ github.repository }}
|
ghcr.io/${{ github.repository }}
|
||||||
|
|
||||||
- name: Build and push Docker images
|
- name: Build and push Docker images
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ name: .NET
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "master" ]
|
branches: [ "*" ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "master" ]
|
branches: [ "*" ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -19,10 +19,10 @@ jobs:
|
|||||||
- name: Setup .NET
|
- name: Setup .NET
|
||||||
uses: actions/setup-dotnet@v3
|
uses: actions/setup-dotnet@v3
|
||||||
with:
|
with:
|
||||||
dotnet-version: 6.0.x
|
dotnet-version: 7.0.x
|
||||||
- name: Restore dependencies
|
- name: Restore dependencies
|
||||||
run: dotnet restore
|
run: dotnet restore "api.yawaflua.ru.csproj"
|
||||||
- name: Build
|
- name: Build
|
||||||
run: dotnet build --no-restore
|
run: dotnet build --no-restore "api.yawaflua.ru.csproj"
|
||||||
- name: Test
|
- name: Test
|
||||||
run: dotnet test --no-build --verbosity normal
|
run: dotnet test --no-build --verbosity normal "api.yawaflua.ru.csproj"
|
||||||
|
|||||||
@@ -361,3 +361,4 @@ MigrationBackup/
|
|||||||
|
|
||||||
# Fody - auto-generated XML schema
|
# Fody - auto-generated XML schema
|
||||||
FodyWeavers.xsd
|
FodyWeavers.xsd
|
||||||
|
/appsettings.json
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
@page
|
|
||||||
@model yaflay.ru.MyFeature.Pages.Page1Model
|
|
||||||
|
|
||||||
<!DOCTYPE html>
|
|
||||||
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="viewport" content="width=device-width" />
|
|
||||||
<title>Page1</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
||||||
|
|
||||||
namespace yaflay.ru.MyFeature.Pages
|
|
||||||
{
|
|
||||||
public class Page1Model : PageModel
|
|
||||||
{
|
|
||||||
public void OnGet()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
using System.Security.Claims;
|
||||||
|
using System.Text.Encodings.Web;
|
||||||
|
using Microsoft.AspNetCore.Authentication;
|
||||||
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using yawaflua.ru.Database.Tables;
|
||||||
|
using yawaflua.ru.Models;
|
||||||
|
using yawaflua.ru.Models.Tables;
|
||||||
|
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Auth;
|
||||||
|
|
||||||
|
public class ApiKeyAuthantication : AuthenticationHandler<AuthenticationSchemeOptions>
|
||||||
|
{
|
||||||
|
private AppDbContext ctx;
|
||||||
|
private IMemoryCache cache;
|
||||||
|
public ApiKeyAuthantication(
|
||||||
|
IOptionsMonitor<AuthenticationSchemeOptions> options,
|
||||||
|
ILoggerFactory logger,
|
||||||
|
UrlEncoder encoder,
|
||||||
|
ISystemClock clock,
|
||||||
|
AppDbContext ctx,
|
||||||
|
IMemoryCache cache
|
||||||
|
) : base(options, logger, encoder, clock)
|
||||||
|
{
|
||||||
|
this.ctx = ctx;
|
||||||
|
this.cache = cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
|
||||||
|
{
|
||||||
|
if (!Request.Host.Value.StartsWith("api"))
|
||||||
|
return AuthenticateResult.NoResult();
|
||||||
|
if (!Request.Headers.TryGetValue("Authorization", out var apiKeyHeaderValues) && Request.Host.Value.StartsWith("api"))
|
||||||
|
return AuthenticateResult.Fail("API Key was not provided.");
|
||||||
|
|
||||||
|
string? providedApiKey = apiKeyHeaderValues.FirstOrDefault()?.Replace("Bearer ", "");
|
||||||
|
Console.WriteLine("APIKEY: " + providedApiKey);
|
||||||
|
|
||||||
|
if (FindApiKey(providedApiKey, out ApiKey? apiKey))
|
||||||
|
{
|
||||||
|
var claims = new[]
|
||||||
|
{
|
||||||
|
new Claim("Bearer", apiKey.Type.ToString())
|
||||||
|
};
|
||||||
|
|
||||||
|
var identity = new ClaimsIdentity(claims, Scheme.Name);
|
||||||
|
var principal = new ClaimsPrincipal(identity);
|
||||||
|
var ticket = new AuthenticationTicket(principal, Scheme.Name);
|
||||||
|
|
||||||
|
return AuthenticateResult.Success(ticket);
|
||||||
|
}
|
||||||
|
Console.WriteLine("im there");
|
||||||
|
return AuthenticateResult.Fail("Invalid API Key provided.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool FindApiKey(string? providedApiKey, out ApiKey? apiKey)
|
||||||
|
{
|
||||||
|
var fromCache = cache.Get<ApiKey>($"apiKey-{providedApiKey}");
|
||||||
|
if (fromCache == null)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Im there: {fromCache}, {providedApiKey}");
|
||||||
|
apiKey = ctx.ApiKeys.Find(providedApiKey);
|
||||||
|
if (apiKey != null)
|
||||||
|
{
|
||||||
|
cache.Set($"apiKey-{providedApiKey}", (object)apiKey, DateTime.Now.AddMinutes(10));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
apiKey = fromCache;
|
||||||
|
}
|
||||||
|
return ctx.ApiKeys.Any(k => k.Key == providedApiKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
namespace yawaflua.ru.Auth
|
||||||
|
{
|
||||||
|
|
||||||
|
public enum ApiKeyTypes
|
||||||
|
{
|
||||||
|
Public,
|
||||||
|
Private
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,215 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.Text.Json.Nodes;
|
||||||
|
using yawaflua.ru.Models.Tables;
|
||||||
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
|
using yawaflua.ru.Models;
|
||||||
|
using System;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using yawaflua.ru.Auth;
|
||||||
|
using yawaflua.ru.Database.Tables;
|
||||||
|
using yawaflua.ru.Utilities;
|
||||||
|
using api.yawaflua.ru.Models.Tables;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/")]
|
||||||
|
public class ApiController : Controller
|
||||||
|
{
|
||||||
|
private IMemoryCache cache;
|
||||||
|
private AppDbContext ctx;
|
||||||
|
public ApiController(IMemoryCache cache, AppDbContext ctx)
|
||||||
|
{
|
||||||
|
this.cache = cache;
|
||||||
|
this.ctx = ctx;
|
||||||
|
}
|
||||||
|
public class authorizeBody
|
||||||
|
{
|
||||||
|
public string melon { get; set; }
|
||||||
|
public string watermelon { get; set; }
|
||||||
|
public string discordId { get; set; }
|
||||||
|
public ApiKeyTypes type { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
public class commentBody
|
||||||
|
{
|
||||||
|
public string text { get; set; }
|
||||||
|
public string sender { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet("Index")]
|
||||||
|
public async Task<IActionResult> getIndexPage()
|
||||||
|
{
|
||||||
|
string? indexPage = cache.Get<string>($"indexPage");
|
||||||
|
if (indexPage == null)
|
||||||
|
{
|
||||||
|
indexPage = await Startup.client.GetStringAsync(Startup.readmeFile);
|
||||||
|
if (indexPage != null)
|
||||||
|
cache.Set($"indexPage", (object)indexPage, DateTime.Now.AddMinutes(10));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(indexPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("Projects")]
|
||||||
|
public async Task<IActionResult> getProjects()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Im here");
|
||||||
|
Projects[] projects = Array.Empty<Projects>();
|
||||||
|
if (cache.TryGetValue("projects", out projects) || ctx.Projects.Any())
|
||||||
|
{
|
||||||
|
projects ??= ctx.Projects.ToArray();
|
||||||
|
cache.Set("projects", (object)projects);
|
||||||
|
}
|
||||||
|
Console.WriteLine(JsonConvert.SerializeObject(projects));
|
||||||
|
return Ok(projects);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("redirects")]
|
||||||
|
[Authorize(AuthenticationSchemes = "DISCORD-OAUTH-PRIVATE")]
|
||||||
|
public async Task<IActionResult> createRedirectUri([FromQuery]string url, [FromQuery] string uri)
|
||||||
|
{
|
||||||
|
HttpResponseMessage message;
|
||||||
|
using (var requestMessage =
|
||||||
|
new HttpRequestMessage(HttpMethod.Get, "https://discordapp.com/api/oauth2/@me"))
|
||||||
|
{
|
||||||
|
requestMessage.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", Request.Cookies["melon"]); ;
|
||||||
|
message = await Startup.client.SendAsync(requestMessage);
|
||||||
|
}
|
||||||
|
string responseBody = await message.Content.ReadAsStringAsync();
|
||||||
|
JsonNode response = JsonNode.Parse(responseBody);
|
||||||
|
if (response["user"] != null || Startup.ownerId?.FirstOrDefault(response["user"]?["id"].ToString()) == null)
|
||||||
|
{
|
||||||
|
Redirects redirects = new()
|
||||||
|
{
|
||||||
|
redirectTo = url,
|
||||||
|
uri = uri
|
||||||
|
};
|
||||||
|
await ctx.Redirects.AddAsync(redirects);
|
||||||
|
await ctx.SaveChangesAsync();
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Unauthorized();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost("Blog")]
|
||||||
|
[Authorize(AuthenticationSchemes = "DISCORD-OAUTH-PRIVATE")]
|
||||||
|
public async Task<IActionResult> createArticle([FromQuery] string title, [FromQuery] string annotation, [FromQuery] string text, [FromQuery] string image, [FromQuery] string author)
|
||||||
|
{
|
||||||
|
|
||||||
|
HttpResponseMessage message;
|
||||||
|
using (var requestMessage =
|
||||||
|
new HttpRequestMessage(HttpMethod.Get, "https://discordapp.com/api/oauth2/@me"))
|
||||||
|
{
|
||||||
|
requestMessage.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", Request.Cookies["melon"]); ;
|
||||||
|
message = await Startup.client.SendAsync(requestMessage);
|
||||||
|
}
|
||||||
|
string responseBody = await message.Content.ReadAsStringAsync();
|
||||||
|
JsonNode response = JsonNode.Parse(responseBody);
|
||||||
|
if (response["user"] != null && Startup.ownerId?.FirstOrDefault(response["user"]?["id"].ToString()) != null )
|
||||||
|
{
|
||||||
|
|
||||||
|
Blogs article = new()
|
||||||
|
{
|
||||||
|
Annotation = annotation,
|
||||||
|
authorId = response["user"]["id"].ToString(),
|
||||||
|
dateTime = DateTime.Now,
|
||||||
|
ImageUrl = image,
|
||||||
|
Text = text,
|
||||||
|
Title = title,
|
||||||
|
authorNickname = response["user"]["global_name"].ToString()
|
||||||
|
};
|
||||||
|
await ctx.Blogs.AddAsync(article);
|
||||||
|
await ctx.SaveChangesAsync();
|
||||||
|
return Ok();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Unauthorized();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpGet("logout")]
|
||||||
|
public async Task<IActionResult> authorizeDiscord()
|
||||||
|
{
|
||||||
|
Response.Cookies.Delete("melon");
|
||||||
|
Response.Cookies.Delete("watermelon");
|
||||||
|
Response.Cookies.Delete("cable");
|
||||||
|
return Redirect("/");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("Blog/{blogId?}/comments")]
|
||||||
|
public async Task<IActionResult> blogComments(int? blogId)
|
||||||
|
{
|
||||||
|
Comments[]? comments = (Comments[]?)cache.Get($"commentsWithBlogId{blogId}");
|
||||||
|
if (comments == null)
|
||||||
|
{
|
||||||
|
comments = ctx.Comments.Where(k => k.postId == blogId).ToArray();
|
||||||
|
if (comments != null)
|
||||||
|
cache.Set($"commentsWithBlogId{blogId}", (object[])comments, DateTime.Now.AddMinutes(5));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(comments);
|
||||||
|
}
|
||||||
|
[HttpPost("Blog/{blogId}/comments")]
|
||||||
|
[Authorize(AuthenticationSchemes = "DISCORD-OAUTH-PUBLIC")]
|
||||||
|
|
||||||
|
public async Task<IActionResult> CreateBlogComments(int blogId, [FromQuery] string text, [FromQuery] string sender)
|
||||||
|
{
|
||||||
|
Comments comment = new()
|
||||||
|
{
|
||||||
|
creatorMail = sender,
|
||||||
|
dateTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
|
||||||
|
Text = text,
|
||||||
|
postId = blogId
|
||||||
|
};
|
||||||
|
await ctx.Comments.AddAsync(comment);
|
||||||
|
await ctx.SaveChangesAsync();
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("Blog/{id}")]
|
||||||
|
public async Task<IActionResult> blog(int id)
|
||||||
|
{
|
||||||
|
Blogs? blog;
|
||||||
|
if (!cache.TryGetValue($"blogWithId{id}", out blog) && ctx.Blogs.TryGetValue(k => k.Id == id, out blog))
|
||||||
|
cache.Set($"blogWithId{id}", blog, DateTime.Now.AddMinutes(30));
|
||||||
|
|
||||||
|
return Ok(blog);
|
||||||
|
}
|
||||||
|
[HttpGet("Blog")]
|
||||||
|
public async Task<IActionResult> allBlogs()
|
||||||
|
{
|
||||||
|
Blogs[]? blogs = cache.Get<Blogs[]>($"allBlogs");
|
||||||
|
if (blogs == null)
|
||||||
|
{
|
||||||
|
blogs = ctx.Blogs.ToArray();
|
||||||
|
if (blogs != null)
|
||||||
|
cache.Set($"allBlogs", (object)blogs, DateTime.Now.AddMinutes(10));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
return Ok(blogs);
|
||||||
|
}
|
||||||
|
[HttpPost("authorize")]
|
||||||
|
public async Task<IActionResult> authorizeUser([FromBody] authorizeBody body)
|
||||||
|
{
|
||||||
|
await ctx.ApiKeys.AddAsync(
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
DiscordOwnerId = ulong.Parse(body.discordId),
|
||||||
|
Key = body.melon,
|
||||||
|
Melon = body.melon,
|
||||||
|
Type = ApiKeyTypes.Public
|
||||||
|
}
|
||||||
|
);
|
||||||
|
await ctx.SaveChangesAsync();
|
||||||
|
return Ok(body.melon);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
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.Новая_папка
|
|
||||||
{
|
|
||||||
[Route("")]
|
|
||||||
public class HomeController : Controller
|
|
||||||
{
|
|
||||||
// GET: HomeController
|
|
||||||
|
|
||||||
private async Task<string?> getUrlFromGit(string baseUrl)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
HttpClient client = new();
|
|
||||||
HttpResponseMessage getter = await client.GetAsync("https://raw.githubusercontent.com/YaFlay/yaflay.ru/master/redirect_uris.json");
|
|
||||||
JsonNodeOptions jsonNodeOptions = new ();
|
|
||||||
JsonDocumentOptions jsonDocumentOptions = new()
|
|
||||||
{
|
|
||||||
AllowTrailingCommas = true
|
|
||||||
};
|
|
||||||
JsonNode? allFile = JsonNode.Parse(await getter.Content.ReadAsStringAsync(),
|
|
||||||
nodeOptions: jsonNodeOptions,
|
|
||||||
documentOptions: jsonDocumentOptions);
|
|
||||||
;
|
|
||||||
return (string?)allFile[baseUrl];
|
|
||||||
}
|
|
||||||
catch (Exception except)
|
|
||||||
{
|
|
||||||
await Console.Out.WriteLineAsync(except.ToString());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("{uri}")]
|
|
||||||
public async Task<IActionResult> FromGitHub(string uri)
|
|
||||||
{
|
|
||||||
|
|
||||||
string? url = await getUrlFromGit(uri);
|
|
||||||
await Console.Out.WriteLineAsync($"New connected user: {HttpContext.Connection.RemoteIpAddress}");
|
|
||||||
if (url != null)
|
|
||||||
{
|
|
||||||
return Redirect(url);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Redirect("/404");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
|
using yawaflua.ru.Models;
|
||||||
|
using yawaflua.ru.Models.Tables;
|
||||||
|
using yawaflua.ru.Utilities;
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Controllers
|
||||||
|
{
|
||||||
|
[Route("/r/")]
|
||||||
|
[Authorize]
|
||||||
|
public class RedirectController : ControllerBase
|
||||||
|
{
|
||||||
|
private AppDbContext ctx;
|
||||||
|
private MemoryCache cache;
|
||||||
|
public RedirectController(AppDbContext ctx, MemoryCache cache)
|
||||||
|
{
|
||||||
|
this.ctx = ctx;
|
||||||
|
this.cache = cache;
|
||||||
|
}
|
||||||
|
[HttpGet("{uri}")]
|
||||||
|
public async Task<IActionResult> FromGitHub(string uri, [FromQuery(Name = "to")] string? to, [FromQuery(Name = "debug")] string debug = "false")
|
||||||
|
{
|
||||||
|
Redirects redirects;
|
||||||
|
if (!cache.TryGetValue($"redirectsWithUrl-{uri}", out redirects) || ctx.Redirects.TryGetValue(k => k.uri == uri, out redirects) )
|
||||||
|
cache.Set($"redirectsWithUrl-{uri}", redirects, DateTime.Now.AddMinutes(20));
|
||||||
|
|
||||||
|
return Redirect(redirects?.redirectTo + to?.Replace("%", "/") ?? "/404");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+29
-18
@@ -1,22 +1,33 @@
|
|||||||
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
# Èñïîëüçóåì îáðàç ASP.NET Core SDK äëÿ ñáîðêè ïðîåêòà
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
# Óñòàíîâêà ðàáî÷åé äèðåêòîðèè
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Êîïèðóåì ôàéëû ïðîåêòà è âîññòàíàâëèâàåì çàâèñèìîñòè
|
||||||
|
COPY . ./
|
||||||
|
RUN dotnet restore "api.yawaflua.ru.csproj"
|
||||||
|
|
||||||
|
# Ñîáèðàåì ïðîåêò
|
||||||
|
RUN dotnet publish -c Release -o /app/out "api.yawaflua.ru.csproj"
|
||||||
|
|
||||||
|
|
||||||
|
# Êîíå÷íûé îáðàç, èñïîëüçóþùèé ASP.NET Core runtime
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=build /app/out ./
|
||||||
|
# Îïðåäåëÿåì ïîðò, êîòîðûé ïðèëîæåíèå áóäåò ñëóøàòü
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
EXPOSE 443
|
# Óñòàíîâêà ïåðåìåííûõ ñðåäû
|
||||||
|
ENV CLIENTID=123
|
||||||
|
ENV CLIENTSECRET=aAbB
|
||||||
|
ENV REDIRECTURL=http://example.org/
|
||||||
|
ENV PSQL_HOST=localhost
|
||||||
|
ENV PSQL_USER=root
|
||||||
|
ENV PSQL_PASSWORD=root
|
||||||
|
ENV PSQL_DATABASE=database
|
||||||
|
ENV OWNERID=1111111
|
||||||
|
ENV READMEFILE=https://raw.githubusercontent.com/yawaflua/yawaflua/main/README.md
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
# Çàïóñêàåì ASP.NET Core ïðèëîæåíèå
|
||||||
WORKDIR /src
|
ENTRYPOINT ["dotnet", "api.yawaflua.ru.dll"]
|
||||||
COPY ["yaflay.ru.csproj", "."]
|
|
||||||
RUN dotnet restore "./yaflay.ru.csproj"
|
|
||||||
COPY . .
|
|
||||||
WORKDIR "/src/."
|
|
||||||
RUN dotnet build "yaflay.ru.csproj" -c Release -o /app/build
|
|
||||||
|
|
||||||
FROM build AS publish
|
|
||||||
RUN dotnet publish "yaflay.ru.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
|
||||||
|
|
||||||
FROM base AS final
|
|
||||||
WORKDIR /app
|
|
||||||
COPY --from=publish /app/publish .
|
|
||||||
ENTRYPOINT ["dotnet", "yaflay.ru.dll"]
|
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
using yawaflua.ru.Models;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(AppDbContext))]
|
||||||
|
[Migration("20231127204250_Migrate271122342")]
|
||||||
|
partial class Migrate271122342
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.12")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Annotation")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ImageUrl")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Text")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("dateTime")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Blogs", "public");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Text")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("creatorMail")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<long>("dateTime")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<int>("postId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Comments", "public");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Migrate271122342 : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.EnsureSchema(
|
||||||
|
name: "public");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Blogs",
|
||||||
|
schema: "public",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
Title = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Text = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Annotation = table.Column<string>(type: "text", nullable: false),
|
||||||
|
ImageUrl = table.Column<string>(type: "text", nullable: true),
|
||||||
|
dateTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Blogs", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Comments",
|
||||||
|
schema: "public",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
dateTime = table.Column<long>(type: "bigint", nullable: false),
|
||||||
|
Text = table.Column<string>(type: "text", nullable: false),
|
||||||
|
creatorMail = table.Column<string>(type: "text", nullable: false),
|
||||||
|
postId = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Comments", x => x.Id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Blogs",
|
||||||
|
schema: "public");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Comments",
|
||||||
|
schema: "public");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
using yawaflua.ru.Models;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(AppDbContext))]
|
||||||
|
[Migration("20231204171742_Migrate04122016")]
|
||||||
|
partial class Migrate04122016
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.12")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Annotation")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ImageUrl")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Text")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("dateTime")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Blogs", "public");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Text")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("creatorMail")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<long>("dateTime")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<int>("postId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Comments", "public");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Migrate04122016 : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+109
@@ -0,0 +1,109 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
using yawaflua.ru.Models;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(AppDbContext))]
|
||||||
|
[Migration("20231204210831_Migrate0512")]
|
||||||
|
partial class Migrate0512
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.12")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Annotation")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ImageUrl")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Text")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("dateTime")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Blogs", "public");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Text")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("creatorMail")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<long>("dateTime")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<int>("postId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Comments", "public");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Redirects", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("redirectTo")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("uri")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Redirects");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Migrate0512 : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Redirects",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
uri = table.Column<string>(type: "text", nullable: false),
|
||||||
|
redirectTo = table.Column<string>(type: "text", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Redirects", x => x.Id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Redirects");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+145
@@ -0,0 +1,145 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
using yawaflua.ru.Models;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(AppDbContext))]
|
||||||
|
[Migration("20231218172614_Migrate18122023")]
|
||||||
|
partial class Migrate18122023
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.12")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Author", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("discordId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("discordNickName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Author");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Annotation")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ImageUrl")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Text")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("authorId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime>("dateTime")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("authorId");
|
||||||
|
|
||||||
|
b.ToTable("Blogs", "public");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Text")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("creatorMail")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<long>("dateTime")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<int>("postId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Comments", "public");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Redirects", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("redirectTo")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("uri")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Redirects");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("yawaflua.ru.Models.Tables.Author", "author")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("authorId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("author");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Migrate18122023 : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "authorId",
|
||||||
|
schema: "public",
|
||||||
|
table: "Blogs",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Author",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
discordId = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
discordNickName = table.Column<string>(type: "text", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Author", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Blogs_authorId",
|
||||||
|
schema: "public",
|
||||||
|
table: "Blogs",
|
||||||
|
column: "authorId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Blogs_Author_authorId",
|
||||||
|
schema: "public",
|
||||||
|
table: "Blogs",
|
||||||
|
column: "authorId",
|
||||||
|
principalTable: "Author",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Blogs_Author_authorId",
|
||||||
|
schema: "public",
|
||||||
|
table: "Blogs");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Author");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Blogs_authorId",
|
||||||
|
schema: "public",
|
||||||
|
table: "Blogs");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "authorId",
|
||||||
|
schema: "public",
|
||||||
|
table: "Blogs");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+145
@@ -0,0 +1,145 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
using yawaflua.ru.Models;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(AppDbContext))]
|
||||||
|
[Migration("20231218173546_Migrate18122035")]
|
||||||
|
partial class Migrate18122035
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.12")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Author", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("discordId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("discordNickName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Author");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Annotation")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ImageUrl")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Text")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("authorId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime>("dateTime")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("authorId");
|
||||||
|
|
||||||
|
b.ToTable("Blogs", "public");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Text")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("creatorMail")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<long>("dateTime")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<int>("postId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Comments", "public");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Redirects", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("redirectTo")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("uri")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Redirects");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("yawaflua.ru.Models.Tables.Author", "author")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("authorId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("author");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Migrate18122035 : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
using yawaflua.ru.Models;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(AppDbContext))]
|
||||||
|
[Migration("20231219143602_Migrate191220231734")]
|
||||||
|
partial class Migrate191220231734
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.12")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Author", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<decimal>("discordId")
|
||||||
|
.HasColumnType("numeric(20,0)");
|
||||||
|
|
||||||
|
b.Property<string>("discordNickName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Author");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Annotation")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ImageUrl")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Text")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("authorId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime>("dateTime")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("authorId");
|
||||||
|
|
||||||
|
b.ToTable("Blogs", "public");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Text")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("creatorMail")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<long>("dateTime")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<int>("postId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Comments", "public");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Redirects", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("redirectTo")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("uri")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Redirects");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("yawaflua.ru.Models.Tables.Author", "author")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("authorId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("author");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Migrate191220231734 : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "uri",
|
||||||
|
table: "Redirects",
|
||||||
|
type: "text",
|
||||||
|
nullable: true,
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "text");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "redirectTo",
|
||||||
|
table: "Redirects",
|
||||||
|
type: "text",
|
||||||
|
nullable: true,
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "text");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<decimal>(
|
||||||
|
name: "discordId",
|
||||||
|
table: "Author",
|
||||||
|
type: "numeric(20,0)",
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(int),
|
||||||
|
oldType: "integer");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "uri",
|
||||||
|
table: "Redirects",
|
||||||
|
type: "text",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: "",
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "text",
|
||||||
|
oldNullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "redirectTo",
|
||||||
|
table: "Redirects",
|
||||||
|
type: "text",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: "",
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "text",
|
||||||
|
oldNullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<int>(
|
||||||
|
name: "discordId",
|
||||||
|
table: "Author",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(decimal),
|
||||||
|
oldType: "numeric(20,0)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
using yawaflua.ru.Models;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(AppDbContext))]
|
||||||
|
[Migration("20231223164820_Migrate321220231944")]
|
||||||
|
partial class Migrate321220231944
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.12")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Annotation")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ImageUrl")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Text")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("authorId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("authorNickname")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("dateTime")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Blogs", "public");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Text")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("creatorMail")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<long>("dateTime")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<int>("postId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Comments", "public");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Redirects", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("redirectTo")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("uri")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Redirects");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Migrate321220231944 : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Blogs_Author_authorId",
|
||||||
|
schema: "public",
|
||||||
|
table: "Blogs");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Author");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Blogs_authorId",
|
||||||
|
schema: "public",
|
||||||
|
table: "Blogs");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<DateTime>(
|
||||||
|
name: "dateTime",
|
||||||
|
schema: "public",
|
||||||
|
table: "Blogs",
|
||||||
|
type: "timestamp without time zone",
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(DateTime),
|
||||||
|
oldType: "timestamp with time zone");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "authorId",
|
||||||
|
schema: "public",
|
||||||
|
table: "Blogs",
|
||||||
|
type: "text",
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(int),
|
||||||
|
oldType: "integer");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "authorNickname",
|
||||||
|
schema: "public",
|
||||||
|
table: "Blogs",
|
||||||
|
type: "text",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: "");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "authorNickname",
|
||||||
|
schema: "public",
|
||||||
|
table: "Blogs");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<DateTime>(
|
||||||
|
name: "dateTime",
|
||||||
|
schema: "public",
|
||||||
|
table: "Blogs",
|
||||||
|
type: "timestamp with time zone",
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(DateTime),
|
||||||
|
oldType: "timestamp without time zone");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<int>(
|
||||||
|
name: "authorId",
|
||||||
|
schema: "public",
|
||||||
|
table: "Blogs",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "text");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Author",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
discordId = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
|
||||||
|
discordNickName = table.Column<string>(type: "text", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Author", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Blogs_authorId",
|
||||||
|
schema: "public",
|
||||||
|
table: "Blogs",
|
||||||
|
column: "authorId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Blogs_Author_authorId",
|
||||||
|
schema: "public",
|
||||||
|
table: "Blogs",
|
||||||
|
column: "authorId",
|
||||||
|
principalTable: "Author",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
using yawaflua.ru.Models;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(AppDbContext))]
|
||||||
|
[Migration("20231225062718_Migrate25122023926")]
|
||||||
|
partial class Migrate25122023926
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.12")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Database.Tables.ApiKey", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Key")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<decimal>("DiscordOwnerId")
|
||||||
|
.HasColumnType("numeric(20,0)");
|
||||||
|
|
||||||
|
b.Property<string>("Melon")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Key");
|
||||||
|
|
||||||
|
b.ToTable("ApiKeys", "public");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Annotation")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ImageUrl")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Text")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("authorId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("authorNickname")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("dateTime")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Blogs", "public");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Text")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("creatorMail")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<long>("dateTime")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<int>("postId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Comments", "public");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Redirects", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("redirectTo")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("uri")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Redirects");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Migrate25122023926 : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "ApiKeys",
|
||||||
|
schema: "public",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Key = table.Column<string>(type: "text", nullable: false),
|
||||||
|
DiscordOwnerId = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
|
||||||
|
Melon = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Type = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_ApiKeys", x => x.Key);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "ApiKeys",
|
||||||
|
schema: "public");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,164 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
using yawaflua.ru.Models;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(AppDbContext))]
|
||||||
|
[Migration("20240315193302_Migrate_22_32__15_03_2024")]
|
||||||
|
partial class Migrate_22_32__15_03_2024
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.12")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("api.yawaflua.ru.Models.Tables.Projects", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("id"));
|
||||||
|
|
||||||
|
b.Property<string>("description")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("image")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("url")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("id");
|
||||||
|
|
||||||
|
b.ToTable("Projects");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Database.Tables.ApiKey", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Key")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<decimal>("DiscordOwnerId")
|
||||||
|
.HasColumnType("numeric(20,0)");
|
||||||
|
|
||||||
|
b.Property<string>("Melon")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Key");
|
||||||
|
|
||||||
|
b.ToTable("ApiKeys", "public");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Annotation")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ImageUrl")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Text")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("authorId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("authorNickname")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("dateTime")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Blogs", "public");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Text")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("creatorMail")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<long>("dateTime")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<int>("postId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Comments", "public");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Redirects", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("redirectTo")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("uri")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Redirects");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Migrate_22_32__15_03_2024 : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Projects",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
name = table.Column<string>(type: "text", nullable: false),
|
||||||
|
description = table.Column<string>(type: "text", nullable: false),
|
||||||
|
url = table.Column<string>(type: "text", nullable: false),
|
||||||
|
image = table.Column<string>(type: "text", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Projects", x => x.id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Projects");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,161 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
using yawaflua.ru.Models;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(AppDbContext))]
|
||||||
|
partial class AppDbContextModelSnapshot : ModelSnapshot
|
||||||
|
{
|
||||||
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.12")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("api.yawaflua.ru.Models.Tables.Projects", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("id"));
|
||||||
|
|
||||||
|
b.Property<string>("description")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("image")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("url")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("id");
|
||||||
|
|
||||||
|
b.ToTable("Projects");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Database.Tables.ApiKey", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Key")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<decimal>("DiscordOwnerId")
|
||||||
|
.HasColumnType("numeric(20,0)");
|
||||||
|
|
||||||
|
b.Property<string>("Melon")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Key");
|
||||||
|
|
||||||
|
b.ToTable("ApiKeys", "public");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Blogs", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Annotation")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ImageUrl")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Text")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("authorId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("authorNickname")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("dateTime")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Blogs", "public");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Comments", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Text")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("creatorMail")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<long>("dateTime")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<int>("postId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Comments", "public");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("yawaflua.ru.Models.Tables.Redirects", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("redirectTo")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("uri")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Redirects");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using api.yawaflua.ru.Models.Tables;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using yawaflua.ru.Database.Tables;
|
||||||
|
using yawaflua.ru.Models.Tables;
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Models
|
||||||
|
{
|
||||||
|
public class AppDbContext : DbContext
|
||||||
|
{
|
||||||
|
|
||||||
|
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) {
|
||||||
|
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DbSet<Blogs> Blogs { get; set; }
|
||||||
|
public DbSet<Comments> Comments { get; set; }
|
||||||
|
public DbSet<Redirects> Redirects { get; set; }
|
||||||
|
public DbSet<ApiKey> ApiKeys { get; set; }
|
||||||
|
public DbSet<Projects> Projects { get; set; }
|
||||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
base.OnModelCreating(modelBuilder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using yawaflua.ru.Auth;
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Database.Tables;
|
||||||
|
|
||||||
|
[Table("ApiKeys", Schema = "public")]
|
||||||
|
public class ApiKey
|
||||||
|
{
|
||||||
|
|
||||||
|
[Key]
|
||||||
|
public string Key { get; set; }
|
||||||
|
[Required]
|
||||||
|
public ulong DiscordOwnerId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string Melon { get; set; }
|
||||||
|
public ApiKeyTypes Type { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Models.Tables
|
||||||
|
{
|
||||||
|
[Table("Blogs", Schema = "public")]
|
||||||
|
public class Blogs
|
||||||
|
{
|
||||||
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
public string Text { get; set; }
|
||||||
|
public string Annotation { get; set; }
|
||||||
|
public string? ImageUrl { get; set; }
|
||||||
|
public DateTime dateTime { get; set; }
|
||||||
|
public string authorId { get; set; }
|
||||||
|
public string authorNickname { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Author
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public ulong discordId { get; set; }
|
||||||
|
public string discordNickName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Net.Mail;
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Models.Tables
|
||||||
|
{
|
||||||
|
[Table("Comments", Schema = "public")]
|
||||||
|
public class Comments
|
||||||
|
{
|
||||||
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public long dateTime { get; set; }
|
||||||
|
public string Text { get; set; }
|
||||||
|
public string creatorMail { get; set; }
|
||||||
|
public int postId { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace api.yawaflua.ru.Models.Tables
|
||||||
|
{
|
||||||
|
[Table("Projects")]
|
||||||
|
public class Projects
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int id { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
public string description { get; set; }
|
||||||
|
public string url { get; set; }
|
||||||
|
public string image { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Models.Tables
|
||||||
|
{
|
||||||
|
public class Redirects
|
||||||
|
{
|
||||||
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string? uri { get; set; }
|
||||||
|
public string? redirectTo { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
@page "{type?}"
|
||||||
|
@model yawaflua.ru.Pages.AdminPanelModel
|
||||||
|
@using System.Text.Json.Nodes
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "AdminPanel";
|
||||||
|
bool isAllowed = true;
|
||||||
|
}
|
||||||
|
@if (Request.Cookies["melon"] != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (Startup.ownerId.FirstOrDefault(Request.Cookies["cable"]).isNull())
|
||||||
|
{
|
||||||
|
<h1 align="center">Вы не авторизованы! Сасни хуйца, олух</h1>
|
||||||
|
isAllowed = false;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
<h1 align="center">Вы не авторизованы! Сасни хуйца, олух</h1>
|
||||||
|
isAllowed = false;
|
||||||
|
}
|
||||||
|
@if (Model.type == "article" & isAllowed){
|
||||||
|
<div class="card margin-2-vm">
|
||||||
|
<div class="card-body bg-dark">
|
||||||
|
<h5 class="card-title">Код статьи (HTML)</h5>
|
||||||
|
<div class="card-text form-group bg-dark text-muted">
|
||||||
|
<label for="titleInput">Тайтл статьи</label>
|
||||||
|
<input type="text" class="form-control bg-dark text-muted" id="titleInput" />
|
||||||
|
|
||||||
|
<label for="annotationArea">Код аннотации</label>
|
||||||
|
<textarea class="form-control bg-dark text-muted" id="annotationArea" rows="2" onkeyup="updateAnnotation(this.value)"></textarea>
|
||||||
|
|
||||||
|
<label for="textArea">Код статьи</label>
|
||||||
|
<textarea class="form-control bg-dark text-muted" id="textArea" rows="5" onkeyup="updatePreview(this.value)"></textarea>
|
||||||
|
|
||||||
|
<label for="imgInput">Ссылка на изображение</label>
|
||||||
|
<input type="url" class="form-control bg-dark text-muted" id="imgInput" ></input>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card margin-2-vm" >
|
||||||
|
<div class="card-body bg-dark">
|
||||||
|
<h5 class="card-title text-muted">Превью аннотации</h5>
|
||||||
|
<div class="card-text text-muted overflow-auto" id="annotationCard">
|
||||||
|
<code id="code"><p id="annotationText"></p></code>
|
||||||
|
</div>
|
||||||
|
<h5 class="card-title text-muted">Превью текста</h5>
|
||||||
|
<div class="card-text text-muted overflow-auto" id="previewCard">
|
||||||
|
<code id="code"><p id="blogText"></p></code>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button type="button" id="sendBlogText" align="center" class="btn-primary margin-2-vm " onclick="sendArticleData()">Send!</button>
|
||||||
|
}
|
||||||
|
else if (Model.type == "redirects" & isAllowed)
|
||||||
|
{
|
||||||
|
<div class="card margin-2-vm">
|
||||||
|
<div class="card-body bg-dark">
|
||||||
|
<h5 class="card-title">Редиректы</h5>
|
||||||
|
<div class="card-text form-group bg-dark text-muted">
|
||||||
|
<label for="urlInput">Ссылка</label>
|
||||||
|
<input type="url" class="form-control bg-dark text-muted" id="urlInput" />
|
||||||
|
|
||||||
|
<label for="uriInput">Uri</label>
|
||||||
|
<input type="text" class="form-control bg-dark text-muted" id="uriInput" />
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button type="button" id="sendRedirect" align="center" class="btn-primary margin-2-vm " onclick="sendRedirectData()">Send!</button>
|
||||||
|
}
|
||||||
|
else if (isAllowed)
|
||||||
|
{
|
||||||
|
<h2 align="center" class="text-white absolute"><a href="/AdminPanel/redirects">Редиректы</a><a href="/AdminPanel/article"> Статьи</a></h2>
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Pages
|
||||||
|
{
|
||||||
|
public class AdminPanelModel : PageModel
|
||||||
|
{
|
||||||
|
public string? type = null;
|
||||||
|
public void OnGet(string? type)
|
||||||
|
{
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
@page "{code}"
|
||||||
|
@model yawaflua.ru.Pages.AuthorizeModel
|
||||||
|
@using System.Text.Json.Nodes
|
||||||
|
@using Newtonsoft.Json
|
||||||
|
@{
|
||||||
|
string path = $"{Request.Method}//{Request.Host}";
|
||||||
|
ViewData["Title"] = "Authorize";
|
||||||
|
string authorizationUrl = $"https://discord.com/api/oauth2/authorize?client_id={Startup.clientId}&response_type=code&redirect_uri={Startup.redirectUrl}&scope=identify";
|
||||||
|
<p style="display:none;">Data: @Startup.clientId @Startup.redirectUrl [@String.Join(",", Startup.ownerId)] @Model.code</p>
|
||||||
|
if (Model.code == null)
|
||||||
|
{
|
||||||
|
if (Request.Cookies["melon"]?.ToString() == null)
|
||||||
|
{
|
||||||
|
<a href="@authorizationUrl">Login while Discord</a>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HttpResponseMessage message;
|
||||||
|
using (var requestMessage =
|
||||||
|
new HttpRequestMessage(HttpMethod.Get, "https://discordapp.com/api/oauth2/@me"))
|
||||||
|
{
|
||||||
|
requestMessage.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", Request.Cookies["melon"]); ;
|
||||||
|
message = await Startup.client.SendAsync(requestMessage);
|
||||||
|
}
|
||||||
|
string responseBody = await message.Content.ReadAsStringAsync();
|
||||||
|
JsonNode response = JsonNode.Parse(responseBody);
|
||||||
|
if (response["user"] != null)
|
||||||
|
{
|
||||||
|
<h4>Вы авторизованы!</h4>
|
||||||
|
<a href="/AdminPanel"> Админка </a>
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<h4>
|
||||||
|
Токен авторизации неправильный! Попробуйте <a href="@authorizationUrl">заново</a>
|
||||||
|
</h4>
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
HttpResponseMessage message;
|
||||||
|
using (var requestMessage =
|
||||||
|
new HttpRequestMessage(HttpMethod.Post, "https://discordapp.com/api/oauth2/token"))
|
||||||
|
{
|
||||||
|
requestMessage.Content = new StringContent(
|
||||||
|
@$"grant_type=authorization_code&code={Model.code}&client_id={Startup.clientId}&client_secret={Startup.clientSecret}&scope=identify&redirect_uri={Startup.redirectUrl}",
|
||||||
|
new System.Net.Http.Headers.MediaTypeHeaderValue("application/x-www-form-urlencoded")
|
||||||
|
);
|
||||||
|
message = await Startup.client.SendAsync(requestMessage);
|
||||||
|
}
|
||||||
|
string responseBody = await message.Content.ReadAsStringAsync();
|
||||||
|
JsonNode? body = JsonNode.Parse(responseBody);
|
||||||
|
if (body["access_token"]?.ToString() == null)
|
||||||
|
{
|
||||||
|
<h4>Ошибка! Попробуй авторизоваться заново</h4>
|
||||||
|
|
||||||
|
Console.Error.WriteLine("debug: START \\/ \ninfo: Don't worry, this message is not bad as you think");
|
||||||
|
Console.Error.WriteLine("error: DiscordAuthorize is not worked");
|
||||||
|
Console.Error.WriteLine($"debug: Body from discord: {body}\ndebug: Sended data to discord: {message.Content.ReadAsStringAsync().Result}");
|
||||||
|
Console.Error.WriteLine($"info: Check environment data: \n ClientId={Startup.clientId}\n ClientSecret={Startup.clientSecret}\n RedirectUrl={Startup.redirectUrl}\n OwnerId={String.Join(",", Startup.ownerId)} ");
|
||||||
|
Console.Error.WriteLine("info: If any data is null and you set data in environment or appsettings.json, please create issue with this debug messages ");
|
||||||
|
Console.Error.WriteLine("debug: END /\\");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Response.Cookies.Append("melon", body["access_token"].ToString());
|
||||||
|
Response.Cookies.Append("watermelon", body["refresh_token"].ToString());
|
||||||
|
try
|
||||||
|
{
|
||||||
|
HttpContent bodytoApi;
|
||||||
|
bodytoApi = new StringContent(JsonConvert.SerializeObject(new yawaflua.ru.Controllers.ApiController.authorizeBody()
|
||||||
|
{
|
||||||
|
discordId = body["user"]["id"].ToString(),
|
||||||
|
melon = body["access_token"].ToString(),
|
||||||
|
type = Auth.ApiKeyTypes.Public,
|
||||||
|
watermelon = body["watermelon"].ToString()
|
||||||
|
}));
|
||||||
|
var req = await Startup.client.PostAsync(path + "/api/authorize", bodytoApi);
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(body);
|
||||||
|
Console.WriteLine(ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
Response.Redirect("/authorize", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Pages
|
||||||
|
{
|
||||||
|
public class AuthorizeModel : PageModel
|
||||||
|
{
|
||||||
|
public string code;
|
||||||
|
public void OnGet(string code)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
this.code = code;
|
||||||
|
Page();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
@page "{id?}"
|
||||||
|
@model BlogModel
|
||||||
|
@using yawaflua.ru.Models.Tables
|
||||||
|
@using Newtonsoft.Json
|
||||||
|
@{
|
||||||
|
string path = $"{this.Request.Scheme}://{this.Request.Host}";
|
||||||
|
if (Model.Id != 0)
|
||||||
|
{
|
||||||
|
var request = await Startup.client.GetAsync(path + "/api/Blog/" + Model.Id);
|
||||||
|
Blogs? Post = JsonConvert.DeserializeObject<Blogs>(request.Content.ReadAsStringAsync().Result);
|
||||||
|
if (Post == null)
|
||||||
|
{
|
||||||
|
ViewData["Title"] = "Blogs";
|
||||||
|
<h1 align="center">Что-то не так...</h1>
|
||||||
|
<h1 align="center">Пост не найден, но ты держи яблочко -> 🍎</h1>
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
ViewData["Title"] = Post.Title;
|
||||||
|
ViewData["og:title"] = Post.Title;
|
||||||
|
ViewData["og:url"] = this.Request.Host.Host + this.Request.Path.ToString();
|
||||||
|
ViewData["og:description"] = Post.Annotation;
|
||||||
|
ViewData["og:image"] = Post.ImageUrl;
|
||||||
|
|
||||||
|
<p align="left">
|
||||||
|
<h1 align="left">@Html.Raw(Post.Title)</h1>
|
||||||
|
<h5>@Post.dateTime</h5>
|
||||||
|
</p>
|
||||||
|
<div id="blogId" style="display:none;">@Model.Id</div>
|
||||||
|
<p align="center"><img src="@Post.ImageUrl" style="width:50vmax;"/></p>
|
||||||
|
<p align="center">@Html.Raw(Post.Text)</p>
|
||||||
|
string userUrl = "https://discord.com/users/" + Post.authorId;
|
||||||
|
<h6 align="left">Статья подготовлена <a href="@userUrl">@Post.authorNickname</a></h6>
|
||||||
|
<div class="container my-5 py-5 bg-dark text-muted">
|
||||||
|
<div class="row d-flex justify-content-center">
|
||||||
|
<div class="col-md-12 col-lg-10">
|
||||||
|
<div class="card text-muted bg-dark">
|
||||||
|
<div class="card-body position-static p-4" id="allComments">
|
||||||
|
<h4 class="mb-0" id="commentBar">Последние комментарии</h4>
|
||||||
|
|
||||||
|
<h1 align="center">Дальше тьма...</h1>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="card-footer text-white bg-dark mb-3 py-3 border-0" >
|
||||||
|
<div class="d-flex flex-start w-100">
|
||||||
|
<div class="form-outline w-100">
|
||||||
|
<label for="userEmail" class="form-label">Адрес электронной почты</label>
|
||||||
|
<input type="email" class="form-control bg-dark text-white" id="userEmail" placeholder="name@example.com" name="userEmail">
|
||||||
|
<label for="commentText" class="form-label">Комментарий</label>
|
||||||
|
<input type="text" class="form-control bg-dark text-white" id="commentText" rows="4" name="commentText">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="float-end mt-2 pt-1">
|
||||||
|
<button type="button" class="btn btn-primary btn-sm" id="postComment" >Запостить коммент</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ViewData["Title"] = "Blog";
|
||||||
|
var request = await Startup.client.GetAsync(path + "/api/Blog/");
|
||||||
|
Blogs[]? allBlogs = JsonConvert.DeserializeObject<Blogs[]>(request.Content.ReadAsStringAsync().Result);
|
||||||
|
if (allBlogs.Length == 0)
|
||||||
|
{
|
||||||
|
<p>
|
||||||
|
<h1 align="center">Ничего нет...</h1>
|
||||||
|
<h1 align="center">Вот вам банан -> 🍌</h1>
|
||||||
|
</p>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (Blogs blog in allBlogs)
|
||||||
|
{
|
||||||
|
<div class="card text-white bg-dark mb-3 text-center" style="width: 18rem;">
|
||||||
|
<img src="@blog.ImageUrl" class="card-img-top" />
|
||||||
|
<div class="card-body ">
|
||||||
|
<h5 class="card-title">@Html.Raw(blog.Title)</h5>
|
||||||
|
<p class="card-text">@Html.Raw(blog.Annotation)</p>
|
||||||
|
<a href="/Blog/@blog.Id" class="btn btn-primary center">Читать</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Razor;
|
||||||
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
|
using yawaflua.ru.Models.Tables;
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Pages
|
||||||
|
{
|
||||||
|
public class BlogModel : PageModel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
//public Comments[] comments { get; set; }
|
||||||
|
public void OnGet(int? id)
|
||||||
|
{
|
||||||
|
Id = id ?? 0;
|
||||||
|
Page();
|
||||||
|
//comments = Startup.dbContext.Comments.Where(k => k.postId == Id).OrderBy(k => k.dateTime).Reverse().ToArray();
|
||||||
|
}
|
||||||
|
public void OnPost(int? id)
|
||||||
|
{
|
||||||
|
Id = id ?? 0;
|
||||||
|
//comments = Startup.dbContext.Comments.Where(k => k.postId == Id).OrderBy(k => k.dateTime).Reverse().ToArray();
|
||||||
|
string userEmail = Request.Form["userEmail"];
|
||||||
|
string commentMessage = Request.Form["commentText"];
|
||||||
|
if (Id == 0 || commentMessage == null || userEmail == null) { Page(); return; }
|
||||||
|
Startup.dbContext.Comments.Add(new Comments()
|
||||||
|
{
|
||||||
|
Text = commentMessage,
|
||||||
|
creatorMail = userEmail,
|
||||||
|
dateTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
|
||||||
|
postId = Id
|
||||||
|
});
|
||||||
|
Startup.dbContext.SaveChanges();
|
||||||
|
Page();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace yaflay.ru.Pages
|
namespace yawaflua.ru.Pages
|
||||||
{
|
{
|
||||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
[IgnoreAntiforgeryToken]
|
[IgnoreAntiforgeryToken]
|
||||||
|
|||||||
+4
-2
@@ -1,13 +1,15 @@
|
|||||||
@page
|
@page
|
||||||
@model IndexModel
|
@model IndexModel
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "YaFlay";
|
ViewData["Title"] = "yawaflua";
|
||||||
}
|
}
|
||||||
|
|
||||||
<h3 align="left" class="readme" >README.md</h3>
|
<h3 align="left" class="readme" >README.md</h3>
|
||||||
|
|
||||||
@{
|
@{
|
||||||
string Github_readme = Startup.client.GetStringAsync("https://raw.githubusercontent.com/yawaflua/yawaflua/main/README.md").Result;
|
string path = $"{this.Request.Scheme}://{this.Request.Host}";
|
||||||
|
string Github_readme = Startup.client.GetStringAsync($"{path}/api/Index").Result;
|
||||||
<div class="text"> @Html.Raw(Github_readme) </div>
|
<div class="text"> @Html.Raw(Github_readme) </div>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+11
-4
@@ -1,21 +1,28 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
|
using yawaflua.ru.Models;
|
||||||
|
using yawaflua.ru.Models.Tables;
|
||||||
|
|
||||||
namespace yaflay.ru.Pages
|
namespace yawaflua.ru.Pages
|
||||||
{
|
{
|
||||||
public class IndexModel : PageModel
|
public class IndexModel : PageModel
|
||||||
{
|
{
|
||||||
private readonly ILogger<IndexModel> _logger;
|
private readonly ILogger<IndexModel> _logger;
|
||||||
|
public IMemoryCache cache;
|
||||||
public IndexModel(ILogger<IndexModel> logger)
|
public AppDbContext ctx;
|
||||||
|
public IndexModel(ILogger<IndexModel> logger, IMemoryCache cache, AppDbContext ctx)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
this.cache = cache;
|
||||||
|
this.ctx = ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnGet()
|
public void OnGet()
|
||||||
{
|
{
|
||||||
|
|
||||||
Page();
|
Page();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Page not found</title>
|
<title>Page not found</title>
|
||||||
<link rel="stylesheet" href="https://yaflay.ru/css/500.css" />
|
<link rel="stylesheet" href="~/css/500.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="main-error-page">
|
<div class="main-error-page">
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<title>Page not found</title>
|
<title>Page not found</title>
|
||||||
<link rel="shortcut icon" type="image/png" href="#">
|
<link rel="shortcut icon" type="image/png" href="#">
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" />
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" />
|
||||||
<link rel="stylesheet" href="https://yaflay.ru/css/404.css" />
|
<link rel="stylesheet" href="~/css/404.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
@@ -21,9 +21,9 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<div class="col-lg-7 text-center">
|
<div class="col-lg-7 text-center">
|
||||||
<img src="https://yaflay.ru/img/error-404.png" alt="image 404">
|
<img src="~/img/error-404.png" alt="image 404">
|
||||||
<h2><b>404</b> Страница не найдена</h2>
|
<h2><b>404</b> Страница не найдена</h2>
|
||||||
<p>посетите главную страницу <br> возможно вы найдёте её</p>
|
<p>посетите главную страницу <br> возможно вы найдёте свой путь</p>
|
||||||
<a href="@path" class="cmn-btn mt-4">На главную</a>
|
<a href="@path" class="cmn-btn mt-4">На главную</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
|
|
||||||
namespace yaflay.ru.Pages
|
namespace yawaflua.ru.Pages
|
||||||
{
|
{
|
||||||
public class Index1Model : PageModel
|
public class Index1Model : PageModel
|
||||||
{
|
{
|
||||||
|
|||||||
+122
-37
@@ -5,48 +5,133 @@
|
|||||||
}
|
}
|
||||||
<h1>@ViewData["Title"]</h1>
|
<h1>@ViewData["Title"]</h1>
|
||||||
|
|
||||||
<h2>End-User License Agreement (EULA) of <span class="app_name">yaflay.ru</span></h2>
|
Statement of Purpose
|
||||||
|
|
||||||
<p>This End-User License Agreement ("EULA") is a legal agreement between you and <span class="company_name">YaFlay</span>. Our EULA was created by <a href="https://www.eulatemplate.com">EULA Template</a> for <span class="app_name">yaflay.ru</span>.</p>
|
<p>The laws of most jurisdictions throughout the world automatically confer
|
||||||
|
exclusive Copyright and Related Rights (defined below) upon the creator
|
||||||
|
and subsequent owner(s) (each and all, an "owner") of an original work of
|
||||||
|
authorship and/or a database (each, a "Work").</p>
|
||||||
|
|
||||||
<p>This EULA agreement governs your acquisition and use of our <span class="app_name">yaflay.ru</span> software ("Software") directly from <span class="company_name">YaFlay</span> or indirectly through a <span class="company_name">YaFlay</span> authorized reseller or distributor (a "Reseller"). </p>
|
<p>Certain owners wish to permanently relinquish those rights to a Work for
|
||||||
|
the purpose of contributing to a commons of creative, cultural and
|
||||||
|
scientific works ("Commons") that the public can reliably and without fear
|
||||||
|
of later claims of infringement build upon, modify, incorporate in other
|
||||||
|
works, reuse and redistribute as freely as possible in any form whatsoever
|
||||||
|
and for any purposes, including without limitation commercial purposes.
|
||||||
|
These owners may contribute to the Commons to promote the ideal of a free
|
||||||
|
culture and the further production of creative, cultural and scientific
|
||||||
|
works, or to gain reputation or greater distribution for their Work in
|
||||||
|
part through the use and efforts of others.</p>
|
||||||
|
|
||||||
<p>Please read this EULA agreement carefully before completing the installation process and using the <span class="app_name">yaflay.ru</span> software. It provides a license to use the <span class="app_name">yaflay.ru</span> software and contains warranty information and liability disclaimers.</p>
|
<p>For these and/or other purposes and motivations, and without any
|
||||||
|
expectation of additional consideration or compensation, the person
|
||||||
|
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
||||||
|
is an owner of Copyright and Related Rights in the Work, voluntarily
|
||||||
|
elects to apply CC0 to the Work and publicly distribute the Work under its
|
||||||
|
terms, with knowledge of his or her Copyright and Related Rights in the
|
||||||
|
Work and the meaning and intended legal effect of CC0 on those rights.</p>
|
||||||
|
|
||||||
<p>If you register for a free trial of the <span class="app_name">yaflay.ru</span> software, this EULA agreement will also govern that trial. By clicking "accept" or installing and/or using the <span class="app_name">yaflay.ru</span> software, you are confirming your acceptance of the Software and agreeing to become bound by the terms of this EULA agreement.</p>
|
<p> Copyright and Related Rights. A Work made available under CC0 may be
|
||||||
|
protected by copyright and related or neighboring rights ("Copyright and
|
||||||
<p>If you are entering into this EULA agreement on behalf of a company or other legal entity, you represent that you have the authority to bind such entity and its affiliates to these terms and conditions. If you do not have such authority or if you do not agree with the terms and conditions of this EULA agreement, do not install or use the Software, and you must not accept this EULA agreement.</p>
|
Related Rights"). Copyright and Related Rights include, but are not
|
||||||
|
limited to, the following:</p>
|
||||||
<p>This EULA agreement shall apply only to the Software supplied by <span class="company_name">YaFlay</span> herewith regardless of whether other software is referred to or described herein. The terms also apply to any <span class="company_name">YaFlay</span> updates, supplements, Internet-based services, and support services for the Software, unless other terms accompany those items on delivery. If so, those terms apply.</p>
|
|
||||||
|
|
||||||
<h3>License Grant</h3>
|
|
||||||
|
|
||||||
<p><span class="company_name">YaFlay</span> hereby grants you a personal, non-transferable, non-exclusive licence to use the <span class="app_name">yaflay.ru</span> software on your devices in accordance with the terms of this EULA agreement.</p>
|
|
||||||
|
|
||||||
<p>You are permitted to load the <span class="app_name">yaflay.ru</span> software (for example a PC, laptop, mobile or tablet) under your control. You are responsible for ensuring your device meets the minimum requirements of the <span class="app_name">yaflay.ru</span> software.</p>
|
|
||||||
|
|
||||||
<p>You are not permitted to:</p>
|
|
||||||
|
|
||||||
|
<ul>i. the right to reproduce, adapt, distribute, perform, display,
|
||||||
|
communicate, and translate a Work.</ul>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Edit, alter, modify, adapt, translate or otherwise change the whole or any part of the Software nor permit the whole or any part of the Software to be combined with or become incorporated in any other software, nor decompile, disassemble or reverse engineer the Software or attempt to do any such things</li>
|
ii. moral rights retained by the original author(s) and/or performer(s);
|
||||||
<li>Reproduce, copy, distribute, resell or otherwise use the Software for any commercial purpose</li>
|
</ul>
|
||||||
<li>Allow any third party to use the Software on behalf of or for the benefit of any third party</li>
|
<ul>
|
||||||
<li>Use the Software in any way which breaches any applicable local, national or international law</li>
|
iii. publicity and privacy rights pertaining to a person's image or
|
||||||
<li>use the Software for any purpose that <span class="company_name">YaFlay</span> considers is a breach of this EULA agreement</li>
|
likeness depicted in a Work;
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
iv. rights protecting against unfair competition in regards to a Work,
|
||||||
|
subject to the limitations in paragraph 4(a), below;
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
v. rights protecting the extraction, dissemination, use and reuse of data
|
||||||
|
in a Work;
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
vi. database rights (such as those arising under Directive 96/9/EC of the
|
||||||
|
European Parliament and of the Council of 11 March 1996 on the legal
|
||||||
|
protection of databases, and under any national implementation
|
||||||
|
thereof, including any amended or successor version of such
|
||||||
|
directive); and
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
vii. other similar, equivalent or corresponding rights throughout the
|
||||||
|
world based on applicable law or treaty, and any national
|
||||||
|
implementations thereof.
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h3>Intellectual Property and Ownership</h3>
|
<p>2. Waiver. To the greatest extent permitted by, but not in contravention
|
||||||
|
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
||||||
<p><span class="company_name">YaFlay</span> shall at all times retain ownership of the Software as originally downloaded by you and all subsequent downloads of the Software by you. The Software (and the copyright, and other intellectual property rights of whatever nature in the Software, including any modifications made thereto) are and shall remain the property of <span class="company_name">YaFlay</span>.</p>
|
irrevocably and unconditionally waives, abandons, and surrenders all of
|
||||||
|
Affirmer's Copyright and Related Rights and associated claims and causes
|
||||||
<p><span class="company_name">YaFlay</span> reserves the right to grant licences to use the Software to third parties.</p>
|
of action, whether now known or unknown (including existing as well as
|
||||||
|
future claims and causes of action), in the Work (i) in all territories
|
||||||
<h3>Termination</h3>
|
worldwide, (ii) for the maximum duration provided by applicable law or
|
||||||
|
treaty (including future time extensions), (iii) in any current or future
|
||||||
<p>This EULA agreement is effective from the date you first use the Software and shall continue until terminated. You may terminate it at any time upon written notice to <span class="company_name">YaFlay</span>.</p>
|
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
||||||
|
including without limitation commercial, advertising or promotional
|
||||||
<p>It will also terminate immediately if you fail to comply with any term of this EULA agreement. Upon such termination, the licenses granted by this EULA agreement will immediately terminate and you agree to stop all access and use of the Software. The provisions that by their nature continue and survive will survive any termination of this EULA agreement.</p>
|
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
||||||
|
member of the public at large and to the detriment of Affirmer's heirs and
|
||||||
<h3>Governing Law</h3>
|
successors, fully intending that such Waiver shall not be subject to
|
||||||
|
revocation, rescission, cancellation, termination, or any other legal or
|
||||||
<p>This EULA agreement, and any dispute arising out of or in connection with this EULA agreement, shall be governed by and construed in accordance with the laws of <span class="country">ru</span>.</p>
|
equitable action to disrupt the quiet enjoyment of the Work by the public
|
||||||
|
as contemplated by Affirmer's express Statement of Purpose.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
3. Public License Fallback. Should any part of the Waiver for any reason
|
||||||
|
be judged legally invalid or ineffective under applicable law, then the
|
||||||
|
Waiver shall be preserved to the maximum extent permitted taking into
|
||||||
|
account Affirmer's express Statement of Purpose. In addition, to the
|
||||||
|
extent the Waiver is so judged Affirmer hereby grants to each affected
|
||||||
|
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
||||||
|
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
||||||
|
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
||||||
|
maximum duration provided by applicable law or treaty (including future
|
||||||
|
time extensions), (iii) in any current or future medium and for any number
|
||||||
|
of copies, and (iv) for any purpose whatsoever, including without
|
||||||
|
limitation commercial, advertising or promotional purposes (the
|
||||||
|
"License"). The License shall be deemed effective as of the date CC0 was
|
||||||
|
applied by Affirmer to the Work. Should any part of the License for any
|
||||||
|
reason be judged legally invalid or ineffective under applicable law, such
|
||||||
|
partial invalidity or ineffectiveness shall not invalidate the remainder
|
||||||
|
of the License, and in such case Affirmer hereby affirms that he or she
|
||||||
|
will not (i) exercise any of his or her remaining Copyright and Related
|
||||||
|
Rights in the Work or (ii) assert any associated claims and causes of
|
||||||
|
action with respect to the Work, in either case contrary to Affirmer's
|
||||||
|
express Statement of Purpose.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
4. Limitations and Disclaimers.
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
||||||
|
surrendered, licensed or otherwise affected by this document.
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
b. Affirmer offers the Work as-is and makes no representations or
|
||||||
|
warranties of any kind concerning the Work, express, implied,
|
||||||
|
statutory or otherwise, including without limitation warranties of
|
||||||
|
title, merchantability, fitness for a particular purpose, non
|
||||||
|
infringement, or the absence of latent or other defects, accuracy, or
|
||||||
|
the present or absence of errors, whether or not discoverable, all to
|
||||||
|
the greatest extent permissible under applicable law.
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
c. Affirmer disclaims responsibility for clearing rights of other persons
|
||||||
|
that may apply to the Work or any use thereof, including without
|
||||||
|
limitation any person's Copyright and Related Rights in the Work.
|
||||||
|
Further, Affirmer disclaims responsibility for obtaining any necessary
|
||||||
|
consents, permissions or other rights required for any use of the
|
||||||
|
Work.
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
d. Affirmer understands and acknowledges that Creative Commons is not a
|
||||||
|
party to this document and has no duty or obligation with respect to
|
||||||
|
this CC0 or use of the Work.
|
||||||
|
</ul>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
|
|
||||||
namespace yaflay.ru.Pages
|
namespace yawaflua.ru.Pages
|
||||||
{
|
{
|
||||||
public class PrivacyModel : PageModel
|
public class PrivacyModel : PageModel
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,7 +3,10 @@
|
|||||||
Layout = null;
|
Layout = null;
|
||||||
this.Response.ContentType = "text/plain";
|
this.Response.ContentType = "text/plain";
|
||||||
}
|
}
|
||||||
# /Robots.txt file for httpы://yaflay.com/
|
|
||||||
User-agent: *
|
User-agent: *
|
||||||
<environment include="Development,Staging">Disallow: /</environment>
|
<environment include="Development,Staging">Disallow: /*</environment>
|
||||||
<environment include="Production">Disallow: /* </environment>
|
<environment include="Production">Disallow: /* </environment>
|
||||||
|
<environment include="Production">Allow: /Blog </environment>
|
||||||
|
<environment include="Production">Allow: /Blog/* </environment>
|
||||||
|
<environment include="Production">Allow: /Privacy </environment>
|
||||||
|
<environment include="Production">Allow: / </environment>
|
||||||
+94
-15
@@ -1,36 +1,60 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
|
@using System.Text.Json.Nodes
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<link rel="icon" href="~/favicon.ico" />
|
<link rel="icon" href="~/favicon.ico" />
|
||||||
<title>@ViewData["Title"] - yaflay.ru</title>
|
<title>@ViewData["Title"] - @Context.Request.Host.Host</title>
|
||||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
||||||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||||
<link type="application/json+oembed" href="~/json/oembed.json" />
|
|
||||||
<meta property="og:title" content="YaFlay ReadMe" />
|
<!--<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">-->
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css">
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
|
||||||
|
|
||||||
|
<!-- and it's easy to individually load additional languages -->
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/go.min.js"></script>
|
||||||
|
@if (!Context.Request.Path.ToString().StartsWith("/Blog/"))
|
||||||
|
{
|
||||||
|
<meta property="og:title" content="yawaflua readme" />
|
||||||
<meta property="og:type" content="rich" />
|
<meta property="og:type" content="rich" />
|
||||||
<meta property="og:url" content="https://yaflay.ru/" />
|
<meta property="og:url" content="@Context.Request.Host.Host" />
|
||||||
<meta property="og:image" content="https://user-images.githubusercontent.com/5713670/87202985-820dcb80-c2b6-11ea-9f56-7ec461c497c3.gif" />
|
<meta property="og:image" content="https://user-images.githubusercontent.com/5713670/87202985-820dcb80-c2b6-11ea-9f56-7ec461c497c3.gif" />
|
||||||
<meta property="og:description"
|
<meta property="og:description"
|
||||||
content="Here you can check info about YaFlay: social networks, programming languages that he knows and his projects." />
|
content="Here you can check info about yawaflua: social networks, programming languages that he knows and his projects." />
|
||||||
<meta property="og:locale" content="en_US" />
|
<meta property="og:locale" content="en_US" />
|
||||||
<meta property="og:site_name" content="yaflay.ru" />
|
<meta property="og:site_name" content="yawaflua.ru" />
|
||||||
|
<link type="application/json+oembed" href="~/json/oembed.json" />
|
||||||
|
}
|
||||||
|
else if (Context.Request.Path.ToString().StartsWith("/Blog/"))
|
||||||
|
{
|
||||||
|
<meta property="og:title" content="@ViewData["og:title"]" />
|
||||||
|
<meta property="og:type" content="rich" />
|
||||||
|
<meta property="og:url" content="@ViewData["og:url"]" />
|
||||||
|
<meta property="og:image" content="@ViewData["og:image"]" />
|
||||||
|
<meta property="og:description"
|
||||||
|
content="@ViewData["og:description"]" />
|
||||||
|
<meta property="og:locale" content="ru_RU" />
|
||||||
|
<meta property="og:site_name" content="yawaflua.ru" />
|
||||||
|
}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light border-bottom box-shadow mb-3" style="background-color: #2c2c2c;">
|
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light border-bottom box-shadow mb-3" style="background-color: #2c2c2c;">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<a class="navbar-brand" style="color: cornflowerblue" asp-area="" asp-page="/Index">
|
|
||||||
<img src="https://cdn.discordapp.com/avatars/945317832290336798/fcd69146cf424ca9b6e507bba67386ab.gif" width="50" height="50" style="border-radius: 10px; margin-right: 10%">
|
|
||||||
yaflay.ru
|
|
||||||
</a>
|
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
||||||
aria-expanded="false" aria-label="Toggle navigation">
|
aria-expanded="false" aria-label="Toggle navigation">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
||||||
</button>
|
</button>
|
||||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||||
<ul class="navbar-nav flex-grow-1">
|
<ul class="navbar-nav flex-grow-1">
|
||||||
|
|
||||||
|
<a class="nav-link " style="color: cornflowerblue;" asp-area="" asp-page="/Index">
|
||||||
|
@Context.Request.Host.Host
|
||||||
|
</a>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-white" asp-area="" asp-page="/Index">Home</a>
|
<a class="nav-link text-white" asp-area="" asp-page="/Index">Home</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -38,28 +62,83 @@
|
|||||||
<a class="nav-link text-white" asp-area="" asp-page="/Privacy">Privacy</a>
|
<a class="nav-link text-white" asp-area="" asp-page="/Privacy">Privacy</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-white" href="https://storespw.ru">StoreSPw</a>
|
<a class="nav-link text-white" asp-area="" asp-page="/Blog">Blog</a>
|
||||||
</li>
|
</li>
|
||||||
|
@{
|
||||||
|
Context.Response.Cookies.Delete("cable");
|
||||||
|
if (Context.Request.Cookies["melon"] != null)
|
||||||
|
{
|
||||||
|
HttpResponseMessage message;
|
||||||
|
using (var requestMessage =
|
||||||
|
new HttpRequestMessage(HttpMethod.Get, "https://discordapp.com/api/oauth2/@me"))
|
||||||
|
{
|
||||||
|
requestMessage.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", Context.Request.Cookies["melon"]); ;
|
||||||
|
message = await Startup.client.SendAsync(requestMessage);
|
||||||
|
}
|
||||||
|
string responseBody = await message.Content.ReadAsStringAsync();
|
||||||
|
JsonNode response = JsonNode.Parse(responseBody);
|
||||||
|
if (!response["user"].isNull())
|
||||||
|
{
|
||||||
|
Context.Response.Cookies.Append("cable", response["user"]["id"].ToString());
|
||||||
|
string userName = response["user"]["global_name"].ToString();
|
||||||
|
<li class="nav-item">
|
||||||
|
<a href="/logout"
|
||||||
|
class="nav-link blurple hover:decoration-wavy underline dashed decoration-purple"
|
||||||
|
style="color: #5865F2; font-size: calc(var(--bs-body-font-size) + .15rem);">
|
||||||
|
@userName
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
|
<div class="migratePushUp">
|
||||||
|
@{
|
||||||
|
|
||||||
|
if (!Context.Request.Host.Host.StartsWith("yawaflua.ru"))
|
||||||
|
{
|
||||||
|
<div aria-live="polite" aria-atomic="true" style="margin-right: 3vh;">
|
||||||
|
<div class="toast bg-dark right-1vm absolute fixed" style="bottom: 0; display:block;">
|
||||||
|
<div class="toast-header bg-dark" >
|
||||||
|
<strong class="mr-auto left-1vm absolute">@Context.Request.Host.Host</strong>
|
||||||
|
<small class="absolute right-1vm">Now</small>
|
||||||
|
</div>
|
||||||
|
<div class="toast-body text-muted">
|
||||||
|
This site is outdated. Use <a href="https://yawaflua.ru">new site</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</div>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<main role="main" class="pb-3">
|
<main role="main" class="pb-3">
|
||||||
@RenderBody()
|
@RenderBody()
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<footer class="border-top footer text-muted">
|
<footer class="border-top footer text-muted margin-2-vm">
|
||||||
<div class="container">
|
<div class="container margin-2-vm">
|
||||||
© 2023 - yaflay.ru - <a asp-area="" asp-page="/Privacy">Privacy</a>
|
© 2023 - @Context.Request.Host.Host - <a asp-area="" asp-page="/Privacy">Privacy</a>
|
||||||
|
<b class="flex-row margin-2-vm container-md">
|
||||||
|
сrafted by <a href="https://yawaflua.ru/gh" class="underline dashed decoration-purple text-white hover:decoration-wavy">yawaflua</a>
|
||||||
|
</b>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||||
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
<script src="~/js/site.js"></script>
|
||||||
|
@if (Context.Request.Path.ToString().StartsWith("/AdminPanel"))
|
||||||
|
{
|
||||||
|
<script src="~/js/AdminPanel.js"></script>
|
||||||
|
}
|
||||||
|
|
||||||
@await RenderSectionAsync("Scripts", required: false)
|
@await RenderSectionAsync("Scripts", required: false)
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
@using yaflay.ru
|
@using yawaflua.ru
|
||||||
@namespace yaflay.ru.Pages
|
@namespace yawaflua.ru.Pages
|
||||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||||
|
|||||||
+13
-3
@@ -1,18 +1,28 @@
|
|||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using yaflay.ru;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using yawaflua.ru;
|
||||||
public class Program
|
public class Program
|
||||||
{
|
{
|
||||||
public static void Main() => CreateHostBuilder()
|
public static void Main()
|
||||||
|
{
|
||||||
|
CreateHostBuilder()
|
||||||
.Build()
|
.Build()
|
||||||
.Run();
|
.Run();
|
||||||
|
}
|
||||||
private static IHostBuilder CreateHostBuilder()
|
private static IHostBuilder CreateHostBuilder()
|
||||||
{
|
{
|
||||||
return Host.CreateDefaultBuilder()
|
return Host.CreateDefaultBuilder()
|
||||||
.ConfigureWebHostDefaults(webHost => {
|
.ConfigureWebHostDefaults(webHost => {
|
||||||
webHost.UseStartup<Startup>();
|
webHost.UseStartup<Startup>();
|
||||||
webHost.UseStaticWebAssets();
|
webHost.UseStaticWebAssets();
|
||||||
webHost.UseKestrel(kestrelOptions => { kestrelOptions.ListenAnyIP(80); });
|
webHost.UseKestrel(kestrelOptions => { kestrelOptions.ListenAnyIP(80);});
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static class StaticProgram
|
||||||
|
{
|
||||||
|
public static bool isNull(this object? value) =>
|
||||||
|
value == null;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,35 +1,56 @@
|
|||||||
{
|
{
|
||||||
"profiles": {
|
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||||
"yaflay.ru": {
|
|
||||||
"commandName": "Project",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
},
|
|
||||||
"dotnetRunMessages": true,
|
|
||||||
"applicationUrl": "https://localhost:7269;http://localhost:5070"
|
|
||||||
},
|
|
||||||
"IIS Express": {
|
|
||||||
"commandName": "IISExpress",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Docker": {
|
|
||||||
"commandName": "Docker",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
|
|
||||||
"publishAllPorts": true,
|
|
||||||
"useSSL": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"iisSettings": {
|
"iisSettings": {
|
||||||
"windowsAuthentication": false,
|
"windowsAuthentication": false,
|
||||||
"anonymousAuthentication": true,
|
"anonymousAuthentication": true,
|
||||||
"iisExpress": {
|
"iisExpress": {
|
||||||
"applicationUrl": "http://localhost:3236",
|
"applicationUrl": "http://localhost:16072",
|
||||||
"sslPort": 44373
|
"sslPort": 44366
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"http": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"applicationUrl": "http://localhost:5144",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||||
|
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Docker": {
|
||||||
|
"commandName": "Docker",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": ".",
|
||||||
|
"applicationUrl": "http://localhost:5144",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||||
|
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"https": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"applicationUrl": "https://localhost:7049;http://localhost:5144",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||||
|
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||||
|
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,79 @@
|
|||||||
# Hello, there!
|
# Hello, there!
|
||||||
This is my custom redirector, used in my profile, with url: [yaflay.ru](https://yaflay.ru/)
|
[](https://yawaflua.ru)
|
||||||
|
[](https://github.com/yawaflua/yaflay.ru/actions/workflows/docker-image.yml)
|
||||||
|

|
||||||
|
|
||||||
Used frameworks: Asp.Net, Razor
|
This is my custom site, with url: [yawaflua.ru](https://yawaflua.ru/)
|
||||||
|
|
||||||
Thanks for the help to @Mih4n!
|
Used frameworks: Asp.Net, Razor, jQuery
|
||||||
|
|
||||||
|
Thanks for the help to [@Mih4n](https://github.com/Mih4n)!
|
||||||
|
|
||||||
If you wanna help me, create Issue or Pull request.
|
If you wanna help me, create Issue or Pull request.
|
||||||
|
|
||||||

|
# Features
|
||||||
|
- Authorization with discord OAuth2
|
||||||
|
- Main page is downloaded from user`s github readme(like [this](https://github.com/yawaflua/yawaflua))
|
||||||
|
- Blog system with loading comments after render a page, for optimization
|
||||||
|
- Admin panel for blog`s, can make article for blog and write to db new redirect setting(Discord OAuth2)
|
||||||
|
- Set discord oauth2 and database settings from .env(docker-compose file, another docker-type function) or appsettings.json(only one from this)
|
||||||
|
|
||||||
|
# How to start?
|
||||||
|
You should to use this command for download this package from ghcr:
|
||||||
|
### For latest version
|
||||||
|
```cli
|
||||||
|
docker pull ghcr.io/yawaflua/yaflay.ru:master
|
||||||
|
```
|
||||||
|
### For stable version
|
||||||
|
```cli
|
||||||
|
docker pull ghcr.io/yawaflua/yaflay.ru:latest
|
||||||
|
```
|
||||||
|
After that create docker-compose file, for example:
|
||||||
|
```yml
|
||||||
|
version: "3.9"
|
||||||
|
|
||||||
|
services:
|
||||||
|
site:
|
||||||
|
image: ghcr.io/yawaflua/yaflay.ru:master
|
||||||
|
environment:
|
||||||
|
PSQL_HOST: example.com
|
||||||
|
PSQL_USER: root
|
||||||
|
PSQL_DATABASE: MySite
|
||||||
|
PSQL_PASSWORD: root
|
||||||
|
REDIRECTURL: https://example.com/authorize
|
||||||
|
CLIENTSECRET: aAbBcCdD123123
|
||||||
|
CLIENTID: 1111111111111111111
|
||||||
|
// You can add many ids, used "," like this:
|
||||||
|
// OWNERID: 111111111111111, 111111111111111, 1111111111111
|
||||||
|
OWNERID: 1111111111111111
|
||||||
|
|
||||||
|
READMEFILE: https://raw.githubusercontent.com/example/example/main/README.md
|
||||||
|
```
|
||||||
|
For normal work this site need to give psql data to docker environ, or appsettings.json, if you download this project from github manually
|
||||||
|
Example data for appsettings.json:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"DetailedErrors": true,
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"clientId": "111111111111",
|
||||||
|
"clientSecret": "aAbBcCdD",
|
||||||
|
"redirectUrl": "https://example.com/authorize",
|
||||||
|
"connectionString": "Host=example.com;Username=root;Password=root;Database=MySite;",
|
||||||
|
"__comment": {
|
||||||
|
"__comment": "You can add many ids, used \",\" like this:",
|
||||||
|
"ownerId": "111111111111111, 1111111111, 11111111111, 1111111111111",
|
||||||
|
"__comment_2": "please, didnt use dictionary-typed json value"
|
||||||
|
},
|
||||||
|
"ownerId": "1111111111",
|
||||||
|
"readmeFile": "https://raw.githubusercontent.com/example/example/main/README.md"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
# Support me
|
||||||
|
[boosty](https://yawaflua.ru/boosty) - boosty
|
||||||
|
|
||||||
|
[patreon](https://yawaflua.ru/patreon) - patreon
|
||||||
|
|||||||
+87
-14
@@ -1,40 +1,100 @@
|
|||||||
|
|
||||||
namespace yaflay.ru
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
using System.Reflection.Metadata.Ecma335;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using DotNetEd.CoreAdmin;
|
||||||
|
using Microsoft.AspNetCore.Authentication;
|
||||||
|
using Microsoft.AspNetCore.Mvc.TagHelpers;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
|
using yawaflua.ru.Auth;
|
||||||
|
using yawaflua.ru.Models;
|
||||||
|
|
||||||
|
|
||||||
|
namespace yawaflua.ru
|
||||||
{
|
{
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
private readonly IConfiguration configuration;
|
private readonly IConfiguration configuration;
|
||||||
public static HttpClient client = new HttpClient();
|
public static CookieContainer cookieContainer = new();
|
||||||
|
public static HttpClientHandler handler = new() { CookieContainer = cookieContainer};
|
||||||
|
public static HttpClient client = new(handler);
|
||||||
|
public static AppDbContext? dbContext;
|
||||||
|
public static string? clientId { get; set; } = null;
|
||||||
|
public static string? clientSecret { get; set; } = null;
|
||||||
|
public static string? redirectUrl { get; set; } = null;
|
||||||
|
public static string[]? ownerId { get; set; } = null;
|
||||||
|
public static string? readmeFile { get; set; } = null;
|
||||||
|
public static string? connectionString { private get; set; } = null;
|
||||||
public Startup()
|
public Startup()
|
||||||
{
|
{
|
||||||
configuration = new ConfigurationBuilder()
|
configuration = new ConfigurationBuilder()
|
||||||
.AddEnvironmentVariables(prefix: "m.")
|
.AddEnvironmentVariables()
|
||||||
.AddJsonFile("appsettings.json", optional: true)
|
.AddJsonFile("appsettings.json", optional: true)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
clientId = configuration.GetValue<string>("clientId");
|
||||||
|
clientSecret = configuration.GetValue<string>("clientSecret");
|
||||||
|
redirectUrl = configuration.GetValue<string>("redirectUrl");
|
||||||
|
connectionString = configuration.GetValue<string>("connectionString");
|
||||||
|
ownerId = configuration.GetValue<string[]>("ownerId");
|
||||||
|
readmeFile = configuration.GetValue<string>("readmeFile");
|
||||||
|
|
||||||
}
|
}
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddControllers()
|
services.AddControllers()
|
||||||
.AddRazorPagesOptions(options =>
|
.AddRazorPagesOptions(options =>
|
||||||
{
|
{
|
||||||
options.Conventions.AddPageRoute("/RobotsTxt", "/Robots.txt");
|
|
||||||
|
options.Conventions.AddPageRoute("/RobotsTxt", "/robots.txt");
|
||||||
options.Conventions.AddPageRoute("/NotFound", "/404");
|
options.Conventions.AddPageRoute("/NotFound", "/404");
|
||||||
options.Conventions.AddPageRoute("/IternalErrorPage", "/500");
|
options.Conventions.AddPageRoute("/IternalErrorPage", "/500");
|
||||||
|
options.Conventions.AddPageRoute("/Authorize", "/authorize");
|
||||||
});
|
});
|
||||||
services.AddRouting();
|
services
|
||||||
services.AddRazorPages();
|
.AddCors(k => { k.AddDefaultPolicy(l => { l.AllowAnyHeader(); l.AllowAnyMethod(); l.AllowAnyOrigin(); }); })
|
||||||
|
.AddRouting()
|
||||||
|
.AddTransient<ApiKeyAuthantication>()
|
||||||
|
.AddSingleton(configuration)
|
||||||
|
.AddDbContext<AppDbContext>(c => c.UseNpgsql(connectionString: connectionString))
|
||||||
|
.AddSwaggerGen()
|
||||||
|
.AddSingleton(new MemoryCache(new MemoryCacheOptions()))
|
||||||
|
.AddAuthorization(k =>
|
||||||
|
{
|
||||||
|
k.AddPolicy("DISCORD-OAUTH-PUBLIC", policyBuilder => {
|
||||||
|
policyBuilder.RequireAuthenticatedUser();
|
||||||
|
policyBuilder.RequireClaim("Bearer", "Public");
|
||||||
|
});
|
||||||
|
k.AddPolicy("DISCORD-OAUTH-PRIVATE", policyBuilder => {
|
||||||
|
policyBuilder.RequireAuthenticatedUser();
|
||||||
|
policyBuilder.RequireClaim("Bearer", "Private");
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.AddAuthentication(options =>
|
||||||
|
{
|
||||||
|
options.DefaultAuthenticateScheme = "Bearer";
|
||||||
|
options.DefaultChallengeScheme = "Bearer";
|
||||||
|
options.AddScheme<ApiKeyAuthantication>("DISCORD-OAUTH-PRIVATE", "DISCORD-OAUTH-PRIVATE");
|
||||||
|
options.AddScheme<ApiKeyAuthantication>("DISCORD-OAUTH-PUBLIC", "DISCORD-OAUTH-PUBLIC");
|
||||||
|
options.RequireAuthenticatedSignIn = false;
|
||||||
|
}).AddScheme<AuthenticationSchemeOptions, ApiKeyAuthantication>("Bearer", options => {});
|
||||||
services.AddMvc()
|
services.AddMvc()
|
||||||
.AddRazorPagesOptions(options =>
|
.AddRazorPagesOptions(options =>
|
||||||
{
|
{
|
||||||
options.Conventions.AddPageRoute("/RobotsTxt", "/Robots.txt");
|
options.Conventions.AddPageRoute("/RobotsTxt", "/robots.txt");
|
||||||
options.Conventions.AddPageRoute("/NotFound", "/404");
|
options.Conventions.AddPageRoute("/NotFound", "/404");
|
||||||
options.Conventions.AddPageRoute("/IternalErrorPage", "/500");
|
options.Conventions.AddPageRoute("/IternalErrorPage", "/500");
|
||||||
|
options.Conventions.AddPageRoute("/Authorize", "/authorize");
|
||||||
});
|
});
|
||||||
//services.AddDirectoryBrowser();
|
services.AddRazorPages();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
dbContext = services.BuildServiceProvider().GetRequiredService<AppDbContext>();
|
||||||
|
#if DEBUG == true
|
||||||
|
services.AddCoreAdmin("admin");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||||
@@ -44,20 +104,33 @@ namespace yaflay.ru
|
|||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.UseDeveloperExceptionPage();
|
app.UseDeveloperExceptionPage();
|
||||||
//app.UseHsts();
|
app.UseHsts();
|
||||||
|
app.UseSpa(x => x.UseProxyToSpaDevelopmentServer("http://localhost:8080"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
|
app.UseAuthentication();
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
app.UseSwagger((options) =>
|
||||||
|
{
|
||||||
|
options.RouteTemplate = "swagger/v1/swagger.json";
|
||||||
|
});
|
||||||
|
app.UseSwaggerUI();
|
||||||
|
#if DEBUG
|
||||||
|
app.UseCoreAdminCustomTitle("yawaflua");
|
||||||
|
app.UseCoreAdminCustomAuth((k) => Task.FromResult(true));
|
||||||
|
app.UseCoreAdminCustomUrl("admin/coreadmin");
|
||||||
|
#endif
|
||||||
|
app.UseCors(k => { k.WithMethods("POST", "GET", "PATCH", "PUT"); k.AllowAnyOrigin(); k.AllowAnyHeader(); });
|
||||||
app.UseEndpoints(endpoints =>
|
app.UseEndpoints(endpoints =>
|
||||||
{
|
{
|
||||||
|
endpoints.MapDefaultControllerRoute().AllowAnonymous();
|
||||||
|
endpoints.MapFallbackToFile("/index.html").AllowAnonymous();
|
||||||
|
endpoints.MapSwagger();
|
||||||
endpoints.MapRazorPages();
|
endpoints.MapRazorPages();
|
||||||
endpoints.MapControllers();
|
endpoints.MapControllers().AllowAnonymous();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace yawaflua.ru.Utilities
|
||||||
|
{
|
||||||
|
public static class AppDbContextUtilities
|
||||||
|
{
|
||||||
|
public static bool TryGetValue<T>(this DbSet<T> set, Func<T, bool> predicate, out T? value) where T : class
|
||||||
|
{
|
||||||
|
value = set.FirstOrDefault(predicate);
|
||||||
|
return value != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<UserSecretsId>0c1057bc-b206-4a40-b003-9b6299aa9c64</UserSecretsId>
|
||||||
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
|
<DockerfileContext>.</DockerfileContext>
|
||||||
|
<EnableSdkContainerSupport>true</EnableSdkContainerSupport>
|
||||||
|
<Authors>yawaflua</Authors>
|
||||||
|
<Company>yawaflua</Company>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.SpaProxy">
|
||||||
|
<Version>8.*-*</Version>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="3.1.32" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="8.0.3" />
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\frontend.yawaflua.ru\frontend.yawaflua.ru.esproj">
|
||||||
|
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||||
|
</ProjectReference>
|
||||||
|
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="AspNet.Security.OAuth.Discord" Version="7.0.4" />
|
||||||
|
<PackageReference Include="CoreAdmin" Version="2.7.1" />
|
||||||
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.12" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.12" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.12">
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.11" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Migrations\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -5,5 +5,8 @@
|
|||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"clientId": "111111111111",
|
||||||
|
"clientSecret": "aAbBcCdD",
|
||||||
|
"redirectUrl": "https://example.com/authorize"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"AllowedHosts": "*"
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"version": "1.0",
|
||||||
|
"defaultProvider": "cdnjs",
|
||||||
|
"libraries": []
|
||||||
|
}
|
||||||
+50
-2
@@ -6,9 +6,16 @@ html {
|
|||||||
color: white;
|
color: white;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
.app_name {
|
||||||
|
font-size: calc(12px + 1vmax);
|
||||||
|
}
|
||||||
.readme{
|
.readme{
|
||||||
font-family: 'Anonymous Pro';
|
font-family: 'Anonymous Pro';
|
||||||
}
|
}
|
||||||
|
.stats {
|
||||||
|
width: 60vmax;
|
||||||
|
max-width: 1000px;
|
||||||
|
}
|
||||||
body {
|
body {
|
||||||
background: #2c2c2c;
|
background: #2c2c2c;
|
||||||
color: white;
|
color: white;
|
||||||
@@ -29,7 +36,18 @@ nav {
|
|||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.absolute {
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
.fixed {
|
||||||
|
position:fixed;
|
||||||
|
}
|
||||||
|
.right-1vm {
|
||||||
|
right: 1vmax;
|
||||||
|
}
|
||||||
|
.left-1vm {
|
||||||
|
left: 1vmax;
|
||||||
|
}
|
||||||
html {
|
html {
|
||||||
position: relative;
|
position: relative;
|
||||||
min-height: 100%;
|
min-height: 100%;
|
||||||
@@ -43,6 +61,21 @@ div .text {
|
|||||||
border: solid white;
|
border: solid white;
|
||||||
border-width: 4px;
|
border-width: 4px;
|
||||||
}
|
}
|
||||||
|
.margin-2-vm {
|
||||||
|
margin: 2vmax;
|
||||||
|
}
|
||||||
|
.underline{
|
||||||
|
text-decoration-line: underline;
|
||||||
|
}
|
||||||
|
.hover\:decoration-wavy:hover {
|
||||||
|
text-decoration-style: wavy
|
||||||
|
}
|
||||||
|
.dashed {
|
||||||
|
text-decoration-style: dashed;
|
||||||
|
}
|
||||||
|
.decoration-purple{
|
||||||
|
text-decoration-color: purple;
|
||||||
|
}
|
||||||
p {
|
p {
|
||||||
margin-right: 5vh;
|
margin-right: 5vh;
|
||||||
margin-left: 5vh;
|
margin-left: 5vh;
|
||||||
@@ -53,7 +86,22 @@ img {
|
|||||||
margin-bottom: 1vh;
|
margin-bottom: 1vh;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
.bot-1 {
|
||||||
|
padding-bottom: 1vmax;
|
||||||
|
}
|
||||||
body {
|
body {
|
||||||
margin-bottom: 60px;
|
margin-bottom: 60px;
|
||||||
}
|
}
|
||||||
|
.margin-left-2-vm{
|
||||||
|
margin-left: 2vmax;
|
||||||
|
}
|
||||||
|
.margin-right-2-vm {
|
||||||
|
margin-right: 2vmax;
|
||||||
|
}
|
||||||
|
|
||||||
|
.width-4 {
|
||||||
|
width: 4vmax;
|
||||||
|
}
|
||||||
|
.blurple {
|
||||||
|
color: #5865F2;
|
||||||
|
}
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 647 KiB |
@@ -0,0 +1,55 @@
|
|||||||
|
function updatePreview(value) {
|
||||||
|
var blogText = $("#previewCard").children("#code").children("#blogText");
|
||||||
|
blogText.empty();
|
||||||
|
blogText.append(value);
|
||||||
|
}
|
||||||
|
function updateAnnotation(value) {
|
||||||
|
var blogText = $("#annotationCard").children("#code").children("#annotationText");
|
||||||
|
blogText.empty();
|
||||||
|
blogText.append(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function sendArticleData() {
|
||||||
|
let melon = document.cookie.split(';')[0].replace("melon=", "");
|
||||||
|
let body = `{
|
||||||
|
"title": "${$("#titleInput").val().replace(/"/g, '\"')}",
|
||||||
|
"annotation": "${$("#annotationArea").val().replace(/\n/g, " \\n").replace(/"/g, '\"')}}",
|
||||||
|
"text": "${$("#textArea").val().replace(/\n/g, " \\n").replace(/"/g, '\"')}",
|
||||||
|
"image": "${$("#imgInput").val()}",
|
||||||
|
"author": "${melon}"
|
||||||
|
}`;
|
||||||
|
fetch("/api/Blog", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${melon}`,
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
body: body
|
||||||
|
}).then(k => console.log(k));
|
||||||
|
$("#titleInput").val('');
|
||||||
|
$("#annotationArea").val('');
|
||||||
|
$("#textArea").val('');
|
||||||
|
$("#imgInput").val('');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function sendRedirectData() {
|
||||||
|
console.log("click!")
|
||||||
|
let melon = document.cookie.split(';')[0].replace("melon=", "");
|
||||||
|
let body = `{
|
||||||
|
"url": "${$("#urlInput").val()}",
|
||||||
|
"uri": "${$("#uriInput").val()}",
|
||||||
|
"author": "${melon}"
|
||||||
|
}`;
|
||||||
|
fetch("/api/redirects", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${melon}`,
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
body: body
|
||||||
|
}).then(k => console.log(k));
|
||||||
|
$("#urlInput").val('');
|
||||||
|
$("#uriInput").val('');
|
||||||
|
}
|
||||||
|
|
||||||
+43
-3
@@ -1,4 +1,44 @@
|
|||||||
// Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
|
let blogId = $("#blogId").text();
|
||||||
// for details on configuring this project to bundle and minify static web assets.
|
function loadComments() {
|
||||||
|
if (document.location.pathname.startsWith("/Blog")) {
|
||||||
|
fetch(`/api/Blog/${blogId}/comments`)
|
||||||
|
.then(response => {
|
||||||
|
let data = response.json();
|
||||||
|
data.then(k => {
|
||||||
|
for (let i = 0; i < k.length; i++) {
|
||||||
|
let date = new Date(k[i].dateTime * 1000);
|
||||||
|
$("#commentBar").after(
|
||||||
|
`<div class="d-flex flex flex-start bg-dark bot-1">
|
||||||
|
<div class="container">
|
||||||
|
<h6 class="fw-bold mb-1">${k[i].creatorMail}</h6>
|
||||||
|
<div class="d-flex align-items-center mb-3">
|
||||||
|
<p class="mb-0">
|
||||||
|
${date.toLocaleString()}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<p class="mb-0">
|
||||||
|
${k[i].text}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$("#postComment").click(
|
||||||
|
function () {
|
||||||
|
var contentBody = {
|
||||||
|
text: $("#commentText").val(),
|
||||||
|
sender: $("#userEmail").val()
|
||||||
|
}
|
||||||
|
$.ajax(`/api/Blog/${blogId}/comments`, {
|
||||||
|
data: JSON.stringify(contentBody),
|
||||||
|
contentType: "application/json",
|
||||||
|
method: "post"
|
||||||
|
}).done(response => { $("#commentText").val(''); $("#userEmail").val(''); $("#commentBar").empty(); loadComments(); })
|
||||||
|
|
||||||
// Write your JavaScript code.
|
}
|
||||||
|
);
|
||||||
|
$(loadComments());
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
"embeds": [
|
"embeds": [
|
||||||
{
|
{
|
||||||
"type": "rich",
|
"type": "rich",
|
||||||
"url": "yaflay.ru",
|
"url": "https://yawaflua.ru/",
|
||||||
"title": "YaFlay ReadMe",
|
"title": "ReadAbout yawaflua",
|
||||||
"description": "Here you can get info about YaFlay: social networks, programming languages that he knows and his projects.",
|
"description": "Here you can get info about yawaflua: social networks, programming languages that he knows and his projects.",
|
||||||
"thumbnail": {
|
"thumbnail": {
|
||||||
"url": "https://user-images.githubusercontent.com/5713670/87202985-820dcb80-c2b6-11ea-9f56-7ec461c497c3.gif",
|
"url": "https://user-images.githubusercontent.com/5713670/87202985-820dcb80-c2b6-11ea-9f56-7ec461c497c3.gif",
|
||||||
"proxy_url": "https://user-images.githubusercontent.com/5713670/87202985-820dcb80-c2b6-11ea-9f56-7ec461c497c3.gif",
|
"proxy_url": "https://user-images.githubusercontent.com/5713670/87202985-820dcb80-c2b6-11ea-9f56-7ec461c497c3.gif",
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 8.9 KiB |
@@ -1,17 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<UserSecretsId>0c1057bc-b206-4a40-b003-9b6299aa9c64</UserSecretsId>
|
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
|
||||||
<DockerfileContext>.</DockerfileContext>
|
|
||||||
<EnableSdkContainerSupport>true</EnableSdkContainerSupport>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -3,13 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.6.33723.286
|
VisualStudioVersion = 17.6.33723.286
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "yaflay.ru", "yaflay.ru.csproj", "{3AA2FE9B-D1AF-4B12-B090-7E4529BA40E0}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "api.yawaflua.ru", "api.yawaflua.ru.csproj", "{3AA2FE9B-D1AF-4B12-B090-7E4529BA40E0}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{82D95147-E21B-45B6-B636-A145A498D56E}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{82D95147-E21B-45B6-B636-A145A498D56E}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
.editorconfig = .editorconfig
|
.editorconfig = .editorconfig
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{54A90642-561A-4BB1-A94E-469ADEE60C69}") = "frontend.yawaflua.ru", "..\frontend.yawaflua.ru\frontend.yawaflua.ru.esproj", "{62466D84-4FD6-4CF4-ACA2-C19662E6B7FD}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -20,6 +22,12 @@ Global
|
|||||||
{3AA2FE9B-D1AF-4B12-B090-7E4529BA40E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{3AA2FE9B-D1AF-4B12-B090-7E4529BA40E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{3AA2FE9B-D1AF-4B12-B090-7E4529BA40E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{3AA2FE9B-D1AF-4B12-B090-7E4529BA40E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{3AA2FE9B-D1AF-4B12-B090-7E4529BA40E0}.Release|Any CPU.Build.0 = Release|Any CPU
|
{3AA2FE9B-D1AF-4B12-B090-7E4529BA40E0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{62466D84-4FD6-4CF4-ACA2-C19662E6B7FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{62466D84-4FD6-4CF4-ACA2-C19662E6B7FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{62466D84-4FD6-4CF4-ACA2-C19662E6B7FD}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||||
|
{62466D84-4FD6-4CF4-ACA2-C19662E6B7FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{62466D84-4FD6-4CF4-ACA2-C19662E6B7FD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{62466D84-4FD6-4CF4-ACA2-C19662E6B7FD}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
Reference in New Issue
Block a user