Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sergio #17098

Closed
wants to merge 9 commits into from
Closed

Sergio #17098

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/OrchardCore.Cms.Web/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "9.0.0",
"commands": [
"dotnet-ef"
],
"rollForward": false
}
}
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions src/OrchardCore.Cms.Web/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:17458/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"OrchardCore.Mvc.Web": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using OrchardCore.BackgroundTasks;
using OrchardCore.ContentManagement;
using OrchardCore.ContentTypes.Editors;
using OrchardCore.Data.Migration;
using OrchardCore.Deployment;
using OrchardCore.DisplayManagement.Descriptors;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.Environment.Shell.Configuration;
using OrchardCore.Modules;
using OrchardCore.Navigation;
using OrchardCore.Queries;
using OrchardCore.Queries.Core;
using OrchardCore.Queries.Sql.Migrations;
using OrchardCore.Search.Abstractions;
using OrchardCore.Search.Elasticsearch.Core.Deployment;
using OrchardCore.Search.Elasticsearch.Core.Models;
using OrchardCore.Search.Elasticsearch.Core.Providers;
using OrchardCore.Search.Elasticsearch.Core.Services;
using OrchardCore.Search.Elasticsearch.Drivers;
using OrchardCore.Search.Elasticsearch.Services;
using OrchardCore.Search.Lucene.Handler;
using OrchardCore.Security.Permissions;

namespace OrchardCore.Search.Elasticsearch;

public sealed class Startup : StartupBase
{
private readonly IShellConfiguration _shellConfiguration;

public Startup(IShellConfiguration shellConfiguration)
{
_shellConfiguration = shellConfiguration;
}

public override void ConfigureServices(IServiceCollection services)
{
services.AddTransient<IConfigureOptions<ElasticsearchConnectionOptions>, ElasticsearchConnectionOptionsConfigurations>();
services.AddSingleton((sp) =>
{
var options = sp.GetRequiredService<IOptions<ElasticsearchConnectionOptions>>().Value;

return ElasticsearchClientFactory.Create(options);
});

services.Configure<ElasticsearchOptions>(options =>
{
var configuration = _shellConfiguration.GetSection(ElasticsearchConnectionOptionsConfigurations.ConfigSectionName);

options.AddIndexPrefix(configuration);
options.AddTokenFilters(configuration);
options.AddAnalyzers(configuration);
});

services.AddElasticsearchServices();
services.AddPermissionProvider<PermissionProvider>();
services.AddNavigationProvider<AdminMenu>();
services.AddDisplayDriver<Query, ElasticsearchQueryDisplayDriver>();
services.AddDataMigration<ElasticsearchQueryMigrations>();
services.AddScoped<IQueryHandler, ElasticsearchQueryHandler>();
}
}

[RequireFeatures("OrchardCore.Search")]
public sealed class SearchStartup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddScoped<ISearchService, ElasticsearchService>();
services.AddSiteDisplayDriver<ElasticSettingsDisplayDriver>();
services.AddScoped<IAuthorizationHandler, ElasticsearchAuthorizationHandler>();
}
}

[RequireFeatures("OrchardCore.Deployment")]
public sealed class DeploymentStartup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddDeployment<ElasticsearchIndexDeploymentSource, ElasticsearchIndexDeploymentStep, ElasticIndexDeploymentStepDriver>();
services.AddDeployment<ElasticSettingsDeploymentSource, ElasticSettingsDeploymentStep, ElasticSettingsDeploymentStepDriver>();
services.AddDeployment<ElasticsearchIndexRebuildDeploymentSource, ElasticsearchIndexRebuildDeploymentStep, ElasticIndexRebuildDeploymentStepDriver>();
services.AddDeployment<ElasticsearchIndexResetDeploymentSource, ElasticsearchIndexResetDeploymentStep, ElasticIndexResetDeploymentStepDriver>();
}
}

[Feature("OrchardCore.Search.Elasticsearch.Worker")]
public sealed class ElasticWorkerStartup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<IBackgroundTask, IndexingBackgroundTask>();
}
}

[Feature("OrchardCore.Search.Elasticsearch.ContentPicker")]
public sealed class ElasticContentPickerStartup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddScoped<IContentPickerResultProvider, ElasticsearchContentPickerResultProvider>();
services.AddScoped<IContentPartFieldDefinitionDisplayDriver, ContentPickerFieldElasticEditorSettingsDriver>();
services.AddShapeAttributes<ElasticContentPickerShapeProvider>();
}
}

