Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Umbraco.Cms" Version="9.0.0-rc002" />
</ItemGroup>


<ItemGroup>
<Content Remove="umbraco\Data\**" />
<Content Remove="umbraco\logs\**" />
<Content Remove="umbraco\MediaCache\**" />
</ItemGroup>
<ItemGroup>
<Compile Remove="umbraco\Data\**" />
<Compile Remove="umbraco\logs\**" />
<Compile Remove="umbraco\MediaCache\**" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Remove="umbraco\Data\**" />
<EmbeddedResource Remove="umbraco\logs\**" />
<EmbeddedResource Remove="umbraco\MediaCache\**" />
</ItemGroup>
<ItemGroup>
<None Include="config\**\*.*">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
</None>
<None Include="umbraco\**\*.*">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
</None>
<None Include="App_Plugins\**\*.*">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
</None>
<None Remove="umbraco\Data\**" />
<None Remove="umbraco\logs\**" />
<None Remove="umbraco\MediaCache\**" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Our.Umbraco.Tables\Our.Umbraco.Tables.csproj" />
</ItemGroup>

<!-- Set this to true if ModelsBuilder mode is not InMemoryAuto-->
<PropertyGroup>
<RazorCompileOnBuild>false</RazorCompileOnBuild>
<RazorCompileOnPublish>false</RazorCompileOnPublish>
</PropertyGroup>
</Project>
19 changes: 19 additions & 0 deletions samples/Our.Umbraco.Tables.Demo.v9/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace Our.Umbraco.Tables.v9
{
public class Program
{
public static void Main(string[] args)
=> CreateHostBuilder(args)
.Build()
.Run();

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureLogging(x => x.ClearProviders())
.ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<Startup>());
}
}
29 changes: 29 additions & 0 deletions samples/Our.Umbraco.Tables.Demo.v9/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:39926",
"sslPort": 44385
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Umbraco.Web.UI.NetCore": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:44385;http://localhost:39926",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
76 changes: 76 additions & 0 deletions samples/Our.Umbraco.Tables.Demo.v9/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Extensions;

namespace Our.Umbraco.Tables.v9
{
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 Host 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>
/// <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)
{
#pragma warning disable IDE0022 // Use expression body for methods
services.AddUmbraco(_env, _config)
.AddBackOffice()
.AddWebsite()
.AddComposers()
.Build();
#pragma warning restore IDE0022 // Use expression body for methods

}

/// <summary>
/// Configures the application
/// </summary>
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();
});
}
}
}
70 changes: 70 additions & 0 deletions samples/Our.Umbraco.Tables.Demo.v9/Views/Home.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
@using Our.Umbraco.Tables.Enums
@using Our.Umbraco.Tables.Models
@using Umbraco.Cms.Web.Common.PublishedModels;
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.Home>
@using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;
@{
Layout = null;
}

@{
var firstRow = Model.Table.Cells.FirstOrDefault();
var rows = Model.Table.Rows.ToList();
var columns = Model.Table.Columns.ToList();
var tableStyles = Model.Table.Settings;
}

@if (firstRow != null)
{
<table class="@GetCssClass(tableStyles)">
<thead>
<tr class="@GetCssClass(tableStyles, Model.Table.Rows.FirstOrDefault())">
@foreach (var cell in firstRow)
{
<th class="@GetCssClass(tableStyles, columns[cell.ColumnIndex])" scope="col">
@Html.Raw(cell.Value)
</th>
}
</tr>
</thead>
<tbody>
@foreach (var row in Model.Table.Cells.Skip(1))
{
<tr class="@GetCssClass(tableStyles, rows[row.FirstOrDefault().RowIndex])">
@foreach (var cell in row)
{
<td class="@GetCssClass(tableStyles, columns[cell.ColumnIndex])">
@Html.Raw(cell.Value)
</td>
}
</tr>
}
</tbody>
</table>
}

@functions
{
public string GetCssClass(StyleData tableStyles, StyleData styleData = null)
{
var styles = tableStyles.BackgroundColor != BackgroundColour.None
? tableStyles.BackgroundColor
: styleData?.BackgroundColor ?? BackgroundColour.None;

switch (styles)
{
case BackgroundColour.OddEven:
return "is-odd-even";
case BackgroundColour.OddEvenReverse:
return "is-odd-even-reversed";
case BackgroundColour.Primary:
return "is-primary";
case BackgroundColour.Secondary:
return "is-secondary";
case BackgroundColour.Tertiary:
return "is-tertiary";
default:
return null;
}
}
}
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()) { 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>
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 != null && Model.GetType() == typeof(JObject) && Model.sections != 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="col-md-@sec.grid 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="col-md-@area.grid column">
<div @RenderElementAttributes(area)>
@foreach (var control in area.controls)
{
if (control != null && control.editor != null && 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