diff --git a/src/Umbraco.Core/UriExtensions.cs b/src/Umbraco.Core/UriExtensions.cs index d018dddfbf..b99fc2695e 100644 --- a/src/Umbraco.Core/UriExtensions.cs +++ b/src/Umbraco.Core/UriExtensions.cs @@ -30,6 +30,7 @@ namespace Umbraco.Core /// These are def back office: /// /Umbraco/RestServices = back office /// /Umbraco/BackOffice = back office + /// /Umbraco/Preview = back office /// If it's not any of the above, and there's no extension then we cannot determine if it's back office or front-end /// so we can only assume that it is not back office. This will occur if people use an UmbracoApiController for the backoffice /// but do not inherit from UmbracoAuthorizedApiController and do not use [IsBackOffice] attribute. @@ -77,7 +78,8 @@ namespace Umbraco.Core //check for special back office paths if (urlPath.InvariantStartsWith("/" + globalSettings.GetUmbracoMvcArea() + "/BackOffice/") - || urlPath.InvariantStartsWith("/" + globalSettings.GetUmbracoMvcArea() + "/RestServices/")) + || urlPath.InvariantStartsWith("/" + globalSettings.GetUmbracoMvcArea() + "/RestServices/") + || urlPath.InvariantStartsWith("/" + globalSettings.GetUmbracoMvcArea() + "/Preview/")) { return true; } diff --git a/src/Umbraco.Tests/Web/AngularIntegration/JsInitializationTests.cs b/src/Umbraco.Tests/Web/AngularIntegration/JsInitializationTests.cs index dacba39163..bcb102726a 100644 --- a/src/Umbraco.Tests/Web/AngularIntegration/JsInitializationTests.cs +++ b/src/Umbraco.Tests/Web/AngularIntegration/JsInitializationTests.cs @@ -19,7 +19,7 @@ namespace Umbraco.Tests.Web.AngularIntegration [Test] public void Parse_Main() { - var result = JsInitialization.WriteScript(new[] {"[World]", "Hello" }); + var result = JsInitialization.WriteScript("[World]", "Hello", "Blah"); Assert.AreEqual(@"LazyLoad.js([World], function () { //we need to set the legacy UmbClientMgr path @@ -27,7 +27,7 @@ namespace Umbraco.Tests.Web.AngularIntegration jQuery(document).ready(function () { - angular.bootstrap(document, ['umbraco']); + angular.bootstrap(document, ['Blah']); }); });".StripWhitespace(), result.StripWhitespace()); diff --git a/src/Umbraco.Web.UI.Client/gulpfile.js b/src/Umbraco.Web.UI.Client/gulpfile.js index 5afe6ecf44..2d34e8ecb3 100644 --- a/src/Umbraco.Web.UI.Client/gulpfile.js +++ b/src/Umbraco.Web.UI.Client/gulpfile.js @@ -80,7 +80,7 @@ var sources = { //js files for backoffie //processed in the js task js: { - preview: { files: ["src/canvasdesigner/**/*.js"], out: "umbraco.canvasdesigner.js" }, + preview: { files: ["src/preview/**/*.js"], out: "umbraco.preview.js" }, installer: { files: ["src/installer/**/*.js"], out: "umbraco.installer.js" }, controllers: { files: ["src/{views,controllers}/**/*.controller.js"], out: "umbraco.controllers.js" }, directives: { files: ["src/common/directives/**/*.js"], out: "umbraco.directives.js" }, diff --git a/src/Umbraco.Web.UI.Client/src/canvasdesigner.loader.js b/src/Umbraco.Web.UI.Client/src/canvasdesigner.loader.js index 8c0ec78025..5476404e6a 100644 --- a/src/Umbraco.Web.UI.Client/src/canvasdesigner.loader.js +++ b/src/Umbraco.Web.UI.Client/src/canvasdesigner.loader.js @@ -1,19 +1,19 @@ LazyLoad.js([ - '../lib/jquery/jquery.min.js', - '../lib/angular/1.1.5/angular.min.js', - '../lib/underscore/underscore-min.js', - '../lib/umbraco/Extensions.js', - '../js/app.js', - '../js/umbraco.resources.js', - '../js/umbraco.services.js', - '../js/umbraco.interceptors.js', - '../ServerVariables', - '../lib/signalr/jquery.signalR.js', - '/umbraco/BackOffice/signalr/hubs', - '../js/umbraco.canvasdesigner.js' + '../lib/jquery/jquery.min.js', + '../lib/angular/angular.js', + '../lib/underscore/underscore-min.js', + '../lib/umbraco/Extensions.js', + '../js/app.js', + '../js/umbraco.resources.js', + '../js/umbraco.services.js', + '../js/umbraco.interceptors.js', + '../ServerVariables', + '../lib/signalr/jquery.signalR.js', + '../BackOffice/signalr/hubs', + '../js/umbraco.canvasdesigner.js' ], function () { - jQuery(document).ready(function () { - angular.bootstrap(document, ['Umbraco.canvasdesigner']); - }); + jQuery(document).ready(function () { + angular.bootstrap(document, ['Umbraco.canvasdesigner']); + }); }); diff --git a/src/Umbraco.Web.UI.Client/src/canvasdesigner/canvasdesigner.controller.js b/src/Umbraco.Web.UI.Client/src/canvasdesigner/canvasdesigner.controller.js deleted file mode 100644 index 975d490086..0000000000 --- a/src/Umbraco.Web.UI.Client/src/canvasdesigner/canvasdesigner.controller.js +++ /dev/null @@ -1,117 +0,0 @@ - -/*********************************************************************************************************/ -/* Canvasdesigner panel app and controller */ -/*********************************************************************************************************/ - -var app = angular.module("Umbraco.canvasdesigner", ['umbraco.resources', 'umbraco.services']) - -.controller("Umbraco.canvasdesignerController", function ($scope, $http, $window, $timeout, $location, dialogService) { - - var isInit = $location.search().init; - if (isInit === "true") { - //do not continue, this is the first load of this new window, if this is passed in it means it's been - //initialized by the content editor and then the content editor will actually re-load this window without - //this flag. This is a required trick to get around chrome popup mgr. We don't want to double load preview.aspx - //since that will double prepare the preview documents - return; - } - - $scope.isOpen = false; - $scope.frameLoaded = false; - var pageId = $location.search().id; - $scope.pageId = pageId; - $scope.pageUrl = "../dialogs/Preview.aspx?id=" + pageId; - $scope.valueAreLoaded = false; - $scope.devices = [ - { name: "desktop", css: "desktop", icon: "icon-display", title: "Desktop" }, - { name: "laptop - 1366px", css: "laptop border", icon: "icon-laptop", title: "Laptop" }, - { name: "iPad portrait - 768px", css: "iPad-portrait border", icon: "icon-ipad", title: "Tablet portrait" }, - { name: "iPad landscape - 1024px", css: "iPad-landscape border", icon: "icon-ipad flip", title: "Tablet landscape" }, - { name: "smartphone portrait - 480px", css: "smartphone-portrait border", icon: "icon-iphone", title: "Smartphone portrait" }, - { name: "smartphone landscape - 320px", css: "smartphone-landscape border", icon: "icon-iphone flip", title: "Smartphone landscape" } - ]; - $scope.previewDevice = $scope.devices[0]; - - /*****************************************************************************/ - /* Preview devices */ - /*****************************************************************************/ - - // Set preview device - $scope.updatePreviewDevice = function (device) { - $scope.previewDevice = device; - }; - - /*****************************************************************************/ - /* Exit Preview */ - /*****************************************************************************/ - - $scope.exitPreview = function () { - window.top.location.href = "../endPreview.aspx?redir=%2f" + $scope.pageId; - }; - - - - /*****************************************************************************/ - /* Panel managment */ - /*****************************************************************************/ - - $scope.openPreviewDevice = function () { - $scope.showDevicesPreview = true; - $scope.closeIntelCanvasdesigner(); - } - - /*****************************************************************************/ - /* Call function into the front-end */ - /*****************************************************************************/ - - - var hideUmbracoPreviewBadge = function () { - var iframe = (document.getElementById("resultFrame").contentWindow || document.getElementById("resultFrame").contentDocument); - if(iframe.document.getElementById("umbracoPreviewBadge")) - iframe.document.getElementById("umbracoPreviewBadge").style.display = "none"; - }; - - /*****************************************************************************/ - /* Init */ - /*****************************************************************************/ - - - // signalr hub - var previewHub = $.connection.previewHub; - - previewHub.client.refreshed = function (message, sender) { - console.log("Notified by SignalR preview hub (" + message+ ")."); - - if ($scope.pageId != message) { - console.log("Not a notification for us (" + $scope.pageId + ")."); - return; - } - - var resultFrame = document.getElementById("resultFrame"); - var iframe = (resultFrame.contentWindow || resultFrame.contentDocument); - //setTimeout(function() { iframe.location.reload(); }, 1000); - iframe.location.reload(); - }; - - $.connection.hub.start() - .done(function () { console.log("Connected to SignalR preview hub (ID=" + $.connection.hub.id + ")"); }) - .fail(function () { console.log("Could not connect to SignalR preview hub."); }); -}) - - -.directive('iframeIsLoaded', function ($timeout) { - return { - restrict: 'A', - link: function (scope, element, attr) { - element.load(function () { - var iframe = (element.context.contentWindow || element.context.contentDocument); - if(iframe && iframe.document.getElementById("umbracoPreviewBadge")) - iframe.document.getElementById("umbracoPreviewBadge").style.display = "none"; - if (!document.getElementById("resultFrame").contentWindow.refreshLayout) { - scope.frameLoaded = true; - scope.$apply(); - } - }); - } - }; -}) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js index 911b561ff3..dbebf840f1 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js @@ -486,10 +486,14 @@ // 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('preview/?init=true', 'umbpreview'); // Build the correct path so both /#/ and #/ work. - var redirect = Umbraco.Sys.ServerVariables.umbracoSettings.umbracoPath + '/preview/?id=' + content.id; + var query = 'id=' + content.id; + if ($scope.culture) { + query += "&culture=" + $scope.culture; + } + var redirect = Umbraco.Sys.ServerVariables.umbracoSettings.umbracoPath + '/preview/?' + query; //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 @@ -497,8 +501,22 @@ previewWindow.location.href = redirect; } else { - $scope.save().then(function (data) { + var selectedVariant; + if (!$scope.culture) { + selectedVariant = $scope.content.variants[0]; + } + else { + selectedVariant = _.find($scope.content.variants, function (v) { + return v.language.culture === $scope.culture; + }); + } + + //ensure the save flag is set + selectedVariant.save = true; + performSave({ saveMethod: contentResource.publish, action: "save" }).then(function (data) { previewWindow.location.href = redirect; + }, function (err) { + //validation issues .... }); } } diff --git a/src/Umbraco.Web.UI.Client/src/preview/preview.controller.js b/src/Umbraco.Web.UI.Client/src/preview/preview.controller.js new file mode 100644 index 0000000000..e87f3a59bf --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/preview/preview.controller.js @@ -0,0 +1,147 @@ + +/*********************************************************************************************************/ +/* Preview app and controller */ +/*********************************************************************************************************/ + +var app = angular.module("umbraco.preview", ['umbraco.resources', 'umbraco.services']) + + .controller("previewController", function ($scope, $http, $window, $timeout, $location, dialogService) { + + //gets a real query string value + function getParameterByName(name, url) { + if (!url) url = $window.location.href; + name = name.replace(/[\[\]]/g, '\\$&'); + var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), + results = regex.exec(url); + if (!results) return null; + if (!results[2]) return ''; + return decodeURIComponent(results[2].replace(/\+/g, ' ')); + } + + function configureSignalR(iframe) { + // signalr hub + var previewHub = $.connection.previewHub; + + previewHub.client.refreshed = function (message, sender) { + console.log("Notified by SignalR preview hub (" + message + ")."); + + if ($scope.pageId != message) { + console.log("Not a notification for us (" + $scope.pageId + ")."); + return; + } + + var iframeDoc = (iframe.contentWindow || iframe.contentDocument); + iframeDoc.location.reload(); + }; + + $.connection.hub.start() + .done(function () { console.log("Connected to SignalR preview hub (ID=" + $.connection.hub.id + ")"); }) + .fail(function () { console.log("Could not connect to SignalR preview hub."); }); + } + + var isInit = getParameterByName("init"); + if (isInit === "true") { + //do not continue, this is the first load of this new window, if this is passed in it means it's been + //initialized by the content editor and then the content editor will actually re-load this window without + //this flag. This is a required trick to get around chrome popup mgr. + return; + } + + $scope.pageId = $location.search().id || getParameterByName("id"); + var culture = $location.search().culture || getParameterByName("culture"); + + if ($scope.pageId) { + var query = 'id=' + $scope.pageId; + if (culture) { + query += "&culture=" + culture; + } + $scope.pageUrl = "frame?" + query; + } + + $scope.isOpen = false; + $scope.frameLoaded = false; + + $scope.valueAreLoaded = false; + $scope.devices = [ + { name: "desktop", css: "desktop", icon: "icon-display", title: "Desktop" }, + { name: "laptop - 1366px", css: "laptop border", icon: "icon-laptop", title: "Laptop" }, + { name: "iPad portrait - 768px", css: "iPad-portrait border", icon: "icon-ipad", title: "Tablet portrait" }, + { name: "iPad landscape - 1024px", css: "iPad-landscape border", icon: "icon-ipad flip", title: "Tablet landscape" }, + { name: "smartphone portrait - 480px", css: "smartphone-portrait border", icon: "icon-iphone", title: "Smartphone portrait" }, + { name: "smartphone landscape - 320px", css: "smartphone-landscape border", icon: "icon-iphone flip", title: "Smartphone landscape" } + ]; + $scope.previewDevice = $scope.devices[0]; + + /*****************************************************************************/ + /* Preview devices */ + /*****************************************************************************/ + + // Set preview device + $scope.updatePreviewDevice = function (device) { + $scope.previewDevice = device; + }; + + /*****************************************************************************/ + /* Exit Preview */ + /*****************************************************************************/ + + $scope.exitPreview = function () { + window.top.location.href = "../endPreview.aspx?redir=%2f" + $scope.pageId; + }; + + $scope.onFrameLoaded = function (iframe) { + $scope.frameLoaded = true; + configureSignalR(iframe); + } + + /*****************************************************************************/ + /* Panel managment */ + /*****************************************************************************/ + + $scope.openPreviewDevice = function () { + $scope.showDevicesPreview = true; + } + + }) + + + .component('previewIFrame', { + + template: "
", + controller: function ($element, $scope, angularHelper) { + + var vm = this; + + vm.$postLink = function () { + var resultFrame = $element.find("#resultFrame"); + resultFrame.on("load", iframeReady); + vm.srcDelayed = vm.src; + }; + + function iframeReady() { + var iframe = $element.find("#resultFrame").get(0); + hideUmbracoPreviewBadge(iframe); + angularHelper.safeApply($scope, function () { + vm.onLoaded({ iframe: iframe }); + }); + } + + function hideUmbracoPreviewBadge (iframe) { + if (iframe && iframe.contentDocument && iframe.contentDocument.getElementById("umbracoPreviewBadge")) { + iframe.contentDocument.getElementById("umbracoPreviewBadge").style.display = "none"; + } + }; + + }, + controllerAs: "vm", + bindings: { + src: "<", + onLoaded: "&" + } + + }) + + .config(function ($locationProvider) { + $locationProvider.html5Mode(false); //turn html5 mode off + $locationProvider.hashPrefix(''); + }); diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index bb1be50baf..4df862dcb3 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -340,7 +340,6 @@ - @@ -427,18 +426,7 @@ - - - - - - - - - - - @@ -600,4 +588,4 @@ - + \ No newline at end of file diff --git a/src/Umbraco.Web.UI/Umbraco/Views/Preview/Background.cshtml b/src/Umbraco.Web.UI/Umbraco/Views/Preview/Background.cshtml deleted file mode 100644 index 6e3793d840..0000000000 --- a/src/Umbraco.Web.UI/Umbraco/Views/Preview/Background.cshtml +++ /dev/null @@ -1,57 +0,0 @@ -@inherits System.Web.Mvc.WebViewPage -
- -
-
-
- -
-
- - -
-
- -
- - diff --git a/src/Umbraco.Web.UI/Umbraco/Views/Preview/Border.cshtml b/src/Umbraco.Web.UI/Umbraco/Views/Preview/Border.cshtml deleted file mode 100644 index 40d46a0f4d..0000000000 --- a/src/Umbraco.Web.UI/Umbraco/Views/Preview/Border.cshtml +++ /dev/null @@ -1,20 +0,0 @@ -@inherits System.Web.Mvc.WebViewPage -
- -
-
    -
  • -
