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/update xbyk v30.0.0 #36

Merged
merged 7 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Azure.Search.Documents" Version="11.6.0-beta.2" />
<PackageVersion Include="Kentico.Xperience.Admin" Version="29.5.3" />
<PackageVersion Include="Kentico.Xperience.WebApp" Version="29.5.3" />
<PackageVersion Include="kentico.xperience.azurestorage" Version="29.5.3" />
<PackageVersion Include="kentico.xperience.imageprocessing" 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.WebApp" Version="30.0.0" />
<PackageVersion Include="kentico.xperience.azurestorage" Version="30.0.0" />
<PackageVersion Include="kentico.xperience.imageprocessing" Version="30.0.0" />
<PackageVersion Include="Kentico.Xperience.Core.Tests" Version="30.0.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="SonarAnalyzer.CSharp" Version="9.20.0.85982" />

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
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;

Expand Down Expand Up @@ -51,7 +53,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 ?? "";
Expand All @@ -63,3 +65,9 @@ public virtual string SanitizeHtmlDocument(string htmlContent)
);
}
}

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

@model GeoLocationSearchViewModel
@{
Dictionary<string, string> GetRouteData(int page) =>
new Dictionary<string, string>() {
{ "query", Model.Query },
{ "pageSize", Model.PageSize.ToString() },
{ "page", page.ToString() },
{ "latitude", Model.Latitude.ToString() },
{ "longitude", Model.Longitude.ToString() },
{ "sortByDistance", Model.SortByDistance.ToString() },
{ "indexName", Model.IndexName }
};
}

<h1>Search</h1>

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

<form asp-action=@Model.Endpoint 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.PageSize" name="pageSize" />
<input type="hidden" asp-for="@Model.Page" name="page" />
<input type="hidden" id="latitude" asp-for="@Model.Latitude" name="latitude" />
<input type="hidden" id="longitude" asp-for="@Model.Longitude" name="longitude" />
<input type="hidden" asp-for="@Model.IndexName" name="indexName" />
</div>
</div>
</div>
</div>
<label for="sortByDistance">Sort By Distance</label>
<input type="checkbox" id="sortByDistance" value="true" asp-for="@Model.SortByDistance" name="sortByDistance">
<input type="submit" value="Submit">
</form>

@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="col-sm-12">
<div class="section-text">
<h3 class="h4 search-tile-title">
<a href="@item.Url">@item.Title</a>
</h3>
<div>
@Html.Raw(item.Location)
</div>
</div>
</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.TotalPages; 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.TotalPages)
{
<li class="PagedList-skipToNext">
<a asp-controller="Search" asp-all-route-data="GetRouteData(Model.Page + 1)">
@HtmlLocalizer["next"]
</a>
</li>
}
</ul>
</div>

<script>
document.addEventListener("DOMContentLoaded", function() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
document.getElementById('latitude').value = position.coords.latitude;
document.getElementById('longitude').value = position.coords.longitude;
});
} else {
alert("Geolocation is not supported by this browser.");
}
});
</script>
105 changes: 105 additions & 0 deletions examples/DancingGoat/Views/Search/Index.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
@using DancingGoat.Search.Models
@using DancingGoat.Search
@using Microsoft.AspNetCore.Mvc.Localization

@model DancingGoatSearchViewModel
@{
Dictionary<string, string> GetRouteData(int page) =>
new Dictionary<string, string>() {
{ "query", Model.Query },
{ "pageSize", Model.PageSize.ToString() },
{ "page", page.ToString() },
{ "indexName", 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=@Model.Endpoint 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.PageSize" name="pageSize" />
<input type="hidden" asp-for="@Model.Page" name="page" />
<input type="hidden" asp-for="@Model.IndexName" name="indexName" />
</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="col-sm-12">
<div class="section-text">
<h3 class="h4 search-tile-title">
<a href="@item.Url">@item.Title</a>
</h3>
</div>
</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.TotalPages; 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.TotalPages)
{
<li class="PagedList-skipToNext">
<a asp-controller="Search" asp-all-route-data="GetRouteData(Model.Page + 1)">
@HtmlLocalizer["next"]
</a>
</li>
}
</ul>
</div>
Loading
Loading