Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
hishamco committed Jan 25, 2025
1 parent cb4f119 commit df6f143
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 124 deletions.
15 changes: 15 additions & 0 deletions src/OrchardCore.Modules/OrchardCore.Liquid/Manifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@
Author = ManifestConstants.OrchardCoreTeam,
Website = ManifestConstants.OrchardCoreWebsite,
Version = ManifestConstants.OrchardCoreVersion,
Category = "Content Management"
)]

[assembly: Feature(
Id = "OrchardCore.Liquid",
Name = "Liquid",
Description = "The liquid module enables content items to have liquid syntax.",
Dependencies = ["OrchardCore.Liquid.Core"],
Category = "Content Management"
)]

[assembly: Feature(
Id = "OrchardCore.Liquid.Core",
Name = "Liquid Core Services",
Description = "Provides liquid core services.",
EnabledByDependencyOnly = true,
Category = "Content Management"
)]
36 changes: 36 additions & 0 deletions src/OrchardCore.Modules/OrchardCore.Liquid/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ public override void ConfigureServices(IServiceCollection services)
}
}

[Feature("OrchardCore.Liquid.Core")]
public sealed class LiquidStartup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
=> services.AddLiquidCoreServices();
}

[RequireFeatures("OrchardCore.Contents")]
public sealed class LiquidPartStartup : StartupBase
{
Expand All @@ -106,3 +113,32 @@ public override void ConfigureServices(IServiceCollection services)
services.AddLiquidFilter<ShortcodeFilter>("shortcode");
}
}

[RequireFeatures("OrchardCore.Resources")]
public sealed class ResourcesStartup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddLiquidFilter<AppendVersionFilter>("append_version")
.AddLiquidFilter<ResourceUrlFilter>("resource_url");
}
}

[RequireFeatures("OrchardCore.Html")]
public sealed class HtmlStartup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
=> services.AddLiquidFilter<SanitizeHtmlFilter>("sanitize_html");
}

[RequireFeatures("OrchardCore.Localization")]
public sealed class localizationStartup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
#pragma warning disable CS0618 // Type or member is obsolete
// Deprecated, remove in a future version.
services.AddLiquidFilter<SupportedCulturesFilter>("supported_cultures");
#pragma warning restore CS0618 // Type or member is obsolete
}
}

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions src/OrchardCore.Modules/OrchardCore.Resources/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.DisplayManagement.Liquid;
using OrchardCore.Environment.Shell.Configuration;
using OrchardCore.Liquid;
using OrchardCore.Modules;
using OrchardCore.ResourceManagement;
using OrchardCore.Resources.Liquid;
Expand Down Expand Up @@ -39,13 +38,3 @@ public override void ConfigureServices(IServiceCollection serviceCollection)
serviceCollection.AddScoped<IResourcesTagHelperProcessor, ResourcesTagHelperProcessor>();
}
}

[RequireFeatures("OrchardCore.Liquid")]
public sealed class ResourcesLiquidStartup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddLiquidFilter<AppendVersionFilter>("append_version")
.AddLiquidFilter<ResourceUrlFilter>("resource_url");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static OrchardCoreBuilder AddOrchardCms(this IServiceCollection services)
.AddScripting()

.AddTheming()
.AddLiquidViews()
.AddGlobalFeatures("OrchardCore.Liquid.Core")
.AddCaching();

// OrchardCoreBuilder is not available in OrchardCore.ResourceManagement as it has to
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Fluid;
using Microsoft.AspNetCore.Mvc.ApplicationParts;
using Microsoft.AspNetCore.Mvc.Razor.Compilation;
using Microsoft.Extensions.Options;
using OrchardCore.DisplayManagement.Descriptors.ShapeTemplateStrategy;
using OrchardCore.DisplayManagement.Liquid;
using OrchardCore.DisplayManagement.Liquid.TagHelpers;
using OrchardCore.DisplayManagement.Liquid.Tags;
using OrchardCore.DisplayManagement.Razor;

namespace Microsoft.Extensions.DependencyInjection;

