-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathStartup.cs
More file actions
94 lines (82 loc) · 3.97 KB
/
Startup.cs
File metadata and controls
94 lines (82 loc) · 3.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using Fluid;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using OrchardCore.Admin.Models;
using OrchardCore.ContentLocalization.Drivers;
using OrchardCore.ContentLocalization.Indexing;
using OrchardCore.ContentLocalization.Liquid;
using OrchardCore.ContentLocalization.Security;
using OrchardCore.ContentLocalization.Services;
using OrchardCore.ContentLocalization.Sitemaps;
using OrchardCore.ContentLocalization.ViewModels;
using OrchardCore.Contents.Services;
using OrchardCore.Contents.ViewModels;
using OrchardCore.DisplayManagement.Extensions;
using OrchardCore.Environment.Shell.Configuration;
using OrchardCore.Indexing;
using OrchardCore.Liquid;
using OrchardCore.Modules;
using OrchardCore.Navigation;
using OrchardCore.Security.Permissions;
using OrchardCore.Sitemaps.Builders;
namespace OrchardCore.ContentLocalization;
public sealed class Startup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.Configure<TemplateOptions>(o =>
{
o.MemberAccessStrategy.Register<LocalizationPartViewModel>();
})
.AddLiquidFilter<ContentLocalizationFilter>("localization_set");
services.AddScoped<IContentPartIndexHandler, LocalizationPartIndexHandler>();
services.AddSingleton<ILocalizationEntries, LocalizationEntries>();
services.AddContentLocalization();
services.AddPermissionProvider<Permissions>();
services.AddScoped<IAuthorizationHandler, LocalizeContentAuthorizationHandler>();
services.AddScoped<IContentsAdminListFilter, LocalizationPartContentsAdminListFilter>();
services.AddTransient<IContentsAdminListFilterProvider, LocalizationPartContentsAdminListFilterProvider>();
services.AddDisplayDriver<ContentOptionsViewModel, LocalizationContentsAdminListDisplayDriver>();
}
}
[Feature("OrchardCore.ContentLocalization.ContentCulturePicker")]
public sealed class ContentPickerStartup : StartupBase
{
private readonly IShellConfiguration _shellConfiguration;
public ContentPickerStartup(IShellConfiguration shellConfiguration)
{
_shellConfiguration = shellConfiguration;
}
public override void ConfigureServices(IServiceCollection services)
{
services.AddDisplayDriver<Navbar, ContentCulturePickerNavbarDisplayDriver>();
services.AddLiquidFilter<SwitchCultureUrlFilter>("switch_culture_url");
services.AddNavigationProvider<AdminMenu>();
services.AddScoped<IContentCulturePickerService, ContentCulturePickerService>();
services.AddSiteDisplayDriver<ContentCulturePickerSettingsDriver>();
services.AddSiteDisplayDriver<ContentRequestCultureProviderSettingsDriver>();
services.Configure<RequestLocalizationOptions>(options => options.AddInitialRequestCultureProvider(new ContentRequestCultureProvider()));
services.Configure<CulturePickerOptions>(_shellConfiguration.GetSection("OrchardCore_ContentLocalization_CulturePickerOptions"));
}
public override void Configure(IApplicationBuilder builder, IEndpointRouteBuilder routes, IServiceProvider serviceProvider)
{
routes.MapAreaControllerRoute(
name: "RedirectToLocalizedContent",
areaName: "OrchardCore.ContentLocalization",
pattern: "RedirectToLocalizedContent",
defaults: new { controller = "ContentCulturePicker", action = "RedirectToLocalizedContent" }
);
}
}
[Feature("OrchardCore.ContentLocalization.Sitemaps")]
public sealed class SitemapsStartup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddScoped<ISitemapContentItemExtendedMetadataProvider, SitemapUrlHrefLangExtendedMetadataProvider>();
services.Replace(ServiceDescriptor.Scoped<IContentItemsQueryProvider, LocalizedContentItemsQueryProvider>());
}
}