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

OSOE-818: Upgrade to Orchard Core 2.0 #74

Merged
merged 99 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
33225fd
Update NuGet versions to pre-release.
sarahelsaig Feb 22, 2024
9c63e0f
Merge remote-tracking branch 'origin/dev' into issue/OSOE-795
sarahelsaig Feb 22, 2024
92962c7
Fix compilation errors.
sarahelsaig Feb 23, 2024
862ed1b
Remove "using Newtonsoft.Json"
sarahelsaig Feb 24, 2024
c46e09a
Fix compilation errors.
sarahelsaig Feb 24, 2024
901b3cf
Fix comment.
sarahelsaig Feb 25, 2024
9d68b96
Update OC to latest (because of bug fix for WorkflowTypeStep)
sarahelsaig Mar 3, 2024
6535bf2
Update OC preview version.
sarahelsaig Mar 7, 2024
1c9cdf7
Update OC package
sarahelsaig Mar 13, 2024
bcd4a87
Merge remote-tracking branch 'origin/dev' into issue/OSOE-795
sarahelsaig Mar 29, 2024
97770fa
Update OC preview version.
sarahelsaig Apr 23, 2024
2ca2e30
Update OC package version.
sarahelsaig Apr 27, 2024
52bea2e
Update OC versions
sarahelsaig May 4, 2024
86623df
Update OC to the latest preview.
sarahelsaig May 7, 2024
907193e
Minor code cleanup.
sarahelsaig May 7, 2024
bd0f831
Make sure the middlewares run first for real.
sarahelsaig May 7, 2024
3ca89f9
Only override ConfigureOrder, not Order.
sarahelsaig May 7, 2024
d5da914
Merge pull request #56 from Lombiq/issue/OSOE-795
dministro May 15, 2024
8e9854b
Merge remote-tracking branch 'origin/dev' into task/system-text-json-…
sarahelsaig May 28, 2024
c49bda8
Update OC preview version.
sarahelsaig May 28, 2024
1a52f74
Fix breaking changes.
sarahelsaig May 28, 2024
38f042e
Update OC preview version.
sarahelsaig May 30, 2024
42c79d2
Update OC preview version.
sarahelsaig Jun 5, 2024
ee19d04
Merge remote-tracking branch 'origin/dev' into task/system-text-json-…
sarahelsaig Jun 14, 2024
dceb884
Merge branch 'task/system-text-json-migration' into issue/OCC-245
sarahelsaig Jun 14, 2024
65f9e93
Update OC version.
sarahelsaig Jun 18, 2024
92b0884
Update OC version.
sarahelsaig Jun 19, 2024
e093987
Update OC preview version.
sarahelsaig Jun 20, 2024
f962d4d
Update OC preview version.
sarahelsaig Jun 21, 2024
4e4042c
Merge remote-tracking branch 'origin/issue/OCC-245' into issue/OCC-245
sarahelsaig Jun 21, 2024
2e529ab
Update HL and UITT NuGet versions.
sarahelsaig Jun 24, 2024
eeff47e
Update OC NuGet versions.
sarahelsaig Jun 24, 2024
f164b11
Update to latest OC preview version.
sarahelsaig Jul 2, 2024
3be544f
Fix Error: CS1061: 'IExtensionManager' does not contain a definition …
sarahelsaig Jul 2, 2024
f8bbcf6
Update OC preview version.
sarahelsaig Jul 11, 2024
71f2287
Merge remote-tracking branch 'origin/dev' into issue/OCC-245
sarahelsaig Jul 11, 2024
e0316a4
Fix package consolidation.
sarahelsaig Jul 11, 2024
35d4fb0
Merge remote-tracking branch 'origin/dev' into task/system-text-json-…
sarahelsaig Jul 12, 2024
2c9434f
Merge remote-tracking branch 'origin/task/system-text-json-migration'…
sarahelsaig Jul 12, 2024
772a451
Update HL version.
sarahelsaig Jul 13, 2024
8683593
Update UITT version.
sarahelsaig Jul 13, 2024
35dac59
Update HL nuget version.
sarahelsaig Jul 16, 2024
7e47986
Update all UITT Nuget versions.
sarahelsaig Jul 16, 2024
7621305
Update package version.
sarahelsaig Jul 16, 2024
28512a9
Update OC preview versions.
sarahelsaig Jul 24, 2024
95ef9d7
Merge remote-tracking branch 'origin/dev' into task/system-text-json-…
sarahelsaig Jul 24, 2024
91be29a
Merge branch 'task/system-text-json-migration' into issue/OCC-245
sarahelsaig Jul 24, 2024
52e3452
Update HL preview version.
sarahelsaig Jul 26, 2024
659a613
Update UITT preview version.
sarahelsaig Jul 26, 2024
4713eab
Update HL preview.
sarahelsaig Jul 27, 2024
65c081b
Update UITT version.
sarahelsaig Jul 27, 2024
94ef03d
Update UITT preview version.
sarahelsaig Jul 27, 2024
f6e579f
NuGet.config
sarahelsaig Jul 27, 2024
d1f4aa7
Update HL nuget version.
sarahelsaig Jul 27, 2024
36b824f
Update HL.
sarahelsaig Jul 27, 2024
e0eb82b
Merge pull request #65 from Lombiq/issue/OCC-245
Piedone Jul 28, 2024
5024e7a
Update OC preview version.
sarahelsaig Jul 29, 2024
ee6a110
Update OC preview version again (sigh).
sarahelsaig Jul 30, 2024
f2ec316
Use the new AddDeployment extension that registers the underlying pol…
sarahelsaig Aug 2, 2024
a168bd0
Add HE dependency for backwards compatibility.
sarahelsaig Aug 4, 2024
28528d3
Update OC preview version.
sarahelsaig Aug 6, 2024
4a9a824
Post-merge fixups.
sarahelsaig Aug 7, 2024
bcd6a88
Update HL alpha version.
sarahelsaig Aug 7, 2024
592f864
Update UITT alpha version.
sarahelsaig Aug 7, 2024
c2931bf
Update OC preview version.
sarahelsaig Aug 7, 2024
6ba808d
Update OC preview.
sarahelsaig Aug 8, 2024
910f4c8
Merge pull request #71 from Lombiq/issue/OSOE-893
sarahelsaig Aug 9, 2024
a14a3e3
Update HL alpha version.
sarahelsaig Aug 9, 2024
b2812d7
Update UITT alpha version.
sarahelsaig Aug 9, 2024
0190151
Update OC previews.
sarahelsaig Aug 13, 2024
d291048
Merge branch 'task/system-text-json-migration' into issue/NEST-536
sarahelsaig Aug 13, 2024
9b24c60
Update OC preview version.
sarahelsaig Aug 17, 2024
205dfbc
Remove code path from FileVersionProviderDecorator that will never be…
sarahelsaig Aug 19, 2024
1bd0c70
Invert this condition to improve readability.
sarahelsaig Aug 19, 2024
1a57b79
MediaTemplatesShapeBindingResolver code organization.
sarahelsaig Aug 19, 2024
7fb210e
Add case insensitive fallback
sarahelsaig Aug 19, 2024
67ecb3a
Update OC preview version.
sarahelsaig Aug 20, 2024
8662637
Update OC preview version.
sarahelsaig Aug 20, 2024
b42fd67
Merge branch 'task/system-text-json-migration' into issue/NEST-536
sarahelsaig Aug 20, 2024
6205528
Update cacheBustingParameterName.
sarahelsaig Aug 20, 2024
2f1cba8
Revert "Remove code path from FileVersionProviderDecorator that will …
sarahelsaig Aug 20, 2024
3ac5e0c
Add comment.
sarahelsaig Aug 20, 2024
22446fd
Update OC preview version.
sarahelsaig Aug 21, 2024
d95d75b
Update OC preview version.
sarahelsaig Aug 23, 2024
f8ec7e8
Update OC preview version.
sarahelsaig Aug 23, 2024
530e774
Merge remote-tracking branch 'origin/issue/NEST-536' into issue/NEST-536
sarahelsaig Aug 23, 2024
18ac502
Merge pull request #72 from Lombiq/issue/NEST-536
sarahelsaig Aug 23, 2024
7fc846a
Use OC release version.
sarahelsaig Sep 22, 2024
7510d67
Fix Task/ValueTask change in OC.
sarahelsaig Sep 22, 2024
991c111
Update HL preview.
sarahelsaig Sep 23, 2024
25ed596
Update HL.
sarahelsaig Sep 23, 2024
75edd9c
Add HE packagereference.
sarahelsaig Sep 23, 2024
6bed828
Use AddNavigationProvider everywhere.
sarahelsaig Sep 24, 2024
9b40a07
Seal INavigationProvider, IAsyncResultFilter, IPermissionProvider, St…
sarahelsaig Sep 24, 2024
a71c6b8
Use AddPermissionProvider.
sarahelsaig Sep 24, 2024
561d3d0
Re-evaluated, nothing needs to be done.
sarahelsaig Sep 24, 2024
d4f7525
Update HL NuGet version.
sarahelsaig Sep 25, 2024
832f5c9
Update UITT version.
sarahelsaig Sep 25, 2024
9971dd4
Update HE version.
sarahelsaig Sep 25, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</ItemGroup>