public static class LiquidCoreServices
{
public static IServiceCollection AddLiquidCoreServices(this IServiceCollection services)
{
services.AddSingleton<LiquidViewParser>();
services.AddSingleton<IAnchorTag, AnchorTag>();

services.AddTransient<IConfigureOptions<TemplateOptions>, TemplateOptionsFileProviderSetup>();

services.AddTransient<IConfigureOptions<LiquidViewOptions>, LiquidViewOptionsSetup>();

services.AddTransient<IConfigureOptions<ShapeTemplateOptions>, LiquidShapeTemplateOptionsSetup>();

services.AddSingleton<IApplicationFeatureProvider<ViewsFeature>, LiquidViewsFeatureProvider>();
services.AddScoped<IRazorViewExtensionProvider, LiquidViewExtensionProvider>();
services.AddSingleton<LiquidTagHelperFactory>();

services.AddSingleton<IConfigureOptions<TemplateOptions>, TemplateOptionsConfigurations>();

return services;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

namespace OrchardCore.DisplayManagement.Liquid.Filters;

[Obsolete("This filter is obsolete. Use OrchardCore.Resources.Liquid.AppendVersionFilter instead.")]
public class AppendVersionFilter : ILiquidFilter
{
private readonly IFileVersionProvider _fileVersionProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace OrchardCore.DisplayManagement.Liquid.Filters;
/// <summary>
/// Returns the Cdn Base Url of the specified resource path.
/// </summary>
[Obsolete("This filter is obsolete. Use OrchardCore.Resources.Liquid.ResourceUrlFilter instead.")]
public class ResourceUrlFilter : ILiquidFilter
{
private readonly IHttpContextAccessor _httpContextAccessor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,14 @@
using Fluid;
using Microsoft.AspNetCore.Mvc.ApplicationParts;
using Microsoft.AspNetCore.Mvc.Razor.Compilation;
using Microsoft.Extensions.Options;
using OrchardCore.DisplayManagement.Descriptors.ShapeTemplateStrategy;
using OrchardCore.DisplayManagement.Liquid;
using OrchardCore.DisplayManagement.Liquid.Filters;
using OrchardCore.DisplayManagement.Liquid.TagHelpers;
using OrchardCore.DisplayManagement.Liquid.Tags;
using OrchardCore.DisplayManagement.Razor;
using OrchardCore.Liquid;

namespace Microsoft.Extensions.DependencyInjection;

public static class OrchardCoreBuilderExtensions
{
/// <summary>
/// Adds tenant level services for managing liquid view template files.
/// </summary>
[Obsolete("This class is deprecated and will be removed in the upcoming major release.")]
public static OrchardCoreBuilder AddLiquidViews(this OrchardCoreBuilder builder)
{
builder.ConfigureServices(services =>
{
services.AddSingleton<LiquidViewParser>();
services.AddSingleton<IAnchorTag, AnchorTag>();

services.AddTransient<IConfigureOptions<TemplateOptions>, TemplateOptionsFileProviderSetup>();

services.AddTransient<IConfigureOptions<LiquidViewOptions>, LiquidViewOptionsSetup>();

services.AddTransient<IConfigureOptions<ShapeTemplateOptions>, LiquidShapeTemplateOptionsSetup>();

services.AddSingleton<IApplicationFeatureProvider<ViewsFeature>, LiquidViewsFeatureProvider>();
services.AddScoped<IRazorViewExtensionProvider, LiquidViewExtensionProvider>();
services.AddSingleton<LiquidTagHelperFactory>();

services.AddSingleton<IConfigureOptions<TemplateOptions>, TemplateOptionsConfigurations>();

#pragma warning disable CS0618 // Type or member is obsolete
services.AddLiquidFilter<SanitizeHtmlFilter>("sanitize_html")

// Deprecated, remove in a future version.
.AddLiquidFilter<SupportedCulturesFilter>("supported_cultures");
#pragma warning restore CS0618 // Type or member is obsolete
});
builder.ConfigureServices(services => services.AddLiquidCoreServices());

return builder;
}
Expand Down

0 comments on commit df6f143

Please sign in to comment.