Skip to content

Commit 20df6aa

Browse files
authored
Merge pull request #58 from umbraco/feature/algolia-integration
Algolia Search Engine integration
2 parents e73cd29 + ef764ff commit 20df6aa

38 files changed

+1592
-5
lines changed

azure-pipeline - Search.Algolia.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,19 @@ steps:
1414
- task: NuGetToolInstaller@1
1515
displayName: 'Install NuGet'
1616

17-
- task: NuGetCommand@2
17+
- task: DotNetCoreCLI@2
1818
displayName: 'NuGet Restore'
1919
inputs:
20-
restoreSolution: '$(solution)'
20+
command: 'restore'
21+
feedsToUse: 'select'
22+
projects: '$(project)'
23+
includeNuGetOrg: true
2124

2225
- task: VSBuild@1
26+
displayName: 'Build Project'
2327
inputs:
24-
solution: '$(solution)'
25-
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
28+
solution: '$(project)'
29+
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
2630
platform: '$(buildPlatform)'
2731
configuration: '$(buildConfiguration)'
2832

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using Algolia.Search.Models.Search;
2+
3+
using Microsoft.Extensions.DependencyInjection;
4+
5+
using Umbraco.Cms.Core.Composing;
6+
using Umbraco.Cms.Core.DependencyInjection;
7+
using Umbraco.Cms.Core.Notifications;
8+
using Umbraco.Cms.Integrations.Search.Algolia;
9+
using Umbraco.Cms.Integrations.Search.Algolia.Configuration;
10+
using Umbraco.Cms.Integrations.Search.Algolia.Handlers;
11+
using Umbraco.Cms.Integrations.Search.Algolia.Migrations;
12+
using Umbraco.Cms.Integrations.Search.Algolia.Models;
13+
using Umbraco.Cms.Integrations.Search.Algolia.Services;
14+
15+
namespace Umbraco.Cms.Integrations.Crm.ActiveCampaign
16+
{
17+
public class AlgoliaComposer : IComposer
18+
{
19+
public void Compose(IUmbracoBuilder builder)
20+
{
21+
builder.AddNotificationHandler<UmbracoApplicationStartingNotification, RunAlgoliaIndicesMigration>();
22+
23+
builder.AddNotificationAsyncHandler<ContentPublishedNotification, ContentPublishedHandler>();
24+
25+
builder.AddNotificationAsyncHandler<ContentDeletedNotification, ContentDeletedHandler>();
26+
27+
builder.AddNotificationAsyncHandler<ContentUnpublishedNotification, ContentUnpublishedHandler>();
28+
29+
var options = builder.Services.AddOptions<AlgoliaSettings>()
30+
.Bind(builder.Config.GetSection(Constants.SettingsPath));
31+
32+
builder.Services.AddSingleton<IAlgoliaIndexService, AlgoliaIndexService>();
33+
34+
builder.Services.AddSingleton<IAlgoliaSearchService<SearchResponse<Record>>, AlgoliaSearchService>();
35+
36+
builder.Services.AddScoped<IAlgoliaIndexDefinitionStorage<AlgoliaIndex>, AlgoliaIndexDefinitionStorage>();
37+
}
38+
39+
}
40+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Umbraco.Cms.Core.Composing;
2+
using Umbraco.Cms.Core.Dashboards;
3+
4+
namespace Umbraco.Cms.Integrations.Search.Algolia
5+
{
6+
[Weight(100)]
7+
public class AlgoliaDashboard : IDashboard
8+
{
9+
public string[] Sections => new[] { Umbraco.Cms.Core.Constants.Applications.Settings };
10+
11+
public IAccessRule[] AccessRules => Array.Empty<IAccessRule>();
12+
13+
public string Alias => "algoliaSearchManagement";
14+
15+
public string View => "/App_Plugins/UmbracoCms.Integrations/Search/Algolia/views/dashboard.html";
16+
}
17+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
2+
<language>
3+
<area alias="dashboardTabs">
4+
<key alias="algoliaSearchManagement">Algolia Search Management</key>
5+
</area>
6+
<area alias="algolia">
7+
<key alias="pushData">Push Data</key>
8+
</area>
9+
</language>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.umb-content-grid {
2+
display:grid;
3+
grid-template-columns: repeat(3, 1fr);
4+
gap:10px;
5+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
angular.module('umbraco.resources').factory('umbracoCmsIntegrationsSearchAlgoliaResource',
2+
function ($http, umbRequestHelper) {
3+
4+
const apiEndpoint = "backoffice/UmbracoCmsIntegrationsSearchAlgolia/Search";
5+
6+
return {
7+
getIndices: function () {
8+
return umbRequestHelper.resourcePromise(
9+
$http.get(`${apiEndpoint}/GetIndices`),
10+
"Failed");
11+
},
12+
saveIndex: function (id, name, contentData) {
13+
return umbRequestHelper.resourcePromise(
14+
$http.post(`${apiEndpoint}/SaveIndex`, { id: id, name: name, contentData: contentData }),
15+
"Failed");
16+
},
17+
buildIndex: function (id) {
18+
return umbRequestHelper.resourcePromise(
19+
$http.post(`${apiEndpoint}/BuildIndex`, { id: id }),
20+
"Failed");
21+
},
22+
deleteIndex: function (id) {
23+
return umbRequestHelper.resourcePromise(
24+
$http.delete(`${apiEndpoint}/DeleteIndex?id=${id}`),
25+
"Failed");
26+
},
27+
search: function (indexId, query) {
28+
return umbRequestHelper.resourcePromise(
29+
$http.get(`${apiEndpoint}/Search?indexId=${indexId}&query=${query}`),
30+
"Failed");
31+
}
32+
};
33+
}
34+
);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
function algoliaService(contentTypeResource) {
2+
return {
3+
getContentTypes: function (callback) {
4+
contentTypeResource.getAll().then(function (data) {
5+
callback(data.filter(item => item.parentId == -1 && !item.isElement).map((item) => {
6+
return {
7+
id: item.id,
8+
icon: item.icon,
9+
alias: item.alias,
10+
name: item.name,
11+
selected: false,
12+
allowRemove: false
13+
}
14+
}));
15+
});
16+
},
17+
getPropertiesByContentTypeId: function (contentTypeId, callback) {
18+
contentTypeResource.getById(contentTypeId).then(function (data) {
19+
var properties = [];
20+
21+
for (var i = 0; i < data.groups.length; i++) {
22+
for (var j = 0; j < data.groups[i].properties.length; j++) {
23+
properties.push({
24+
id: data.groups[i].properties[j].id,
25+
icon: "icon-indent",
26+
alias: data.groups[i].properties[j].alias,
27+
name: data.groups[i].properties[j].label,
28+
group: data.groups[i].name,
29+
selected: false
30+
});
31+
}
32+
}
33+
34+
callback(properties);
35+
});
36+
}
37+
}
38+
}
39+
40+
angular.module("umbraco.services")
41+
.factory("algoliaService", algoliaService);

0 commit comments

Comments
 (0)