Skip to content

Commit

Permalink
- end of episode 6 where we added the grid
Browse files Browse the repository at this point in the history
  • Loading branch information
prjseal committed Oct 10, 2019
1 parent eeb97c6 commit 0752146
Show file tree
Hide file tree
Showing 10 changed files with 499 additions and 44 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -8,3 +8,5 @@
/CleanBlog.Web/obj/Debug
/CleanBlog.Web/Umbraco
/packages
/CleanBlog.Core/bin/Debug
/CleanBlog.Core/obj/Debug
251 changes: 251 additions & 0 deletions CleanBlog.Core/CleanBlog.Core.csproj

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions CleanBlog.Core/Extensions/HtmlExtensions.cs
@@ -0,0 +1,22 @@
using System.Web;
using System.Web.Mvc;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Web;

namespace CleanBlog.Core.Extensions
{
public static class HtmlExtensions
{
public static IHtmlString GetGridHtml(this HtmlHelper html, IPublishedContent contentItem, string framework, string propertyAlias, bool fluidImages)
{
if (fluidImages)
{
return html.Raw(html.GetGridHtml(contentItem, framework, propertyAlias).ToString().Replace("<img ", "<img class=\"img-fluid\" "));
}
else
{
return html.GetGridHtml(contentItem, propertyAlias, framework);
}
}
}
}
36 changes: 36 additions & 0 deletions CleanBlog.Core/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("CleanBlog.Core")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CleanBlog.Core")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("e508ad0f-0e2a-4dde-b0e7-213ff9d8e78e")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
35 changes: 35 additions & 0 deletions CleanBlog.Core/app.config
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
57 changes: 57 additions & 0 deletions CleanBlog.Core/packages.config
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ClientDependency" version="1.9.7" targetFramework="net472" />
<package id="ClientDependency-Mvc5" version="1.8.0.0" targetFramework="net472" />
<package id="CSharpTest.Net.Collections" version="14.906.1403.1082" targetFramework="net472" />
<package id="Examine" version="1.0.0" targetFramework="net472" />
<package id="HtmlAgilityPack" version="1.8.14" targetFramework="net472" />
<package id="ImageProcessor" version="2.7.0.100" targetFramework="net472" />
<package id="LightInject" version="5.4.0" targetFramework="net472" />
<package id="LightInject.Annotation" version="1.1.0" targetFramework="net472" />
<package id="LightInject.Mvc" version="2.0.0" targetFramework="net472" />
<package id="LightInject.Web" version="2.0.0" targetFramework="net472" />
<package id="LightInject.WebApi" version="2.0.0" targetFramework="net472" />
<package id="Lucene.Net" version="3.0.3" targetFramework="net472" />
<package id="Markdown" version="2.2.1" targetFramework="net472" />
<package id="Microsoft.AspNet.Identity.Core" version="2.2.2" targetFramework="net472" />
<package id="Microsoft.AspNet.Identity.Owin" version="2.2.2" targetFramework="net472" />
<package id="Microsoft.AspNet.Mvc" version="5.2.7" targetFramework="net472" />
<package id="Microsoft.AspNet.Razor" version="3.2.7" targetFramework="net472" />
<package id="Microsoft.AspNet.SignalR.Core" version="2.4.0" targetFramework="net472" />
<package id="Microsoft.AspNet.WebApi" version="5.2.7" targetFramework="net472" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.7" targetFramework="net472" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.7" targetFramework="net472" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.7" targetFramework="net472" />
<package id="Microsoft.AspNet.WebPages" version="3.2.7" targetFramework="net472" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="2.0.0" targetFramework="net472" />
<package id="Microsoft.Owin" version="4.0.1" targetFramework="net472" />
<package id="Microsoft.Owin.Host.SystemWeb" version="4.0.1" targetFramework="net472" />
<package id="Microsoft.Owin.Security" version="4.0.1" targetFramework="net472" />
<package id="Microsoft.Owin.Security.Cookies" version="4.0.1" targetFramework="net472" />
<package id="Microsoft.Owin.Security.OAuth" version="4.0.1" targetFramework="net472" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net472" />
<package id="MiniProfiler" version="4.0.138" targetFramework="net472" />
<package id="MiniProfiler.Shared" version="4.0.138" targetFramework="net472" />
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net472" />
<package id="NPoco" version="3.9.4" targetFramework="net472" />
<package id="Owin" version="1.0" targetFramework="net472" />
<package id="Semver" version="2.0.4" targetFramework="net472" />
<package id="Serilog" version="2.8.0" targetFramework="net472" />
<package id="Serilog.Enrichers.Process" version="2.0.1" targetFramework="net472" />
<package id="Serilog.Enrichers.Thread" version="3.0.0" targetFramework="net472" />
<package id="Serilog.Filters.Expressions" version="2.0.0" targetFramework="net472" />
<package id="Serilog.Formatting.Compact" version="1.0.0" targetFramework="net472" />
<package id="Serilog.Formatting.Compact.Reader" version="1.0.3" targetFramework="net472" />
<package id="Serilog.Settings.AppSettings" version="2.2.2" targetFramework="net472" />
<package id="Serilog.Sinks.Async" version="1.3.0" targetFramework="net472" />
<package id="Serilog.Sinks.File" version="4.0.0" targetFramework="net472" />
<package id="Serilog.Sinks.Map" version="1.0.0" targetFramework="net472" />
<package id="SharpZipLib" version="0.86.0" targetFramework="net472" />
<package id="Superpower" version="2.0.0" targetFramework="net472" />
<package id="System.Diagnostics.DiagnosticSource" version="4.4.1" targetFramework="net472" />
<package id="System.Threading.Tasks.Dataflow" version="4.9.0" targetFramework="net472" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
<package id="Umbraco.SqlServerCE" version="4.0.0.1" targetFramework="net472" />
<package id="UmbracoCms.Core" version="8.1.4" targetFramework="net472" />
<package id="UmbracoCms.Web" version="8.1.4" targetFramework="net472" />
</packages>
6 changes: 6 additions & 0 deletions CleanBlog.Web.sln
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.28307.168
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CleanBlog.Web", "CleanBlog.Web\CleanBlog.Web.csproj", "{781623CE-C6E6-499E-A237-68B28B53CC0E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CleanBlog.Core", "CleanBlog.Core\CleanBlog.Core.csproj", "{E508AD0F-0E2A-4DDE-B0E7-213FF9D8E78E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,10 @@ Global
{781623CE-C6E6-499E-A237-68B28B53CC0E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{781623CE-C6E6-499E-A237-68B28B53CC0E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{781623CE-C6E6-499E-A237-68B28B53CC0E}.Release|Any CPU.Build.0 = Release|Any CPU
{E508AD0F-0E2A-4DDE-B0E7-213FF9D8E78E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E508AD0F-0E2A-4DDE-B0E7-213FF9D8E78E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E508AD0F-0E2A-4DDE-B0E7-213FF9D8E78E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E508AD0F-0E2A-4DDE-B0E7-213FF9D8E78E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
7 changes: 7 additions & 0 deletions CleanBlog.Web/CleanBlog.Web.csproj
Expand Up @@ -463,6 +463,7 @@
<Content Include="Views\contact.cshtml" />
<Content Include="Views\search.cshtml" />
<Content Include="Views\Partials\pageHeader.cshtml" />
<Content Include="Views\Partials\Grid\Clean.cshtml" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>
Expand All @@ -474,6 +475,12 @@
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.Analyzers.2.6.1\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.Analyzers.2.6.1\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CleanBlog.Core\CleanBlog.Core.csproj">
<Project>{e508ad0f-0e2a-4dde-b0e7-213ff9d8e78e}</Project>
<Name>CleanBlog.Core</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
Expand Down
80 changes: 80 additions & 0 deletions CleanBlog.Web/Views/Partials/Grid/Clean.cshtml
@@ -0,0 +1,80 @@
@inherits UmbracoViewPage<dynamic>
@using Umbraco.Web.Templates
@using Newtonsoft.Json.Linq

@if (Model != null && Model.sections != null)
{
<div class="umb-grid">
@foreach (var section in Model.sections)
{
<div class="container">
<div class="row">
<div class="col-lg-8 col-md-10 mx-auto">
<div class="grid-section">
@foreach (var row in section.rows)
{
@renderRow(row);
}
</div>
</div>
</div>
</div>
}
</div>
}

@helper 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>@Html.Partial("grid/editors/base", (object)control)</text>
}
}
</div>
</div>}
</div>
</div>
}

@functions {
public static MvcHtmlString 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 MvcHtmlString(string.Join(" ", attrs));
}
}
47 changes: 3 additions & 44 deletions CleanBlog.Web/Views/content.cshtml
@@ -1,5 +1,7 @@
@inherits Umbraco.Web.Mvc.UmbracoViewPage<Umbraco.Web.PublishedModels.Content>