[RequireFeatures("OrchardCore.ContentTypes")]
public sealed class ContentTypesStartup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddScoped<IContentTypePartDefinitionDisplayDriver, ContentTypePartIndexSettingsDisplayDriver>();
services.AddScoped<IContentPartFieldDefinitionDisplayDriver, ContentPartFieldIndexSettingsDisplayDriver>();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;

using OrchardCore.BackgroundTasks;
using OrchardCore.ContentManagement;
using OrchardCore.ContentTypes.Editors;
using OrchardCore.Data.Migration;
using OrchardCore.Deployment;
using OrchardCore.DisplayManagement.Descriptors;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.Environment.Shell.Configuration;
using OrchardCore.Modules;
using OrchardCore.Navigation;
using OrchardCore.Queries;
using OrchardCore.Queries.Core;
using OrchardCore.Queries.Sql.Migrations;
using OrchardCore.Search.Abstractions;
using OrchardCore.Search.Elasticsearch.Core.Deployment;
using OrchardCore.Search.Elasticsearch.Core.Models;
using OrchardCore.Search.Elasticsearch.Core.Providers;
using OrchardCore.Search.Elasticsearch.Core.Services;
using OrchardCore.Search.Elasticsearch.Drivers;
using OrchardCore.Search.Elasticsearch.Services;
using OrchardCore.Search.Lucene.Handler;
using OrchardCore.Security.Permissions;

namespace OrchardCore.Search.Elasticsearch;

public sealed class Startup : StartupBase
{
private readonly IShellConfiguration _shellConfiguration;

public Startup(IShellConfiguration shellConfiguration)
{
_shellConfiguration = shellConfiguration;
}

public override void ConfigureServices(IServiceCollection services)
{
services.AddTransient<IConfigureOptions<ElasticsearchConnectionOptions>, ElasticsearchConnectionOptionsConfigurations>();
services.AddSingleton((sp) =>
{
var options = sp.GetRequiredService<IOptions<ElasticsearchConnectionOptions>>().Value;

return ElasticsearchClientFactory.Create(options);
});

services.Configure<ElasticsearchOptions>(options =>
{
var configuration = _shellConfiguration.GetSection(ElasticsearchConnectionOptionsConfigurations.ConfigSectionName);

options.AddIndexPrefix(configuration);
options.AddTokenFilters(configuration);
options.AddAnalyzers(configuration);
});

services.AddElasticsearchServices();
services.AddPermissionProvider<PermissionProvider>();
services.AddNavigationProvider<AdminMenu>();
services.AddDisplayDriver<Query, ElasticsearchQueryDisplayDriver>();
services.AddDataMigration<ElasticsearchQueryMigrations>();
services.AddScoped<IQueryHandler, ElasticsearchQueryHandler>();
}
}

[RequireFeatures("OrchardCore.Search")]
public sealed class SearchStartup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddScoped<ISearchService, ElasticsearchService>();
services.AddSiteDisplayDriver<ElasticSettingsDisplayDriver>();
services.AddScoped<IAuthorizationHandler, ElasticsearchAuthorizationHandler>();
}
}

[RequireFeatures("OrchardCore.Deployment")]
public sealed class DeploymentStartup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddDeployment<ElasticsearchIndexDeploymentSource, ElasticsearchIndexDeploymentStep, ElasticIndexDeploymentStepDriver>();
services.AddDeployment<ElasticSettingsDeploymentSource, ElasticSettingsDeploymentStep, ElasticSettingsDeploymentStepDriver>();
services.AddDeployment<ElasticsearchIndexRebuildDeploymentSource, ElasticsearchIndexRebuildDeploymentStep, ElasticIndexRebuildDeploymentStepDriver>();
services.AddDeployment<ElasticsearchIndexResetDeploymentSource, ElasticsearchIndexResetDeploymentStep, ElasticIndexResetDeploymentStepDriver>();
}
}

[Feature("OrchardCore.Search.Elasticsearch.Worker")]
public sealed class ElasticWorkerStartup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<IBackgroundTask, IndexingBackgroundTask>();
}
}

[Feature("OrchardCore.Search.Elasticsearch.ContentPicker")]
public sealed class ElasticContentPickerStartup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddScoped<IContentPickerResultProvider, ElasticsearchContentPickerResultProvider>();
services.AddScoped<IContentPartFieldDefinitionDisplayDriver, ContentPickerFieldElasticEditorSettingsDriver>();
services.AddShapeAttributes<ElasticContentPickerShapeProvider>();
}
}

[RequireFeatures("OrchardCore.ContentTypes")]
public sealed class ContentTypesStartup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddScoped<IContentTypePartDefinitionDisplayDriver, ContentTypePartIndexSettingsDisplayDriver>();
services.AddScoped<IContentPartFieldDefinitionDisplayDriver, ContentPartFieldIndexSettingsDisplayDriver>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@

