Skip to content

Commit

Permalink
Merge pull request #56 from Kentico/feat/refresh-v30
Browse files Browse the repository at this point in the history
Feat/refresh v30
  • Loading branch information
Rumec authored Dec 19, 2024
2 parents 0a8b9c3 + 8b8af20 commit 36921f2
Show file tree
Hide file tree
Showing 18 changed files with 4,109 additions and 3,105 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
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.5.3" />
<PackageVersion Include="Kentico.Xperience.Azurestorage" Version="29.5.3" />
<PackageVersion Include="Kentico.Xperience.Cloud" 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.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="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
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
2 changes: 1 addition & 1 deletion examples/DancingGoat/DancingGoat.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>DancingGoat</RootNamespace>
<UserSecretsId>79c858af-5444-4954-8d0a-6592a961e82a</UserSecretsId>
<SeparatedAdmin Condition="'$(SeparatedAdmin)' == ''">false</SeparatedAdmin>
Expand Down
Binary file modified examples/DancingGoat/Data/Template.zip
Binary file not shown.
12 changes: 10 additions & 2 deletions examples/DancingGoat/Search/Services/WebScraperHtmlSanitizer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using AngleSharp.Html.Parser;
using System.Text.RegularExpressions;

using AngleSharp.Html.Parser;
using CMS.Helpers;

namespace DancingGoat.Search.Services;
Expand Down Expand Up @@ -50,7 +52,7 @@ public virtual string SanitizeHtmlDocument(string htmlContent)
string textContent = body.TextContent;

// Normalizes and trims whitespace characters
textContent = HTMLHelper.RegexHtmlToTextWhiteSpace.Replace(textContent, " ");
textContent = WebScraperHtmlSanitizerParser.WhiteSpace().Replace(textContent, " ");
textContent = textContent.Trim();

string title = doc.Head?.QuerySelector("title")?.TextContent ?? string.Empty;
Expand All @@ -62,3 +64,9 @@ public virtual string SanitizeHtmlDocument(string htmlContent)
);
}
}

public static partial class WebScraperHtmlSanitizerParser
{
[GeneratedRegex(@"\\s+")]
public static partial Regex WhiteSpace();
}
98 changes: 98 additions & 0 deletions examples/DancingGoat/Views/Search/Index.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
@using Kentico.Xperience.Algolia.Search
@using Algolia.Search.Models.Search
@using DancingGoat.Search
@using Microsoft.AspNetCore.Mvc.Localization
@using DancingGoat.Search.Models

@model SearchResponse<DancingGoatSearchResultModel>
@{
Dictionary<string, string> GetRouteData(int page) =>
new Dictionary<string, string>() { { "query", Model.Query }, { "pageSize", Model.ToString() }, { "page", page.ToString() } };
}

<h1>Search</h1>

<style>
.form-field {
margin-bottom: 0.8rem;
}
</style>

<div class="row" style="padding: 1rem;">
<div class="col-12">
<form asp-action="Index" method="get">
<div class="row">
<div class="col-md-12">
<div class="form-field">
<label class="control-label" asp-for="@Model.Query"></label>
<div class="editing-form-control-nested-control">
<input class="form-control" asp-for="@Model.Query" name="query">
<input type="hidden" asp-for="@Model.Page" name="page" />
</div>
</div>
</div>
</div>

<input type="submit" value="Submit">
</form>
</div>
</div>

@if (!Model.Hits.Any())
{
if (!String.IsNullOrWhiteSpace(Model.Query))
{
@HtmlLocalizer["Sorry, no results match {0}", Model.Query]
}

return;
}

@foreach (var item in Model.Hits)
{
<div class="row search-tile">
<h3 class="h4 search-tile-title">
<a href="@item.Url">@item.Title</a>
</h3>
</div>
}

<div class="pagination-container">
<ul class="pagination">
@if (Model.Page > 1)
{
<li class="PagedList-skipToPrevious">
<a asp-controller="Search" asp-all-route-data="GetRouteData(Model.Page - 1)">
@HtmlLocalizer["previous"]
</a>
</li>
}

@for (int pageNumber = 1; pageNumber <= Model.NbPages; pageNumber++)
{
if (pageNumber == Model.Page)
{
<li class="active">
<span>
@pageNumber
</span>
</li>
}
else
{
<li>
<a asp-controller="Search" asp-all-route-data="GetRouteData(pageNumber)">@pageNumber</a>
</li>
}
}

@if (Model.Page < Model.NbPages)
{
<li class="PagedList-skipToNext">
<a asp-controller="Search" asp-all-route-data="GetRouteData(Model.Page + 1)">
@HtmlLocalizer["next"]
</a>
</li>
}
</ul>
</div>
98 changes: 98 additions & 0 deletions examples/DancingGoat/Views/Search/Simple.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
@using Kentico.Xperience.Algolia.Search
@using Algolia.Search.Models.Search
@using DancingGoat.Search
@using Microsoft.AspNetCore.Mvc.Localization
@using DancingGoat.Search.Models

@model SearchResponse<DancingGoatSimpleSearchResultModel>
@{
Dictionary<string, string> GetRouteData(int page) =>
new Dictionary<string, string>() { { "query", Model.Query }, { "pageSize", Model.ToString() }, { "page", page.ToString() } };
}

<h1>Search</h1>

<style>
.form-field {
margin-bottom: 0.8rem;
}
</style>

<div class="row" style="padding: 1rem;">
<div class="col-12">
<form asp-action="Index" method="get">
<div class="row">
<div class="col-md-12">
<div class="form-field">
<label class="control-label" asp-for="@Model.Query"></label>
<div class="editing-form-control-nested-control">
<input class="form-control" asp-for="@Model.Query" name="query">
<input type="hidden" asp-for="@Model.Page" name="page" />
</div>
</div>
</div>
</div>

<input type="submit" value="Submit">
</form>
</div>
</div>

@if (!Model.Hits.Any())
{
if (!String.IsNullOrWhiteSpace(Model.Query))
{
@HtmlLocalizer["Sorry, no results match {0}", Model.Query]
}

return;
}

@foreach (var item in Model.Hits)
{
<div class="row search-tile">
<h3 class="h4 search-tile-title">
<a href="@item.Url">@item.Title</a>
</h3>
</div>
}

<div class="pagination-container">
<ul class="pagination">
@if (Model.Page > 1)
{
<li class="PagedList-skipToPrevious">
<a asp-controller="Search" asp-all-route-data="GetRouteData(Model.Page - 1)">
@HtmlLocalizer["previous"]
</a>
</li>
}

@for (int pageNumber = 1; pageNumber <= Model.NbPages; pageNumber++)
{
if (pageNumber == Model.Page)
{
<li class="active">
<span>
@pageNumber
</span>
</li>
}
else
{
<li>
<a asp-controller="Search" asp-all-route-data="GetRouteData(pageNumber)">@pageNumber</a>
</li>
}
}

@if (Model.Page < Model.NbPages)
{
<li class="PagedList-skipToNext">
<a asp-controller="Search" asp-all-route-data="GetRouteData(Model.Page + 1)">
@HtmlLocalizer["next"]
</a>
</li>
}
</ul>
</div>
Loading

0 comments on commit 36921f2

Please sign in to comment.