Migrated partial views (#9420)

Signed-off-by: Bjarke Berg <mail@bergmania.dk>
This commit is contained in:
Bjarke Berg
2020-11-24 09:05:16 +01:00
committed by GitHub
parent ebe643e30b
commit 4a7f6d3cc1
12 changed files with 108 additions and 112 deletions

View File

@@ -1,13 +1,13 @@
@inherits UmbracoViewPage<BlockListModel>
@using Umbraco.Core.Models.Blocks
@{
if (!Model.Any()) { return; }
}
<div class="umb-block-list">
@foreach (var block in Model)
{
if (block?.ContentUdi == null) { continue; }
var data = block.Content;
@Html.Partial("BlockList/Components/" + data.ContentType.Alias, block)
}
</div>
@inherits Umbraco.Web.Common.AspNetCore.UmbracoViewPage<BlockListModel>
@using Umbraco.Core.Models.Blocks
@{
if (!Model.Any()) { return; }
}
<div class="umb-block-list">
@foreach (var block in Model)
{
if (block?.ContentUdi == null) { continue; }
var data = block.Content;
@Html.Partial("BlockList/Components/" + data.ContentType.Alias, block)
}
</div>

View File

@@ -1,5 +1,6 @@
@inherits UmbracoViewPage<dynamic>
@using Umbraco.Web.Templates
@inherits Umbraco.Web.Common.AspNetCore.UmbracoViewPage<dynamic>
@using System.Web
@using Microsoft.AspNetCore.Html
@using Newtonsoft.Json.Linq
@*
@@ -36,25 +37,28 @@
</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>}
@functions {
private void 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>
</div>
}
}
@functions {
public static MvcHtmlString RenderElementAttributes(dynamic contentItem)
public static HtmlString RenderElementAttributes(dynamic contentItem)
{
var attrs = new List<string>();
JObject cfg = contentItem.config;
@@ -83,6 +87,6 @@
attrs.Add("style='" + HttpUtility.HtmlAttributeEncode(string.Join(" ", cssVals)) + "'");
}
return new MvcHtmlString(string.Join(" ", attrs));
return new HtmlString(string.Join(" ", attrs));
}
}

View File

@@ -1,5 +1,6 @@
@inherits UmbracoViewPage<dynamic>
@using Umbraco.Web.Templates
@inherits Umbraco.Web.Common.AspNetCore.UmbracoViewPage<dynamic>
@using System.Web
@using Microsoft.AspNetCore.Html
@using Newtonsoft.Json.Linq
@if (Model != null && Model.sections != null)
@@ -34,31 +35,37 @@
</div>
}
@helper 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 !=null && control.editor != null && control.editor.view != null ) {
<text>@Html.Partial("grid/editors/base", (object)control)</text>
}
}
</div>
</div>}
@functions {
private void 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 !=null && control.editor != null && control.editor.view != null ) {
<text>@Html.Partial("grid/editors/base", (object)control)</text>
}
}
</div>
</div>}
</div>
@if (singleColumn) {
@:</div>
}
</div>
@if (singleColumn) {
@:</div>
}
</div>
}
}
@functions {
public static MvcHtmlString RenderElementAttributes(dynamic contentItem)
public static HtmlString RenderElementAttributes(dynamic contentItem)
{
var attrs = new List<string>();
JObject cfg = contentItem.config;
@@ -87,6 +94,6 @@
attrs.Add("style=\"" + HttpUtility.HtmlAttributeEncode(string.Join(" ", cssVals)) + "\"");
}
return new MvcHtmlString(string.Join(" ", attrs));
return new HtmlString(string.Join(" ", attrs));
}
}

View File

@@ -1,12 +1,11 @@
@model dynamic
@using Umbraco.Web.Templates
@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;
}
@@ -16,9 +15,9 @@
}
@try
{
string editor = EditorView(Model);
string editor = EditorView(Model);
<text>@Html.Partial(editor, (object)Model)</text>
}
catch (Exception ex) {
catch (Exception ex) {
<pre>@ex.ToString()</pre>
}
}

View File