<Target Name="EnsureRazorSdk"
BeforeTargets="BeforeBuild">
<Error
Code="OC2001"
Condition="!('@(RazorGenerate)' == '' or '$(ResolvedRazorCompileToolset)' == 'RazorSdk')"
Text="The 'Microsoft.NET.Sdk.Razor' SDK is required on Themes and Modules for Razor files to be precompiled." />
</Target>

<Target Name="NoWarnOnRazorViewImportedTypeConflicts"
Expand Down Expand Up @@ -167,10 +163,6 @@
<Target Name="OrchardCoreErrorsModuleAtMostOne"
DependsOnTargets="OrchardCoreFilterModules"
BeforeTargets="BeforeBuild">
<Error
Code="OC2002"
Condition="@(OrchardCoreModules->Count()) > 1"
Text="'$(MSBuildProjectName)' cannot declare itself to be more than one 'Module' (@(OrchardCoreModules->Count()))." />
</Target>

<!-- Keyed on ItemGroup OrchardCoreModules list item, ctor args by position:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Elastic.Clients.Elasticsearch;
using Elastic.Transport;
using OrchardCore.Search.Elasticsearch.Core.Models;

namespace OrchardCore.Search.Elasticsearch.Core.Services;

public class ElasticsearchClientFactory
{
public static ElasticsearchClient Create(ElasticsearchConnectionOptions elasticConfiguration)
{
var settings = elasticConfiguration.ConnectionType switch
{
ElasticsearchConnectionType.CloudConnectionPool => new ElasticsearchClientSettings(elasticConfiguration.CloudId, new BasicAuthentication(elasticConfiguration.Username, elasticConfiguration.Password)),
ElasticsearchConnectionType.StaticConnectionPool => new ElasticsearchClientSettings(new StaticNodePool(GetNodeUris(elasticConfiguration))),
ElasticsearchConnectionType.SniffingConnectionPool => new ElasticsearchClientSettings(new SniffingNodePool(GetNodeUris(elasticConfiguration))),
ElasticsearchConnectionType.StickyConnectionPool => new ElasticsearchClientSettings(new StickyNodePool(GetNodeUris(elasticConfiguration))),
_ => new ElasticsearchClientSettings(GetNodeUris(elasticConfiguration).First()),
};

if (!string.IsNullOrWhiteSpace(elasticConfiguration.CertificateFingerprint))
{
settings.CertificateFingerprint(elasticConfiguration.CertificateFingerprint);
}

settings.EnableHttpCompression();

return new ElasticsearchClient(settings);
}

private static IEnumerable<Uri> GetNodeUris(ElasticsearchConnectionOptions elasticConfiguration)
{
return elasticConfiguration.Ports.Select(port => new Uri($"{elasticConfiguration.Url}:{port}")).Distinct();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Elastic.Clients.Elasticsearch;
using Elastic.Transport;

using OrchardCore.Search.Elasticsearch.Core.Models;

namespace OrchardCore.Search.Elasticsearch.Core.Services;

public class ElasticsearchClientFactory
{
public static ElasticsearchClient Create(ElasticsearchConnectionOptions elasticConfiguration)
{
var settings = elasticConfiguration.ConnectionType switch
{
ElasticsearchConnectionType.CloudConnectionPool => new ElasticsearchClientSettings(elasticConfiguration.CloudId, new BasicAuthentication(elasticConfiguration.Username, elasticConfiguration.Password)),
ElasticsearchConnectionType.StaticConnectionPool => new ElasticsearchClientSettings(new StaticNodePool(GetNodeUris(elasticConfiguration))),
ElasticsearchConnectionType.SniffingConnectionPool => new ElasticsearchClientSettings(new SniffingNodePool(GetNodeUris(elasticConfiguration))),
ElasticsearchConnectionType.StickyConnectionPool => new ElasticsearchClientSettings(new StickyNodePool(GetNodeUris(elasticConfiguration))),
_ => new ElasticsearchClientSettings(GetNodeUris(elasticConfiguration).First()),
};

if (!string.IsNullOrWhiteSpace(elasticConfiguration.CertificateFingerprint))
{
settings.CertificateFingerprint(elasticConfiguration.CertificateFingerprint);
}

settings.EnableHttpCompression();

return new ElasticsearchClient(settings);
}

private static IEnumerable<Uri> GetNodeUris(ElasticsearchConnectionOptions elasticConfiguration)
{
return elasticConfiguration.Ports.Select(port => new Uri($"{elasticConfiguration.Url}:{port}")).Distinct();
}
}
Loading