@using CleanBlog.Core.Extensions

@{
Layout = "master.cshtml";
}
Expand All @@ -8,48 +10,5 @@

<!-- Post Content -->
<article>
<div class="container">
<div class="row">
<div class="col-lg-8 col-md-10 mx-auto">
<p>Never in all their history have men been able truly to conceive of the world as one: a single sphere, a globe, having the qualities of a globe, a round earth in which all the directions eventually meet, in which there is no center because every point, or none, is center — an equal earth which all men occupy as equals. The airman's earth, if free men make it, will be truly round: a globe in practice, not in theory.</p>

<p>Science cuts two ways, of course; its products can be used for both good and evil. But there's no turning back from science. The early warnings about technological dangers also come from science.</p>

<p>What was most significant about the lunar voyage was not that man set foot on the Moon but that they set eye on the earth.</p>

<p>A Chinese tale tells of some men sent to harm a young girl who, upon seeing her beauty, become her protectors rather than her violators. That's how I felt seeing the Earth for the first time. I could not help but love and cherish her.</p>

<p>For those who have seen the Earth from space, and for the hundreds and perhaps thousands more who will, the experience most certainly changes your perspective. The things that we share in our world are far more valuable than those which divide us.</p>

<h2 class="section-heading">The Final Frontier</h2>

