Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into saas_auth
Browse files Browse the repository at this point in the history
  • Loading branch information
jptissot committed Apr 8, 2021
2 parents 90f5e38 + 76dd7ca commit 5cb6985
Show file tree
Hide file tree
Showing 59 changed files with 260 additions and 224 deletions.
2 changes: 1 addition & 1 deletion docs/en/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Welcome to the `StatCan.OrchardCore` documentation. Learn how to use our collect

## OrchardCore CMS

The project is built on OrchardCore CMS version `1.0.0-rc2-15907`. To learn more about the underlying framework, take a look through the [Orchard Core CMS documentation](https://docs.orchardcore.net) and the [Orchard Core Github repository](https://github.com/OrchardCMS/OrchardCore).
The project is built on OrchardCore CMS version `1.0.0-rc2-16071`. To learn more about the underlying framework, take a look through the [Orchard Core CMS documentation](https://docs.orchardcore.net) and the [Orchard Core Github repository](https://github.com/OrchardCMS/OrchardCore).


## Where to Start?
Expand Down
2 changes: 1 addition & 1 deletion src/Build/Dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<AspNetCoreTargetFramework>net5.0</AspNetCoreTargetFramework>
<OrchardCoreVersion>1.0.0-rc2-15907</OrchardCoreVersion>
<OrchardCoreVersion>1.0.0-rc2-16071</OrchardCoreVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ namespace StatCan.OrchardCore.ContentFields.MultiValueTextField
[Feature(Constants.Features.MultiValueTextField)]
public class Startup : StartupBase
{
static Startup()
{
TemplateContext.GlobalMemberAccessStrategy.Register<Fields.MultiValueTextField>();
TemplateContext.GlobalMemberAccessStrategy.Register<DisplayMultiValueTextFieldViewModel>();
}
public override void ConfigureServices(IServiceCollection services)
{
services.AddContentField<Fields.MultiValueTextField>()
.UseDisplayDriver<MultiValueTextFieldDisplayDriver>();
services.AddScoped<IContentPartFieldDefinitionDisplayDriver, MultiValueTextFieldSettingsDriver>();
services.AddScoped<IContentPartFieldDefinitionDisplayDriver, TextFieldHeaderDisplaySettingsDriver>();
services.AddScoped<IContentPartFieldDefinitionDisplayDriver, MultiValueTextFieldEditorSettingsDriver>();
services.Configure<TemplateOptions>(o =>
{
o.MemberAccessStrategy.Register<Fields.MultiValueTextField>();
o.MemberAccessStrategy.Register<DisplayMultiValueTextFieldViewModel>();
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public UserCanViewFilter(IContentPermissionsService contentPermissionsService)

#region Implementation

public ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments arguments, TemplateContext context)
public ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments arguments, LiquidTemplateContext context)
{
var item = input.ToObjectValue() as ContentItem;

Expand Down
5 changes: 3 additions & 2 deletions src/Modules/StatCan.OrchardCore.ContentPermissions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ Users can be displayed an alternative by customising the view template, as shown
Example of how to check users permission and display alternative content with Liquid template.

```
{% if Model.ContentItem | user_can_view %}
{% assign canView = Model.ContentItem | user_can_view %}
{% if canView %}
<p>Awesome content that you have permission to view.</p>
{% else %}
<p>Unfortunately you're not able to view this content.</p>
Expand All @@ -41,4 +42,4 @@ else
{
<p>Unfortunately you're not able to view this content.</p>
}
```
```

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ namespace StatCan.OrchardCore.DisplayHelpers.Filters
{
public class BoolFilter : ILiquidFilter
{
public ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments args, TemplateContext context)
public ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments args, LiquidTemplateContext context)
{
var content = input.ToBooleanValue();
return new ValueTask<FluidValue>(BooleanValue.Create(content));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace StatCan.OrchardCore.DisplayHelpers.Filters
{
public class ClonePropertiesFilter : ILiquidFilter
{
public ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments arguments, TemplateContext ctx)
public ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments arguments, LiquidTemplateContext ctx)
{
if (input.ToObjectValue() is IShape inputShape && arguments.At(0).ToObjectValue() is IShape toClone)
{
Expand All @@ -19,7 +19,7 @@ public ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments argu
inputShape.Properties.Add(prop.Key, prop.Value);
}
}
return new ValueTask<FluidValue>(FluidValue.Create(inputShape));
return new ValueTask<FluidValue>(FluidValue.Create(inputShape, ctx.Options));
}
return new ValueTask<FluidValue>(input);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace StatCan.OrchardCore.DisplayHelpers.Filters
{
public class GetClaimLiquidFilter : ILiquidFilter
{
public ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments arguments, TemplateContext context)
public ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments arguments, LiquidTemplateContext context)
{
var claimType = arguments["type"].Or(arguments.At(0)).ToStringValue();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public IsCurrentUrlFilter(IHttpContextAccessor httpContextAccessor)
_httpContext = httpContextAccessor.HttpContext;
}

public ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments args, TemplateContext context)
public ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments args, LiquidTemplateContext context)
{
var path = (_httpContext.Request.PathBase + _httpContext.Request.Path).ToString().TrimEnd('/');
var toCompare = input.ToStringValue().TrimEnd('/');
Expand All @@ -27,4 +27,4 @@ public ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments args
return new ValueTask<FluidValue>(BooleanValue.False);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Fluid.Values;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Routing;
using OrchardCore.Liquid;
using System;
using System.Threading.Tasks;
Expand All @@ -11,18 +12,17 @@ namespace StatCan.OrchardCore.DisplayHelpers.Filters
public class ReturnUrlFilter : ILiquidFilter
{
private readonly HttpContext _httpContext;
private readonly IUrlHelperFactory _urlHelperFactory;

public ReturnUrlFilter(IHttpContextAccessor httpContextAccessor)
public ReturnUrlFilter(IUrlHelperFactory urlHelperFactory, IHttpContextAccessor httpContextAccessor)
{
_httpContext = httpContextAccessor.HttpContext;
_urlHelperFactory = urlHelperFactory;
}

public ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments arguments, TemplateContext context)
public ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments arguments, LiquidTemplateContext context)
{
if (!context.AmbientValues.TryGetValue("UrlHelper", out var urlHelper))
{
throw new ArgumentException("UrlHelper missing while invoking 'return_url'");
}
var urlHelper = _urlHelperFactory.GetUrlHelper(context.ViewContext);

var returnPath = (_httpContext.Request.PathBase + _httpContext.Request.Path).ToString();
if (arguments["type"].Or(arguments.At(0)).ToStringValue() != "")
Expand All @@ -40,4 +40,4 @@ public ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments argu
return new ValueTask<FluidValue>(new StringValue(((IUrlHelper)urlHelper).Content(string.Concat(targetPath, "?returnUrl=", returnPath))));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace StatCan.OrchardCore.DisplayHelpers.Filters
{
public class UsersByRoleFilter : ILiquidFilter
{
public async ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments arguments, TemplateContext ctx)
public async ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments arguments, LiquidTemplateContext ctx)
{
if (!ctx.AmbientValues.TryGetValue("Services", out var services))
{
Expand All @@ -33,12 +33,12 @@ public async ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArgument
var query = session.Query<User>();
query.With<UserByRoleNameIndex>(x => x.RoleName.IsIn(userRoles));

return FluidValue.Create(await query.ListAsync());
return FluidValue.Create(await query.ListAsync(), ctx.Options);
}
else
{
var normalizedRoleName = roleManager.NormalizeKey(input.ToStringValue());
return FluidValue.Create(await session.Query<User, UserByRoleNameIndex>(u => u.RoleName == normalizedRoleName).ListAsync());
return FluidValue.Create(await session.Query<User, UserByRoleNameIndex>(u => u.RoleName == normalizedRoleName).ListAsync(), ctx.Options);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static Task<string> LiquidAsync(this IOrchardHelper orchardHelper, string
var liquidTemplateManager = orchardHelper.HttpContext.RequestServices.GetRequiredService<ILiquidTemplateManager>();
var htmlEncoder = orchardHelper.HttpContext.RequestServices.GetRequiredService<HtmlEncoder>();

return liquidTemplateManager.RenderAsync(liquid, htmlEncoder, model);
return liquidTemplateManager.RenderStringAsync(liquid, htmlEncoder, model);
}

/// <summary>
Expand All @@ -49,7 +49,7 @@ public static async Task<IHtmlContent> LiquidToSanitizedHtmlAsync(this IOrchardH
var htmlSanitizer= orchardHelper.HttpContext.RequestServices.GetRequiredService<IHtmlSanitizer>();
var htmlEncoder = orchardHelper.HttpContext.RequestServices.GetRequiredService<HtmlEncoder>();

liquid = await liquidTemplateManager.RenderAsync(liquid, htmlEncoder, model);
liquid = await liquidTemplateManager.RenderStringAsync(liquid, htmlEncoder, model);

return new HtmlString(htmlSanitizer.Sanitize(liquid));
}
Expand All @@ -65,7 +65,7 @@ public static async Task<string> LiquidShortcodesAsync(this IOrchardHelper orcha
var shortcodeService = orchardHelper.HttpContext.RequestServices.GetRequiredService<IShortcodeService>();
var htmlEncoder = orchardHelper.HttpContext.RequestServices.GetRequiredService<HtmlEncoder>();

liquid = await liquidTemplateManager.RenderAsync(liquid, htmlEncoder, model);
liquid = await liquidTemplateManager.RenderStringAsync(liquid, htmlEncoder, model);
liquid = await shortcodeService.ProcessAsync(liquid);

return liquid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public async Task<IActionResult> Index(ViewModels.ContentOptions options, PagerP

if (!string.IsNullOrWhiteSpace(options.Search))
{
templates = templates.Where(x => x.Value.Name.ToLower().Contains(options.Search.ToLower())).ToList();
templates = templates.Where(x => x.Value.Name.Contains(options.Search, StringComparison.OrdinalIgnoreCase)).ToList();
}

var count = templates.Count;
Expand Down Expand Up @@ -385,7 +385,7 @@ public async Task<IActionResult> SendEmail(SendEmailTemplateViewModel model, str
}

return View(model);
}
}

private IActionResult RedirectToReturnUrlOrIndex(string returnUrl)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ public Task<string> RenderLiquid(string liquid, object model)
{
if (!string.IsNullOrWhiteSpace(liquid))
{
return _liquidTemplateManager.RenderAsync(liquid, _htmlEncoder, model, null);
return _liquidTemplateManager.RenderStringAsync(liquid, _htmlEncoder, model, null);
}
return Task.FromResult(liquid);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace StatCan.OrchardCore.GitHub.Liquid
{
public class GetIssueCommentsFilter : ILiquidFilter
{
public async ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments arguments, TemplateContext ctx)
public async ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments arguments, LiquidTemplateContext ctx)
{
if (!ctx.AmbientValues.TryGetValue("Services", out var services))
{
Expand All @@ -39,11 +39,11 @@ public async ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArgument
try
{
var client = await gitHubApiService.GetGitHubClient(tokenName);
return FluidValue.Create(await client.Issue.Comment.GetAllForIssue(owner, repo, parsedNumber));
return FluidValue.Create(await client.Issue.Comment.GetAllForIssue(owner, repo, parsedNumber), ctx.Options);
}
catch(Octokit.ApiException ex)
{
return FluidValue.Create(ex.Message);
return FluidValue.Create(ex.Message, ctx.Options);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace StatCan.OrchardCore.GitHub.Liquid
{
public class GetIssueFilter : ILiquidFilter
{
public async ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments arguments, TemplateContext ctx)
public async ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments arguments, LiquidTemplateContext ctx)
{
if (!ctx.AmbientValues.TryGetValue("Services", out var services))
{
Expand Down Expand Up @@ -38,11 +38,11 @@ public async ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArgument
{
var client = await gitHubApiService.GetGitHubClient(tokenName);

return FluidValue.Create(await client.Issue.Get(owner, repo, parsedNumber));
return FluidValue.Create(await client.Issue.Get(owner, repo, parsedNumber), ctx.Options);
}
catch (Octokit.ApiException ex)
{
return FluidValue.Create(ex.Message);
return FluidValue.Create(ex.Message, ctx.Options);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace StatCan.OrchardCore.GitHub.Liquid
{
public class GetPullRequestCommentsFilter : ILiquidFilter
{
public async ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments arguments, TemplateContext ctx)
public async ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments arguments, LiquidTemplateContext ctx)
{
if (!ctx.AmbientValues.TryGetValue("Services", out var services))
{
Expand Down Expand Up @@ -39,11 +39,11 @@ public async ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArgument
{
var client = await gitHubApiService.GetGitHubClient(tokenName);

return FluidValue.Create(await client.PullRequest.ReviewComment.GetAll(owner, repo, parsedNumber));
return FluidValue.Create(await client.PullRequest.ReviewComment.GetAll(owner, repo, parsedNumber), ctx.Options);
}
catch (Octokit.ApiException ex)
{
return FluidValue.Create(ex.Message);
return FluidValue.Create(ex.Message, ctx.Options);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace StatCan.OrchardCore.GitHub.Liquid
{
public class GetPullRequestFilter : ILiquidFilter
{
public async ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments arguments, TemplateContext ctx)
public async ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments arguments, LiquidTemplateContext ctx)
{
if (!ctx.AmbientValues.TryGetValue("Services", out var services))
{
Expand Down Expand Up @@ -38,11 +38,11 @@ public async ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArgument
{
var client = await gitHubApiService.GetGitHubClient(tokenName);

return FluidValue.Create(await client.PullRequest.Get(owner, repo, parsedNumber));
return FluidValue.Create(await client.PullRequest.Get(owner, repo, parsedNumber), ctx.Options);
}
catch (Octokit.ApiException ex)
{
return FluidValue.Create(ex.Message);
return FluidValue.Create(ex.Message, ctx.Options);
}
}
}
Expand Down
Loading

0 comments on commit 5cb6985

Please sign in to comment.