diff --git a/src/Umbraco.Web.UI.Client/src/views/content/edit.html b/src/Umbraco.Web.UI.Client/src/views/content/edit.html index be79f797a0..baf1cd7b3d 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/edit.html +++ b/src/Umbraco.Web.UI.Client/src/views/content/edit.html @@ -58,7 +58,7 @@ { + public ContentItemDisplay() + { + AllowPreview = true; + } + [DataMember(Name = "publishDate")] public DateTime? PublishDate { get; set; } @@ -34,7 +39,16 @@ namespace Umbraco.Web.Models.ContentEditing [DataMember(Name = "urls")] public string[] Urls { get; set; } - + + /// + /// Determines whether previewing is allowed for this node + /// + /// + /// By default this is true but by using events developers can toggle this off for certain documents if there is nothing to preview + /// + [DataMember( Name = "allowPreview" )] + public bool AllowPreview { get; set; } + /// /// The allowed 'actions' based on the user's permissions - Create, Update, Publish, Send to publish /// diff --git a/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs b/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs index 7f50b618d4..e2cdd1f7e4 100644 --- a/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs +++ b/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs @@ -66,6 +66,7 @@ namespace Umbraco.Web.Models.Mapping ? new[] {"Cannot generate urls without a current Umbraco Context"} : content.GetContentUrls(UmbracoContext.Current))) .ForMember(display => display.Properties, expression => expression.Ignore()) + .ForMember(display => display.AllowPreview, expression => expression.Ignore()) .ForMember(display => display.TreeNodeUrl, expression => expression.Ignore()) .ForMember(display => display.Notifications, expression => expression.Ignore()) .ForMember(display => display.Errors, expression => expression.Ignore()) diff --git a/src/Umbraco.Web/Redirects/RedirectTrackingEventHandler.cs b/src/Umbraco.Web/Redirects/RedirectTrackingEventHandler.cs index 39b3351aac..417238bdbe 100644 --- a/src/Umbraco.Web/Redirects/RedirectTrackingEventHandler.cs +++ b/src/Umbraco.Web/Redirects/RedirectTrackingEventHandler.cs @@ -93,6 +93,8 @@ namespace Umbraco.Web.Redirects { get { + if (UmbracoContext.Current == null) + return null; var oldRoutes = (Dictionary>) UmbracoContext.Current.HttpContext.Items[ContextKey3]; if (oldRoutes == null) UmbracoContext.Current.HttpContext.Items[ContextKey3] = oldRoutes = new Dictionary>(); @@ -165,8 +167,11 @@ namespace Umbraco.Web.Redirects private void PageCacheRefresher_CacheUpdated(PageCacheRefresher sender, CacheRefresherEventArgs cacheRefresherEventArgs) { - var removeKeys = new List(); + if (OldRoutes == null) + return; + var removeKeys = new List(); + foreach (var oldRoute in OldRoutes) { // assuming we cannot have 'CacheUpdated' for only part of the infos else we'd need