Skip to content

Commit

Permalink
Merge pull request #29 from Kentico/migrate-xbk
Browse files Browse the repository at this point in the history
Migrate xbk
  • Loading branch information
kentico-ericd authored Dec 13, 2022
2 parents e0a4779 + d82f3ee commit 2f80c3b
Show file tree
Hide file tree
Showing 82 changed files with 5,340 additions and 2,767 deletions.
26 changes: 6 additions & 20 deletions CMS/CMSModules/Kentico.Xperience.AlgoliaSearch/AlgoliaUIPage.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,18 @@
using Kentico.Xperience.AlgoliaSearch.Attributes;
using Kentico.Xperience.AlgoliaSearch.Services;

using CMS.Core;
using CMS.UIControls;

using System;
using System;
using System.Collections.Generic;
using System.Data;

namespace Kentico.Xperience.AlgoliaSearch
using Kentico.Xperience.Algolia.Attributes;

using CMS.UIControls;

namespace Kentico.Xperience.Algolia
{
/// <summary>
/// Base class for Algolia custom module pages.
/// </summary>
public class AlgoliaUIPage : CMSPage
{
protected IAlgoliaRegistrationService algoliaRegistrationService;
protected IAlgoliaSearchService algoliaSearchService;


protected override void OnInit(EventArgs e)
{
base.OnInit(e);
algoliaRegistrationService = Service.Resolve<IAlgoliaRegistrationService>();
algoliaSearchService = Service.Resolve<IAlgoliaSearchService>();
}


/// <summary>
/// Converts a collection of objects into a <see cref="DataSet"/>.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="AlgoliaSearch_Dashboard.aspx.cs" Inherits="Kentico.Xperience.AlgoliaSearch.Pages.AlgoliaSearch_Dashboard"
<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="AlgoliaSearch_Dashboard.aspx.cs" Inherits="Kentico.Xperience.Algolia.Pages.AlgoliaSearch_Dashboard"
Title="Algolia Index - Dashboard" MasterPageFile="~/CMSMasterPages/UI/SimplePage.master" Theme="Default" EnableEventValidation="false" ValidateRequest="false" %>

<%@ Register src="~/CMSAdminControls/UI/UniGrid/UniGrid.ascx" tagname="UniGrid" tagprefix="cms" %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,42 @@
using Algolia.Search.Models.Common;
using System;
using System.Collections.Generic;
using System.Linq;

using Algolia.Search.Models.Common;

using CMS.Core;
using CMS.Helpers;
using CMS.Modules;

using Kentico.Xperience.AlgoliaSearch.Models;
using Kentico.Xperience.AlgoliaSearch.Services;

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using Kentico.Xperience.Algolia.Models;
using Kentico.Xperience.Algolia.Services;

namespace Kentico.Xperience.AlgoliaSearch.Pages
namespace Kentico.Xperience.Algolia.Pages
{
public partial class AlgoliaSearch_Dashboard : AlgoliaUIPage
{
private IAlgoliaClient algoliaClient;


protected void Page_Load(object sender, EventArgs e)
{
ShowTaskCount();

var siteIndexes = algoliaRegistrationService.RegisteredIndexes.Where(i => i.SiteNames == null || i.SiteNames.Contains(CurrentSiteName));
if (siteIndexes.Count() == 0)
var siteIndexes = IndexStore.Instance.GetAll().Where(i => !i.SiteNames.Any() || i.SiteNames.Contains(CurrentSiteName));
if (!siteIndexes.Any())
{
ShowInformation("No Algolia indexes registered. See <a target='_blank' href='https://github.com/Kentico/xperience-algolia#gear-creating-and-registering-an-algolia-index'>our instructions</a> to read more about creating and registering Algolia indexes.");
return;
}

algoliaClient = Service.Resolve<IAlgoliaClient>();

LoadIndexes(siteIndexes);
}


private void ShowTaskCount()
{
if (algoliaRegistrationService.RegisteredIndexes.Count == 0)
if (!IndexStore.Instance.GetAll().Any())
{
return;
}
Expand All @@ -45,7 +48,7 @@ private void ShowTaskCount()
private void LoadIndexes(IEnumerable<AlgoliaIndex> indexes)
{
var indexesToList = new List<IndicesResponse>();
var indexStatistics = algoliaSearchService.GetStatistics();
var indexStatistics = algoliaClient.GetStatistics();
foreach (var index in indexes)
{
// Find statistics with matching name
Expand Down Expand Up @@ -94,7 +97,7 @@ private object UgIndexes_OnExternalDataBound(object sender, string sourceName, o

private void UgIndexes_OnAction(string actionName, object actionArgument)
{
var indexName = ValidationHelper.GetString(actionArgument, "");
var indexName = ValidationHelper.GetString(actionArgument, String.Empty);
if (String.IsNullOrEmpty(indexName))
{
ShowError("Unable to load index name.");
Expand All @@ -106,9 +109,7 @@ private void UgIndexes_OnAction(string actionName, object actionArgument)
case "rebuild":
try
{
var conn = Service.Resolve<IAlgoliaConnection>();
conn.Initialize(indexName);
conn.Rebuild();
algoliaClient.Rebuild(indexName);
ShowInformation("Index is rebuilding.");
}
catch (InvalidOperationException ex)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="AlgoliaSearch_IndexedContent.aspx.cs" Inherits="Kentico.Xperience.AlgoliaSearch.Pages.AlgoliaSearch_IndexedContent"
<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="AlgoliaSearch_IndexedContent.aspx.cs" Inherits="Kentico.Xperience.Algolia.Pages.AlgoliaSearch_IndexedContent"
Title="Algolia search - Indexed content" MasterPageFile="~/CMSMasterPages/UI/SimplePage.master" Theme="Default" EnableEventValidation="false" ValidateRequest="false" %>

<%@ Register src="~/CMSAdminControls/UI/UniGrid/UniGrid.ascx" tagname="UniGrid" tagprefix="cms" %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using CMS.Helpers;

using Kentico.Xperience.AlgoliaSearch.Attributes;
using Kentico.Xperience.AlgoliaSearch.Models;

using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace Kentico.Xperience.AlgoliaSearch.Pages
using CMS.Helpers;

using Kentico.Xperience.Algolia.Attributes;
using Kentico.Xperience.Algolia.Models;

namespace Kentico.Xperience.Algolia.Pages
{
public partial class AlgoliaSearch_IndexedContent : AlgoliaUIPage
{
Expand All @@ -27,7 +27,7 @@ protected override void OnLoad(EventArgs e)
return;
}

var foundIndex = algoliaRegistrationService.RegisteredIndexes.FirstOrDefault(i => i.IndexName == indexName);
var foundIndex = IndexStore.Instance.Get(indexName);
if (foundIndex == null)
{
ShowError($"Error loading registered Algolia index '{indexName}.'");
Expand Down Expand Up @@ -77,9 +77,8 @@ private void LoadPaths()
foreach (var includedPathAttribute in includedPathAttributes)
{
var includedPath = includedPathAttribute as IncludedPathAttribute;
var pageTypes = (includedPath.PageTypes.Length == 0) ? "(all)" : String.Join(", ", includedPath.PageTypes);
var cultures = (includedPath.Cultures.Length == 0) ? "(all)" : String.Join(", ", includedPath.Cultures);

var pageTypes = includedPath.PageTypes.Any() ? String.Join(", ", includedPath.PageTypes) : "(all)";
var cultures = includedPath.Cultures.Any() ? String.Join(", ", includedPath.Cultures) : "(all)";
includedContent.Add(new IncludedContent
{
Path = includedPath.AliasPath,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="AlgoliaSearch_Preview.aspx.cs" Inherits="Kentico.Xperience.AlgoliaSearch.Pages.AlgoliaSearch_Preview"
<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="AlgoliaSearch_Preview.aspx.cs" Inherits="Kentico.Xperience.Algolia.Pages.AlgoliaSearch_Preview"
Title="Algolia search - Search preview" MasterPageFile="~/CMSMasterPages/UI/SimplePage.master" Theme="Default" EnableEventValidation="false" ValidateRequest="false" %>

<%@ Register Src="~/CMSAdminControls/UI/Pager/UIPager.ascx" TagName="UIPager" TagPrefix="cms" %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using Algolia.Search.Models.Search;
using System;
using System.Text;
using System.Web;

using Algolia.Search.Models.Search;

using CMS.Core;
using CMS.Helpers;

using Kentico.Xperience.AlgoliaSearch.Services;
using Kentico.Xperience.Algolia.Services;

using Newtonsoft.Json.Linq;

using System;
using System.Text;
using System.Web;

namespace Kentico.Xperience.AlgoliaSearch.Pages
namespace Kentico.Xperience.Algolia.Pages
{
public partial class AlgoliaSearch_Preview : AlgoliaUIPage
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2f80c3b

Please sign in to comment.