UAASSCRUM-1405 Clean up preview for Headless

This commit is contained in:
Claus
2018-02-27 15:47:47 +01:00
parent 7ee510ed38
commit 9c8c9d8a39
5 changed files with 55 additions and 11 deletions

View File

@@ -242,10 +242,10 @@
// Chromes popup blocker will kick in if a window is opened
// without the initial scoped request. This trick will fix that.
//
var previewWindow = $window.open('preview/?init=true&id=' + content.id, 'umbpreview');
var previewWindow = $window.open('previews/?init=true&id=' + content.id, 'umbpreview');
// Build the correct path so both /#/ and #/ work.
var redirect = Umbraco.Sys.ServerVariables.umbracoSettings.umbracoPath + '/preview/?id=' + content.id;
var redirect = Umbraco.Sys.ServerVariables.umbracoSettings.umbracoPath + '/previews/?id=' + content.id;
//The user cannot save if they don't have access to do that, in which case we just want to preview
//and that's it otherwise they'll get an unauthorized access message
@@ -255,11 +255,9 @@
else {
$scope.save().then(function (data) {
previewWindow.location.href = redirect;
});
});
}
}
};
$scope.restore = function (content) {

View File

@@ -837,6 +837,18 @@
<Content Include="Views\Partials\Grid\Editors\Base.cshtml" />
<Content Include="Views\Partials\Grid\Bootstrap3-Fluid.cshtml" />
<Content Include="Views\Partials\Grid\Bootstrap2-Fluid.cshtml" />
<Content Include="Umbraco\Views\Preview\Background.cshtml" />
<Content Include="Umbraco\Views\Preview\Border.cshtml" />
<Content Include="Umbraco\Views\Preview\Color.cshtml" />
<Content Include="Umbraco\Views\Preview\Googlefontpicker.cshtml" />
<Content Include="Umbraco\Views\Preview\GridRow.cshtml" />
<Content Include="Umbraco\Views\Preview\Index.cshtml" />
<Content Include="Umbraco\Views\Preview\Layout.cshtml" />
<Content Include="Umbraco\Views\Preview\Margin.cshtml" />
<Content Include="Umbraco\Views\Preview\Padding.cshtml" />
<Content Include="Umbraco\Views\Preview\Radius.cshtml" />
<Content Include="Umbraco\Views\Preview\Shadow.cshtml" />
<Content Include="Umbraco\Views\Preview\Slider.cshtml" />
<None Include="Web.Debug.config.transformed" />
<None Include="web.Template.Debug.config">
<DependentUpon>Web.Template.config</DependentUpon>

View File

@@ -0,0 +1,27 @@
using System;
using System.Web.Mvc;
using Umbraco.Web.Features;
using Umbraco.Web.Mvc;
namespace Umbraco.Web.Editors
{
[UmbracoAuthorize]
[DisableBrowserCache]
public class PreviewController : Controller
{
private const string ViewsPath = "~/Umbraco/Views/Preview/";
public ActionResult Index()
{
ViewData["DisableDevicePreview"] = FeaturesResolver.Current.Features.Disabled.DevicePreview;
return View(ViewsPath + "Index.cshtml");
}
[AllowAnonymous]
public ActionResult Editors(string editor)
{
if (string.IsNullOrEmpty(editor)) throw new ArgumentNullException("editor");
return View(ViewsPath + editor.Replace(".html", string.Empty) + ".cshtml");
}
}
}

View File

@@ -20,5 +20,10 @@ namespace Umbraco.Web.Features
/// Gets the disabled controllers.
/// </summary>
public TypeList<UmbracoApiControllerBase> Controllers { get; private set; }
/// <summary>
/// Disables the device preview feature of previewing.
/// </summary>
public bool DevicePreview { get; set; }
}
}

View File

@@ -1,10 +1,6 @@
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web.Mvc;
using Umbraco.Core.Configuration;
using Umbraco.Web.Editors;
using Umbraco.Web.Install;
using Umbraco.Web.Install.Controllers;
namespace Umbraco.Web.Mvc
{
@@ -24,6 +20,12 @@ namespace Umbraco.Web.Mvc
/// </remarks>
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Umbraco_preview",
GlobalSettings.UmbracoMvcArea + "/previews/{action}/{editor}",
new {controller = "Preview", action = "Index", editor = UrlParameter.Optional},
new[] { "Umbraco.Web.Editors" });
context.MapRoute(
"Umbraco_back_office",
GlobalSettings.UmbracoMvcArea + "/{action}/{id}",
@@ -51,4 +53,4 @@ namespace Umbraco.Web.Mvc
get { return GlobalSettings.UmbracoMvcArea; }
}
}
}
}