-
- -
-
- - -
- -
-
-
- -
diff --git a/src/Umbraco.Web.UI/Umbraco/Views/Preview/Color.cshtml b/src/Umbraco.Web.UI/Umbraco/Views/Preview/Color.cshtml deleted file mode 100644 index 02213f2cd2..0000000000 --- a/src/Umbraco.Web.UI/Umbraco/Views/Preview/Color.cshtml +++ /dev/null @@ -1,4 +0,0 @@ -@inherits System.Web.Mvc.WebViewPage -
-
-
diff --git a/src/Umbraco.Web.UI/Umbraco/Views/Preview/Googlefontpicker.cshtml b/src/Umbraco.Web.UI/Umbraco/Views/Preview/Googlefontpicker.cshtml deleted file mode 100644 index e1e61e379e..0000000000 --- a/src/Umbraco.Web.UI/Umbraco/Views/Preview/Googlefontpicker.cshtml +++ /dev/null @@ -1,34 +0,0 @@ -@inherits System.Web.Mvc.WebViewPage -
- -
-
- Aa - {{ item.values.fontFamily }} - -
-
- -
- - diff --git a/src/Umbraco.Web.UI/Umbraco/Views/Preview/GridRow.cshtml b/src/Umbraco.Web.UI/Umbraco/Views/Preview/GridRow.cshtml deleted file mode 100644 index 52f24cb25e..0000000000 --- a/src/Umbraco.Web.UI/Umbraco/Views/Preview/GridRow.cshtml +++ /dev/null @@ -1,8 +0,0 @@ -@inherits System.Web.Mvc.WebViewPage -
- -
- -
- -
diff --git a/src/Umbraco.Web.UI/Umbraco/Views/Preview/Index.cshtml b/src/Umbraco.Web.UI/Umbraco/Views/Preview/Index.cshtml index 0b1c3fbe17..4924985689 100644 --- a/src/Umbraco.Web.UI/Umbraco/Views/Preview/Index.cshtml +++ b/src/Umbraco.Web.UI/Umbraco/Views/Preview/Index.cshtml @@ -1,17 +1,30 @@ -@using System.Web.Mvc.Html -@inherits System.Web.Mvc.WebViewPage +@using Umbraco.Core +@using ClientDependency.Core +@using ClientDependency.Core.Mvc +@using Umbraco.Core.IO +@using Umbraco.Web +@using Umbraco.Core.Configuration + +@inherits System.Web.Mvc.WebViewPage @{ var disableDevicePreview = Model.DisableDevicePreview.ToString().ToLowerInvariant(); + + Html + .RequiresCss("assets/css/canvasdesigner.css", "Umbraco"); } - Umbraco Canvas Designer - - + + Umbraco Preview + + + @Html.RenderCssHere( + new BasicPath("Umbraco", IOHelper.ResolveUrl(SystemDirectories.Umbraco))) + - +
@if (string.IsNullOrWhiteSpace(Model.PreviewExtendedHeaderView) == false) @@ -19,8 +32,8 @@ @Html.Partial(Model.PreviewExtendedHeaderView) } -
- +
+
@@ -30,17 +43,19 @@ ../assets/img/application/logo@3x.png 3x" />
    -
  • - +
  • +
  • -
  • - +
  • +
