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-751: Upgrade to Orchard Core 1.8 #51

Merged
merged 21 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 14 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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
</PropertyGroup>

Expand All @@ -28,12 +28,12 @@
</ItemGroup>

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

Expand Down
2 changes: 1 addition & 1 deletion Lombiq.Hosting.MediaTheme.Bridge/Manifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
Version = "0.0.1",
Description = "Provides the processing logic for the Media Theme.",
Category = "Hosting",
Dependencies = new[] { "OrchardCore.Deployment", "OrchardCore.Media" }
Dependencies = ["OrchardCore.Deployment", "OrchardCore.Media"]
)]
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public async Task InvokeAsync(HttpContext context)
}

context.Response.StatusCode = 404;
context.Response.Headers.Add("Content-Length", "0");
context.Response.Headers.Append("Content-Length", "0");
await context.Response.Body.FlushAsync(context.RequestAborted);
context.Abort();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public IEnumerable<IFeatureInfo> GetFeatures(string[] featureIdsToLoad)
if (featureIdsToLoad.Contains(FeatureNames.MediaTheme))
{
var baseThemeId = GetBaseThemeId();
if (!string.IsNullOrEmpty(baseThemeId)) featureIdsToLoad = featureIdsToLoad.Append(baseThemeId).ToArray();
if (!string.IsNullOrEmpty(baseThemeId)) featureIdsToLoad = [.. featureIdsToLoad, baseThemeId];
}

return _decorated.GetFeatures(featureIdsToLoad);
Expand Down
2 changes: 1 addition & 1 deletion Lombiq.Hosting.MediaTheme.Bridge/Views/Admin/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

<div class="mb-3">
<div class="mb-3" asp-validation-class-for="BaseThemeId">
<label asp-for="BaseThemeId">@T["Base Theme"]</label>
<label class="form-label" asp-for="BaseThemeId">@T["Base Theme"]</label>
<select asp-for="BaseThemeId" asp-items="availableThemesSelectList" class="form-control"></select>
<span asp-validation-for="BaseThemeId"></span>
<div class="hint">@T["By updating the base theme the shape table cache will be invalidated."]</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div class="mb-3">
<div class="form-check">
<label class="form-check-label">
<label class="form-label form-check-label">
<input class="form-check-input" asp-for="ClearMediaThemeFolder"
data-reverseToggle=".media-sel"/>
@T["Clear Media Theme files when imported."]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackAsTool>true</PackAsTool>
Expand Down
18 changes: 11 additions & 7 deletions Lombiq.Hosting.MediaTheme.Deployer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ public class CommandLineOptions
public string? RemoteDeploymentClientApiKey { get; set; }
}

internal static class Program
internal static partial class Program
{
internal static readonly string[] FeaturesToEnable = ["Lombiq.Hosting.MediaTheme.Bridge", "Lombiq.Hosting.MediaTheme"];

public static Task Main(string[] args) =>
Parser.Default.ParseArguments<CommandLineOptions>(args)
.WithNotParsed(HandleParseError)
Expand All @@ -76,7 +78,7 @@ public static Task Main(string[] args) =>
private static void HandleParseError(IEnumerable<Error> errors)
{
var errorsList = errors.ToList();
if (errorsList.Any())
if (errorsList.Count != 0)
{
foreach (var error in errorsList)
{
Expand Down Expand Up @@ -134,7 +136,7 @@ private static async Task RunOptionsInnerAsync(CommandLineOptions options)
var featureStep = JObject.FromObject(new
{
name = "Feature",
enable = new[] { "Lombiq.Hosting.MediaTheme.Bridge", "Lombiq.Hosting.MediaTheme" },
enable = FeaturesToEnable,
});
recipeSteps.Add(featureStep);

Expand All @@ -152,12 +154,11 @@ private static async Task RunOptionsInnerAsync(CommandLineOptions options)
{
var manifestPath = Path.Combine(themePath, "Manifest.cs");
var manifestContent = await File.ReadAllTextAsync(manifestPath);
var basteThemeMatch = Regex.Match(
manifestContent, @"BaseTheme\s*=\s*""(?<baseThemeId>.*)""", RegexOptions.ExplicitCapture, TimeSpan.FromSeconds(1));
var baseThemeMatch = BaseThemeRegex().Match(manifestContent);

if (basteThemeMatch.Success)
if (baseThemeMatch.Success)
{
baseThemeId = basteThemeMatch.Groups["baseThemeId"].Value;
baseThemeId = baseThemeMatch.Groups["baseThemeId"].Value;
}
}

Expand Down Expand Up @@ -343,4 +344,7 @@ private static void CreateRecipeAndWriteIt(CommandLineOptions options, JArray st

file.Close();
}

[GeneratedRegex(@"BaseTheme\s*=\s*""(?<baseThemeId>.*)""", RegexOptions.ExplicitCapture, matchTimeoutMilliseconds: 1000)]
private static partial Regex BaseThemeRegex();
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<DefaultItemExcludes>$(DefaultItemExcludes);.git*;node_modules\**</DefaultItemExcludes>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions Lombiq.Hosting.MediaTheme/Lombiq.Hosting.MediaTheme.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
</PropertyGroup>

Expand Down Expand Up @@ -32,7 +32,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OrchardCore.Theme.Targets" Version="1.7.0" />
<PackageReference Include="OrchardCore.Theme.Targets" Version="1.8.2" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Lombiq.Hosting.MediaTheme/Manifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
Version = "0.0.1",
Description = "Allows developers to host their themes in the Orchard Core Media Library, including templates and assets.",
Category = "Hosting",
Dependencies = new[] { MediaThemeBridge }
Dependencies = [MediaThemeBridge]
)]