@@ -1,5 +1,6 @@
@model dynamic
@using Umbraco.Web.Templates
@using Umbraco.Core
@model dynamic
@{
string embedValue = Convert.ToString(Model.value);
embedValue = embedValue.DetectIsJson() ? Model.value.preview : Model.value;

View File

@@ -0,0 +1,17 @@
@inherits Umbraco.Web.Common.AspNetCore.UmbracoViewPage<dynamic>
@using Umbraco.Web.Website
@inject UmbracoHelper Umbraco;
@if (Model.value != null)
{
string macroAlias = Model.value.macroAlias.ToString();
var parameters = new Dictionary<string,object>();
foreach (var mpd in Model.value.macroParamsDictionary)
{
parameters.Add(mpd.Name, mpd.Value);
}
<text>
@Umbraco.RenderMacro(macroAlias, parameters)
</text>
}

View File

@@ -0,0 +1,13 @@
@model dynamic
@using Umbraco.Web.Templates
@inject HtmlLocalLinkParser HtmlLocalLinkParser;
@inject HtmlUrlParser HtmlUrlParser;
@inject HtmlImageSourceParser HtmlImageSourceParser;
@{
var value = HtmlUrlParser.EnsureUrls(Model.value.ToString());
value = HtmlImageSourceParser.EnsureImageSources(value);
value = HtmlLocalLinkParser.EnsureInternalLinks(value);
}
@Html.Raw(value)

View File

@@ -1,6 +1,6 @@
@model dynamic
@using Umbraco.Web.Composing
@using Umbraco.Web.Templates
@using System.Web
@using Umbraco.Extensions
@model dynamic
@if (Model.editor.config.markup != null)
{

View File

@@ -200,14 +200,6 @@
<Content Include="Web.config">
<SubType>Designer</SubType>
</Content>
<Content Include="Views\Partials\Grid\Bootstrap3.cshtml" />
<Content Include="Views\Partials\Grid\Editors\Embed.cshtml" />
<Content Include="Views\Partials\Grid\Editors\Macro.cshtml" />
<Content Include="Views\Partials\Grid\Editors\Rte.cshtml" />
<Content Include="Views\Partials\Grid\Editors\Textstring.cshtml" />
<Content Include="Views\Partials\Grid\Editors\Base.cshtml" />
<Content Include="Views\Partials\Grid\Bootstrap3-Fluid.cshtml" />
<Content Include="Views\Partials\BlockList\Default.cshtml" />
<None Include="web.Template.Debug.config">
<DependentUpon>Web.Template.config</DependentUpon>
<SubType>Designer</SubType>

View File

@@ -1,17 +0,0 @@
@inherits UmbracoViewPage<dynamic>
@using Umbraco.Web.Templates
@if (Model.value != null)
{
string macroAlias = Model.value.macroAlias.ToString();
ViewDataDictionary parameters = new ViewDataDictionary();
foreach (dynamic mpd in Model.value.macroParamsDictionary)
{
parameters.Add(mpd.Name, mpd.Value);
}
<text>
@Umbraco.RenderMacro(macroAlias, parameters)
</text>
}

View File

@@ -1,20 +0,0 @@
@model dynamic
@using Umbraco.Web.Composing
@using Umbraco.Web.Templates
@*
TODO: When this project is asp.net core we can @inject HtmlLocalLinkParser etc (or come up with something even better)
*@
@using Microsoft.Extensions.DependencyInjection
@{
var htmlLocalLinkParser = Current.Factory.GetRequiredService<HtmlLocalLinkParser>();
var htmlUrlParser = Current.Factory.GetRequiredService<HtmlUrlParser>();
var htmlImageSourceParser = Current.Factory.GetRequiredService<HtmlImageSourceParser>();
var value = htmlUrlParser.EnsureUrls(Model.value.ToString());
value = htmlImageSourceParser.EnsureImageSources(value);
value = htmlLocalLinkParser.EnsureInternalLinks(value);
}
@Html.Raw(value)

View File

@@ -893,7 +893,7 @@ namespace Umbraco.Extensions
/// <returns>
/// The HTML encoded text with text line breaks replaced with HTML line breaks (<c>&lt;br /&gt;</c>).
/// </returns>
public static IHtmlContent ReplaceLineBreaks(this HtmlHelper helper, string text)
public static IHtmlContent ReplaceLineBreaks(this IHtmlHelper helper, string text)
{
return StringUtilities.ReplaceLineBreaks(text);
}
@@ -905,7 +905,7 @@ namespace Umbraco.Extensions
/// <param name="helper"></param>
/// <param name="text">The text to create a hash from</param>
/// <returns>Hash of the text string</returns>
public static string CreateHash(this HtmlHelper helper, string text)
public static string CreateHash(this IHtmlHelper helper, string text)
{
return text.GenerateHash();
}