<ItemGroup Condition="'$(NuGetBuild)' == 'true'">
<PackageReference Include="Lombiq.Tests.UI" Version="10.0.1" />
<PackageReference Include="Lombiq.Tests.UI" Version="11.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace Lombiq.Hosting.MediaTheme.Bridge.Controllers;

public class AdminController : Controller
public sealed class AdminController : Controller
{
private readonly IAuthorizationService _authorizationService;
private readonly IMediaThemeStateStore _mediaThemeStateStore;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using Lombiq.Hosting.MediaTheme.Bridge.Constants;
using Lombiq.Hosting.MediaTheme.Bridge.Models;
using Lombiq.Hosting.MediaTheme.Bridge.Services;
using Newtonsoft.Json.Linq;
using OrchardCore.Deployment;
using System.Collections.Generic;
using System.Text.Json.Nodes;
using System.Threading.Tasks;

namespace Lombiq.Hosting.MediaTheme.Bridge.Deployment;
Expand All @@ -23,10 +24,11 @@ public async Task ProcessDeploymentStepAsync(DeploymentStep step, DeploymentPlan

var mediaThemeState = await _mediaThemeStateStore.GetMediaThemeStateAsync();

result.Steps.Add(new JObject(
new JProperty("name", RecipeStepIds.MediaTheme),
new JProperty(nameof(MediaThemeDeploymentStep.ClearMediaThemeFolder), mediaThemeStep.ClearMediaThemeFolder),
new JProperty(nameof(MediaThemeStateDocument.BaseThemeId), mediaThemeState.BaseThemeId)
));
result.Steps.Add(new JsonObject(new Dictionary<string, JsonNode>
{
["name"] = RecipeStepIds.MediaTheme,
[nameof(MediaThemeDeploymentStep.ClearMediaThemeFolder)] = mediaThemeStep.ClearMediaThemeFolder,
[nameof(MediaThemeStateDocument.BaseThemeId)] = mediaThemeState.BaseThemeId,
}));
}
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
using Lombiq.Hosting.MediaTheme.Bridge.ViewModels;
using OrchardCore.Deployment;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;
using System.Threading.Tasks;
using static Lombiq.HelpfulLibraries.OrchardCore.Contents.CommonContentDisplayTypes;
using static Lombiq.HelpfulLibraries.OrchardCore.Contents.CommonLocationNames;

namespace Lombiq.Hosting.MediaTheme.Bridge.Deployment;

public class MediaThemeDeploymentStepDriver : DisplayDriver<DeploymentStep, MediaThemeDeploymentStep>
public sealed class MediaThemeDeploymentStepDriver : DisplayDriver<DeploymentStep, MediaThemeDeploymentStep>
{
public override IDisplayResult Display(MediaThemeDeploymentStep model) =>
public override IDisplayResult Display(MediaThemeDeploymentStep model, BuildDisplayContext context) =>
Combine(
View($"{nameof(MediaThemeDeploymentStep)}_Fields_Summary", model).Location("Summary", "Content"),
View($"{nameof(MediaThemeDeploymentStep)}_Fields_Thumbnail", model).Location("Thumbnail", "Content")
View($"{nameof(MediaThemeDeploymentStep)}_Fields_Summary", model).Location(Summary, Content),
View($"{nameof(MediaThemeDeploymentStep)}_Fields_Thumbnail", model).Location(Thumbnail, Content)
);

public override IDisplayResult Edit(MediaThemeDeploymentStep model) =>
public override IDisplayResult Edit(MediaThemeDeploymentStep model, BuildEditorContext context) =>
Initialize<MediaThemeDeploymentStepViewModel>(
$"{nameof(MediaThemeDeploymentStep)}_Fields_Edit",
viewModel => viewModel.ClearMediaThemeFolder = model.ClearMediaThemeFolder)
.Location("Content");
.Location(Content);

public override async Task<IDisplayResult> UpdateAsync(MediaThemeDeploymentStep model, IUpdateModel updater)
public override async Task<IDisplayResult> UpdateAsync(MediaThemeDeploymentStep model, UpdateEditorContext context)
{
await updater.TryUpdateModelAsync(model, Prefix, viewModel => viewModel.ClearMediaThemeFolder);
await context.Updater.TryUpdateModelAsync(model, Prefix, viewModel => viewModel.ClearMediaThemeFolder);

return Edit(model);
return await EditAsync(model, context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,23 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OrchardCore.Deployment.Abstractions" Version="1.8.0" />
<PackageReference Include="OrchardCore.DisplayManagement.Abstractions" Version="1.8.0" />
<PackageReference Include="OrchardCore.Recipes.Abstractions" Version="1.8.0" />
<PackageReference Include="OrchardCore.ResourceManagement.Abstractions" Version="1.8.0" />
<PackageReference Include="OrchardCore.Media" Version="1.8.0" />
<PackageReference Include="OrchardCore.Module.Targets" Version="1.8.0" />
<PackageReference Include="OrchardCore.Deployment.Abstractions" Version="2.0.0" />
<PackageReference Include="OrchardCore.DisplayManagement.Abstractions" Version="2.0.0" />
<PackageReference Include="OrchardCore.Recipes.Abstractions" Version="2.0.0" />
<PackageReference Include="OrchardCore.ResourceManagement.Abstractions" Version="2.0.0" />
<PackageReference Include="OrchardCore.Media" Version="2.0.0" />
<PackageReference Include="OrchardCore.Module.Targets" Version="2.0.0" />
<PackageReference Include="Scrutor" Version="4.2.2" />
</ItemGroup>

<ItemGroup Condition="'$(NuGetBuild)' != 'true'">
<ProjectReference Include="..\..\..\Libraries\Lombiq.HelpfulLibraries\Lombiq.HelpfulLibraries.OrchardCore\Lombiq.HelpfulLibraries.OrchardCore.csproj" />
<ProjectReference Include="..\..\..\Modules\Lombiq.HelpfulExtensions\Lombiq.HelpfulExtensions\Lombiq.HelpfulExtensions.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(NuGetBuild)' == 'true'">
<PackageReference Include="Lombiq.HelpfulLibraries.OrchardCore" Version="10.0.0" />
<PackageReference Include="Lombiq.HelpfulLibraries.OrchardCore" Version="11.0.0" />
<PackageReference Include="Lombiq.HelpfulExtensions" Version="9.0.0" />
</ItemGroup>

</Project>
3 changes: 2 additions & 1 deletion Lombiq.Hosting.MediaTheme.Bridge/Manifest.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Lombiq.HelpfulExtensions;
using OrchardCore.Modules.Manifest;

[assembly: Module(
Expand All @@ -7,5 +8,5 @@
Version = "0.0.1",
Description = "Provides the processing logic for the Media Theme.",
Category = "Hosting",
Dependencies = ["OrchardCore.Deployment", "OrchardCore.Media"]
Dependencies = ["OrchardCore.Deployment", "OrchardCore.Media", FeatureIds.GoogleTag]
)]
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Lombiq.Hosting.MediaTheme.Bridge.Constants;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Options;
using Microsoft.Net.Http.Headers;
using OrchardCore.Media;
using OrchardCore.Routing;
using System;
Expand Down Expand Up @@ -37,8 +38,8 @@ public async Task InvokeAsync(HttpContext context)
return;
}

context.Response.StatusCode = 404;
context.Response.Headers.Append("Content-Length", "0");
context.Response.StatusCode = StatusCodes.Status404NotFound;
context.Response.Headers.Append(HeaderNames.ContentLength, "0");
await context.Response.Body.FlushAsync(context.RequestAborted);
// Use Complete instead of Abort which actually causes a 502 Bad Gateway response.
await context.Response.CompleteAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

namespace Lombiq.Hosting.MediaTheme.Bridge.Navigation;

public class MediaThemeDeploymentSettingsAdminMenu : INavigationProvider
public sealed class MediaThemeDeploymentSettingsAdminMenu : INavigationProvider
{
private readonly IStringLocalizer T;

public MediaThemeDeploymentSettingsAdminMenu(IStringLocalizer<MediaThemeDeploymentSettingsAdminMenu> stringLocalizer) => T = stringLocalizer;

public Task BuildNavigationAsync(string name, NavigationBuilder builder)
public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder)
{
if (!string.Equals(name, "admin", StringComparison.OrdinalIgnoreCase)) return Task.CompletedTask;
if (!string.Equals(name, "admin", StringComparison.OrdinalIgnoreCase)) return ValueTask.CompletedTask;

builder
.Add(T["Configuration"], configuration => configuration
Expand All @@ -25,6 +25,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder)
.Permission(ManageMediaTheme)
.LocalNav()));

return Task.CompletedTask;
return ValueTask.CompletedTask;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Lombiq.Hosting.MediaTheme.Bridge.Permissions;

public class MediaThemeDeploymentPermissions : IPermissionProvider
public sealed class MediaThemeDeploymentPermissions : IPermissionProvider
{
public static readonly Permission ManageMediaTheme = new(
nameof(ManageMediaTheme),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Lombiq.Hosting.MediaTheme.Bridge.Services;

public class ExtensionManagerDecorator : IExtensionManager
public sealed class ExtensionManagerDecorator : IExtensionManager
{
private readonly IExtensionManager _decorated;
private readonly IMediaThemeStateStore _mediaThemeStateStore;
Expand Down Expand Up @@ -68,13 +68,13 @@ public IEnumerable<IFeatureInfo> GetFeatures(string[] featureIdsToLoad)
public IEnumerable<IFeatureInfo> GetDependentFeatures(string featureId) =>
_decorated.GetDependentFeatures(featureId);

public Task<IEnumerable<FeatureEntry>> LoadFeaturesAsync() =>
Task<IEnumerable<IFeatureInfo>> IExtensionManager.LoadFeaturesAsync() =>
_decorated.LoadFeaturesAsync();

public Task<IEnumerable<FeatureEntry>> LoadFeaturesAsync(string[] featureIdsToLoad) =>
Task<IEnumerable<IFeatureInfo>> IExtensionManager.LoadFeaturesAsync(string[] featureIdsToLoad) =>
_decorated.LoadFeaturesAsync(featureIdsToLoad);

private string GetBaseThemeId() =>
// It'll be retrieved from cache so it's not an issue.
// It'll be retrieved from cache, so it's not an issue.
_mediaThemeStateStore.GetMediaThemeStateAsync().GetAwaiter().GetResult()?.BaseThemeId;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Http;
using OrchardCore.Admin;
using OrchardCore.DisplayManagement;
using OrchardCore.DisplayManagement.Descriptors;
using OrchardCore.DisplayManagement.Implementation;
using OrchardCore.Liquid;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
Expand All @@ -27,27 +29,20 @@ public MediaTemplatesShapeBindingResolver(
_mediaThemeCachingService = mediaThemeCachingService;
}

public async Task<ShapeBinding> GetShapeBindingAsync(string shapeType)
{
if (AdminAttribute.IsApplied(_hca.HttpContext))
{
return null;
}
public async Task<ShapeBinding> GetShapeBindingAsync(string shapeType) =>
!AdminAttribute.IsApplied(_hca.HttpContext) &&
await _mediaThemeCachingService.GetMemoryCachedMediaTemplateAsync(shapeType) is { } mediaTemplate
? new()
{
BindingName = shapeType,
BindingSource = shapeType,
BindingAsync = displayContext => BindingAsync(displayContext, mediaTemplate.Content),
}
: null;

return await _mediaThemeCachingService.GetMemoryCachedMediaTemplateAsync(shapeType) is not { } mediaTemplate
? null
: BuildShapeBinding(shapeType, mediaTemplate.Content);
private async Task<IHtmlContent> BindingAsync(DisplayContext displayContext, string text)
{
var content = await _liquidTemplateManager.RenderHtmlContentAsync(text, _htmlEncoder, displayContext.Value);
return content;
}

private ShapeBinding BuildShapeBinding(string shapeType, string text) =>
new()
{
BindingName = shapeType,
BindingSource = shapeType,
BindingAsync = async displayContext =>
{
var content = await _liquidTemplateManager.RenderHtmlContentAsync(text, _htmlEncoder, displayContext.Value);
return content;
},
};
}
26 changes: 21 additions & 5 deletions Lombiq.Hosting.MediaTheme.Bridge/Services/MediaThemeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ namespace Lombiq.Hosting.MediaTheme.Bridge.Services;

public class MediaThemeManager : IMediaThemeManager
{
private const string LiquidExtension = ".liquid";

private readonly IMediaThemeStateStore _mediaThemeStateStore;
private readonly IShellFeaturesManager _shellFeaturesManager;
private readonly IMemoryCache _memoryCache;
Expand Down Expand Up @@ -77,11 +79,20 @@ public async Task UpdateBaseThemeAsync(string baseThemeId)

public async Task<MediaTemplate> GetMediaTemplateByShapeTypeAsync(string shapeType)
{
var templatePath = _mediaFileStore.Combine(
Paths.MediaThemeRootFolder,
Paths.MediaThemeTemplatesFolder,
shapeType + ".liquid");
if (!await _mediaFileStore.FileExistsAsync(templatePath)) return null;
var templatePath = GetPath(shapeType + LiquidExtension);

// Check if the file exists with a different casing, before giving up.
if (!await _mediaFileStore.FileExistsAsync(templatePath))
{
var basePath = GetPath();
var file = await _mediaFileStore
.GetDirectoryContentAsync(basePath)
.Where(file => file.Name.EqualsOrdinalIgnoreCase(shapeType + LiquidExtension))
.FirstOrDefaultAsync();

if (file == null) return null;
templatePath = GetPath(file.Name);
}

await using var templateFileStream = await _mediaFileStore.GetFileStreamAsync(templatePath);
using var reader = new StreamReader(templateFileStream);
Expand All @@ -95,6 +106,11 @@ public async Task<MediaTemplate> GetMediaTemplateByShapeTypeAsync(string shapeTy
};
}

private string GetPath(string shapeType = null) =>
shapeType == null
? _mediaFileStore.Combine(Paths.MediaThemeRootFolder, Paths.MediaThemeTemplatesFolder)
: _mediaFileStore.Combine(Paths.MediaThemeRootFolder, Paths.MediaThemeTemplatesFolder, shapeType);

private static void ThrowIfBaseThemeIdIsInvalid(string baseThemeId)
{
if (baseThemeId == FeatureNames.MediaTheme)
Expand Down
5 changes: 3 additions & 2 deletions Lombiq.Hosting.MediaTheme.Bridge/Services/MediaThemeStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
using OrchardCore.Recipes.Models;
using OrchardCore.Recipes.Services;
using System;
using System.Text.Json;
using System.Threading.Tasks;

namespace Lombiq.Hosting.MediaTheme.Bridge.Services;

public class MediaThemeStep : IRecipeStepHandler
public sealed class MediaThemeStep : IRecipeStepHandler
{
private readonly IMediaFileStore _mediaFileStore;
private readonly IMediaThemeManager _mediaThemeManager;
Expand All @@ -28,7 +29,7 @@ public async Task ExecuteAsync(RecipeExecutionContext context)
return;
}

var model = context.Step.ToObject<MediaThemeStepModel>();
var model = context.Step.Deserialize<MediaThemeStepModel>();

await _mediaThemeManager.UpdateBaseThemeAsync(model.BaseThemeId);

Expand Down
15 changes: 6 additions & 9 deletions Lombiq.Hosting.MediaTheme.Bridge/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Deployment;
using OrchardCore.DisplayManagement;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.Environment.Extensions;
using OrchardCore.Modules;
using OrchardCore.Navigation;
Expand All @@ -21,23 +20,21 @@

namespace Lombiq.Hosting.MediaTheme.Bridge;

public class Startup : StartupBase
public sealed class Startup : StartupBase
{
// Make sure the middlewares run first so we can block Media Theme template requests in time.
public override int Order => -100;
// Make sure the middlewares run first, so we can block Media Theme template requests in time.
public override int ConfigureOrder => int.MinValue;

public override void ConfigureServices(IServiceCollection services)
{
services.AddScoped<IPermissionProvider, MediaThemeDeploymentPermissions>();
services.AddScoped<INavigationProvider, MediaThemeDeploymentSettingsAdminMenu>();
services.AddPermissionProvider<MediaThemeDeploymentPermissions>();
services.AddNavigationProvider<MediaThemeDeploymentSettingsAdminMenu>();
services.AddSingleton<IMediaThemeStateStore, MediaThemeStateStore>();
services.Decorate<IExtensionManager, ExtensionManagerDecorator>();
services.AddScoped<IShapeBindingResolver, MediaTemplatesShapeBindingResolver>();
services.AddScoped<IMediaThemeManager, MediaThemeManager>();
services.AddRecipeExecutionStep<MediaThemeStep>();
services.AddTransient<IDeploymentSource, MediaThemeDeploymentSource>();
services.AddSingleton<IDeploymentStepFactory>(new DeploymentStepFactory<MediaThemeDeploymentStep>());
services.AddScoped<IDisplayDriver<DeploymentStep>, MediaThemeDeploymentStepDriver>();
services.AddDeployment<MediaThemeDeploymentSource, MediaThemeDeploymentStep, MediaThemeDeploymentStepDriver>();
services.AddScoped<IAuthorizationHandler, ManageMediaThemeFolderAuthorizationHandler>();
services.AddScoped<IMediaThemeCachingService, MediaThemeCachingService>();
services.AddOrchardServices();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading