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

feat(Algolia): indexing reusable items #49

Merged
merged 23 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d6f35b5
feat(Algolia): indexing reusable items
bkapustik Aug 19, 2024
fcaded0
refactor(docs): change "" to string.Empty
bkapustik Aug 26, 2024
e9d63ae
refactor(Algolia): change "" constants to string.Empty
bkapustik Aug 26, 2024
ada129a
refactor(Algolia): change info providers to generic iinfoprovider
bkapustik Aug 26, 2024
a31c4e8
refactor(Algolia): remove infoprovider definitions
bkapustik Aug 26, 2024
f0b9df7
fix(docs): typo
bkapustik Aug 26, 2024
2d309c2
refactor(sln): change "" constants to string.Empty
bkapustik Aug 26, 2024
0c712db
fix(DancingGoat): refactor conditional blocks
bkapustik Aug 26, 2024
9ecfad9
feat(Indexing-reusable-items): update Kentico nuget versions to 29.4.2
bkapustik Sep 9, 2024
c306204
fix(algolia typescript component): incorrect selection description
bkapustik Sep 9, 2024
4a9e2fb
fix(indexed extensions): add channel check
bkapustik Sep 9, 2024
79abdff
fix(Kentico.Xperience.Algolia): null checks
bkapustik Sep 9, 2024
6655a60
fix(gitattributes): line endings
bkapustik Sep 9, 2024
2e28cb4
fix(example): dancing goat nullable
bkapustik Sep 9, 2024
16a045b
fix(Tests): apply channel check to test cases
bkapustik Sep 9, 2024
45c68dd
feat(Algolia): update client Kentico packages to 29.4.2
bkapustik Sep 9, 2024
a4c8774
fix(Algolia): intendation
bkapustik Sep 9, 2024
7823fe6
fix: src/Kentico.Xperience.Algolia/Admin/Client/package.json & src/Ke…
snyk-bot Sep 20, 2024
47ead41
fix(solution): update XbyK versions
bkapustik Sep 30, 2024
fb2d130
merge XbyK version updates
bkapustik Sep 30, 2024
c6fa0ed
fix(DancingGoat): delete unwanted files
bkapustik Sep 30, 2024
2e11b73
fix(repository): update kentico.xperience.dbmanager version in dotnet…
bkapustik Sep 30, 2024
8015f00
fix(Admin): use IPageLinkGenerator instead of obsolete IWebPageUrlGen…
bkapustik Sep 30, 2024
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
12 changes: 11 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -349,4 +349,14 @@ csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent

