Skip to content

Commit a7873eb

Browse files
author
Rick Butterfield
committed
First pass at a working v14 setup
1 parent 73ad84f commit a7873eb

File tree

73 files changed

+7178
-68
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+7178
-68
lines changed

src/Umbraco.Community.Sustainability.TestSite.14.x/.gitignore

Lines changed: 482 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();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
<PropertyGroup>
3+
<TargetFramework>net8.0</TargetFramework>
4+
<ImplicitUsings>enable</ImplicitUsings>
5+
<Nullable>enable</Nullable>
6+
<RootNamespace>Umbraco.Community.Sustainability.TestSite._14.x</RootNamespace>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Umbraco.Cms" Version="14.0.0--preview004" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<!-- Opt-in to app-local ICU to ensure consistent globalization APIs across different platforms -->
15+
<PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="72.1.0.3" />
16+
<RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="72.1.0.3" Condition="$(RuntimeIdentifier.StartsWith('linux')) or $(RuntimeIdentifier.StartsWith('win')) or ('$(RuntimeIdentifier)' == '' and !$([MSBuild]::IsOSPlatform('osx')))" />
17+
</ItemGroup>
18+
19+
<PropertyGroup>
20+
<!-- Razor files are needed for the backoffice to work correctly -->
21+
<CopyRazorGenerateFilesToPublishDirectory>true</CopyRazorGenerateFilesToPublishDirectory>
22+
</PropertyGroup>
23+
24+
<PropertyGroup>
25+
<!-- Remove RazorCompileOnBuild and RazorCompileOnPublish when not using ModelsMode InMemoryAuto -->
26+
<RazorCompileOnBuild>false</RazorCompileOnBuild>
27+
<RazorCompileOnPublish>false</RazorCompileOnPublish>
28+
</PropertyGroup>
29+
30+
<ItemGroup>
31+
<ProjectReference Include="..\Umbraco.Community.Sustainability\Umbraco.Community.Sustainability.csproj" />
32+
</ItemGroup>
33+
34+
</Project>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@using ContentModels = Umbraco.Cms.Web.Common.PublishedModels
2+
3+
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.Blog>
4+
5+
@{
6+
Layout = "master.cshtml";
7+
}
8+
@Html.Partial("~/Views/Partials/SectionHeader.cshtml")
9+
10+
<section class="section">
11+
12+
<div class="container">
13+
@await Umbraco.RenderMacroAsync("latestBlogposts",
14+
new
15+
{
16+
numberOfPosts = Model.HowManyPostsShouldBeShown,
17+
startNodeId = Model.Id
18+
})
19+
</div>
20+
21+
</section>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@using ContentModels = Umbraco.Cms.Web.Common.PublishedModels
2+
@using Microsoft.AspNetCore.Mvc.Rendering
3+
@using Umbraco.Extensions
4+
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.Blogpost>
5+
@{
6+
Layout = "master.cshtml";
7+
}
8+
@Html.Partial("~/Views/Partials/SectionHeader.cshtml")
9+
10+
<section class="section">
11+
<div class="container">
12+
<article>
13+
<div class="blogpost-meta">
14+
<small class="blogpost-date">@Model.CreateDate.ToShortDateString()</small>
15+
<span class="blogpost-cat">
16+
@Html.Partial("~/Views/Partials/CategoryLinks.cshtml", Model.Categories)
17+
</span>
18+
</div>
19+
<h3>@Model.Excerpt</h3>
20+
@await Html.GetBlockGridHtmlAsync(Model, "bodyText")
21+
<!-- todo: implement discus comments -->
22+
</article>
23+
</div>
24+
</section>
25+
26+
<link rel="stylesheet" href="@Url.Content("~/css/umbraco-starterkit-blockgrid.css")" />
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
@using Umbraco.Cms.Core.Models.PublishedContent
2+
@using Umbraco.Cms.Core.Routing
3+
@using Umbraco.Cms.Web.Common
4+
@using Umbraco.Extensions
5+
@inherits Umbraco.Cms.Web.Common.Macros.PartialViewMacroPage
6+
@inject UmbracoHelper Umbraco
7+
@inject IPublishedValueFallback PublishedValueFallback
8+
@inject IPublishedUrlProvider PublishedUrlProvider
9+
@*
10+
This snippet lists the items from a Multinode tree picker, using the pickers default settings.
11+
Content Values stored as xml.
12+
13+
To get it working with any site's data structure, set the selection equal to the property which has the
14+
multinode treepicker (so: replace "PropertyWithPicker" with the alias of your property).
15+
*@
16+
17+
@{ var selection = Model.Content.Value<IEnumerable<IPublishedContent>>(PublishedValueFallback, "PropertyWithPicker").ToArray(); }
18+
19+
<ul>
20+
@foreach (var id in selection)
21+
{
22+
var item = Umbraco.Content(id);
23+
<li>
24+
<a href="@item.Url(PublishedUrlProvider)">@item.Name</a>
25+
</li>
26+
}
27+
</ul>
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
@using Microsoft.AspNetCore.Http
2+
@using ContentModels = Umbraco.Cms.Web.Common.PublishedModels
3+
@using Microsoft.AspNetCore.Mvc.Rendering
4+
@using Umbraco.Cms.Core.Routing
5+
@using Umbraco.Cms.Web.Common
6+
@inherits Umbraco.Cms.Web.Common.Macros.PartialViewMacroPage
7+
@inject UmbracoHelper Umbraco
8+
@inject IPublishedUrlProvider PublishedUrlProvider
9+
@inject IHttpContextAccessor HttpContextAccessor
10+
@{
11+
var startNodeId = Model.MacroParameters["startNodeId"] ?? Model.Content.Id;
12+
13+
var numberOfPosts = 3;
14+
if (Model.MacroParameters["numberOfPosts"] != null)
15+
{
16+
int.TryParse((string)Model.MacroParameters["numberOfPosts"], out numberOfPosts);
17+
}
18+
}
19+
20+
@if (startNodeId != null)
21+
{
22+
@* Get the starting page *@
23+
var startNode = Umbraco.Content(startNodeId);
24+
25+
if (startNode == null)
26+
{
27+
<div class="blogposts">
28+
<h1>There are no posts at this time, try again later.</h1>
29+
</div>
30+
31+
return;
32+
}
33+
34+
var httpContext = HttpContextAccessor.HttpContext;
35+
36+
//Gets all blogposts to calculate pages
37+
var blogposts = startNode.Children.OrderBy(x => x.CreateDate).ToList();
38+
var pageCount = (int)Math.Ceiling((double)blogposts.Count / (double)numberOfPosts);
39+
//gets the page from the querystring and sets it to one if it is out of range
40+
var page = 1;
41+
if (httpContext != null && !string.IsNullOrEmpty(httpContext.Request.Query["page"]))
42+
{
43+
int.TryParse(httpContext.Request.Query["page"], out page);
44+
if (page <= 0 || page > pageCount)
45+
{
46+
page = 1;
47+
}
48+
}
49+
//Gets the blogposts for the current page
50+
var pagedBlogposts = blogposts.Skip((page - 1) * numberOfPosts).Take(numberOfPosts).ToList();
51+
52+
if (pagedBlogposts.Count > 0)
53+
{
54+
<div class="blogposts">
55+
56+
@foreach (ContentModels.Blogpost post in pagedBlogposts)
57+
{
58+
<a href="@post.Url(PublishedUrlProvider)" class="blogpost">
59+
<div class="blogpost-meta">
60+
<small class="blogpost-date">@post.CreateDate.ToShortDateString()</small>
61+
<small class="blogpost-cat">
62+
@await Html.PartialAsync("~/Views/Partials/CategoryLinks.cshtml", post.Categories)
63+
</small>
64+
</div>
65+
<h3 class="blogpost-title">@post.PageTitle</h3>
66+
<div class="blogpost-excerpt">@post.Excerpt</div>
67+
</a>
68+
}
69+
</div>
70+
}
71+
72+
if (blogposts.Count > numberOfPosts)
73+
{
74+
<div class="pagination">
75+
<nav class="nav-bar nav-bar--center">
76+
@if (page <= 1)
77+
{
78+
<span class="nav-link nav-link--black nav-link--disabled">Prev</span>
79+
}
80+
else
81+
{
82+
<a class="nav-link nav-link--black" href="@(Model.Content.Url(PublishedUrlProvider) + "?page=" + (page - 1))">Prev</a>
83+
}
84+
85+
@for (int i = 1; i <= pageCount; i++)
86+
{
87+
<a class="nav-link nav-link--black @(page == i ? " nav-link--active" : null)" href="@(Model.Content.Url(PublishedUrlProvider) + "?page=" + i)">@i</a>
88+
}
89+
@if (page == pageCount)
90+
{
91+
<span class="nav-link nav-link--black nav-link--disabled">Next</span>
92+
}
93+
else
94+
{
95+
<a class="nav-link nav-link--black" href="@(Model.Content.Url(PublishedUrlProvider) + "?page=" + (page + 1))">Next</a>
96+
}
97+
98+
</nav>
99+
</div>
100+
}
101+
}
102+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@model IEnumerable<string>
2+
@foreach (var category in Model)
3+
{
4+
<!-- TODO: Add links to categories-->
5+
@category
6+
<text> </text>
7+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
@using Umbraco.Extensions
2+
@using Umbraco.SampleSite.Controllers
3+
@model Umbraco.SampleSite.Models.ContactFormViewModel
4+
5+
@{
6+
var message = TempData["Message"]?.ToString();
7+
}
8+
<div class="form-group">
9+
@using (Html.BeginUmbracoForm<ContactFormController>(nameof(ContactFormController.Submit)))
10+
{
11+
<div>
12+
@Html.TextBoxFor(m => m.Name, new {@class="form-control", placeholder = Html.DisplayNameFor(m => m.Name)})
13+
@Html.ValidationMessageFor(m => m.Name)
14+
</div>
15+
<div>
16+
@Html.TextBoxFor(m => m.Email, new {@class="form-control", placeholder = Html.DisplayNameFor(m => m.Email)})
17+
@Html.ValidationMessageFor(m => m.Email)
18+
</div>
19+
<div>
20+
@Html.TextAreaFor(m => m.Message, new {@class="form-control", placeholder = Html.DisplayNameFor(m => m.Message)})
21+
@Html.ValidationMessageFor(m => m.Message)
22+
</div>
23+
<input type="submit" name="Submit" value="Submit"/>
24+
@if (!string.IsNullOrEmpty(message))
25+
{
26+
@message
27+
}
28+
}
29+
</div>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
2+
@using Umbraco.Cms.Core.Models.PublishedContent
3+
@using Umbraco.Cms.Core.Routing
4+
@using Umbraco.Extensions
5+
6+
@inject IPublishedValueFallback PublishedValueFallback
7+
@inject IPublishedUrlProvider PublishedUrlProvider
8+
@{
9+
var siteSection = Model.AncestorOrSelf(2);
10+
var selection = siteSection.Children.Where(x => x.IsVisible(PublishedValueFallback));
11+
}
12+
13+
@foreach (var item in selection)
14+
{
15+
<a class="nav-link nav-link--black nav-link--air-bottom @(item.IsAncestorOrSelf(Model) ? "nav-link--active" : null)" href="@item.Url(PublishedUrlProvider)">@item.Name</a>
16+
}

0 commit comments

Comments
 (0)