<p>There can be no thought of finishing for ‘aiming for the stars.’ Both figuratively and literally, it is a task to occupy the generations. And no matter how much progress one makes, there is always the thrill of just beginning.</p>

<p>There can be no thought of finishing for ‘aiming for the stars.’ Both figuratively and literally, it is a task to occupy the generations. And no matter how much progress one makes, there is always the thrill of just beginning.</p>

<blockquote class="blockquote">The dreams of yesterday are the hopes of today and the reality of tomorrow. Science has not yet mastered prophecy. We predict too much for the next year and yet far too little for the next ten.</blockquote>

<p>Spaceflights cannot be stopped. This is not the work of any one man or even a group of men. It is a historical process which mankind is carrying out in accordance with the natural laws of human development.</p>

<h2 class="section-heading">Reaching for the Stars</h2>

<p>As we got further and further away, it [the Earth] diminished in size. Finally it shrank to the size of a marble, the most beautiful you can imagine. That beautiful, warm, living object looked so fragile, so delicate, that if you touched it with a finger it would crumble and fall apart. Seeing this has to change a man.</p>

<a href="#">
<img class="img-fluid" src="/img/post-sample-image.jpg" alt="">
</a>
<span class="caption text-muted">To go places and do things that have never been done before – that’s what living is all about.</span>

<p>Space, the final frontier. These are the voyages of the Starship Enterprise. Its five-year mission: to explore strange new worlds, to seek out new life and new civilizations, to boldly go where no man has gone before.</p>

<p>As I stand out here in the wonders of the unknown at Hadley, I sort of realize there’s a fundamental truth to our nature, Man must explore, and this is exploration at its greatest.</p>

<p>
Placeholder text by
<a href="http://spaceipsum.com/">Space Ipsum</a>. Photographs by
<a href="https://www.flickr.com/photos/nasacommons/">NASA on The Commons</a>.
</p>
</div>
</div>
</div>
@Html.GetGridHtml(Model, "mainContent","Clean", true)
</article>

0 comments on commit 0752146

Please sign in to comment.