dotnet_style_prefer_collection_expression = true:suggestion
dotnet_style_namespace_match_folder = true:suggestion
dotnet_style_namespace_match_folder = true:suggestion
csharp_style_prefer_primary_constructors = true:suggestion
[*.{cs,vb}]
dotnet_style_coalesce_expression = true:error
dotnet_style_null_propagation = true:error
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:error
dotnet_style_prefer_auto_properties = true:warning
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
indent_size = 4
end_of_line = crlf
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text eol=crlf
*.png binary
*.jpg binary
12 changes: 6 additions & 6 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Kentico.Xperience.Admin" Version="29.0.0" />
<PackageVersion Include="Kentico.Xperience.Azurestorage" Version="29.0.0" />
<PackageVersion Include="Kentico.Xperience.Cloud" Version="29.0.0" />
<PackageVersion Include="Kentico.Xperience.Imageprocessing" Version="29.0.0" />
<PackageVersion Include="Kentico.Xperience.WebApp" Version="29.0.0" />
<PackageVersion Include="Kentico.Xperience.Core.Tests" Version="29.0.0" />
<PackageVersion Include="Kentico.Xperience.Admin" Version="29.5.0" />
<PackageVersion Include="Kentico.Xperience.Azurestorage" Version="29.5.0" />
<PackageVersion Include="Kentico.Xperience.Cloud" Version="29.5.0" />
<PackageVersion Include="Kentico.Xperience.Imageprocessing" Version="29.5.0" />
<PackageVersion Include="Kentico.Xperience.WebApp" Version="29.5.0" />
<PackageVersion Include="Kentico.Xperience.Core.Tests" Version="29.5.0" />
<PackageVersion Include="Algolia.Search" Version="6.16.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.UserSecrets" Version="6.0.1" />
<PackageVersion Include="SonarAnalyzer.CSharp" Version="9.6.0.74858" />
Expand Down
11 changes: 6 additions & 5 deletions docs/Custom-index-strategy.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class ExampleSearchIndexingStrategy : DefaultAlgoliaIndexingStrategy
{
var result = new List<JObject>();

string title = "";
string title = string.Empty;

// IIndexEventItemModel could be a reusable content item or a web page item, so we use
// pattern matching to get access to the web page item specific type and fields
Expand Down Expand Up @@ -95,11 +95,12 @@ Some properties of the `IIndexEventItemModel` are added to the JObjects by defau

public class AlgoliaSearchResultModel
{
public string Url { get; set; } = "";
public string ContentTypeName { get; set; } = "";
public string LanguageName { get; set; } = "";
// This field is defaultly only added to the document if the indexed item is a web page.
public string Url { get; set; } = string.Empty;
public string ContentTypeName { get; set; } = string.Empty;
public string LanguageName { get; set; } = string.Empty;
public Guid ItemGuid { get; set; }
public string ObjectID { get; set; } = "";
public string ObjectID { get; set; } = string.Empty;
}
```

Expand Down
18 changes: 13 additions & 5 deletions docs/Managing-Indexes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,24 @@ Fill out the search index form, populating the fields with your custom values.

![Administration search edit form](/images/xperience-administration-search-index-edit-form.jpg)

- Rebuild Hook - for validating a request rebuild of the search index from an external source (ex: API request)
- Indexed Languages - the index will only include content in the selected languages
- Channel Name - the index will only be triggered by web page item creation or modication in the selected website channel
- Index Name - the name of the displayed index.

- Included Reusable Content Types - these are the reusable content types that will be processed by your custom indexing strategy.
If no option is selected, no items will be processed.

- Indexed Languages - the index will only include content in the selected languages.

- Channel Name - the index will only be triggered by web page item creation or modification in the selected website channel.

- Indexing Strategy - the indexing strategy specified in code during dependency registration of a custom indexing strategies.
- If you want the default strategy to appear here, register it explicitly in `IServiceCollection.AddKenticoAlgolia()` method
- If you want the default strategy to appear here, register it explicitly in `IServiceCollection.AddKenticoAlgolia()` method.

- Rebuild Hook - for validating a request rebuild of the search index from an external source (ex: API request).

Now, configure the web page paths and content types that the search index depends on by clicking the Add New Path button
or clicking an existing path in the table at the top of the index configuration form.

![Administration search index list](/images/xperience-administration-search-index-edit-form-paths-edit.jpg)
![Administration search edit paths form](/images/xperience-administration-search-index-edit-form-paths-edit.jpg)

- Included Path - can be an exact relative path of a web page item, (ex: `/path/to/my/page`), or a wildcard path (ex: `/parent-path/%`)
- To determine a web page path, select the web page in the website channel page tree, then view the "Current URL" in the Content tab of the web page. The path will be the relative path excluding the domain
Expand Down
10 changes: 5 additions & 5 deletions docs/Scraping-web-page-content.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class WebCrawlerService
ex,
$"Tree Path: {page.SystemFields.WebPageItemTreePath}");
}
return "";
return string.Empty;
}

public async Task<string> CrawlPage(string url)
Expand All @@ -65,7 +65,7 @@ public class WebCrawlerService
ex,
$"Url: {url}");
}
return "";
return string.Empty;
}
}
```
Expand Down Expand Up @@ -126,8 +126,8 @@ public class WebScraperHtmlSanitizer
textContent = HTMLHelper.RegexHtmlToTextWhiteSpace.Replace(textContent, " ");
textContent = textContent.Trim();

string title = doc.Head?.QuerySelector("title")?.TextContent ?? "";
string description = doc.Head?.QuerySelector("meta[name='description']")?.GetAttribute("content") ?? "";
string title = doc.Head?.QuerySelector("title")?.TextContent ?? string.Empty;
string description = doc.Head?.QuerySelector("meta[name='description']")?.GetAttribute("content") ?? string.Empty;

return string.Join(
" ",
Expand Down Expand Up @@ -179,7 +179,7 @@ public override async Task<IEnumerable<JObject>> MapToAlgoliaJObjectsOrNull(IInd
{
// ...

string content = "";
string content = string.Empty;

if (item is IndexEventWebPageItemModel webpageItem &&
string.Equals(indexedModel.ContentTypeName, ArticlePage.CONTENT_TYPE_NAME, StringComparison.OrdinalIgnorecase))
Expand Down
86 changes: 0 additions & 86 deletions examples/DancingGoat/$CDRepository/repository.config

This file was deleted.

2 changes: 1 addition & 1 deletion examples/DancingGoat/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"kentico.xperience.dbmanager": {
"version": "28.1.2",
"version": "29.5.0",
"commands": [
"kentico-xperience-dbmanager"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class SampleDataGeneratorApplication : OverviewPageBase
private readonly IInfoProvider<ConsentInfo> consentInfoProvider;
private readonly IInfoProvider<BizFormInfo> bizFormInfoProvider;
private readonly IInfoProvider<ContactGroupInfo> contactGroupInfoProvider;
private readonly ISettingsKeyInfoProvider settingsKeyInfoProvider;
private readonly IInfoProvider<SettingsKeyInfo> settingsKeyInfoProvider;
private readonly IInfoProvider<WebsiteChannelInfo> websiteChannelInfoProvider;


Expand All @@ -63,7 +63,7 @@ public SampleDataGeneratorApplication(
IInfoProvider<ConsentInfo> consentInfoProvider,
IInfoProvider<BizFormInfo> bizFormInfoProvider,
IInfoProvider<ContactGroupInfo> contactGroupInfoProvider,
ISettingsKeyInfoProvider settingsKeyInfoProvider,
IInfoProvider<SettingsKeyInfo> settingsKeyInfoProvider,
IInfoProvider<WebsiteChannelInfo> websiteChannelInfoProvider)
{
this.formBuilderConfigurationSerializer = formBuilderConfigurationSerializer;
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion examples/DancingGoat/Components/ComponentIdentifiers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ public static class ComponentIdentifiers
public const string ARTICLE_TEMPLATE = "DancingGoat.Article";
public const string ARTICLE_WITH_SIDEBAR_TEMPLATE = "DancingGoat.ArticleWithSidebar";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

using Kentico.Forms.Web.Mvc;

[assembly: RegisterFormSection("DancingGoat.TitledSection", "Section with title", "~/Components/FormSections/TitledSection/_TitledSection.cshtml", Description = "Single-column section with one zone and an editable title", IconClass = "icon-rectangle-a", PropertiesType = typeof(TitledSectionProperties))]
[assembly: RegisterFormSection("DancingGoat.TitledSection", "Section with title", "~/Components/FormSections/TitledSection/_TitledSection.cshtml", Description = "Single-column section with one zone and an editable title", IconClass = "icon-rectangle-a", PropertiesType = typeof(TitledSectionProperties))]
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ public sealed class ColorPickerEditorViewModel : InlineEditorViewModel
/// </summary>
public string ColorCssClass { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ public abstract class InlineEditorViewModel
/// </summary>
public string PropertyName { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ public sealed class TextEditorViewModel : InlineEditorViewModel
/// </summary>
public string PlaceholderText { get; set; } = "Type your text";
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using DancingGoat;
using DancingGoat;
using DancingGoat.Models;
using DancingGoat.PageTemplates;
using DancingGoat.Sections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ public override bool Evaluate()
return contact.IsInAnyContactGroup(SelectedContactGroups.Select(c => c.ObjectCodeName).ToArray());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ public class ThemeSectionProperties : ISectionProperties
[DropDownComponent(Label = "Color scheme", Order = 1, Options = ";None\nsection-white;Flat white\nsection-cappuccino;Cappuccino")]
public string Theme { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ public class ThreeColumnSectionProperties : ThemeSectionProperties
[TextInputComponent(Label = "Title", Order = 1)]
public string Title { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ private static IEnumerable<string> GetWidgetsIdentifiers()
.Select(definition => definition.Identifier);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public async Task<ViewViewComponentResult> InvokeAsync(WebPageRelatedItem articl
var articlesSection = await articlesSectionRepository.GetArticlesSection(articlesSectionItem.WebPageGuid, languageName);
if (articlesSection == null)
{
return View("~/Components/ViewComponents/Articles/Default.cshtml", ArticlesSectionViewModel.GetViewModel(Enumerable.Empty<ArticleViewModel>(), string.Empty));
return View("~/Components/ViewComponents/Articles/Default.cshtml", ArticlesSectionViewModel.GetViewModel(null, Enumerable.Empty<ArticleViewModel>(), string.Empty));
}

var articlePages = await articlePageRepository.GetArticles(articlesSection.SystemFields.WebPageItemTreePath,
Expand All @@ -61,9 +61,9 @@ public async Task<ViewViewComponentResult> InvokeAsync(WebPageRelatedItem articl

var url = (await urlRetriever.Retrieve(articlesSection, languageName)).RelativePath;

var viewModel = ArticlesSectionViewModel.GetViewModel(models, url);
var viewModel = ArticlesSectionViewModel.GetViewModel(articlesSection, models, url);

return View("~/Components/ViewComponents/Articles/Default.cshtml", viewModel);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ public ViewViewComponentResult Invoke(BannerViewModel banner)
return View("~/Components/ViewComponents/Banner/Default.cshtml", banner);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ public ViewViewComponentResult Invoke(CafeViewModel cafe)
return View("~/Components/ViewComponents/Cafe/Default.cshtml", cafe);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace DancingGoat.ViewComponents
/// <summary>
/// Cafe card section view component.
/// </summary>
public class CafeCardSectionViewComponent: ViewComponent
public class CafeCardSectionViewComponent : ViewComponent
{
public ViewViewComponentResult Invoke(IEnumerable<CafeViewModel> cafes)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ public async Task<IViewComponentResult> InvokeAsync()
return View($"~/Components/ViewComponents/NavigationMenu/Default.cshtml", navigationViewModels);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ public class CTAButtonWidgetViewModel
/// </summary>
public bool OpenInNewTab { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ public class CardWidgetProperties : IWidgetProperties
/// </summary>
public string Text { get; set; }
}
}
}
Loading
Loading