mirror of
https://github.com/yawaflua/yaflay.ru.git
synced 2026-02-04 19:04:12 +02:00
rework oembed, because he didn`t work as well
This commit is contained in:
@@ -6,7 +6,9 @@ using System.Net.Http.Headers;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using System.Xml.Schema;
|
using HeyRed.OEmbed.Abstractions;
|
||||||
|
using HeyRed.OEmbed.Models;
|
||||||
|
using HeyRed.OEmbed;
|
||||||
|
|
||||||
namespace yaflay.ru.Новая_папка
|
namespace yaflay.ru.Новая_папка
|
||||||
{
|
{
|
||||||
@@ -40,11 +42,12 @@ namespace yaflay.ru.Новая_папка
|
|||||||
public async Task<IActionResult> fromGitHub(string? uri)
|
public async Task<IActionResult> fromGitHub(string? uri)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (uri == "Robots.txt") { return Ok("User-Agent: * \n Disallow: \"/*\""); }
|
if (uri == "Robots.txt") { return Ok("User-Agent: * \n Disallow: /*"); }
|
||||||
|
|
||||||
|
|
||||||
string? url = await getUrlFromGit(uri);
|
string? url = await getUrlFromGit(uri);
|
||||||
|
await Console.Out.WriteLineAsync(url == null ? "Null" : $"notNull {url}");
|
||||||
return Redirect(url != null ? url : "https://yaflay.ru/");
|
return Redirect(url ?? "https://yaflay.ru/");
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET: HomeController/Create
|
// GET: HomeController/Create
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
<title>@ViewData["Title"] - yaflay.ru</title>
|
<title>@ViewData["Title"] - yaflay.ru</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 rel="stylesheet" href="~/yaflay.ru.styles.css" asp-append-version="true" />
|
<!-- <link rel="stylesheet" href="~/yaflay.ru.styles.css" asp-append-version="true" /> --!/>
|
||||||
|
<link type="application/json+oembed" href="~/json/oembed.json" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
|
|||||||
34
Startup.cs
34
Startup.cs
@@ -1,52 +1,22 @@
|
|||||||
using Microsoft.Extensions.Options;
|
|
||||||
using HeyRed.OEmbed;
|
|
||||||
using HeyRed.OEmbed.Providers;
|
|
||||||
|
|
||||||
namespace yaflay.ru
|
namespace yaflay.ru
|
||||||
{
|
{
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
private readonly IConfiguration configuration;
|
private readonly IConfiguration configuration;
|
||||||
private readonly OEmbedOptions options;
|
|
||||||
public Startup()
|
public Startup()
|
||||||
{
|
{
|
||||||
configuration = new ConfigurationBuilder()
|
configuration = new ConfigurationBuilder()
|
||||||
.AddEnvironmentVariables(prefix: "m.")
|
.AddEnvironmentVariables(prefix: "m.")
|
||||||
.AddJsonFile("appsettings.json", optional: true)
|
.AddJsonFile("appsettings.json", optional: true)
|
||||||
.Build();
|
.Build();
|
||||||
options = new OEmbedOptions()
|
|
||||||
{
|
|
||||||
EnableCache = true
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddControllers();
|
services.AddControllers();
|
||||||
services.AddRouting();
|
services.AddRouting();
|
||||||
services.AddRazorPages();
|
services.AddRazorPages();
|
||||||
services.AddOEmbed(options =>
|
|
||||||
{
|
|
||||||
options.EnableCache = true; // true by default
|
|
||||||
options.EnsureNotNull();
|
|
||||||
})
|
|
||||||
.ClearProviders()
|
|
||||||
.AddProvider<YoutubeProvider>()
|
|
||||||
.AddProvider<YandexMusicProvider>()
|
|
||||||
.AddProvider<FlickrProvider>()
|
|
||||||
.AddProvider<TwitterProvider>(options =>
|
|
||||||
{
|
|
||||||
options.Parameters = new Dictionary<string, string?>
|
|
||||||
{
|
|
||||||
["theme"] = "dark"
|
|
||||||
};
|
|
||||||
})
|
|
||||||
.AddProvider<FacebookProvider>(options =>
|
|
||||||
{
|
|
||||||
options.Parameters = new Dictionary<string, string?>
|
|
||||||
{
|
|
||||||
["access_token"] = "app_id|token"
|
|
||||||
};
|
|
||||||
});
|
|
||||||
services.AddMvc()
|
services.AddMvc()
|
||||||
.AddRazorPagesOptions(options =>
|
.AddRazorPagesOptions(options =>
|
||||||
{
|
{
|
||||||
|
|||||||
16
wwwroot/json/oembed.json
Normal file
16
wwwroot/json/oembed.json
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"embeds": [
|
||||||
|
{
|
||||||
|
"type": "link",
|
||||||
|
"url": "https://yaflay.ru/",
|
||||||
|
"title": "YaFlay ReadMe",
|
||||||
|
"description": "Here you can learn about YaFlay: social networks, programming languages that he knows and his projects.",
|
||||||
|
"thumbnail": {
|
||||||
|
"url": "https://avatars.githubusercontent.com/u/93622229?v=4",
|
||||||
|
"proxy_url": "https://avatars.githubusercontent.com/u/93622229?v=4",
|
||||||
|
"width": 1200,
|
||||||
|
"height": 1200
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user