Skip to content
This repository has been archived by the owner on Feb 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #128 from umco/develop
Browse files Browse the repository at this point in the history
Preparing v0.6.1 release
  • Loading branch information
leekelleher authored Jan 14, 2019
2 parents fd809be + d9d11f2 commit 117b3f7
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 19 deletions.
3 changes: 2 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
image: Visual Studio 2017

# version format
version: 0.6.0.{build}
version: 0.6.1.{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
Expand Down Expand Up @@ -46,6 +46,7 @@ deploy:
# NuGet Deployment for releases
- provider: NuGet
server:
skip_symbols: true
api_key:
secure: vEophXSqus5F60LRBY4/j1l6K/S5+n3/yYpiID3O7JJW1gyj+0q0enuHhN3tgdhl
artifact: /.*\.nupkg/
Expand Down
10 changes: 5 additions & 5 deletions docs/developers-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

1. [Introduction](#introduction)
2. [Getting Set Up](#getting-set-up)
a. [System Requirements](#system-requirements)
1. [System Requirements](#system-requirements)
3. [Configuring The Doc Type Grid Editor](#configuring-the-doc-type-grid-editor)
4. [Hooking Up The Doc Type Grid Editor](#hooking-up-the-doc-type-grid-editor)
5. [Rendering a Doc Type Grid Editor](#rendering-a-doc-type-grid-editor)
a. [Rendering Alternative Preview Content](#rendering-alternative-preview-content)
b. [DocTypeGridEditorSurfaceController](#doctypegrideditorsurfacecontroller)
1. [Rendering Alternative Preview Content](#rendering-alternative-preview-content)
2. [DocTypeGridEditorSurfaceController](#doctypegrideditorsurfacecontroller)
6. [Useful Links](#useful-links)

---
Expand Down Expand Up @@ -139,11 +139,11 @@ Because we treat your data as a standard `IPublishedContent` entity, that means

#### Rendering Alternative Preview Content

If your front end view is rather complex, you may decide that you want to feed the back office preview an alternative, less complex view. To do this, within your Razor view/partial, check for a RouteData parameter `dtgePreview` being set to true to detect being in preview mode to provide an alternative view.
If your front end view is rather complex, you may decide that you want to feed the back office preview an alternative, less complex view. To do this, within your Razor view/partial, check for a querystring parameter `dtgePreview` being set to "1" to detect being in preview mode to provide an alternative view.

```
@inherits Umbraco.Web.Mvc.UmbracoViewPage
@if (ViewContext.RouteData.Values["dtgePreview"])
@if (Request.QueryString["dtgePreview"] == "1")
{
// Render preview view
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,6 @@ public HttpResponseMessage GetPreviewMarkup([FromBody] PreviewData data, [FromUr
System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
}

// Set DTGE's preview to be in "preview mode", (storing the original value in a temp variable for resetting it later).
var inPreviewMode = UmbracoContext.InPreviewMode;
UmbracoContext.InPreviewMode = true;

// Get content node object
var content = DocTypeGridEditorHelper.ConvertValueToContent(data.Id, data.ContentTypeAlias, data.Value);

Expand All @@ -157,9 +153,6 @@ public HttpResponseMessage GetPreviewMarkup([FromBody] PreviewData data, [FromUr
var partialName = "~/App_Plugins/DocTypeGridEditor/Render/DocTypeGridEditorPreviewer.cshtml";
var markup = Helpers.ViewHelper.RenderPartial(partialName, model, UmbracoContext.HttpContext);

// Restore the "preview mode" to its original value
UmbracoContext.InPreviewMode = inPreviewMode;

// Return response
var response = new HttpResponseMessage
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Web.Mvc;
using Our.Umbraco.DocTypeGridEditor.Extensions;
using Our.Umbraco.DocTypeGridEditor.Web.Helpers;
using Umbraco.Core;
using Umbraco.Core.Models;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using Our.Umbraco.DocTypeGridEditor.Extensions;
using Our.Umbraco.DocTypeGridEditor.Web.Helpers;
using Our.Umbraco.DocTypeGridEditor.Web.Mvc;
using Umbraco.Core;
Expand Down Expand Up @@ -86,8 +85,7 @@ public static HtmlString RenderDocTypeGridEditorItem(
}

// Check for preview view
if (string.IsNullOrWhiteSpace(previewViewPath) == false
&& isPreview)
if (string.IsNullOrWhiteSpace(previewViewPath) == false && isPreview)
{
var fullPreviewViewPath = $"{previewViewPath}{editorAlias}.cshtml";
if (ViewHelper.ViewExists(helper.ViewContext, fullPreviewViewPath, true))
Expand Down
16 changes: 15 additions & 1 deletion src/Our.Umbraco.DocTypeGridEditor/Web/Helpers/ViewHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,37 @@
using System.Web.Mvc;
using System.Web.Routing;
using Umbraco.Core.Logging;
using Umbraco.Web;
using Umbraco.Web.Mvc;
using UmbracoWebConstants = Umbraco.Core.Constants.Web;

namespace Our.Umbraco.DocTypeGridEditor.Web.Helpers
{
internal static class ViewHelper
{
private class DummyController : Controller { }

public static string RenderPartial(string partialName, object model, HttpContextBase httpContext = null)
public static string RenderPartial(string partialName, object model, HttpContextBase httpContext = null, UmbracoContext umbracoContext = null)
{
using (var sw = new StringWriter())
{
if (httpContext == null)
httpContext = new HttpContextWrapper(HttpContext.Current);

if (umbracoContext == null)
umbracoContext = UmbracoContext.Current;

var routeData = new RouteData();
routeData.Values.Add("controller", "DummyController");

if (umbracoContext.PublishedContentRequest != null)
{
routeData.DataTokens[UmbracoWebConstants.UmbracoRouteDefinitionDataToken] = new RouteDefinition
{
PublishedContentRequest = umbracoContext.PublishedContentRequest
};
}

var controllerContext = new ControllerContext(new RequestContext(httpContext, routeData), new DummyController());

var viewResult = ViewEngines.Engines.FindPartialView(controllerContext, partialName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
);
},
getEditorMarkupForDocTypePartial: function (pageId, id, editorAlias, contentTypeAlias, value, viewPath, previewViewPath, published) {
var url = umbRequestHelper.convertVirtualToAbsolutePath("~/umbraco/backoffice/DocTypeGridEditorApi/DocTypeGridEditorApi/GetPreviewMarkup?pageId=" + pageId);
var url = umbRequestHelper.convertVirtualToAbsolutePath("~/umbraco/backoffice/DocTypeGridEditorApi/DocTypeGridEditorApi/GetPreviewMarkup?dtgePreview=1&pageId=" + pageId);
return $http({
method: 'POST',
url: url,
Expand Down

0 comments on commit 117b3f7

Please sign in to comment.