Skip to content

Commit

Permalink
feature; multi target support
Browse files Browse the repository at this point in the history
  • Loading branch information
jcdcdev committed Jan 3, 2024
1 parent 8651461 commit 714411c
Show file tree
Hide file tree
Showing 94 changed files with 4,132 additions and 197 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -466,16 +466,13 @@ appsettings-schema.json
# Temp folder containing Examine indexes, NuCache, MediaCache, etc.
/umbraco/Data/TEMP/

# SQLite database files - enable if you don't want to commit your test DB to the repo
#/umbraco/Data/*.sqlite.db
#/umbraco/Data/*.sqlite.db-shm
#/umbraco/Data/*.sqlite.db-wal
# SQLite database files
/umbraco/Data/*.sqlite.db
/umbraco/Data/*.sqlite.db-shm
/umbraco/Data/*.sqlite.db-wal

# Log files
/umbraco/Logs/

# Media files
/wwwroot/media/

# Test Site App_Plugins packages folder (exclude here as in jcdcdev.Umbraco.Core project)
/App_Plugins/jcdcdev.Umbraco.Core/
19 changes: 19 additions & 0 deletions src/TestSite.10/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace TestSite.Ten
{
public class Program
{
public static void Main(string[] args)
=> CreateHostBuilder(args)
.Build()
.Run();

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureUmbracoDefaults()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStaticWebAssets();
webBuilder.UseStartup<Startup>();
});
}
}
29 changes: 29 additions & 0 deletions src/TestSite.10/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:16958",
"sslPort": 44316
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Umbraco.Web.UI": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:44316;http://localhost:16958",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
65 changes: 65 additions & 0 deletions src/TestSite.10/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
namespace TestSite.Ten
{
public class Startup
{
private readonly IWebHostEnvironment _env;
private readonly IConfiguration _config;

/// <summary>
/// Initializes a new instance of the <see cref="Startup" /> class.
/// </summary>
/// <param name="webHostEnvironment">The web hosting environment.</param>
/// <param name="config">The configuration.</param>
/// <remarks>
/// Only a few services are possible to be injected here https://github.com/dotnet/aspnetcore/issues/9337.
/// </remarks>
public Startup(IWebHostEnvironment webHostEnvironment, IConfiguration config)
{
_env = webHostEnvironment ?? throw new ArgumentNullException(nameof(webHostEnvironment));
_config = config ?? throw new ArgumentNullException(nameof(config));
}

/// <summary>
/// Configures the services.
/// </summary>
/// <param name="services">The services.</param>
/// <remarks>
/// This method gets called by the runtime. Use this method to add services to the container.
/// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940.
/// </remarks>
public void ConfigureServices(IServiceCollection services)
{
services.AddUmbraco(_env, _config)
.AddBackOffice()
.AddWebsite()
.AddComposers()
.Build();
}

/// <summary>
/// Configures the application.
/// </summary>
/// <param name="app">The application builder.</param>
/// <param name="env">The web hosting environment.</param>
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

app.UseUmbraco()
.WithMiddleware(u =>
{
u.UseBackOffice();
u.UseWebsite();
})
.WithEndpoints(u =>
{
u.UseInstallerEndpoints();
u.UseBackOfficeEndpoints();
u.UseWebsiteEndpoints();
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>TestSite.Ten</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Umbraco.Cms" Version="10.6.1"/>
<PackageReference Include="Umbraco.Cms" Version="10.4.0"/>
</ItemGroup>

<ItemGroup>
Expand All @@ -15,6 +16,16 @@
<RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="68.2.0.9" Condition="$(RuntimeIdentifier.StartsWith('linux')) or $(RuntimeIdentifier.StartsWith('win')) or ('$(RuntimeIdentifier)' == '' and !$([MSBuild]::IsOSPlatform('osx')))"/>
</ItemGroup>

<ItemGroup>
<Content Update="appsettings.*.json">
<DependentUpon>appsettings.json</DependentUpon>
</Content>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\jcdcdev.Umbraco.Core\jcdcdev.Umbraco.Core.csproj"/>
</ItemGroup>

<PropertyGroup>
<!-- Razor files are needed for the backoffice to work correctly -->
<CopyRazorGenerateFilesToPublishDirectory>true</CopyRazorGenerateFilesToPublishDirectory>
Expand All @@ -26,14 +37,4 @@
<RazorCompileOnPublish>false</RazorCompileOnPublish>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\jcdcdev.Umbraco.Core\jcdcdev.Umbraco.Core.csproj"/>
</ItemGroup>

<ItemGroup>
<Content Update="appsettings.*.json">
<DependentUpon>appsettings.json</DependentUpon>
</Content>
</ItemGroup>

</Project>
</Project>
10 changes: 10 additions & 0 deletions src/TestSite.10/Views/Partials/blockgrid/area.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@using Umbraco.Extensions
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.BlockGridArea>

<div class="umb-block-grid__area"
data-area-col-span="@Model.ColumnSpan"
data-area-row-span="@Model.RowSpan"
data-area-alias="@Model.Alias"
style="--umb-block-grid--grid-columns: @Model.ColumnSpan;--umb-block-grid--area-column-span: @Model.ColumnSpan; --umb-block-grid--area-row-span: @Model.RowSpan;">
@await Html.GetBlockGridItemsHtmlAsync(Model)
</div>
13 changes: 13 additions & 0 deletions src/TestSite.10/Views/Partials/blockgrid/areas.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@using Umbraco.Extensions
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.BlockGridItem>
@{
if (Model?.Areas.Any() != true) { return; }
}

<div class="umb-block-grid__area-container"
style="--umb-block-grid--area-grid-columns: @(Model.AreaGridColumns?.ToString() ?? Model.GridColumns?.ToString() ?? "12");">
@foreach (var area in Model.Areas)
{
@await Html.GetBlockGridItemAreaHtmlAsync(area)
}
</div>
11 changes: 11 additions & 0 deletions src/TestSite.10/Views/Partials/blockgrid/default.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@using Umbraco.Extensions
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.BlockGridModel>
@{
if (Model?.Any() != true) { return; }
}

<div class="umb-block-grid"
data-grid-columns="@(Model.GridColumns?.ToString() ?? "12");"
style="--umb-block-grid--grid-columns: @(Model.GridColumns?.ToString() ?? "12");">
@await Html.GetBlockGridItemsHtmlAsync(Model)
</div>
36 changes: 36 additions & 0 deletions src/TestSite.10/Views/Partials/blockgrid/items.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@using Umbraco.Cms.Core.Models.Blocks
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<IEnumerable<BlockGridItem>>
@{
if (Model?.Any() != true) { return; }
}

<div class="umb-block-grid__layout-container">
@foreach (var item in Model)
{

<div
class="umb-block-grid__layout-item"
data-content-element-type-alias="@item.Content.ContentType.Alias"
data-content-element-type-key="@item.Content.ContentType.Key"
data-element-udi="@item.ContentUdi"
data-col-span="@item.ColumnSpan"
data-row-span="@item.RowSpan"
style=" --umb-block-grid--item-column-span: @item.ColumnSpan; --umb-block-grid--item-row-span: @item.RowSpan; ">
@{
var partialViewName = "blockgrid/Components/" + item.Content.ContentType.Alias;
try
{
@await Html.PartialAsync(partialViewName, item)
}
catch (InvalidOperationException)
{
<p>
<strong>Could not render component of type: @(item.Content.ContentType.Alias)</strong>
<br/>
This likely happened because the partial view <em>@partialViewName</em> could not be found.
</p>
}
}
</div>
}
</div>
13 changes: 13 additions & 0 deletions src/TestSite.10/Views/Partials/blocklist/default.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.BlockListModel>
@{
if (Model?.Any() != true) { return; }
}
<div class="umb-block-list">
@foreach (var block in Model)
{
if (block?.ContentUdi == null) { continue; }
var data = block.Content;

@await Html.PartialAsync("blocklist/Components/" + data.ContentType.Alias, block)
}
</div>
106 changes: 106 additions & 0 deletions src/TestSite.10/Views/Partials/grid/bootstrap3-fluid.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
@using System.Web
@using Microsoft.AspNetCore.Html
@using Newtonsoft.Json.Linq
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<dynamic>

@*
Razor helpers located at the bottom of this file
*@

@if (Model is JObject && Model?.sections is not null)
{
var oneColumn = ((System.Collections.ICollection)Model.sections).Count == 1;

<div class="umb-grid">
@if (oneColumn)
{
foreach (var section in Model.sections)
{
<div class="grid-section">
@foreach (var row in section.rows)
{
renderRow(row);
}
</div>
}
}
else
{
<div class="row clearfix">
@foreach (var sec in Model.sections)
{
<div class="grid-section">
<div class="[email protected] column">
@foreach (var row in sec.rows)
{
renderRow(row);
}
</div>
</div>
}
</div>
}
</div>
}

@functions{

private async Task renderRow(dynamic row)
{
<div @RenderElementAttributes(row)>
<div class="row clearfix">
@foreach (var area in row.areas)
{
<div class="[email protected] column">
<div @RenderElementAttributes(area)>
@foreach (var control in area.controls)
{
if (control?.editor?.view != null)
{
<text>@await Html.PartialAsync("grid/editors/base", (object)control)</text>
}
}
</div>
</div>
}
</div>
</div>
}
}

@functions{

public static HtmlString RenderElementAttributes(dynamic contentItem)
{
var attrs = new List<string>();
JObject cfg = contentItem.config;

if (cfg != null)
{
foreach (JProperty property in cfg.Properties())
{
var propertyValue = HttpUtility.HtmlAttributeEncode(property.Value.ToString());
attrs.Add(property.Name + "=\"" + propertyValue + "\"");
}
}

JObject style = contentItem.styles;

if (style != null) {
var cssVals = new List<string>();
foreach (JProperty property in style.Properties())
{
var propertyValue = property.Value.ToString();
if (string.IsNullOrWhiteSpace(propertyValue) == false)
{
cssVals.Add(property.Name + ":" + propertyValue + ";");
}
}

if (cssVals.Any())
attrs.Add("style='" + HttpUtility.HtmlAttributeEncode(string.Join(" ", cssVals)) + "'");
}

return new HtmlString(string.Join(" ", attrs));
}
}
Loading

0 comments on commit 714411c

Please sign in to comment.