diff --git a/appveyor.yml b/appveyor.yml index 47e24bd..feb434d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ image: Visual Studio 2017 # version format -version: 2.0.1.{build} +version: 2.0.2.{build} # UMBRACO_PACKAGE_PRERELEASE_SUFFIX if a rtm release build this should be blank, otherwise if empty will default to alpha # example UMBRACO_PACKAGE_PRERELEASE_SUFFIX=beta @@ -46,8 +46,9 @@ deploy: # NuGet Deployment for releases - provider: NuGet server: + skip_symbols: true api_key: - secure: 0+oAleUTnr9UuJrhLW5rphRR+QGz00XX1Ui3k5kwyr2kUdEamiQ3F+gW0q8MJbDT + secure: vEophXSqus5F60LRBY4/j1l6K/S5+n3/yYpiID3O7JJW1gyj+0q0enuHhN3tgdhl artifact: /.*\.nupkg/ on: branch: master diff --git a/src/Our.Umbraco.StackedContent/Web/Controllers/StackedContentApiController.cs b/src/Our.Umbraco.StackedContent/Web/Controllers/StackedContentApiController.cs index cf21cb0..32ed8b5 100644 --- a/src/Our.Umbraco.StackedContent/Web/Controllers/StackedContentApiController.cs +++ b/src/Our.Umbraco.StackedContent/Web/Controllers/StackedContentApiController.cs @@ -1,4 +1,5 @@ -using System.Net.Http; +using System; +using System.Net.Http; using System.Net.Http.Headers; using System.Net.Mime; using System.Web.Http; @@ -7,7 +8,9 @@ using Our.Umbraco.StackedContent.Models; using Our.Umbraco.StackedContent.Web.Helpers; using Umbraco.Core.Models; +using Umbraco.Web; using Umbraco.Web.Mvc; +using Umbraco.Web.Routing; using Umbraco.Web.WebApi; namespace Our.Umbraco.StackedContent.Web.Controllers @@ -23,17 +26,27 @@ public HttpResponseMessage GetPreviewMarkup([FromBody] JObject item, int pageId) // If the page is new, then the ID will be zero if (pageId > 0) { - // Get page container node - page = UmbracoContext.ContentCache.GetById(pageId); - if (page == null) + // TODO: Review. Previewing multiple blocks on the same page will make subsequent calls to the ContentService. Is it cacheable? [LK:2018-12-12] + // Get page container node, otherwise it's unpublished then fake PublishedContent (by IContent object) + page = UmbracoContext.ContentCache.GetById(pageId) ?? new UnpublishedContent(pageId, Services); + + // Ensure PublishedContentRequest exists, just in case there are any RTE Macros to render + if (UmbracoContext.PublishedContentRequest == null) { - // If unpublished, then fake PublishedContent (with IContent object) - page = new UnpublishedContent(pageId, Services); +#pragma warning disable CS0618 // Type or member is obsolete + var pcr = new PublishedContentRequest(new Uri(page.UrlAbsolute()), UmbracoContext.RoutingContext); +#pragma warning restore CS0618 // Type or member is obsolete + + UmbracoContext.PublishedContentRequest = pcr; + UmbracoContext.PublishedContentRequest.PublishedContent = page; + UmbracoContext.PublishedContentRequest.Prepare(); } } + // TODO: Review. The values in `item` are the "editor values", whereas for prevalue-based editors, the converter is expecting the "database value". [LK:2018-12-12] + // Convert item - var content = InnerContentHelper.ConvertInnerContentToPublishedContent(item, page); + var content = InnerContentHelper.ConvertInnerContentToPublishedContent(item, page, preview: true); // Construct preview model var model = new PreviewModel { Page = page, Item = content };