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:
34
Startup.cs
34
Startup.cs
@@ -1,52 +1,22 @@
|
||||
using Microsoft.Extensions.Options;
|
||||
using HeyRed.OEmbed;
|
||||
using HeyRed.OEmbed.Providers;
|
||||
|
||||
|
||||
namespace yaflay.ru
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
private readonly IConfiguration configuration;
|
||||
private readonly OEmbedOptions options;
|
||||
public Startup()
|
||||
{
|
||||
configuration = new ConfigurationBuilder()
|
||||
.AddEnvironmentVariables(prefix: "m.")
|
||||
.AddJsonFile("appsettings.json", optional: true)
|
||||
.Build();
|
||||
options = new OEmbedOptions()
|
||||
{
|
||||
EnableCache = true
|
||||
};
|
||||
|
||||
}
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddControllers();
|
||||
services.AddRouting();
|
||||
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()
|
||||
.AddRazorPagesOptions(options =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user