From 36e1c012d4d3e718afc464bac3e8e82b65fa89dc Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Fri, 5 Feb 2021 16:31:14 +0100 Subject: [PATCH] lowercasing files --- .../Extensions/GridTemplateExtensions.cs | 16 +-- .../Partials/grid/bootstrap3-fluid.cshtml | 92 +++++++++++++++++ .../Views/Partials/grid/bootstrap3.cshtml | 99 +++++++++++++++++++ .../Views/Partials/grid/editors/base.cshtml | 23 +++++ .../Views/Partials/grid/editors/embed.cshtml | 11 +++ .../Views/Partials/grid/editors/macro.cshtml | 17 ++++ .../Views/Partials/grid/editors/rte.cshtml | 13 +++ .../Partials/grid/editors/textstring.cshtml | 23 +++++ 8 files changed, 286 insertions(+), 8 deletions(-) create mode 100644 src/Umbraco.Web.UI.NetCore/Views/Partials/grid/bootstrap3-fluid.cshtml create mode 100644 src/Umbraco.Web.UI.NetCore/Views/Partials/grid/bootstrap3.cshtml create mode 100644 src/Umbraco.Web.UI.NetCore/Views/Partials/grid/editors/base.cshtml create mode 100644 src/Umbraco.Web.UI.NetCore/Views/Partials/grid/editors/embed.cshtml create mode 100644 src/Umbraco.Web.UI.NetCore/Views/Partials/grid/editors/macro.cshtml create mode 100644 src/Umbraco.Web.UI.NetCore/Views/Partials/grid/editors/rte.cshtml create mode 100644 src/Umbraco.Web.UI.NetCore/Views/Partials/grid/editors/textstring.cshtml diff --git a/src/Umbraco.Web.Common/Extensions/GridTemplateExtensions.cs b/src/Umbraco.Web.Common/Extensions/GridTemplateExtensions.cs index b60c93cb68..e4a1c0d117 100644 --- a/src/Umbraco.Web.Common/Extensions/GridTemplateExtensions.cs +++ b/src/Umbraco.Web.Common/Extensions/GridTemplateExtensions.cs @@ -7,7 +7,7 @@ namespace Umbraco.Extensions { public static class GridTemplateExtensions { - public static IHtmlContent GetGridHtml(this IHtmlHelper html, IPublishedProperty property, string framework = "Bootstrap3") + public static IHtmlContent GetGridHtml(this IHtmlHelper html, IPublishedProperty property, string framework = "bootstrap3") { var asString = property.GetValue() as string; if (asString != null && string.IsNullOrEmpty(asString)) return new HtmlString(string.Empty); @@ -18,7 +18,7 @@ namespace Umbraco.Extensions public static IHtmlContent GetGridHtml(this IHtmlHelper html, IPublishedContent contentItem) { - return html.GetGridHtml(contentItem, "bodyText", "Bootstrap3"); + return html.GetGridHtml(contentItem, "bodyText", "bootstrap3"); } public static IHtmlContent GetGridHtml(this IHtmlHelper html, IPublishedContent contentItem, string propertyAlias) @@ -26,7 +26,7 @@ namespace Umbraco.Extensions if (propertyAlias == null) throw new ArgumentNullException(nameof(propertyAlias)); if (string.IsNullOrWhiteSpace(propertyAlias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(propertyAlias)); - return html.GetGridHtml(contentItem, propertyAlias, "Bootstrap3"); + return html.GetGridHtml(contentItem, propertyAlias, "bootstrap3"); } public static IHtmlContent GetGridHtml(this IHtmlHelper html, IPublishedContent contentItem, string propertyAlias, string framework) @@ -47,7 +47,7 @@ namespace Umbraco.Extensions public static IHtmlContent GetGridHtml(this IHtmlHelper html, IPublishedElement contentItem) { - return html.GetGridHtml(contentItem, "bodyText", "Bootstrap3"); + return html.GetGridHtml(contentItem, "bodyText", "bootstrap3"); } public static IHtmlContent GetGridHtml(this IHtmlHelper html, IPublishedElement contentItem, string propertyAlias) @@ -55,7 +55,7 @@ namespace Umbraco.Extensions if (propertyAlias == null) throw new ArgumentNullException(nameof(propertyAlias)); if (string.IsNullOrWhiteSpace(propertyAlias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(propertyAlias)); - return html.GetGridHtml(contentItem, propertyAlias, "Bootstrap3"); + return html.GetGridHtml(contentItem, propertyAlias, "bootstrap3"); } public static IHtmlContent GetGridHtml(this IHtmlHelper html, IPublishedElement contentItem, string propertyAlias, string framework) @@ -73,7 +73,7 @@ namespace Umbraco.Extensions return html.Partial(view, model); } - public static IHtmlContent GetGridHtml(this IPublishedProperty property, IHtmlHelper html, string framework = "Bootstrap3") + public static IHtmlContent GetGridHtml(this IPublishedProperty property, IHtmlHelper html, string framework = "bootstrap3") { var asString = property.GetValue() as string; if (asString != null && string.IsNullOrEmpty(asString)) return new HtmlString(string.Empty); @@ -84,7 +84,7 @@ namespace Umbraco.Extensions public static IHtmlContent GetGridHtml(this IPublishedContent contentItem, IHtmlHelper html) { - return GetGridHtml(contentItem, html, "bodyText", "Bootstrap3"); + return GetGridHtml(contentItem, html, "bodyText", "bootstrap3"); } public static IHtmlContent GetGridHtml(this IPublishedContent contentItem, IHtmlHelper html, string propertyAlias) @@ -92,7 +92,7 @@ namespace Umbraco.Extensions if (propertyAlias == null) throw new ArgumentNullException(nameof(propertyAlias)); if (string.IsNullOrWhiteSpace(propertyAlias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(propertyAlias)); - return GetGridHtml(contentItem, html, propertyAlias, "Bootstrap3"); + return GetGridHtml(contentItem, html, propertyAlias, "bootstrap3"); } public static IHtmlContent GetGridHtml(this IPublishedContent contentItem, IHtmlHelper html, string propertyAlias, string framework) diff --git a/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/bootstrap3-fluid.cshtml b/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/bootstrap3-fluid.cshtml new file mode 100644 index 0000000000..cfbf3e4a1c --- /dev/null +++ b/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/bootstrap3-fluid.cshtml @@ -0,0 +1,92 @@ +@using System.Web +@using Microsoft.AspNetCore.Html +@using Newtonsoft.Json.Linq +@inherits Umbraco.Web.Common.AspNetCore.UmbracoViewPage + +@* + Razor helpers located at the bottom of this file +*@ + +@if (Model != null && Model.sections != null) +{ + var oneColumn = ((System.Collections.ICollection)Model.sections).Count == 1; + +
+ @if (oneColumn) + { + foreach (var section in Model.sections) { +
+ @foreach (var row in section.rows) { + renderRow(row) + } +
+ } + }else { +
+ @foreach (var s in Model.sections) { +
+
+ @foreach (var row in s.rows) { + renderRow(row) + } +
+
+ } +
+ } +
+} + +@functions { + private void renderRow(dynamic row) + { +
+
+ @foreach ( var area in row.areas ) { +
+
+ @foreach (var control in area.controls) { + if (control !=null && control.editor != null && control.editor.view != null ) { + @Html.Partial("grid/editors/base", (object)control) + } + } +
+
} +
+
+ } +} + +@functions { + public static HtmlString RenderElementAttributes(dynamic contentItem) + { + var attrs = new List(); + 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(); + 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)); + } +} diff --git a/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/bootstrap3.cshtml b/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/bootstrap3.cshtml new file mode 100644 index 0000000000..7e48dd1ae3 --- /dev/null +++ b/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/bootstrap3.cshtml @@ -0,0 +1,99 @@ +@using System.Web +@using Microsoft.AspNetCore.Html +@using Newtonsoft.Json.Linq +@inherits Umbraco.Web.Common.AspNetCore.UmbracoViewPage + +@if (Model != null && Model.sections != null) +{ + var oneColumn = ((System.Collections.ICollection)Model.sections).Count == 1; + +
+ @if (oneColumn) + { + foreach (var section in Model.sections) { +
+ @foreach (var row in section.rows) { + renderRow(row, true) + } +
+ } + }else { +
+
+ @foreach (var s in Model.sections) { +
+
+ @foreach (var row in s.rows) { + renderRow(row, false) + } +
+
+ } +
+
+ } +
+} + +@functions { + + private void renderRow(dynamic row, bool singleColumn) + { +
+ @if (singleColumn) { + @:
+ } +
+ @foreach ( var area in row.areas ) { +
+
+ @foreach (var control in area.controls) { + if (control !=null && control.editor != null && control.editor.view != null ) { + @Html.Partial("grid/editors/base", (object)control) + } + } +
+
} +
+ @if (singleColumn) { + @:
+ } +
+ } + +} + + +@functions { + public static HtmlString RenderElementAttributes(dynamic contentItem) + { + var attrs = new List(); + 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(); + 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)); + } +} diff --git a/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/editors/base.cshtml b/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/editors/base.cshtml new file mode 100644 index 0000000000..d3cdf80f06 --- /dev/null +++ b/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/editors/base.cshtml @@ -0,0 +1,23 @@ +@model dynamic + +@functions { + public static string EditorView(dynamic contentItem) + { + string view = contentItem.editor.render != null ? contentItem.editor.render.ToString() : contentItem.editor.view.ToString(); + view = view.ToLower().Replace(".html", ".cshtml"); + + if (!view.Contains("/")) { + view = "grid/editors/" + view; + } + + return view; + } +} +@try +{ + string editor = EditorView(Model); + @Html.Partial(editor, (object)Model) +} +catch (Exception ex) { +
@ex.ToString()
+} diff --git a/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/editors/embed.cshtml b/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/editors/embed.cshtml new file mode 100644 index 0000000000..250310217c --- /dev/null +++ b/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/editors/embed.cshtml @@ -0,0 +1,11 @@ +@using Umbraco.Core +@model dynamic + +@{ + string embedValue = Convert.ToString(Model.value); + embedValue = embedValue.DetectIsJson() ? Model.value.preview : Model.value; +} + +
+ @Html.Raw(embedValue) +
diff --git a/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/editors/macro.cshtml b/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/editors/macro.cshtml new file mode 100644 index 0000000000..32d08ad5a5 --- /dev/null +++ b/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/editors/macro.cshtml @@ -0,0 +1,17 @@ +@using Umbraco.Web.Website +@inherits Umbraco.Web.Common.AspNetCore.UmbracoViewPage +@inject UmbracoHelper Umbraco; + +@if (Model.value != null) +{ + string macroAlias = Model.value.macroAlias.ToString(); + var parameters = new Dictionary(); + foreach (var mpd in Model.value.macroParamsDictionary) + { + parameters.Add(mpd.Name, mpd.Value); + } + + + @Umbraco.RenderMacro(macroAlias, parameters) + +} diff --git a/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/editors/rte.cshtml b/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/editors/rte.cshtml new file mode 100644 index 0000000000..76b665af46 --- /dev/null +++ b/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/editors/rte.cshtml @@ -0,0 +1,13 @@ +@using Umbraco.Web.Templates +@model dynamic +@inject HtmlLocalLinkParser HtmlLocalLinkParser; +@inject HtmlUrlParser HtmlUrlParser; +@inject HtmlImageSourceParser HtmlImageSourceParser; + +@{ + + var value = HtmlLocalLinkParser.EnsureInternalLinks(Model.value.ToString()); + value = HtmlUrlParser.EnsureUrls(value); + value = HtmlImageSourceParser.EnsureImageSources(value); +} +@Html.Raw(value) diff --git a/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/editors/textstring.cshtml b/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/editors/textstring.cshtml new file mode 100644 index 0000000000..77d92d6825 --- /dev/null +++ b/src/Umbraco.Web.UI.NetCore/Views/Partials/grid/editors/textstring.cshtml @@ -0,0 +1,23 @@ +@using System.Web +@model dynamic + +@if (Model.editor.config.markup != null) +{ + string markup = Model.editor.config.markup.ToString(); + markup = markup.Replace("#value#", Html.ReplaceLineBreaks(HttpUtility.HtmlEncode((string)Model.value.ToString())).ToString()); + + if (Model.editor.config.style != null) + { + markup = markup.Replace("#style#", Model.editor.config.style.ToString()); + } + + + @Html.Raw(markup) + +} +else +{ + +
@Model.value
+
+}