- +
+ - + + diff --git a/src/Umbraco.Web.UI/Umbraco/Views/Preview/Layout.cshtml b/src/Umbraco.Web.UI/Umbraco/Views/Preview/Layout.cshtml deleted file mode 100644 index 3df51ae23f..0000000000 --- a/src/Umbraco.Web.UI/Umbraco/Views/Preview/Layout.cshtml +++ /dev/null @@ -1,10 +0,0 @@ -@inherits System.Web.Mvc.WebViewPage -
- -
- Box - Wide - Full -
- -
diff --git a/src/Umbraco.Web.UI/Umbraco/Views/Preview/Margin.cshtml b/src/Umbraco.Web.UI/Umbraco/Views/Preview/Margin.cshtml deleted file mode 100644 index f14e592420..0000000000 --- a/src/Umbraco.Web.UI/Umbraco/Views/Preview/Margin.cshtml +++ /dev/null @@ -1,14 +0,0 @@ -@inherits System.Web.Mvc.WebViewPage -
- -
-
    -
  • -
-
- -
-
-
- -
diff --git a/src/Umbraco.Web.UI/Umbraco/Views/Preview/Padding.cshtml b/src/Umbraco.Web.UI/Umbraco/Views/Preview/Padding.cshtml deleted file mode 100644 index 3f2c440945..0000000000 --- a/src/Umbraco.Web.UI/Umbraco/Views/Preview/Padding.cshtml +++ /dev/null @@ -1,14 +0,0 @@ -@inherits System.Web.Mvc.WebViewPage -
- -
-
    -
  • -
