-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New example site based on Umbraco 10.1.0
- Loading branch information
Warren Buckley
committed
Aug 4, 2022
1 parent
2b3d685
commit 2d6f5e6
Showing
19 changed files
with
1,084 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
Our.Umbraco.TagHelpers.ExampleSite/Our.Umbraco.TagHelpers.ExampleSite.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Umbraco.Cms" Version="10.1.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<!-- Opt-in to app-local ICU to ensure consistent globalization APIs across different platforms --> | ||
<PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.9" /> | ||
<ProjectReference Include="..\Our.Umbraco.TagHelpers\Our.Umbraco.TagHelpers.csproj" /> | ||
<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> | ||
|
||
<PropertyGroup> | ||
<!-- Razor files are needed for the backoffice to work correctly --> | ||
<CopyRazorGenerateFilesToPublishDirectory>true</CopyRazorGenerateFilesToPublishDirectory> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<!-- Remove RazorCompileOnBuild and RazorCompileOnPublish when not using ModelsMode InMemoryAuto --> | ||
<RazorCompileOnBuild>false</RazorCompileOnBuild> | ||
<RazorCompileOnPublish>false</RazorCompileOnPublish> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace Our.Umbraco.TagHelpers.ExampleSite | ||
{ | ||
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
29
Our.Umbraco.TagHelpers.ExampleSite/Properties/launchSettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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:46843", | ||
"sslPort": 44370 | ||
} | ||
}, | ||
"profiles": { | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"Umbraco.Web.UI": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"applicationUrl": "https://localhost:44370;http://localhost:46843", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
namespace Our.Umbraco.TagHelpers.ExampleSite | ||
{ | ||
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(); | ||
}); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Our.Umbraco.TagHelpers.ExampleSite/Views/Partials/blocklist/default.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
106
Our.Umbraco.TagHelpers.ExampleSite/Views/Partials/grid/bootstrap3-fluid.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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="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?.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)); | ||
} | ||
} |
112 changes: 112 additions & 0 deletions
112
Our.Umbraco.TagHelpers.ExampleSite/Views/Partials/grid/bootstrap3.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
@using System.Web | ||
@using Microsoft.AspNetCore.Html | ||
@using Newtonsoft.Json.Linq | ||
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<dynamic> | ||
|
||
@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, true); | ||
} | ||
</div> | ||
} | ||
} | ||
else | ||
{ | ||
<div class="container"> | ||
<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, false); | ||
} | ||
</div> | ||
</div> | ||
} | ||
</div> | ||
</div> | ||
} | ||
</div> | ||
} | ||
|
||
@functions{ | ||
|
||
private async Task renderRow(dynamic row, bool singleColumn) | ||
{ | ||
<div @RenderElementAttributes(row)> | ||
@if (singleColumn) { | ||
@:<div class="container"> | ||
} | ||
<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?.editor?.view != null) | ||
{ | ||
<text>@await Html.PartialAsync("grid/editors/base", (object)control)</text> | ||
} | ||
} | ||
</div> | ||
</div> | ||
} | ||
</div> | ||
@if (singleColumn) { | ||
@:</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)); | ||
} | ||
} |
Oops, something went wrong.