Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into srvcs_acct_to_login…
Browse files Browse the repository at this point in the history
…_data
  • Loading branch information
PiemP committed May 22, 2024
2 parents 2ee51cd + 77c69c6 commit a12d557
Show file tree
Hide file tree
Showing 48 changed files with 640 additions and 462 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Orchard Core
# Orchard Core

Orchard Core is an open-source, modular, multi-tenant application framework and CMS for ASP.NET Core.

Expand All @@ -13,12 +13,12 @@ Orchard Core consists of two distinct projects:

## Build Status

Stable (`release/1.8.3`):
Stable (`release/1.8.3`):

[![Build status](https://github.com/OrchardCMS/OrchardCore/actions/workflows/release_ci.yml/badge.svg)](https://github.com/OrchardCMS/OrchardCore/actions?query=workflow%3A%22Release+-+CI%22)
[![NuGet](https://img.shields.io/nuget/v/OrchardCore.Application.Cms.Targets.svg)](https://www.nuget.org/packages/OrchardCore.Application.Cms.Targets)

Nightly (`main`):
Nightly (`main`):

[![Build status](https://github.com/OrchardCMS/OrchardCore/actions/workflows/preview_ci.yml/badge.svg)](https://github.com/OrchardCMS/OrchardCore/actions?query=workflow%3A%22Preview+-+CI%22)
[![Cloudsmith](https://api-prd.cloudsmith.io/badges/version/orchardcore/preview/nuget/OrchardCore.Application.Cms.Targets/latest/x/?render=true&badge_token=gAAAAABey9hKFD_C-ZIpLvayS3HDsIjIorQluDs53KjIdlxoDz6Ntt1TzvMNJp7a_UWvQbsfN5nS7_0IbxCyqHZsjhmZP6cBkKforo-NqwrH5-E6QCrJ3D8%3D)](https://cloudsmith.io/~orchardcore/repos/preview/packages/detail/nuget/OrchardCore.Application.Cms.Targets/latest/)
Expand Down Expand Up @@ -46,8 +46,9 @@ Do you need some help with Orchard Core? Don't worry, there are ways to get help
## Get in Touch

- [X (Twitter)](https://twitter.com/orchardcms)
- [LinkedIn](https://www.linkedin.com/groups/13605669/)
- [LinkedIn](https://orchardcore.net/linkedin)
- [Facebook](https://www.facebook.com/OrchardCore)
- [Discord](https://orchardcore.net/discord)
- Please report security issues privately, via email, to [contact@orchardcore.net](mailto:contact@orchardcore.net).

### Local Communities
Expand Down
4 changes: 2 additions & 2 deletions src/OrchardCore.Build/Dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<PackageManagement Include="GraphQL.MicrosoftDI" Version="7.8.0" />
<PackageManagement Include="GraphQL.SystemTextJson" Version="7.8.0" />
<PackageManagement Include="Jint" Version="3.1.1" />
<PackageManagement Include="JsonPath.Net" Version="1.0.4" />
<PackageManagement Include="JsonPath.Net" Version="1.1.0" />
<PackageManagement Include="HtmlSanitizer" Version="8.1.860-beta" />
<PackageManagement Include="Irony" Version="1.5.1" />
<PackageManagement Include="libphonenumber-csharp" Version="8.13.37" />
Expand All @@ -41,7 +41,7 @@
<PackageManagement Include="MessagePack" Version="2.2.60" />
<PackageManagement Include="Microsoft.Extensions.Azure" Version="1.7.3" />
<PackageManagement Include="Microsoft.Extensions.Http.Resilience" Version="8.5.0" />
<PackageManagement Include="Microsoft.Identity.Web" Version="2.18.1" />
<PackageManagement Include="Microsoft.Identity.Web" Version="2.18.2" />

<!--
Important: the version of the Microsoft.IdentityModel.Protocols.OpenIdConnect package MUST
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public async Task<IActionResult> Update([FromForm] DashboardPartViewModel[] part
return Unauthorized();
}

var contentItemIds = parts.Select(i => i.ContentItemId).ToList();
var contentItemIds = parts.Select(i => i.ContentItemId).ToArray();

// Load the latest version first if any.
var latestItems = await _contentManager.GetAsync(contentItemIds, VersionOptions.Latest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ public async Task<IActionResult> SearchContentItems(string part, string field, s
.GetAsync(results.Select(r => r.ContentItemId));

var selectedItems = new List<VueMultiselectItemViewModel>();
var user = _httpContextAccessor.HttpContext?.User;
foreach (var contentItem in contentItems)
{
selectedItems.Add(new VueMultiselectItemViewModel()
{
Id = contentItem.ContentItemId,
DisplayText = contentItem.ToString(),
HasPublished = contentItem.IsPublished(),
IsViewable = await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext?.User,
CommonPermissions.EditContent, contentItem)
IsViewable = await _authorizationService.AuthorizeAsync(user, CommonPermissions.EditContent, contentItem)
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@model OrchardCore.ContentFields.ViewModels.DisplayContentPickerFieldViewModel
@using OrchardCore.ContentManagement
@using OrchardCore.Mvc.Utilities
@using OrchardCore.ContentManagement.Metadata.Models

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,15 @@ public async ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArgument
{
if (input.Type == FluidValues.Array)
{
// List of content item ids
var contentItemIds = input.Enumerate(ctx).Select(x => x.ToStringValue()).ToArray();
// List of content item ids to return.
var contentItemIds = input.Enumerate(ctx).Select(x => x.ToStringValue());

return FluidValue.Create(await _contentManager.GetAsync(contentItemIds), ctx.Options);
}
else
{
var contentItemId = input.ToStringValue();

return FluidValue.Create(await _contentManager.GetAsync(contentItemId), ctx.Options);
}
var contentItemId = input.ToStringValue();

return FluidValue.Create(await _contentManager.GetAsync(contentItemId), ctx.Options);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using OrchardCore;
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.Records;
using YesSql;

#pragma warning disable CA1050 // Declare types in namespaces
namespace OrchardCore;

public static class ContentRazorHelperExtensions
#pragma warning restore CA1050 // Declare types in namespaces
{
/// <summary>
/// Returns a content item id by its handle.
Expand All @@ -30,54 +29,53 @@ public static Task<string> GetContentItemIdByHandleAsync(this IOrchardHelper orc
/// </summary>
/// <param name="orchardHelper">The <see cref="IOrchardHelper"/>.</param>
/// <param name="handle">The handle to load.</param>
/// <param name="latest">Whether a draft should be loaded if available. <c>false</c> by default.</param>
/// <example>GetContentItemByHandleAsync("alias:carousel").</example>
/// <example>GetContentItemByHandleAsync("slug:myblog/my-blog-post", true).</example>
/// <param name="option">A specific version to load or the default version.</param>
/// <returns>A content item with the specific name, or <c>null</c> if it doesn't exist.</returns>
public static async Task<ContentItem> GetContentItemByHandleAsync(this IOrchardHelper orchardHelper, string handle, bool latest = false)
public static async Task<ContentItem> GetContentItemByHandleAsync(this IOrchardHelper orchardHelper, string handle, VersionOptions option = null)
{
var contentItemId = await GetContentItemIdByHandleAsync(orchardHelper, handle);
var contentManager = orchardHelper.HttpContext.RequestServices.GetService<IContentManager>();
return await contentManager.GetAsync(contentItemId, latest ? VersionOptions.Latest : VersionOptions.Published);
return await contentManager.GetAsync(contentItemId, option);
}

/// <summary>
/// Loads a content item by its id.
/// </summary>
/// <param name="orchardHelper">The <see cref="IOrchardHelper"/>.</param>
/// <param name="contentItemId">The content item id to load.</param>
/// <param name="latest">Whether a draft should be loaded if available. <c>false</c> by default.</param>
/// <example>GetContentItemByIdAsync("4xxxxxxxxxxxxxxxx").</example>
/// <param name="option">A specific version to load or the default version.</param>
/// <returns>A content item with the specific id, or <c>null</c> if it doesn't exist.</returns>
public static Task<ContentItem> GetContentItemByIdAsync(this IOrchardHelper orchardHelper, string contentItemId, bool latest = false)
public static Task<ContentItem> GetContentItemByIdAsync(this IOrchardHelper orchardHelper, string contentItemId, VersionOptions option = null)
{
var contentManager = orchardHelper.HttpContext.RequestServices.GetService<IContentManager>();
return contentManager.GetAsync(contentItemId, latest ? VersionOptions.Latest : VersionOptions.Published);

return contentManager.GetAsync(contentItemId, option);
}

/// <summary>
/// Loads a list of content items by their ids.
/// </summary>
/// <param name="orchardHelper">The <see cref="IOrchardHelper"/>.</param>
/// <param name="contentItemIds">The content item ids to load.</param>
/// <param name="latest">Whether a draft should be loaded if available. <c>false</c> by default.</param>
/// <param name="option">A specific version to load or the default version.</param>
/// <returns>A list of content items with the specific ids.</returns>
public static Task<IEnumerable<ContentItem>> GetContentItemsByIdAsync(this IOrchardHelper orchardHelper, IEnumerable<string> contentItemIds, bool latest = false)
public static Task<IEnumerable<ContentItem>> GetContentItemsByIdAsync(this IOrchardHelper orchardHelper, IEnumerable<string> contentItemIds, VersionOptions option = null)
{
var contentManager = orchardHelper.HttpContext.RequestServices.GetService<IContentManager>();
return contentManager.GetAsync(contentItemIds, latest);

return contentManager.GetAsync(contentItemIds, option);
}

/// <summary>
/// Loads a content item by its version id.
/// </summary>
/// <param name="orchardHelper">The <see cref="IOrchardHelper"/>.</param>
/// <param name="contentItemVersionId">The content item version id to load.</param>
/// <example>GetContentItemByVersionIdAsync("4xxxxxxxxxxxxxxxx").</example>
/// <returns>A content item with the specific version id, or <c>null</c> if it doesn't exist.</returns>
public static Task<ContentItem> GetContentItemByVersionIdAsync(this IOrchardHelper orchardHelper, string contentItemVersionId)
{
var contentManager = orchardHelper.HttpContext.RequestServices.GetService<IContentManager>();

return contentManager.GetVersionAsync(contentItemVersionId);
}

Expand All @@ -102,6 +100,8 @@ public static async Task<IEnumerable<ContentItem>> QueryContentItemsAsync(this I
/// <param name="maxContentItems">The maximum content items to return.</param>
public static Task<IEnumerable<ContentItem>> GetRecentContentItemsByContentTypeAsync(this IOrchardHelper orchardHelper, string contentType, int maxContentItems = 10)
{
return orchardHelper.QueryContentItemsAsync(query => query.Where(x => x.ContentType == contentType && x.Published == true).OrderByDescending(x => x.CreatedUtc).Take(maxContentItems));
return orchardHelper.QueryContentItemsAsync(query => query.Where(x => x.ContentType == contentType && x.Published == true)
.OrderByDescending(x => x.CreatedUtc)
.Take(maxContentItems));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ static ResourceManagementOptionsConfiguration()

_manifest
.DefineStyle("flowpart-edit")
.SetDependencies("widgetslist-edit")
.SetUrl( "~/OrchardCore.Flows/Styles/flows.edit.min.css", "~/OrchardCore.Flows/Styles/flows.edit.css");

_manifest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@
{
Context.Items["BagPart.Edit"] = new object();
<script asp-name="flowpart-edit" at="Foot"></script>
<script asp-name="widgetslist-edit" at="Foot"></script>
<style asp-name="flowpart-edit" at="Head"></style>
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
}

<script asp-name="flowpart-edit" at="Foot"></script>
<script asp-name="widgetslist-edit" at="Foot"></script>
<style asp-name="flowpart-edit" at="Head"></style>
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,31 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Html;
using Microsoft.Extensions.DependencyInjection;
using OrchardCore;
using OrchardCore.Infrastructure.Html;
using OrchardCore.Liquid;
using OrchardCore.Markdown.Services;
using OrchardCore.Shortcodes.Services;

#pragma warning disable CA1050 // Declare types in namespaces
namespace OrchardCore;

public static class ContentRazorHelperExtensions
#pragma warning restore CA1050 // Declare types in namespaces
{
/// <summary>
/// Converts Markdown string to HTML.
/// </summary>
/// <param name="orchardHelper">The <see cref="IOrchardHelper"/>.</param>
/// <param name="markdown">The markdown to convert.</param>
/// <param name="sanitize">Whether to sanitze the markdown. Defaults to <see langword="true"/>.</param>
/// <param name="sanitize">Whether to sanitize the markdown. Defaults to <see langword="true"/>.</param>
public static async Task<IHtmlContent> MarkdownToHtmlAsync(this IOrchardHelper orchardHelper, string markdown, bool sanitize = true)
{
var shortcodeService = orchardHelper.HttpContext.RequestServices.GetRequiredService<IShortcodeService>();
var markdownService = orchardHelper.HttpContext.RequestServices.GetRequiredService<IMarkdownService>();

// The default Markdown option is to entity escape html
// so filters must be run after the markdown has been processed.
markdown = markdownService.ToHtml(markdown ?? "");
markdown = markdownService.ToHtml(markdown ?? string.Empty);

// The liquid rendering is for backwards compatability and can be removed in a future version.
// The liquid rendering is for backwards compatibility and can be removed in a future version.
if (!sanitize)
{
var liquidTemplateManager = orchardHelper.HttpContext.RequestServices.GetRequiredService<ILiquidTemplateManager>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ public async Task<IActionResult> Index(AzureAIIndexOptions options, PagerParamet

indexes = indexes
.Skip(pager.GetStartIndex())
.Take(pager.PageSize).ToList();
.Take(pager.PageSize)
.ToList();

// Maintain previous route data when generating page links.
var routeData = new RouteData();
Expand Down Expand Up @@ -246,7 +247,7 @@ public async Task<IActionResult> CreatePost(AzureAISettingsViewModel model)
settings.QueryAnalyzerName = settings.AnalyzerName;
}

settings.IndexMappings = await _azureAIIndexDocumentManager.GetMappingsAsync(settings.IndexedContentTypes);
settings.IndexMappings = await _azureAIIndexDocumentManager.GetMappingsAsync(settings);

if (await _indexManager.CreateAsync(settings))
{
Expand Down Expand Up @@ -366,7 +367,7 @@ public async Task<IActionResult> EditPost(AzureAISettingsViewModel model)
settings.QueryAnalyzerName = settings.AnalyzerName;
}

settings.IndexMappings = await _azureAIIndexDocumentManager.GetMappingsAsync(settings.IndexedContentTypes);
settings.IndexMappings = await _azureAIIndexDocumentManager.GetMappingsAsync(settings);

if (!await _indexManager.CreateAsync(settings))
{
Expand Down Expand Up @@ -452,12 +453,8 @@ public async Task<IActionResult> Rebuild(string indexName)
return NotFound();
}

if (!await _indexManager.ExistsAsync(indexName))
{
return NotFound();
}

settings.IndexMappings = await _azureAIIndexDocumentManager.GetMappingsAsync(settings.IndexedContentTypes);
settings.SetLastTaskId(0);
settings.IndexMappings = await _azureAIIndexDocumentManager.GetMappingsAsync(settings);
await _indexSettingsService.UpdateAsync(settings);
await _indexManager.RebuildAsync(settings);
await AsyncContentItemsAsync(settings.IndexName);
Expand Down Expand Up @@ -488,11 +485,13 @@ public async Task<IActionResult> Reset(string indexName)

if (!await _indexManager.ExistsAsync(indexName))
{
return NotFound();
await _notifier.ErrorAsync(H["Unable to reset the <em>{0}</em> index. Try rebuilding it instead.", indexName]);

return RedirectToAction(nameof(Index));
}

settings.SetLastTaskId(0);
settings.IndexMappings = await _azureAIIndexDocumentManager.GetMappingsAsync(settings.IndexedContentTypes);
settings.IndexMappings = await _azureAIIndexDocumentManager.GetMappingsAsync(settings);
await _indexSettingsService.UpdateAsync(settings);
await AsyncContentItemsAsync(settings.IndexName);
await _notifier.SuccessAsync(H["Index <em>{0}</em> reset successfully.", indexName]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ await shellScope.UsingAsync(async scope =>

var allPublishedContentItems = await contentManager.GetAsync(updatedContentItemIds);
allPublished = allPublishedContentItems.DistinctBy(x => x.ContentItemId).ToDictionary(k => k.ContentItemId, v => v);
var allLatestContentItems = await contentManager.GetAsync(updatedContentItemIds, latest: true);
var allLatestContentItems = await contentManager.GetAsync(updatedContentItemIds, VersionOptions.Latest);
allLatest = allLatestContentItems.DistinctBy(x => x.ContentItemId).ToDictionary(k => k.ContentItemId, v => v);

// Group all DocumentIndex by index to batch update them.
Expand Down
Loading

0 comments on commit a12d557

Please sign in to comment.