From 3e2fa6482009e6fa87d34b074779c71d5be786bc Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 14 Mar 2018 13:56:49 +1100 Subject: [PATCH] Changes the Preview Index.cshtml to use a real model instead of viewdata, adds the correct razor web.config for these preview views, changes the enabled feature to be able to inject a razor view instead of strings --- src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 1 + .../Umbraco/Views/Preview/Index.cshtml | 13 +++++-------- src/Umbraco.Web/Editors/PreviewController.cs | 17 ++++++++++++++--- src/Umbraco.Web/Features/DisabledFeatures.cs | 2 +- src/Umbraco.Web/Features/EnabledFeatures.cs | 7 +++++-- src/Umbraco.Web/Features/UmbracoFeatures.cs | 1 + .../Models/ContentEditing/AuditLog.cs | 3 ++- .../Models/ContentEditing/BackOfficePreview.cs | 11 +++++++++++ src/Umbraco.Web/Umbraco.Web.csproj | 1 + 9 files changed, 41 insertions(+), 15 deletions(-) create mode 100644 src/Umbraco.Web/Models/ContentEditing/BackOfficePreview.cs diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index 61ac4c8e29..1ca41f656f 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -849,6 +849,7 @@ + Web.Template.config diff --git a/src/Umbraco.Web.UI/Umbraco/Views/Preview/Index.cshtml b/src/Umbraco.Web.UI/Umbraco/Views/Preview/Index.cshtml index 1ccac9379c..556d4ff0c1 100644 --- a/src/Umbraco.Web.UI/Umbraco/Views/Preview/Index.cshtml +++ b/src/Umbraco.Web.UI/Umbraco/Views/Preview/Index.cshtml @@ -1,8 +1,5 @@ -@inherits System.Web.Mvc.WebViewPage -@{ - var disableDevicePreview = ViewData["DisableDevicePreview"].ToString().ToLowerInvariant(); - var extendPreviewHtml = ViewData["ExtendPreviewHtml"] != null ? ViewData["ExtendPreviewHtml"].ToString() : null; -} +@inherits System.Web.Mvc.WebViewPage + @@ -12,15 +9,15 @@ - @if (extendPreviewHtml != null) + @if (string.IsNullOrWhiteSpace(Model.PreviewExtendedView) == false) { - @Html.Raw(extendPreviewHtml) + @Html.Partial(Model.PreviewExtendedView) }
-
+
/// Disables the device preview feature of previewing. /// - public bool DevicePreview { get; set; } + public bool DisableDevicePreview { get; set; } /// /// If true, all references to templates will be removed in the back office and routing diff --git a/src/Umbraco.Web/Features/EnabledFeatures.cs b/src/Umbraco.Web/Features/EnabledFeatures.cs index a9ebae60cd..4e6b5fa085 100644 --- a/src/Umbraco.Web/Features/EnabledFeatures.cs +++ b/src/Umbraco.Web/Features/EnabledFeatures.cs @@ -7,8 +7,11 @@ namespace Umbraco.Web.Features { /// - /// This allows us to inject html into the preview function extending the view with custom data. + /// This allows us to inject a razor view into the Umbraco preview view to extend it /// - public string ExtendPreviewHtml { get; set; } + /// + /// This is set to a virtual path of a razor view file + /// + public string PreviewExtendedView { get; set; } } } diff --git a/src/Umbraco.Web/Features/UmbracoFeatures.cs b/src/Umbraco.Web/Features/UmbracoFeatures.cs index 03b70c874d..fb2684583e 100644 --- a/src/Umbraco.Web/Features/UmbracoFeatures.cs +++ b/src/Umbraco.Web/Features/UmbracoFeatures.cs @@ -14,6 +14,7 @@ namespace Umbraco.Web.Features public UmbracoFeatures() { Disabled = new DisabledFeatures(); + Enabled = new EnabledFeatures(); } /// diff --git a/src/Umbraco.Web/Models/ContentEditing/AuditLog.cs b/src/Umbraco.Web/Models/ContentEditing/AuditLog.cs index 48c489135a..b7a5a4afe4 100644 --- a/src/Umbraco.Web/Models/ContentEditing/AuditLog.cs +++ b/src/Umbraco.Web/Models/ContentEditing/AuditLog.cs @@ -6,6 +6,7 @@ using Umbraco.Core.Models; namespace Umbraco.Web.Models.ContentEditing { + [DataContract(Name = "auditLog", Namespace = "")] public class AuditLog { @@ -31,4 +32,4 @@ namespace Umbraco.Web.Models.ContentEditing [DataMember(Name = "comment")] public string Comment { get; set; } } -} \ No newline at end of file +} diff --git a/src/Umbraco.Web/Models/ContentEditing/BackOfficePreview.cs b/src/Umbraco.Web/Models/ContentEditing/BackOfficePreview.cs new file mode 100644 index 0000000000..aa2cee57b9 --- /dev/null +++ b/src/Umbraco.Web/Models/ContentEditing/BackOfficePreview.cs @@ -0,0 +1,11 @@ +namespace Umbraco.Web.Models.ContentEditing +{ + /// + /// The model representing Previewing of a content item from the back office + /// + public class BackOfficePreview + { + public string PreviewExtendedView { get; set; } + public bool DisableDevicePreview { get; set; } + } +} diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index a505fb477a..650c840e30 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -334,6 +334,7 @@ +