mirror of
https://github.com/yawaflua/yaflay.ru.git
synced 2026-04-25 17:20:38 +03:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 83c7fc1723 | |||
| 5e966809b0 | |||
| dd4a2798c4 | |||
| 152b5d8812 | |||
| 87e1f51e08 | |||
| ab6180b0d2 | |||
| 89f1ab0b85 | |||
| 75c8f58544 | |||
| 62e030436a | |||
| a83b2169f7 | |||
| 05d5f8291c |
@@ -5,9 +5,9 @@ name: .NET
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "master" ]
|
branches: [ "*" ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "master" ]
|
branches: [ "*" ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ namespace yaflay.ru.Controllers
|
|||||||
}
|
}
|
||||||
string responseBody = await message.Content.ReadAsStringAsync();
|
string responseBody = await message.Content.ReadAsStringAsync();
|
||||||
JsonNode response = JsonNode.Parse(responseBody);
|
JsonNode response = JsonNode.Parse(responseBody);
|
||||||
if (response["user"] != null || Startup.ownerId.FirstOrDefault(response["user"]?["id"].ToString()) == null)
|
if (response["user"] != null || Startup.ownerId?.FirstOrDefault(response["user"]?["id"].ToString()) == null)
|
||||||
{
|
{
|
||||||
Redirects redirects = new()
|
Redirects redirects = new()
|
||||||
{
|
{
|
||||||
@@ -109,7 +109,7 @@ namespace yaflay.ru.Controllers
|
|||||||
}
|
}
|
||||||
string responseBody = await message.Content.ReadAsStringAsync();
|
string responseBody = await message.Content.ReadAsStringAsync();
|
||||||
JsonNode response = JsonNode.Parse(responseBody);
|
JsonNode response = JsonNode.Parse(responseBody);
|
||||||
if (response["user"] != null || Startup.ownerId.FirstOrDefault(response["user"]?["id"].ToString()) == null )
|
if (response["user"] != null || Startup.ownerId?.FirstOrDefault(response["user"]?["id"].ToString()) == null )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -235,7 +235,7 @@ namespace yaflay.ru.Controllers
|
|||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
return Ok(body.melon);
|
return Ok(body.melon);
|
||||||
}
|
}
|
||||||
[HttpGet("{uri}")]
|
[HttpGet("r/{uri}")]
|
||||||
public async Task<IActionResult> FromGitHub(string uri)
|
public async Task<IActionResult> FromGitHub(string uri)
|
||||||
{
|
{
|
||||||
Console.WriteLine(uri);
|
Console.WriteLine(uri);
|
||||||
@@ -248,7 +248,7 @@ namespace yaflay.ru.Controllers
|
|||||||
if (fromCache != null)
|
if (fromCache != null)
|
||||||
cache.Set($"redirectsWithUrl-{uri}", (object)fromCache, DateTime.Now.AddMinutes(10));
|
cache.Set($"redirectsWithUrl-{uri}", (object)fromCache, DateTime.Now.AddMinutes(10));
|
||||||
}
|
}
|
||||||
Console.WriteLine(fromCache.ToString());
|
Console.WriteLine(fromCache?.ToString());
|
||||||
return Redirect(fromCache?.redirectTo ?? "/404");
|
return Redirect(fromCache?.redirectTo ?? "/404");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@
|
|||||||
Console.Error.WriteLine("debug: START \\/ \nDon't worry, this message is not bad as you think");
|
Console.Error.WriteLine("debug: START \\/ \nDon't worry, this message is not bad as you think");
|
||||||
Console.Error.WriteLine("error: DiscordAuthorize is not worked");
|
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($"debug: Body from discord: {body}\ndebug: Sended data to discord: {message.Content.ReadAsStringAsync().Result}");
|
||||||
Console.Error.WriteLine($"info: Check environment data: \nClientId={Startup.clientId}\nClientSecret={Startup.clientSecret}\nRedirectUrl={Startup.redirectUrl}\nOwnerId={Startup.ownerId} ");
|
Console.Error.WriteLine($"info: Check environment data: \nClientId={Startup.clientId}\nClientSecret={Startup.clientSecret}\nRedirectUrl={Startup.redirectUrl}\nOwnerId={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("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 /\\");
|
Console.Error.WriteLine("debug: END /\\");
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
@page
|
@page "{uri?}"
|
||||||
@model IndexModel
|
@model IndexModel
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "yawaflua";
|
ViewData["Title"] = "yawaflua";
|
||||||
|
|||||||
+30
-6
@@ -1,22 +1,46 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
|
using yaflay.ru.Models;
|
||||||
|
using yaflay.ru.Models.Tables;
|
||||||
|
|
||||||
namespace yaflay.ru.Pages
|
namespace yaflay.ru.Pages
|
||||||
{
|
{
|
||||||
public class IndexModel : PageModel
|
public class IndexModel : PageModel
|
||||||
{
|
{
|
||||||
private readonly ILogger<IndexModel> _logger;
|
private readonly ILogger<IndexModel> _logger;
|
||||||
//public string? uri { get; set; } = null;
|
public IMemoryCache cache;
|
||||||
public IndexModel(ILogger<IndexModel> logger)
|
public AppDbContext ctx;
|
||||||
|
public string? uri { get; set; } = null;
|
||||||
|
public IndexModel(ILogger<IndexModel> logger, IMemoryCache cache, AppDbContext ctx)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
this.cache = cache;
|
||||||
|
this.ctx = ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnGet(/**string? uri**/)
|
public void OnGet(string? uri)
|
||||||
{
|
{
|
||||||
Page();
|
|
||||||
//this.uri = uri ?? null;
|
this.uri = uri ?? null;
|
||||||
|
Console.WriteLine(uri);
|
||||||
|
if (this.uri != null)
|
||||||
|
{
|
||||||
|
Redirects? fromCache = cache.Get<Redirects>($"redirectsWithUrl-{uri}") ?? null;
|
||||||
|
if (fromCache == null)
|
||||||
|
{
|
||||||
|
fromCache = ctx.Redirects.FirstOrDefault(k => k.uri == uri);
|
||||||
|
Console.WriteLine("Im here!");
|
||||||
|
if (fromCache != null)
|
||||||
|
cache.Set($"redirectsWithUrl-{uri}", (object)fromCache, DateTime.Now.AddMinutes(10));
|
||||||
|
}
|
||||||
|
Console.WriteLine(fromCache?.ToString());
|
||||||
|
Response.Redirect(fromCache?.redirectTo ?? "/404");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Page();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,6 +114,7 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<main role="main" class="pb-3">
|
<main role="main" class="pb-3">
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
# Hello, there!
|
# Hello, there!
|
||||||
[](https://yawaflua.ru)
|
[](https://yawaflua.ru)
|
||||||
[](https://github.com/yawaflua/yaflay.ru/actions/workflows/docker-image.yml)
|
[](https://github.com/yawaflua/yaflay.ru/actions/workflows/docker-image.yml)
|
||||||
|

|
||||||
|
|
||||||
This is my custom site, with url: [yawaflua.ru](https://yawaflua.ru/)
|
This is my custom site, with url: [yawaflua.ru](https://yawaflua.ru/)
|
||||||
|
|
||||||
@@ -15,13 +16,18 @@ If you wanna help me, create Issue or Pull request.
|
|||||||
- Main page is downloaded from user`s github readme(like [this](https://github.com/yawaflua/yawaflua))
|
- 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
|
- 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)
|
- Admin panel for blog`s, can make article for blog and write to db new redirect setting(Discord OAuth2)
|
||||||
- Future plans to make this project fully manageable from a docker-compose file (.env file or environment settings are supported by Docker)
|
- 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?
|
# How to start?
|
||||||
You should to use this command for download this package from ghcr:
|
You should to use this command for download this package from ghcr:
|
||||||
```cli
|
### For latest version
|
||||||
docker pull ghcr.io/yawaflua/yaflay.ru:master
|
```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:
|
After that create docker-compose file, for example:
|
||||||
```yml
|
```yml
|
||||||
version: "3.9"
|
version: "3.9"
|
||||||
|
|||||||
@@ -57,6 +57,10 @@ namespace yaflay.ru
|
|||||||
if (readmeFile == null)
|
if (readmeFile == null)
|
||||||
{
|
{
|
||||||
readmeFile = configuration.GetValue<string>("readmeFile");
|
readmeFile = configuration.GetValue<string>("readmeFile");
|
||||||
|
if (readmeFile == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("ReadmeFile link is null");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user