add providers to oembed, add robots.txt

This commit is contained in:
Дмитрий Шиманский
2023-10-22 01:51:58 +03:00
parent 0fa9a491ae
commit 5471ad08ba
4 changed files with 37 additions and 3 deletions

View File

@@ -44,7 +44,7 @@ namespace yaflay.ru.Новая_папка
string? url = await getUrlFromGit(uri);
return Redirect(url != null ? url : uri);
return Redirect(url != null ? url : "https://yaflay.ru/");
}
// GET: HomeController/Create

9
Pages/RobotsTxt.cshtml Normal file
View File

@@ -0,0 +1,9 @@
@page
@{
Layout = null;
this.Response.ContentType = "text/plain";
}
# /robots.txt file for http://www.hanselman.com/
User-agent: *
<environment include="Development,Staging">Disallow: /</environment>
<environment include="Production">Disallow: /* </environment>

View File

@@ -1,5 +1,7 @@
using Microsoft.Extensions.Options;
using HeyRed.OEmbed;
using HeyRed.OEmbed.Providers;
namespace yaflay.ru
{
public class Startup
@@ -26,7 +28,30 @@ namespace yaflay.ru
{
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()
.AddRazorPagesOptions(options =>
{
options.Conventions.AddPageRoute("/robotstxt", "/Robots.Txt");
});
//services.AddDirectoryBrowser();

View File

@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.6.33723.286
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "yaflay.ru", "yaflay.ru.csproj", "{3AA2FE9B-D1AF-4B12-B090-7E4529BA40E0}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "yaflay.ru", "yaflay.ru.csproj", "{3AA2FE9B-D1AF-4B12-B090-7E4529BA40E0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution