Skip to content

Commit 1f8ba87

Browse files
committed
Add Umbraco 13 testsite
1 parent ac9005a commit 1f8ba87

22 files changed

+1104
-1
lines changed

src/Umbraco.Cms.Integrations.Testsite.V13/.gitignore

Lines changed: 479 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
2+
3+
builder.CreateUmbracoBuilder()
4+
.AddBackOffice()
5+
.AddWebsite()
6+
.AddDeliveryApi()
7+
.AddComposers()
8+
.Build();
9+
10+
WebApplication app = builder.Build();
11+
12+
await app.BootUmbracoAsync();
13+
14+
15+
app.UseUmbraco()
16+
.WithMiddleware(u =>
17+
{
18+
u.UseBackOffice();
19+
u.UseWebsite();
20+
})
21+
.WithEndpoints(u =>
22+
{
23+
u.UseInstallerEndpoints();
24+
u.UseBackOfficeEndpoints();
25+
u.UseWebsiteEndpoints();
26+
});
27+
28+
await app.RunAsync();
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
3+
"iisSettings": {
4+
"windowsAuthentication": false,
5+
"anonymousAuthentication": true,
6+
"iisExpress": {
7+
"applicationUrl": "http://localhost:11291",
8+
"sslPort": 44392
9+
}
10+
},
11+
"profiles": {
12+
"IIS Express": {
13+
"commandName": "IISExpress",
14+
"launchBrowser": true,
15+
"environmentVariables": {
16+
"ASPNETCORE_ENVIRONMENT": "Development"
17+
}
18+
},
19+
"Umbraco.Web.UI": {
20+
"commandName": "Project",
21+
"dotnetRunMessages": true,
22+
"launchBrowser": true,
23+
"applicationUrl": "https://localhost:44392;http://localhost:11291",
24+
"environmentVariables": {
25+
"ASPNETCORE_ENVIRONMENT": "Development"
26+
}
27+
}
28+
}
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
<PropertyGroup>
3+
<TargetFramework>net8.0</TargetFramework>
4+
<ImplicitUsings>enable</ImplicitUsings>
5+
<Nullable>enable</Nullable>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="Umbraco.Cms" Version="13.0.0" />
10+
</ItemGroup>
11+
12+
<ItemGroup>
13+
<!-- Opt-in to app-local ICU to ensure consistent globalization APIs across different platforms -->
14+
<PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="72.1.0.3" />
15+
<RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="72.1.0.3" Condition="$(RuntimeIdentifier.StartsWith('linux')) or $(RuntimeIdentifier.StartsWith('win')) or ('$(RuntimeIdentifier)' == '' and !$([MSBuild]::IsOSPlatform('osx')))" />
16+
</ItemGroup>
17+
18+
<PropertyGroup>
19+
<!-- Razor files are needed for the backoffice to work correctly -->
20+
<CopyRazorGenerateFilesToPublishDirectory>true</CopyRazorGenerateFilesToPublishDirectory>
21+
</PropertyGroup>
22+
23+
<PropertyGroup>
24+
<!-- Remove RazorCompileOnBuild and RazorCompileOnPublish when not using ModelsMode InMemoryAuto -->
25+
<RazorCompileOnBuild>false</RazorCompileOnBuild>
26+
<RazorCompileOnPublish>false</RazorCompileOnPublish>
27+
</PropertyGroup>
28+
29+
</Project>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@using Umbraco.Extensions
2+
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.BlockGridArea>
3+
4+
<div class="umb-block-grid__area"
5+
data-area-col-span="@Model.ColumnSpan"
6+
data-area-row-span="@Model.RowSpan"
7+
data-area-alias="@Model.Alias"
8+
style="--umb-block-grid--grid-columns: @Model.ColumnSpan;--umb-block-grid--area-column-span: @Model.ColumnSpan; --umb-block-grid--area-row-span: @Model.RowSpan;">
9+
@await Html.GetBlockGridItemsHtmlAsync(Model)
10+
</div>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@using Umbraco.Extensions
2+
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.BlockGridItem>
3+
@{
4+
if (Model?.Areas.Any() != true) { return; }
5+
}
6+
7+
<div class="umb-block-grid__area-container"
8+
style="--umb-block-grid--area-grid-columns: @(Model.AreaGridColumns?.ToString() ?? Model.GridColumns?.ToString() ?? "12");">
9+
@foreach (var area in Model.Areas)
10+
{
11+
@await Html.GetBlockGridItemAreaHtmlAsync(area)
12+
}
13+
</div>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@using Umbraco.Extensions
2+
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.BlockGridModel>
3+
@{
4+
if (Model?.Any() != true) { return; }
5+
}
6+
7+
<div class="umb-block-grid"
8+
data-grid-columns="@(Model.GridColumns?.ToString() ?? "12");"
9+
style="--umb-block-grid--grid-columns: @(Model.GridColumns?.ToString() ?? "12");">
10+
@await Html.GetBlockGridItemsHtmlAsync(Model)
11+
</div>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
@using Umbraco.Cms.Core.Models.Blocks
2+
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<IEnumerable<BlockGridItem>>
3+
@{
4+
if (Model?.Any() != true) { return; }
5+
}
6+
7+
<div class="umb-block-grid__layout-container">
8+
@foreach (var item in Model)
9+
{
10+
11+
<div
12+
class="umb-block-grid__layout-item"
13+
data-content-element-type-alias="@item.Content.ContentType.Alias"
14+
data-content-element-type-key="@item.Content.ContentType.Key"
15+
data-element-udi="@item.ContentUdi"
16+
data-col-span="@item.ColumnSpan"
17+
data-row-span="@item.RowSpan"
18+
style=" --umb-block-grid--item-column-span: @item.ColumnSpan; --umb-block-grid--item-row-span: @item.RowSpan; ">
19+
@{
20+
var partialViewName = "blockgrid/Components/" + item.Content.ContentType.Alias;
21+
try
22+
{
23+
@await Html.PartialAsync(partialViewName, item)
24+
}
25+
catch (InvalidOperationException)
26+
{
27+
<p>
28+
<strong>Could not render component of type: @(item.Content.ContentType.Alias)</strong>
29+
<br/>
30+
This likely happened because the partial view <em>@partialViewName</em> could not be found.
31+
</p>
32+
}
33+
}
34+
</div>
35+
}
36+
</div>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.BlockListModel>
2+
@{
3+
if (Model?.Any() != true) { return; }
4+
}
5+
<div class="umb-block-list">
6+
@foreach (var block in Model)
7+
{
8+
if (block?.ContentUdi == null) { continue; }
9+
var data = block.Content;
10+
11+
@await Html.PartialAsync("blocklist/Components/" + data.ContentType.Alias, block)
12+
}
13+
</div>
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
@using System.Web
2+
@using Microsoft.AspNetCore.Html
3+
@using Newtonsoft.Json.Linq
4+
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<dynamic>
5+
6+
@*
7+
Razor helpers located at the bottom of this file
8+
*@
9+
10+
@if (Model is JObject && Model?.sections is not null)
11+
{
12+
var oneColumn = ((System.Collections.ICollection)Model.sections).Count == 1;
13+
14+
<div class="umb-grid">
15+
@if (oneColumn)
16+
{
17+
foreach (var section in Model.sections)
18+
{
19+
<div class="grid-section">
20+
@foreach (var row in section.rows)
21+
{
22+
renderRow(row);
23+
}
24+
</div>
25+
}
26+
}
27+
else
28+
{
29+
<div class="row clearfix">
30+
@foreach (var sec in Model.sections)
31+
{
32+
<div class="grid-section">
33+
<div class="[email protected] column">
34+
@foreach (var row in sec.rows)
35+
{
36+
renderRow(row);
37+
}
38+
</div>
39+
</div>
40+
}
41+
</div>
42+
}
43+
</div>
44+
}
45+
46+
@functions{
47+
48+
private async Task renderRow(dynamic row)
49+
{
50+
<div @RenderElementAttributes(row)>
51+
<div class="row clearfix">
52+
@foreach (var area in row.areas)
53+
{
54+
<div class="[email protected] column">
55+
<div @RenderElementAttributes(area)>
56+
@foreach (var control in area.controls)
57+
{
58+
if (control?.editor?.view != null)
59+
{
60+
<text>@await Html.PartialAsync("grid/editors/base", (object)control)</text>
61+
}
62+
}
63+
</div>
64+
</div>
65+
}
66+
</div>
67+
</div>
68+
}
69+
}
70+
71+
@functions{
72+
73+
public static HtmlString RenderElementAttributes(dynamic contentItem)
74+
{
75+
var attrs = new List<string>();
76+
JObject cfg = contentItem.config;
77+
78+
if (cfg != null)
79+
{
80+
foreach (JProperty property in cfg.Properties())
81+
{
82+
var propertyValue = HttpUtility.HtmlAttributeEncode(property.Value.ToString());
83+
attrs.Add(property.Name + "=\"" + propertyValue + "\"");
84+
}
85+
}
86+
87+
JObject style = contentItem.styles;
88+
89+
if (style != null) {
90+
var cssVals = new List<string>();
91+
foreach (JProperty property in style.Properties())
92+
{
93+
var propertyValue = property.Value.ToString();
94+
if (string.IsNullOrWhiteSpace(propertyValue) == false)
95+
{
96+
cssVals.Add(property.Name + ":" + propertyValue + ";");
97+
}
98+
}
99+
100+
if (cssVals.Any())
101+
attrs.Add("style='" + HttpUtility.HtmlAttributeEncode(string.Join(" ", cssVals)) + "'");
102+
}
103+
104+
return new HtmlString(string.Join(" ", attrs));
105+
}
106+
}

0 commit comments

Comments
 (0)