-
- -
-
-
- -
diff --git a/src/Umbraco.Web.UI/Umbraco/Views/Preview/Radius.cshtml b/src/Umbraco.Web.UI/Umbraco/Views/Preview/Radius.cshtml deleted file mode 100644 index 1e8a96b712..0000000000 --- a/src/Umbraco.Web.UI/Umbraco/Views/Preview/Radius.cshtml +++ /dev/null @@ -1,21 +0,0 @@ -@inherits System.Web.Mvc.WebViewPage -
- -
-
    - -
  • - - - - -
  • - -
-
- -
-
-
- -
diff --git a/src/Umbraco.Web.UI/Umbraco/Views/Preview/Shadow.cshtml b/src/Umbraco.Web.UI/Umbraco/Views/Preview/Shadow.cshtml deleted file mode 100644 index 6b9d4763e8..0000000000 --- a/src/Umbraco.Web.UI/Umbraco/Views/Preview/Shadow.cshtml +++ /dev/null @@ -1,8 +0,0 @@ -@inherits System.Web.Mvc.WebViewPage -
- -
-
-
- -
diff --git a/src/Umbraco.Web.UI/Umbraco/Views/Preview/Slider.cshtml b/src/Umbraco.Web.UI/Umbraco/Views/Preview/Slider.cshtml deleted file mode 100644 index 414159d714..0000000000 --- a/src/Umbraco.Web.UI/Umbraco/Views/Preview/Slider.cshtml +++ /dev/null @@ -1,8 +0,0 @@ -@inherits System.Web.Mvc.WebViewPage -
- -
-
-
- -
diff --git a/src/Umbraco.Web.UI/Umbraco/dialogs/Preview.aspx b/src/Umbraco.Web.UI/Umbraco/dialogs/Preview.aspx deleted file mode 100644 index 0469ae7a61..0000000000 --- a/src/Umbraco.Web.UI/Umbraco/dialogs/Preview.aspx +++ /dev/null @@ -1,19 +0,0 @@ -<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="../masterpages/umbracoDialog.Master" Inherits="umbraco.presentation.dialogs.Preview" %> -<%@ Register TagPrefix="cc1" Namespace="Umbraco.Web._Legacy.Controls" Assembly="Umbraco.Web" %> - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Umbraco.Web/Editors/BackOfficeController.cs b/src/Umbraco.Web/Editors/BackOfficeController.cs index d201919cef..ab89390bf6 100644 --- a/src/Umbraco.Web/Editors/BackOfficeController.cs +++ b/src/Umbraco.Web/Editors/BackOfficeController.cs @@ -44,7 +44,7 @@ namespace Umbraco.Web.Editors /// Represents a controller user to render out the default back office view and JS results. /// [UmbracoRequireHttps] - [DisableClientCache] + [DisableBrowserCache] public class BackOfficeController : UmbracoController { private readonly ManifestParser _manifestParser; @@ -192,7 +192,8 @@ namespace Umbraco.Web.Editors //get the legacy ActionJs file references to append as well var legacyActionJsRef = GetLegacyActionJs(LegacyJsActionType.JsUrl); - var result = initJs.GetJavascriptInitialization(HttpContext, JsInitialization.GetDefaultInitialization(), legacyActionJsRef); + var files = initJs.OptimizeBackOfficeScriptFiles(HttpContext, JsInitialization.GetDefaultInitialization(), legacyActionJsRef); + var result = JsInitialization.GetJavascriptInitialization(HttpContext, files, "umbraco"); result += initCss.GetStylesheetInitialization(HttpContext); return JavaScript(result); @@ -211,7 +212,7 @@ namespace Umbraco.Web.Editors var initJs = new JsInitialization(_manifestParser); var initCss = new CssInitialization(_manifestParser); var assets = new List(); - assets.AddRange(initJs.GetScriptFiles(HttpContext, Enumerable.Empty())); + assets.AddRange(initJs.OptimizeBackOfficeScriptFiles(HttpContext, Enumerable.Empty())); assets.AddRange(initCss.GetStylesheetFiles(HttpContext)); return new JArray(assets); } diff --git a/src/Umbraco.Web/Editors/BackOfficeModel.cs b/src/Umbraco.Web/Editors/BackOfficeModel.cs index 75a388ee80..9833121301 100644 --- a/src/Umbraco.Web/Editors/BackOfficeModel.cs +++ b/src/Umbraco.Web/Editors/BackOfficeModel.cs @@ -3,6 +3,7 @@ using Umbraco.Web.Features; namespace Umbraco.Web.Editors { + public class BackOfficeModel { public BackOfficeModel(UmbracoFeatures features, IGlobalSettings globalSettings) diff --git a/src/Umbraco.Web/Editors/BackOfficePreviewModel.cs b/src/Umbraco.Web/Editors/BackOfficePreviewModel.cs new file mode 100644 index 0000000000..1298575e50 --- /dev/null +++ b/src/Umbraco.Web/Editors/BackOfficePreviewModel.cs @@ -0,0 +1,15 @@ +using Umbraco.Core.Configuration; +using Umbraco.Web.Features; + +namespace Umbraco.Web.Editors +{ + public class BackOfficePreviewModel : BackOfficeModel + { + public BackOfficePreviewModel(UmbracoFeatures features, IGlobalSettings globalSettings) : base(features, globalSettings) + { + } + + public bool DisableDevicePreview => Features.Disabled.DisableDevicePreview; + public string PreviewExtendedHeaderView => Features.Enabled.PreviewExtendedView; + } +} diff --git a/src/Umbraco.Web/Editors/PreviewController.cs b/src/Umbraco.Web/Editors/PreviewController.cs index 9c0d46cedb..6a91d20ae0 100644 --- a/src/Umbraco.Web/Editors/PreviewController.cs +++ b/src/Umbraco.Web/Editors/PreviewController.cs @@ -1,10 +1,16 @@ using System; +using System.Web; using System.Web.Mvc; +using System.Web.UI; using Umbraco.Core; using Umbraco.Core.Configuration; +using Umbraco.Web.Composing; using Umbraco.Web.Features; using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Mvc; +using Umbraco.Web.PublishedCache; +using Umbraco.Web.UI.JavaScript; +using Constants = Umbraco.Core.Constants; namespace Umbraco.Web.Editors { @@ -13,21 +19,22 @@ namespace Umbraco.Web.Editors { private readonly UmbracoFeatures _features; private readonly IGlobalSettings _globalSettings; + private readonly IPublishedSnapshotService _publishedSnapshotService; + private readonly UmbracoContext _umbracoContext; - public PreviewController(UmbracoFeatures features, IGlobalSettings globalSettings) + public PreviewController(UmbracoFeatures features, IGlobalSettings globalSettings, IPublishedSnapshotService publishedSnapshotService, UmbracoContext umbracoContext) { _features = features; _globalSettings = globalSettings; + _publishedSnapshotService = publishedSnapshotService; + _umbracoContext = umbracoContext; } [UmbracoAuthorize(redirectToUmbracoLogin: true)] + [DisableBrowserCache] public ActionResult Index() { - var model = new BackOfficePreview - { - DisableDevicePreview = _features.Disabled.DisableDevicePreview, - PreviewExtendedHeaderView = _features.Enabled.PreviewExtendedView - }; + var model = new BackOfficePreviewModel(_features, _globalSettings); if (model.PreviewExtendedHeaderView.IsNullOrWhiteSpace() == false) { @@ -41,10 +48,45 @@ namespace Umbraco.Web.Editors return View(_globalSettings.Path.EnsureEndsWith('/') + "Views/Preview/" + "Index.cshtml", model); } - public ActionResult Editors(string editor) + /// + /// Returns the JavaScript file for preview + /// + /// + [MinifyJavaScriptResult(Order = 0)] + [OutputCache(Order = 1, VaryByParam = "none", Location = OutputCacheLocation.Server, Duration = 5000)] + public JavaScriptResult Application() { - if (string.IsNullOrEmpty(editor)) throw new ArgumentNullException(nameof(editor)); - return View(_globalSettings.Path.EnsureEndsWith('/') + "Views/Preview/" + editor.Replace(".html", string.Empty) + ".cshtml"); + var files = JsInitialization.OptimizeScriptFiles(HttpContext, JsInitialization.GetPreviewInitialization()); + var result = JsInitialization.GetJavascriptInitialization(HttpContext, files, "umbraco.preview"); + + return JavaScript(result); } + + /// + /// The endpoint that is loaded within the preview iframe + /// + /// + [UmbracoAuthorize] + public ActionResult Frame(int id, string culture) + { + var user = _umbracoContext.Security.CurrentUser; + + var previewToken = _publishedSnapshotService.EnterPreview(user, id); + + Response.Cookies.Set(new HttpCookie(Constants.Web.PreviewCookieName, previewToken)); + + // use a numeric url because content may not be in cache and so .Url would fail + var query = culture.IsNullOrWhiteSpace() ? string.Empty : $"?culture={culture}"; + Response.Redirect($"../../{id}.aspx{query}", true); + + return null; + } + + ////fixme: not sure we need this anymore since there is no canvas editing - then we can remove that route too + //public ActionResult Editors(string editor) + //{ + // if (string.IsNullOrEmpty(editor)) throw new ArgumentNullException(nameof(editor)); + // return View(_globalSettings.Path.EnsureEndsWith('/') + "Views/Preview/" + editor.Replace(".html", string.Empty) + ".cshtml"); + //} } } diff --git a/src/Umbraco.Web/Models/ContentEditing/BackOfficePreview.cs b/src/Umbraco.Web/Models/ContentEditing/BackOfficePreview.cs deleted file mode 100644 index f8633acdd0..0000000000 --- a/src/Umbraco.Web/Models/ContentEditing/BackOfficePreview.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Umbraco.Web.Models.ContentEditing -{ - /// - /// The model representing Previewing of a content item from the back office - /// - public class BackOfficePreview - { - public string PreviewExtendedHeaderView { get; set; } - - //TODO: We could potentially have a 'footer' view - public bool DisableDevicePreview { get; set; } - } -} diff --git a/src/Umbraco.Web/Mvc/DisableBrowserCacheAttribute.cs b/src/Umbraco.Web/Mvc/DisableBrowserCacheAttribute.cs index bcf7b34b4f..380ec4cd4e 100644 --- a/src/Umbraco.Web/Mvc/DisableBrowserCacheAttribute.cs +++ b/src/Umbraco.Web/Mvc/DisableBrowserCacheAttribute.cs @@ -9,9 +9,9 @@ namespace Umbraco.Web.Mvc /// public class DisableBrowserCacheAttribute : ActionFilterAttribute { - public override void OnActionExecuted(ActionExecutedContext filterContext) + public override void OnResultExecuting(ResultExecutingContext filterContext) { - base.OnActionExecuted(filterContext); + base.OnResultExecuting(filterContext); // could happens if exception (but afaik this wouldn't happen in MVC) if (filterContext.HttpContext == null || filterContext.HttpContext.Response == null || @@ -20,6 +20,18 @@ namespace Umbraco.Web.Mvc return; } + if (filterContext.IsChildAction) + { + return; + } + + if (filterContext.HttpContext.Response.StatusCode != 200) + { + return; + } + + filterContext.HttpContext.Response.Cache.SetLastModified(DateTime.Now); + filterContext.HttpContext.Response.Cache.SetValidUntilExpires(false); filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache); filterContext.HttpContext.Response.Cache.SetMaxAge(TimeSpan.Zero); filterContext.HttpContext.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches); diff --git a/src/Umbraco.Web/Mvc/DisableClientCacheAttribute.cs b/src/Umbraco.Web/Mvc/DisableClientCacheAttribute.cs deleted file mode 100644 index a874d93d7a..0000000000 --- a/src/Umbraco.Web/Mvc/DisableClientCacheAttribute.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Web; -using System.Web.Mvc; - -namespace Umbraco.Web.Mvc -{ - /// - /// Will ensure that client-side cache does not occur by sending the correct response headers - /// - public class DisableClientCacheAttribute : ActionFilterAttribute - { - public override void OnResultExecuting(ResultExecutingContext filterContext) - { - if (filterContext.IsChildAction) base.OnResultExecuting(filterContext); - - filterContext.HttpContext.Response.Cache.SetExpires(DateTime.Now.AddDays(-10)); - filterContext.HttpContext.Response.Cache.SetLastModified(DateTime.Now); - filterContext.HttpContext.Response.Cache.SetValidUntilExpires(false); - filterContext.HttpContext.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches); - filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache); - filterContext.HttpContext.Response.Cache.SetNoStore(); - - base.OnResultExecuting(filterContext); - } - } -} diff --git a/src/Umbraco.Web/Routing/ContentFinderByIdPath.cs b/src/Umbraco.Web/Routing/ContentFinderByIdPath.cs index 447d4e34af..8360ad7e38 100644 --- a/src/Umbraco.Web/Routing/ContentFinderByIdPath.cs +++ b/src/Umbraco.Web/Routing/ContentFinderByIdPath.cs @@ -3,6 +3,7 @@ using Umbraco.Core; using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.Models.PublishedContent; +using System.Globalization; namespace Umbraco.Web.Routing { @@ -53,6 +54,13 @@ namespace Umbraco.Web.Routing if (node != null) { + //if we have a node, check if we have a culture in the query string + if (frequest.UmbracoContext.HttpContext.Request.QueryString.ContainsKey("culture")) + { + //we're assuming it will match a culture, if an invalid one is passed in, an exception will throw (there is no TryGetCultureInfo method), i think this is ok though + frequest.Culture = CultureInfo.GetCultureInfo(frequest.UmbracoContext.HttpContext.Request.QueryString["culture"]); + } + frequest.PublishedContent = node; _logger.Debug("Found node with id={PublishedContentId}", frequest.PublishedContent.Id); } diff --git a/src/Umbraco.Web/UI/JavaScript/AssetInitialization.cs b/src/Umbraco.Web/UI/JavaScript/AssetInitialization.cs index 9c5e0f1ec2..cd7270ac62 100644 --- a/src/Umbraco.Web/UI/JavaScript/AssetInitialization.cs +++ b/src/Umbraco.Web/UI/JavaScript/AssetInitialization.cs @@ -28,7 +28,7 @@ namespace Umbraco.Web.UI.JavaScript return toParse.Split(new[] { DependencyPathRenderer.Delimiter }, StringSplitOptions.RemoveEmptyEntries); } - protected IEnumerable OptimizeAssetCollection(IEnumerable assets, ClientDependencyType assetType, HttpContextBase httpContext) + internal static IEnumerable OptimizeAssetCollection(IEnumerable assets, ClientDependencyType assetType, HttpContextBase httpContext) { if (httpContext == null) throw new ArgumentNullException(nameof(httpContext)); @@ -41,11 +41,11 @@ namespace Umbraco.Web.UI.JavaScript // ike lib/blah/blah.js so we need to turn them into absolutes here if (x.StartsWith("/") == false && Uri.IsWellFormedUriString(x, UriKind.Relative)) { - return (IClientDependencyFile) new BasicFile(assetType) { FilePath = new Uri(requestUrl, x).AbsolutePath }; + return new BasicFile(assetType) { FilePath = new Uri(requestUrl, x).AbsolutePath }; } return assetType == ClientDependencyType.Javascript - ? (IClientDependencyFile) new JavascriptFile(x) + ? new JavascriptFile(x) : (IClientDependencyFile) new CssFile(x); }).ToList(); diff --git a/src/Umbraco.Web/UI/JavaScript/JsInitialization.cs b/src/Umbraco.Web/UI/JavaScript/JsInitialization.cs index 4b3ef62b58..0471b47e8e 100644 --- a/src/Umbraco.Web/UI/JavaScript/JsInitialization.cs +++ b/src/Umbraco.Web/UI/JavaScript/JsInitialization.cs @@ -33,16 +33,20 @@ namespace Umbraco.Web.UI.JavaScript private static readonly Regex Token = new Regex("(\"##\\w+?##\")", RegexOptions.Compiled); /// - /// Processes all found manifest files and outputs the main.js file containing all plugin manifests + /// Gets the JS initialization script to boot the back office application /// - public string GetJavascriptInitialization(HttpContextBase httpContext, IEnumerable umbracoInit, IEnumerable additionalJsFiles = null) + /// + /// + /// + /// The angular module name to boot + /// + /// + public static string GetJavascriptInitialization(HttpContextBase httpContext, IEnumerable scripts, string angularModule) { - var files = GetScriptFiles(httpContext, umbracoInit, additionalJsFiles); - var jarray = new StringBuilder(); jarray.AppendLine("["); var first = true; - foreach (var file in files) + foreach (var file in scripts) { if (first) first = false; else jarray.AppendLine(","); @@ -53,10 +57,22 @@ namespace Umbraco.Web.UI.JavaScript } jarray.Append("]"); - return WriteScript(jarray.ToString(), IOHelper.ResolveUrl(SystemDirectories.Umbraco)); + return WriteScript(jarray.ToString(), IOHelper.ResolveUrl(SystemDirectories.Umbraco), angularModule); } - public IEnumerable GetScriptFiles(HttpContextBase httpContext, IEnumerable umbracoInit, IEnumerable additionalJsFiles = null) + /// + /// Returns a list of optimized script paths for the back office + /// + /// + /// + /// + /// + /// Cache busted/optimized script paths for the back office including manifest and property editor scripts + /// + /// + /// Used to cache bust and optimize script paths for the back office + /// + public IEnumerable OptimizeBackOfficeScriptFiles(HttpContextBase httpContext, IEnumerable umbracoInit, IEnumerable additionalJsFiles = null) { var scripts = new HashSet(); foreach (var script in umbracoInit) @@ -75,6 +91,26 @@ namespace Umbraco.Web.UI.JavaScript return scripts.ToArray(); } + /// + /// Returns a list of optimized script paths + /// + /// + /// + /// + /// + /// Used to cache bust and optimize script paths + /// + public static IEnumerable OptimizeScriptFiles(HttpContextBase httpContext, IEnumerable scriptFiles) + { + var scripts = new HashSet(); + foreach (var script in scriptFiles) + scripts.Add(script); + + scripts = new HashSet(OptimizeAssetCollection(scripts, ClientDependencyType.Javascript, httpContext)); + + return scripts.ToArray(); + } + /// /// Returns the default config as a JArray /// @@ -85,15 +121,25 @@ namespace Umbraco.Web.UI.JavaScript return resources.Where(x => x.Type == JTokenType.String).Select(x => x.ToString()); } + /// + /// Returns the default config as a JArray + /// + /// + internal static IEnumerable GetPreviewInitialization() + { + var resources = JsonConvert.DeserializeObject(Resources.PreviewInitialize); + return resources.Where(x => x.Type == JTokenType.String).Select(x => x.ToString()); + } + /// /// Parses the JsResources.Main and replaces the replacement tokens accordingly. /// /// /// - internal static string WriteScript(params string[] replacements) + internal static string WriteScript(string scripts, string umbracoPath, string angularModule) { var count = 0; - + var replacements = new[] { scripts, umbracoPath, angularModule }; // replace, catering for the special syntax when we have // js function() objects contained in the json diff --git a/src/Umbraco.Web/UI/JavaScript/Main.js b/src/Umbraco.Web/UI/JavaScript/Main.js index 2998a98b6a..8aa431376a 100644 --- a/src/Umbraco.Web/UI/JavaScript/Main.js +++ b/src/Umbraco.Web/UI/JavaScript/Main.js @@ -1,10 +1,12 @@ LazyLoad.js("##JsInitialize##", function () { //we need to set the legacy UmbClientMgr path - UmbClientMgr.setUmbracoPath('"##UmbracoPath##"'); + if ((typeof UmbClientMgr) !== "undefined") { + UmbClientMgr.setUmbracoPath('"##UmbracoPath##"'); + } jQuery(document).ready(function () { - angular.bootstrap(document, ['umbraco']); + angular.bootstrap(document, ['"##AngularModule##"']); }); -}); \ No newline at end of file +}); diff --git a/src/Umbraco.Web/UI/JavaScript/PreviewInitialize.js b/src/Umbraco.Web/UI/JavaScript/PreviewInitialize.js new file mode 100644 index 0000000000..0b0c24f378 --- /dev/null +++ b/src/Umbraco.Web/UI/JavaScript/PreviewInitialize.js @@ -0,0 +1,14 @@ +[ + '../lib/jquery/jquery.min.js', + '../lib/angular/angular.js', + '../lib/underscore/underscore-min.js', + '../lib/umbraco/Extensions.js', + '../js/app.js', + '../js/umbraco.resources.js', + '../js/umbraco.services.js', + '../js/umbraco.interceptors.js', + '../ServerVariables', + '../lib/signalr/jquery.signalR.js', + '../BackOffice/signalr/hubs', + '../js/umbraco.preview.js' +] diff --git a/src/Umbraco.Web/UI/JavaScript/Resources.Designer.cs b/src/Umbraco.Web/UI/JavaScript/Resources.Designer.cs index 4ac359c360..2f320ef839 100644 --- a/src/Umbraco.Web/UI/JavaScript/Resources.Designer.cs +++ b/src/Umbraco.Web/UI/JavaScript/Resources.Designer.cs @@ -63,22 +63,22 @@ namespace Umbraco.Web.UI.JavaScript { /// /// Looks up a localized string similar to [ /// 'lib/jquery/jquery.min.js', - /// 'lib/angular/1.1.5/angular.min.js', + /// 'lib/jquery-ui/jquery-ui.min.js', + /// 'lib/jquery-ui-touch-punch/jquery.ui.touch-punch.js', + /// + /// 'lib/angular/angular.js', /// 'lib/underscore/underscore-min.js', /// /// 'lib/moment/moment.min.js', /// - /// 'lib/jquery-ui/jquery-ui.min.js', - /// 'lib/jquery-ui-touch-punch/jquery.ui.touch-punch.js', + /// 'lib/animejs/anime.min.js', /// - /// 'lib/angular/1.1.5/angular-cookies.min.js', - /// 'lib/angular/1.1.5/angular-mobile.js', - /// 'lib/angular/1.1.5/angular-sanitize.min.js', - /// - /// 'lib/angular/angular-ui-sortable.js', - /// - /// 'lib/angular-dynamic-locale/tmhDynamicLocale.min.js', - /// 'lib [rest of string was truncated]";. + /// 'lib/angular-route/angular-route.js', + /// 'lib/angular-cookies/angular-cookies.js', + /// 'lib/angular-touch/angular-touch.js', + /// 'lib/angular-sanitize/angular-sanitize.js', + /// 'lib/angular-animate/angular-animate.js', + /// [rest of string was truncated]";. /// internal static string JsInitialize { get { @@ -93,10 +93,11 @@ namespace Umbraco.Web.UI.JavaScript { /// /// jQuery(document).ready(function () { /// - /// angular.bootstrap(document, ['umbraco']); + /// angular.bootstrap(document, ['##AngularModule##']); /// /// }); - ///});. + ///}); + ///. /// internal static string Main { get { @@ -104,6 +105,29 @@ namespace Umbraco.Web.UI.JavaScript { } } + /// + /// Looks up a localized string similar to [ + /// '../lib/jquery/jquery.min.js', + /// '../lib/angular/angular.js', + /// '../lib/underscore/underscore-min.js', + /// '../lib/umbraco/Extensions.js', + /// '../js/app.js', + /// '../js/umbraco.resources.js', + /// '../js/umbraco.services.js', + /// '../js/umbraco.interceptors.js', + /// '../ServerVariables', + /// '../lib/signalr/jquery.signalR.js', + /// '../BackOffice/signalr/hubs', + /// '../js/umbraco.canvasdesigner.js' + ///] + ///. + /// + internal static string PreviewInitialize { + get { + return ResourceManager.GetString("PreviewInitialize", resourceCulture); + } + } + /// /// Looks up a localized string similar to //TODO: This would be nicer as an angular module so it can be injected into stuff... that'd be heaps nicer, but ///// how to do that when this is not a regular JS file, it is a server side JS file and RequireJS seems to only want diff --git a/src/Umbraco.Web/UI/JavaScript/Resources.resx b/src/Umbraco.Web/UI/JavaScript/Resources.resx index 2e03928e43..34cea3a2d4 100644 --- a/src/Umbraco.Web/UI/JavaScript/Resources.resx +++ b/src/Umbraco.Web/UI/JavaScript/Resources.resx @@ -124,6 +124,9 @@ Main.js;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + + previewinitialize.js;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + servervariables.js;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 771d4d7e9f..0a7eecb4c8 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -111,6 +111,7 @@ + @@ -258,7 +259,6 @@ - @@ -637,7 +637,6 @@ - @@ -1302,13 +1301,6 @@ - - Preview.aspx - ASPXCodeBehind - - - Preview.aspx - insertMasterpageContent.aspx ASPXCodeBehind @@ -1458,6 +1450,7 @@ + ASPXCodeBehind @@ -1477,7 +1470,6 @@ - ASPXCodeBehind diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/Preview.aspx b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/Preview.aspx deleted file mode 100644 index 1519e540be..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/Preview.aspx +++ /dev/null @@ -1,19 +0,0 @@ -<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="../masterpages/umbracoDialog.Master" CodeBehind="Preview.aspx.cs" Inherits="umbraco.presentation.dialogs.Preview" %> -<%@ Register TagPrefix="cc1" Namespace="Umbraco.Web._Legacy.Controls" %> - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/Preview.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/Preview.aspx.cs deleted file mode 100644 index ea66e32477..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/Preview.aspx.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Web; -using Umbraco.Web; -using Umbraco.Core; -using Umbraco.Web.Composing; - -namespace umbraco.presentation.dialogs -{ - public partial class Preview : Umbraco.Web.UI.Pages.UmbracoEnsuredPage - { - public Preview() - { - CurrentApp = Constants.Applications.Content; - } - - protected void Page_Load(object sender, EventArgs e) - { - var user = UmbracoContext.Security.CurrentUser; - var contentId = Request.GetItemAs("id"); - - var publishedSnapshotService = Current.PublishedSnapshotService; - var previewToken = publishedSnapshotService.EnterPreview(user, contentId); - - UmbracoContext.HttpContext.Response.Cookies.Set(new HttpCookie(Constants.Web.PreviewCookieName, previewToken)); - - // use a numeric url because content may not be in cache and so .Url would fail - Response.Redirect($"../../{contentId}.aspx", true); - } - } -} diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/Preview.aspx.designer.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/Preview.aspx.designer.cs deleted file mode 100644 index 7b419b30e1..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/Preview.aspx.designer.cs +++ /dev/null @@ -1,69 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace umbraco.presentation.dialogs { - - - public partial class Preview { - - /// - /// feedback1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Umbraco.Web._Legacy.Controls.Feedback feedback1; - - /// - /// pane_form control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Umbraco.Web._Legacy.Controls.Pane pane_form; - - /// - /// PropertyPanel1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Umbraco.Web._Legacy.Controls.PropertyPanel PropertyPanel1; - - /// - /// docLit control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Literal docLit; - - /// - /// PropertyPanel2 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Umbraco.Web._Legacy.Controls.PropertyPanel PropertyPanel2; - - /// - /// changeSetUrl control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Literal changeSetUrl; - } -}