Skip to content
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
2 changes: 1 addition & 1 deletion src/NavigationDemo.Web/NavigationDemo.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="cloudscribe.Web.Localization" Version="8.6.0" />
<PackageReference Include="cloudscribe.Web.Localization" Version="8.7.0" />
</ItemGroup>

<ItemGroup>
Expand Down
11 changes: 8 additions & 3 deletions src/cloudscribe.Web.Navigation/CachingNavigationViewComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,17 @@
// In a simplecontent system I'd probably need to use the IHandlePageCreated (etc)
// hooks to clear a navcache of known name.

public async Task<IViewComponentResult> InvokeAsync(string viewName,
string filterName,
string startingNodeKey,
public async Task<IViewComponentResult> InvokeAsync(string viewName,
string filterName,
string startingNodeKey,
int expirationSeconds = 60,
bool testMode = false)
{
if (NavigationSuppressor.IsFilterSuppressed(Request.HttpContext, filterName))
{
return Content(string.Empty);
}

NavigationViewModel model = null;

string cacheKey = $"{viewName}_{filterName}_{startingNodeKey}";
Expand Down Expand Up @@ -142,7 +147,7 @@
catch (Exception ex)
{
_log.LogError(ex, $"CachingNavigationViewComponent: Failed to render view for {fullViewName}");
throw (ex);

Check warning on line 150 in src/cloudscribe.Web.Navigation/CachingNavigationViewComponent.cs

View workflow job for this annotation

GitHub Actions / build

Re-throwing caught exception changes stack information (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2200)

Check warning on line 150 in src/cloudscribe.Web.Navigation/CachingNavigationViewComponent.cs

View workflow job for this annotation

GitHub Actions / build

Re-throwing caught exception changes stack information (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2200)

Check warning on line 150 in src/cloudscribe.Web.Navigation/CachingNavigationViewComponent.cs

View workflow job for this annotation

GitHub Actions / build

Re-throwing caught exception changes stack information (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2200)

Check warning on line 150 in src/cloudscribe.Web.Navigation/CachingNavigationViewComponent.cs

View workflow job for this annotation

GitHub Actions / build

Re-throwing caught exception changes stack information (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2200)
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/cloudscribe.Web.Navigation/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ namespace cloudscribe.Web.Navigation
public static class Constants
{
public static readonly string TailCrumbsContexctKey = "navigationtailcrumbs";
public static readonly string NavigationSuppressContextKey = "navigation-suppress";
}
}
43 changes: 43 additions & 0 deletions src/cloudscribe.Web.Navigation/NavigationSuppressor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) Source Tree Solutions, LLC. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;

namespace cloudscribe.Web.Navigation
{
/// <summary>
/// Allows consuming applications to suppress specific navigation filters for the current request.
/// When a filter is suppressed, the NavigationViewComponent and CachingNavigationViewComponent
/// will return empty content immediately, avoiding all tree-building computation.
/// </summary>
public static class NavigationSuppressor
{
public static void SuppressFilter(HttpContext context, string filterName)
{
if (context == null) throw new ArgumentNullException(nameof(context));
if (string.IsNullOrEmpty(filterName)) return;

var key = Constants.NavigationSuppressContextKey;
if (context.Items[key] is not HashSet<string> suppressed)
{
suppressed = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
context.Items[key] = suppressed;
}
suppressed.Add(filterName);
}

public static bool IsFilterSuppressed(HttpContext context, string filterName)
{
if (context == null) return false;
if (string.IsNullOrEmpty(filterName)) return false;

if (context.Items[Constants.NavigationSuppressContextKey] is HashSet<string> suppressed)
{
return suppressed.Contains(filterName);
}
return false;
}
}
}
5 changes: 5 additions & 0 deletions src/cloudscribe.Web.Navigation/NavigationViewComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public NavigationViewComponent(

public async Task<IViewComponentResult> InvokeAsync(string viewName, string filterName, string startingNodeKey)
{
if (NavigationSuppressor.IsFilterSuppressed(Request.HttpContext, filterName))
{
return Content(string.Empty);
}

var rootNode = await _builder.GetTree();
var urlHelper = _urlHelperFactory.GetUrlHelper(_actionContextAccesor.ActionContext);
NavigationViewModel model = new NavigationViewModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>an ASP.NET Core viewcomponent for menus and breadcrumbs</Description>
<Version>8.6.0</Version>
<Version>8.7.0</Version>
<TargetFramework>net8.0</TargetFramework>
<Authors>Joe Audette</Authors>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>cloudscribe.Web.SiteMap.FromNavigation a library that implements ISiteMapNodeService using existing tree of nodes from cloudscribe.Web.Navigation.NavigationTreeBuilderService</Description>
<Version>8.6.0</Version>
<Version>8.7.0</Version>
<TargetFramework>net8.0</TargetFramework>
<Authors>Joe Audette</Authors>
<PackageTags>cloudscribe;mvc;sitemap</PackageTags>
Expand Down
2 changes: 1 addition & 1 deletion src/cloudscribe.Web.SiteMap/cloudscribe.Web.SiteMap.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>ASP.NET Core controller and models for generating an xml sitemap for search indexes http://www.sitemaps.org</Description>
<Version>8.6.0</Version>
<Version>8.7.0</Version>
<TargetFramework>net8.0</TargetFramework>

<Authors>Joe Audette</Authors>
Expand Down
6 changes: 3 additions & 3 deletions update_version.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
$directory = "src"

# Define the old & new versions
$oldVersion = '8\.5' # slash needed !
$newVersion = "8.6.0"
$newWildcardVersion = "8.6.*"
$oldVersion = '8\.6' # slash needed !
$newVersion = "8.7.0"
$newWildcardVersion = "8.7.*"


# Get all .csproj files in the directory and subdirectories
Expand Down
Loading