Skip to content

Commit

Permalink
feat(XbyK Update): update XbyK libraries to version 30.0.0. Update da…
Browse files Browse the repository at this point in the history
…ncing goat to the latest version. (#84)

* feat(XbyK Update): update XbyK libraries to version 30.0.0. Update dancing goat to the latest version.

* fix(DancingGoat): Return back example search view

* update(npm): xperience libraries v30.0.0

* feat(WebScrapper example): repelace obsolete regex

---------

Co-authored-by: Boris Kapustík <kapustik@nittin.cz>
  • Loading branch information
bkapustik and Boris Kapustík authored Dec 19, 2024
1 parent 50f1e82 commit 2ac2da4
Show file tree
Hide file tree
Showing 40 changed files with 3,266 additions and 3,203 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</ItemGroup>

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<WarningsAsErrors>nullable</WarningsAsErrors>
Expand Down
14 changes: 7 additions & 7 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Kentico.Xperience.Admin" Version="29.5.3" />
<PackageVersion Include="Kentico.Xperience.Azurestorage" Version="29.5.3" />
<PackageVersion Include="Kentico.Xperience.Cloud" Version="29.5.3" />
<PackageVersion Include="Kentico.Xperience.Core" Version="29.5.3" />
<PackageVersion Include="Kentico.Xperience.Imageprocessing" Version="29.5.3" />
<PackageVersion Include="Kentico.Xperience.WebApp" Version="29.5.3" />
<PackageVersion Include="Kentico.Xperience.Core.Tests" Version="29.5.3" />
<PackageVersion Include="Kentico.Xperience.Admin" Version="30.0.0" />
<PackageVersion Include="Kentico.Xperience.Azurestorage" Version="30.0.0" />
<PackageVersion Include="Kentico.Xperience.Cloud" Version="30.0.0" />
<PackageVersion Include="Kentico.Xperience.Core" Version="30.0.0" />
<PackageVersion Include="Kentico.Xperience.Imageprocessing" Version="30.0.0" />
<PackageVersion Include="Kentico.Xperience.WebApp" Version="30.0.0" />
<PackageVersion Include="Kentico.Xperience.Core.Tests" Version="30.0.0" />
<PackageVersion Include="Kentico.Xperience.Lucene" Version="" Condition="'$(LOCAL_NUGET)' == 'true'" />
<PackageVersion Include="Lucene.Net" Version="4.8.0-beta00016" />
<PackageVersion Include="Lucene.Net.Analysis.Common" Version="4.8.0-beta00016" />
Expand Down
32 changes: 16 additions & 16 deletions Kentico.Xperience.Lucene.sln
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{91F22D92
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kentico.Xperience.Lucene.Core.Tests", "tests\Kentico.Xperience.Lucene.Tests\Kentico.Xperience.Lucene.Core.Tests.csproj", "{DEB25130-C00C-44E5-8393-07BB49F7480B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DancingGoat", "examples\DancingGoat\DancingGoat.csproj", "{A4F272B0-A8F0-4CFB-856D-DE88C0255339}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kentico.Xperience.Lucene.Admin", "src\Kentico.Xperience.Lucene.Admin\Kentico.Xperience.Lucene.Admin.csproj", "{786BEEC5-48CD-45BA-924E-451D93A50AD9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kentico.Xperience.Lucene.Core", "src\Kentico.Xperience.Lucene.Core\Kentico.Xperience.Lucene.Core.csproj", "{84E60E84-9684-40DB-B4F1-578A45D24A02}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DancingGoat", "examples\DancingGoat\DancingGoat.csproj", "{F6EE04A5-F1A2-47E2-80E8-1D9C61C2DBF1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -71,18 +71,6 @@ Global
{DEB25130-C00C-44E5-8393-07BB49F7480B}.Release|x64.Build.0 = Release|Any CPU
{DEB25130-C00C-44E5-8393-07BB49F7480B}.Release|x86.ActiveCfg = Release|Any CPU
{DEB25130-C00C-44E5-8393-07BB49F7480B}.Release|x86.Build.0 = Release|Any CPU
{A4F272B0-A8F0-4CFB-856D-DE88C0255339}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A4F272B0-A8F0-4CFB-856D-DE88C0255339}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A4F272B0-A8F0-4CFB-856D-DE88C0255339}.Debug|x64.ActiveCfg = Debug|Any CPU
{A4F272B0-A8F0-4CFB-856D-DE88C0255339}.Debug|x64.Build.0 = Debug|Any CPU
{A4F272B0-A8F0-4CFB-856D-DE88C0255339}.Debug|x86.ActiveCfg = Debug|Any CPU
{A4F272B0-A8F0-4CFB-856D-DE88C0255339}.Debug|x86.Build.0 = Debug|Any CPU
{A4F272B0-A8F0-4CFB-856D-DE88C0255339}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A4F272B0-A8F0-4CFB-856D-DE88C0255339}.Release|Any CPU.Build.0 = Release|Any CPU
{A4F272B0-A8F0-4CFB-856D-DE88C0255339}.Release|x64.ActiveCfg = Release|Any CPU
{A4F272B0-A8F0-4CFB-856D-DE88C0255339}.Release|x64.Build.0 = Release|Any CPU
{A4F272B0-A8F0-4CFB-856D-DE88C0255339}.Release|x86.ActiveCfg = Release|Any CPU
{A4F272B0-A8F0-4CFB-856D-DE88C0255339}.Release|x86.Build.0 = Release|Any CPU
{786BEEC5-48CD-45BA-924E-451D93A50AD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{786BEEC5-48CD-45BA-924E-451D93A50AD9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{786BEEC5-48CD-45BA-924E-451D93A50AD9}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand All @@ -107,19 +95,31 @@ Global
{84E60E84-9684-40DB-B4F1-578A45D24A02}.Release|x64.Build.0 = Release|Any CPU
{84E60E84-9684-40DB-B4F1-578A45D24A02}.Release|x86.ActiveCfg = Release|Any CPU
{84E60E84-9684-40DB-B4F1-578A45D24A02}.Release|x86.Build.0 = Release|Any CPU
{F6EE04A5-F1A2-47E2-80E8-1D9C61C2DBF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F6EE04A5-F1A2-47E2-80E8-1D9C61C2DBF1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F6EE04A5-F1A2-47E2-80E8-1D9C61C2DBF1}.Debug|x64.ActiveCfg = Debug|Any CPU
{F6EE04A5-F1A2-47E2-80E8-1D9C61C2DBF1}.Debug|x64.Build.0 = Debug|Any CPU
{F6EE04A5-F1A2-47E2-80E8-1D9C61C2DBF1}.Debug|x86.ActiveCfg = Debug|Any CPU
{F6EE04A5-F1A2-47E2-80E8-1D9C61C2DBF1}.Debug|x86.Build.0 = Debug|Any CPU
{F6EE04A5-F1A2-47E2-80E8-1D9C61C2DBF1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F6EE04A5-F1A2-47E2-80E8-1D9C61C2DBF1}.Release|Any CPU.Build.0 = Release|Any CPU
{F6EE04A5-F1A2-47E2-80E8-1D9C61C2DBF1}.Release|x64.ActiveCfg = Release|Any CPU
{F6EE04A5-F1A2-47E2-80E8-1D9C61C2DBF1}.Release|x64.Build.0 = Release|Any CPU
{F6EE04A5-F1A2-47E2-80E8-1D9C61C2DBF1}.Release|x86.ActiveCfg = Release|Any CPU
{F6EE04A5-F1A2-47E2-80E8-1D9C61C2DBF1}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{1B7E6E21-7FC4-4D8C-ADD3-5783B3690761} = {0D915C08-6113-4ECF-BC23-1D315BA4C0A5}
{DEB25130-C00C-44E5-8393-07BB49F7480B} = {91F22D92-B6DD-4C46-9853-1A5B649DD04C}
{A4F272B0-A8F0-4CFB-856D-DE88C0255339} = {57981684-9BC2-40B6-801F-22128F63F825}
{786BEEC5-48CD-45BA-924E-451D93A50AD9} = {0D915C08-6113-4ECF-BC23-1D315BA4C0A5}
{84E60E84-9684-40DB-B4F1-578A45D24A02} = {0D915C08-6113-4ECF-BC23-1D315BA4C0A5}
{F6EE04A5-F1A2-47E2-80E8-1D9C61C2DBF1} = {57981684-9BC2-40B6-801F-22128F63F825}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DDFD806E-9ACE-48D6-BA63-57AEC6D0465B}
{DB2B3A3A-F27B-42ED-88F2-AFF48626D16D} = {BFECEDB7-D450-48DF-B7A4-78BA2F20EEC2}
SolutionGuid = {DDFD806E-9ACE-48D6-BA63-57AEC6D0465B}
EndGlobalSection
EndGlobal
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": "29.5.3",
"version": "30.0.0",
"commands": [
"kentico-xperience-dbmanager"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private async Task<string> GetContactsPagePath(string languageName, Cancellation
const string CONTACTS_PAGE_TREE_PATH = "/Contacts";

var contactsPage = await contactsPageRepository.GetContactsPage(CONTACTS_PAGE_TREE_PATH, languageName, cancellationToken);
var url = await webPageUrlRetriever.Retrieve(contactsPage, cancellationToken);
var url = await webPageUrlRetriever.Retrieve(contactsPage, languageName, cancellationToken);

return url.RelativePath;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public async Task<IActionResult> Article()
return NotFound();
}

var model = await ArticleDetailViewModel.GetViewModel(article, languageName, articlePageRepository, urlRetriever);
var model = await ArticleDetailViewModel.GetViewModel(article, languageName, urlRetriever);

return new TemplateResult(model);
}
Expand Down
38 changes: 34 additions & 4 deletions examples/DancingGoat/Controllers/DancingGoatHomeController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using System.Threading.Tasks;
using System.Linq;
using System.Threading.Tasks;

using CMS.ContentEngine;
using CMS.Helpers;

using DancingGoat;
using DancingGoat.Controllers;
Expand All @@ -17,21 +21,47 @@ public class DancingGoatHomeController : Controller
{
private readonly HomePageRepository homePageRepository;
private readonly IWebPageDataContextRetriever webPageDataContextRetriever;
private readonly IContentQueryExecutor executor;
private readonly IProgressiveCache progressiveCache;

public DancingGoatHomeController(HomePageRepository homePageRepository, IWebPageDataContextRetriever webPageDataContextRetriever)
public DancingGoatHomeController(HomePageRepository homePageRepository, IWebPageDataContextRetriever webPageDataContextRetriever, IContentQueryExecutor executor, IProgressiveCache progressiveCache)
{
this.homePageRepository = homePageRepository;
this.webPageDataContextRetriever = webPageDataContextRetriever;
this.executor = executor;
this.progressiveCache = progressiveCache;
}


public async Task<IActionResult> Index()
{
var webPage = webPageDataContextRetriever.Retrieve().WebPage;

var homePage = await homePageRepository.GetHomePage(webPage.WebPageItemID, webPage.LanguageName, HttpContext.RequestAborted);

return View(HomePageViewModel.GetViewModel(homePage));
var cafes = await progressiveCache.LoadAsync(async (settings, cancellationToken) =>
{
var builder = new ContentItemQueryBuilder();
builder.ForContentTypes(p =>
{
p.InSmartFolder(homePage.HomePageCafesFolder.Identifier)
.WithContentTypeFields()
.OfContentType(Cafe.CONTENT_TYPE_NAME)
.WithLinkedItems(1);
})
.InLanguage(webPage.LanguageName)
.Parameters(p => p.TopN(3));

var cafes = (await executor.GetMappedResult<Cafe>(builder, cancellationToken: cancellationToken)).ToArray();

var cacheDependencyKeys = cafes.Select(c => "contentitem|byid|" + c.SystemFields.ContentItemID).ToList();
cacheDependencyKeys.Add($"webpage|byid|{webPage.WebPageItemID}|{webPage.LanguageName}");
cacheDependencyKeys.Add($"{SmartFolderInfo.OBJECT_TYPE}|byguid|{homePage.HomePageCafesFolder.Identifier}");
settings.CacheDependency = CacheHelper.GetCacheDependency(cacheDependencyKeys);

return cafes;
}, new CacheSettings(5, DancingGoatConstants.WEBSITE_CHANNEL_NAME, nameof(Cafe), webPage.WebPageItemID, webPage.LanguageName), HttpContext.RequestAborted);

return View(HomePageViewModel.GetViewModel(homePage, cafes));
}
}
}
Binary file modified examples/DancingGoat/Data/Template.zip
Binary file not shown.
44 changes: 24 additions & 20 deletions examples/DancingGoat/Models/Reusable/Tag/TagViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,39 @@

using Tag = CMS.ContentEngine.Tag;

namespace DancingGoat.Models;

public record TagViewModel(string Name, int Level, Guid Value, bool IsChecked = false)
namespace DancingGoat.Models
{
private const int ROOT_TAG_ID = 0;

public static TagViewModel GetViewModel(Tag tag, int level = 0) => new(tag.Title, level, tag.Identifier);


public static List<TagViewModel> GetViewModels(IEnumerable<Tag> tags)
public record TagViewModel(string Name, int Level, Guid Value, bool IsChecked = false)
{
var result = new List<TagViewModel>();
var tagsByParentId = tags.GroupBy(tag => tag.ParentID).ToDictionary(group => group.Key, group => group.ToList());
private const int ROOT_TAG_ID = 0;

if (tagsByParentId.TryGetValue(ROOT_TAG_ID, out var firstLevelTags))
public static TagViewModel GetViewModel(Tag tag, int level = 0)
{
GetTagsWithTagViewModels(firstLevelTags, ROOT_TAG_ID);
return new TagViewModel(tag.Title, level, tag.Identifier);
}

return result;


void GetTagsWithTagViewModels(IEnumerable<Tag> currentLevelTags, int level)
public static List<TagViewModel> GetViewModels(IEnumerable<Tag> tags)
{
foreach (var tag in currentLevelTags.OrderBy(tag => tag.Order))
var result = new List<TagViewModel>();
var tagsByParentId = tags.GroupBy(tag => tag.ParentID).ToDictionary(group => group.Key, group => group.ToList());

if (tagsByParentId.TryGetValue(ROOT_TAG_ID, out var firstLevelTags))
{
GetTagsWithTagViewModels(firstLevelTags, ROOT_TAG_ID);
}

return result;


void GetTagsWithTagViewModels(IEnumerable<Tag> currentLevelTags, int level)
{
var children = tagsByParentId.TryGetValue(tag.ID, out var childrenTags) ? childrenTags : Enumerable.Empty<Tag>();
result.Add(GetViewModel(tag, level));
GetTagsWithTagViewModels(children, level + 1);
foreach (var tag in currentLevelTags.OrderBy(tag => tag.Order))
{
var children = tagsByParentId.TryGetValue(tag.ID, out var childrenTags) ? childrenTags : Enumerable.Empty<Tag>();
result.Add(GetViewModel(tag, level));
GetTagsWithTagViewModels(children, level + 1);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace DancingGoat.Models
{
public record ArticleDetailViewModel(string Title, string TeaserUrl, string Summary, string Text, DateTime PublicationDate, Guid Guid, bool IsSecured, string Url, IEnumerable<RelatedArticleViewModel> RelatedArticles)
public record ArticleDetailViewModel(string Title, string TeaserUrl, string Summary, string Text, DateTime PublicationDate, Guid Guid, bool IsSecured, string Url, IEnumerable<RelatedPageViewModel> RelatedPages)
: IWebPageBasedViewModel
{
/// <inheritdoc/>
Expand All @@ -17,18 +17,15 @@ public record ArticleDetailViewModel(string Title, string TeaserUrl, string Summ
/// <summary>
/// Validates and maps <see cref="ArticlePage"/> to a <see cref="ArticleDetailViewModel"/>.
/// </summary>
public static async Task<ArticleDetailViewModel> GetViewModel(ArticlePage articlePage, string languageName, ArticlePageRepository articlePageRepository, IWebPageUrlRetriever urlRetriever)
public static async Task<ArticleDetailViewModel> GetViewModel(ArticlePage articlePage, string languageName, IWebPageUrlRetriever urlRetriever)
{
var teaser = articlePage.ArticlePageTeaser.FirstOrDefault();

var relatedArticles = await articlePageRepository
.GetArticles(articlePage.ArticleRelatedArticles.Select(article => article.WebPageGuid).ToList(), languageName);
var relatedPageViewModels = new List<RelatedPageViewModel>();

var relatedArticlesViewModels = new List<RelatedArticleViewModel>();

foreach (var relatedArticle in relatedArticles)
foreach (var relatedPage in articlePage.ArticleRelatedPages)
{
relatedArticlesViewModels.Add(await RelatedArticleViewModel.GetViewModel(relatedArticle, urlRetriever, languageName));
relatedPageViewModels.Add(await RelatedPageViewModel.GetViewModel(relatedPage, urlRetriever, languageName));
}

var url = await urlRetriever.Retrieve(articlePage, languageName);
Expand All @@ -42,7 +39,7 @@ public static async Task<ArticleDetailViewModel> GetViewModel(ArticlePage articl
articlePage.SystemFields.ContentItemGUID,
articlePage.SystemFields.ContentItemIsSecured,
url.RelativePath,
relatedArticlesViewModels)
relatedPageViewModels)
{
WebPage = articlePage
};
Expand Down
Loading

0 comments on commit 2ac2da4

Please sign in to comment.