Skip to content

Commit

Permalink
Releasing v2 finally
Browse files Browse the repository at this point in the history
  • Loading branch information
YodasMyDad committed Dec 3, 2024
1 parent 7a17585 commit cd0a888
Show file tree
Hide file tree
Showing 14 changed files with 81 additions and 69 deletions.
2 changes: 1 addition & 1 deletion ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ _Core tech used is: .Net 9, Blazor, EF Core, Identity, Mediatr, [Radzen Componen

This repo comes with a starter site example, if you clone this repo, build and run the **ZauberCMS.Web** project you will see the starter kit (Go to /admin, register an account to see everything).

However, fastest way to get started building your own website is using the .Net Template, firstly install the ZauberCMS template (--force just makes sure you install the latest one)
However, fastest way to get started building your own website is using the .Net Template, firstly install the ZauberCMS template (--force just makes sure you install the latest one, which is 2.0.8)

`dotnet new install ZauberCMS.Template --force`

Expand Down
14 changes: 9 additions & 5 deletions ZauberCMS.Components/Pages/BlankLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@
@implements ZauberCMS.Core.Membership.Interfaces.IAccountLayout

<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<base href="/"/>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<link rel="stylesheet" href="_content/ZauberCMS.Components/ZauberCMS.Components.bundle.scp.css">
<HeadOutlet/>
<ImportMap/>
</head>

<body style="display: flex; justify-content: center; align-items: center; height: 100vh; width: 100vw; overflow: hidden;">
@Body

@*<div id="blazor-error-ui" data-nosnippet>
An unhandled error has occurred.
<a href="." class="reload">Reload</a>
<span class="dismiss">🗙</span>
</div>*@
<div id="blazor-error-ui" style="display: none" data-nosnippet>
An unhandled error has occurred.
<a href="." class="reload">Reload</a>
<span class="dismiss">🗙</span>
</div>
</body>

@code
Expand Down
4 changes: 2 additions & 2 deletions ZauberCMS.Components/ZauberCMS.Components.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>ZauberCMS.Components</PackageId>
<Version>2.0.6</Version>
<Version>2.0.8</Version>
<Authors>Lee Messenger</Authors>
<Description>ZauberCMS components package</Description>
<PackageTags>Web</PackageTags>
Expand Down Expand Up @@ -47,7 +47,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="ZauberCMS.Core" Version="2.0.6" />
<PackageReference Include="ZauberCMS.Core" Version="2.0.8" />
</ItemGroup>

<ItemGroup>
Expand Down
44 changes: 25 additions & 19 deletions ZauberCMS.Components/wwwroot/js/shadow-dom.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
window.cachedStylesheets = window.cachedStylesheets || new Map();

window.initializeShadowDOMWithMultipleStylesheets = (element, stylesheetPaths) => {
if (element && Array.isArray(stylesheetPaths)) {
const shadowRoot = element.attachShadow({ mode: 'open' });
if (!element || typeof element.attachShadow !== 'function') {
return;
}

if (!Array.isArray(stylesheetPaths)) {
return;
}

stylesheetPaths.forEach((stylesheetPath) => {
if (cachedStylesheets.has(stylesheetPath)) {
// Reuse cached style
shadowRoot.appendChild(cachedStylesheets.get(stylesheetPath).cloneNode(true));
} else {
// Load new stylesheet
const link = document.createElement('link');
link.rel = 'stylesheet';
link.href = stylesheetPath;
const shadowRoot = element.attachShadow({ mode: 'open' });

// Cache the stylesheet
cachedStylesheets.set(stylesheetPath, link);
shadowRoot.appendChild(link);
}
});
stylesheetPaths.forEach((stylesheetPath) => {
if (cachedStylesheets.has(stylesheetPath)) {
// Reuse cached style
shadowRoot.appendChild(cachedStylesheets.get(stylesheetPath).cloneNode(true));
} else {
// Load new stylesheet
const link = document.createElement('link');
link.rel = 'stylesheet';
link.href = stylesheetPath;

// Move the inner content of the component to the shadow root
while (element.firstChild) {
shadowRoot.appendChild(element.firstChild);
// Cache the stylesheet
cachedStylesheets.set(stylesheetPath, link);
shadowRoot.appendChild(link);
}
});

// Move the inner content of the component to the shadow root
while (element.firstChild) {
shadowRoot.appendChild(element.firstChild);
}
};
2 changes: 1 addition & 1 deletion ZauberCMS.Core/Settings/ZauberSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class ZauberSettings
public string AdminDefaultLanguage { get; set; } = "en-US";

public bool EnablePathUrls { get; set; }

public bool ShowDetailedErrors { get; set; }
public EmailSettings Email { get; set; } = new();
public PluginSettings Plugins { get; set; } = new()
{
Expand Down
2 changes: 1 addition & 1 deletion ZauberCMS.Core/ZauberCMS.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>ZauberCMS.Core</PackageId>
<Version>2.0.6</Version>
<Version>2.0.8</Version>
<Authors>Lee Messenger</Authors>
<Description>ZauberCMS core package</Description>
<PackageTags>Web</PackageTags>
Expand Down
40 changes: 19 additions & 21 deletions ZauberCMS.Core/ZauberSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,25 @@ public static void AddZauberCms(this WebApplicationBuilder builder)

builder.Services.AddControllers();

// Add services to the container.
#if DEBUG
builder.Services
.AddRazorComponents(c => c.DetailedErrors = true)
.AddInteractiveServerComponents(c => c.DetailedErrors = true);
builder.Services.AddDatabaseDeveloperPageExceptionFilter();
#else
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
#endif

// Bind configuration to ZauberSettings instance
var zauberSettings = new ZauberSettings();
builder.Configuration.GetSection(Constants.SettingsConfigName).Bind(zauberSettings);
builder.Services.Configure<ZauberSettings>(builder.Configuration.GetSection(Constants.SettingsConfigName));

// Detailed errors have been enabled
if (zauberSettings.ShowDetailedErrors)
{
builder.Services
.AddRazorComponents(c => c.DetailedErrors = true)
.AddInteractiveServerComponents(c => c.DetailedErrors = true);
builder.Services.AddDatabaseDeveloperPageExceptionFilter();
}
else
{
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
}

builder.Services.AddHttpClient();

builder.Services.AddScoped(sp =>
Expand All @@ -107,12 +115,6 @@ public static void AddZauberCms(this WebApplicationBuilder builder)
});

builder.Services.AddCascadingAuthenticationState();

// Bind configuration to ZauberSettings instance
var zauberSettings = new ZauberSettings();
builder.Configuration.GetSection(Constants.SettingsConfigName).Bind(zauberSettings);

builder.Services.Configure<ZauberSettings>(builder.Configuration.GetSection(Constants.SettingsConfigName));
builder.Services.AddScoped<IdentityUserAccessor>();
builder.Services.AddScoped<IdentityRedirectManager>();
builder.Services.AddScoped<AuthenticationStateProvider, IdentityRevalidatingAuthenticationStateProvider>();
Expand All @@ -139,10 +141,6 @@ public static void AddZauberCms(this WebApplicationBuilder builder)
builder.Services.AddDbContext<ZauberDbContext>();
break;
}

#if DEBUG
builder.Services.AddDatabaseDeveloperPageExceptionFilter();
#endif

builder.Services.AddIdentityCore<User>(options =>
{
Expand Down
4 changes: 2 additions & 2 deletions ZauberCMS.Routing/ZauberCMS.Routing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>ZauberCMS.Routing</PackageId>
<Version>2.0.6</Version>
<Version>2.0.8</Version>
<Authors>Lee Messenger</Authors>
<Description>ZauberCMS routing package</Description>
<PackageTags>Web</PackageTags>
Expand Down Expand Up @@ -37,7 +37,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="9.0.0" />

<PackageReference Include="ZauberCMS.Components" Version="2.0.6" />
<PackageReference Include="ZauberCMS.Components" Version="2.0.8" />
</ItemGroup>

<Target Name="CopyNuGetPackage" AfterTargets="Pack">
Expand Down
4 changes: 2 additions & 2 deletions ZauberCMS.Template/ZauberCMS.Template.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>true</IsPackable>
<Version>2.0.6</Version>
<Version>2.0.8</Version>
<Authors>Lee Messenger</Authors>
<PackageId>ZauberCMS.Template</PackageId>
<Description>Package that creates a ZauberCMS website project.</Description>
Expand All @@ -15,7 +15,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ZauberCMS" Version="2.0.6"/>
<PackageReference Include="ZauberCMS" Version="2.0.8"/>
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion ZauberCMS.Web/ContentBlocks/RTEBlock.razor
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@implements ZauberCMS.Core.Content.Interfaces.IContentBlockView
@if (Content != null)
{
<div class="fs-6">
<div>
@((MarkupString)(Content.GetValue<string>("Content") ?? string.Empty))
</div>
}
Expand Down
1 change: 0 additions & 1 deletion ZauberCMS.Web/Custom/ContactForm.razor
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@using System.ComponentModel.DataAnnotations
@implements ZauberCMS.Core.Content.Interfaces.ICustomContentComponent
@rendermode InteractiveServer

<div class="pt-2">
@if (Sent)
Expand Down
4 changes: 2 additions & 2 deletions ZauberCMS.Web/ZauberCMS.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
</PropertyGroup>

<ItemGroup>
<!--<ProjectReference Include="..\ZauberCMS\ZauberCMS.csproj" />-->
<PackageReference Include="ZauberCMS" Version="2.0.6" />
<ProjectReference Include="..\ZauberCMS\ZauberCMS.csproj" />
<!--<PackageReference Include="ZauberCMS" Version="2.0.8" />-->
</ItemGroup>

<ItemGroup>
Expand Down
21 changes: 13 additions & 8 deletions ZauberCMS/Components/App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@

@code {

[CascadingParameter]
private HttpContext? HttpContext { get; set; }

[CascadingParameter] private HttpContext? HttpContext { get; set; }

private bool IsAdmin
{
get
Expand All @@ -23,12 +22,18 @@
return requestPathSpan.StartsWith(Constants.Urls.AdminBaseUrl, StringComparison.OrdinalIgnoreCase);
}
}

private static IComponentRenderMode RenderModeForPage => InteractiveServer;

/*if (HttpContext == null)

private IComponentRenderMode? RenderModeForPage
{
get
{
if (HttpContext == null)
{
return InteractiveServer;
}
return HttpContext?.AcceptsInteractiveRouting() == true ? InteractiveServer : null;*/

return HttpContext?.AcceptsInteractiveRouting() == true ? InteractiveServer : null;
}
}

}
6 changes: 3 additions & 3 deletions ZauberCMS/ZauberCMS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>ZauberCMS</PackageId>
<Version>2.0.6</Version>
<Version>2.0.8</Version>
<Authors>Lee Messenger</Authors>
<Description>The main ZauberCMS nuget package</Description>
<PackageTags>Web</PackageTags>
Expand Down Expand Up @@ -60,8 +60,8 @@
<ProjectReference Include="..\ZauberCMS.Routing\ZauberCMS.Routing.csproj"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="ZauberCMS.Components" Version="2.0.6"/>
<PackageReference Include="ZauberCMS.Routing" Version="2.0.6"/>
<PackageReference Include="ZauberCMS.Components" Version="2.0.8"/>
<PackageReference Include="ZauberCMS.Routing" Version="2.0.8"/>
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit cd0a888

Please sign in to comment.