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/common/directives/components/content/edit.controller.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js
index afc3e45be7..2c32f4a9ca 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
@@ -471,10 +471,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', '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 redirect = Umbraco.Sys.ServerVariables.umbracoSettings.umbracoPath + '/preview/?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
diff --git a/src/Umbraco.Web.UI.Client/src/canvasdesigner/canvasdesigner.controller.js b/src/Umbraco.Web.UI.Client/src/preview/preview.controller.js
similarity index 66%
rename from src/Umbraco.Web.UI.Client/src/canvasdesigner/canvasdesigner.controller.js
rename to src/Umbraco.Web.UI.Client/src/preview/preview.controller.js
index 697599b97d..b3525613ef 100644
--- a/src/Umbraco.Web.UI.Client/src/canvasdesigner/canvasdesigner.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/preview/preview.controller.js
@@ -3,10 +3,10 @@
/* 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 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;
@@ -18,7 +18,28 @@ var app = angular.module("Umbraco.canvasdesigner", ['umbraco.resources', 'umbrac
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
- var isInit = $location.search().init;
+ 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
@@ -45,6 +66,7 @@ var app = angular.module("Umbraco.canvasdesigner", ['umbraco.resources', 'umbrac
$scope.pageId = pageId;
$scope.pageUrl = "frame?id=" + pageId;
+
$scope.valueAreLoaded = false;
$scope.devices = [
{ name: "desktop", css: "desktop", icon: "icon-display", title: "Desktop" },
@@ -73,8 +95,9 @@ var app = angular.module("Umbraco.canvasdesigner", ['umbraco.resources', 'umbrac
window.top.location.href = "../endPreview.aspx?redir=%2f" + $scope.pageId;
};
- $scope.onFrameLoaded = function () {
+ $scope.onFrameLoaded = function (iframe) {
$scope.frameLoaded = true;
+ configureSignalR(iframe);
}
/*****************************************************************************/
@@ -91,54 +114,35 @@ var app = angular.module("Umbraco.canvasdesigner", ['umbraco.resources', 'umbrac
.component('previewIFrame', {
- template: "
",
- controller: function ($element) {
+ template: "",
+ controller: function ($element, $scope, angularHelper) {
var vm = this;
- vm.$onInit = function () {
-
- ////TODO: Move this to the callback on the controller
-
- //// 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 iframe = ($element.context.contentWindow || $element.context.contentDocument);
- // 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."); });
- };
-
vm.$postLink = function () {
- $element.find("#resultFrame").on("load", function () {
- var iframe = $element.find("#resultFrame").get(0);
- hideUmbracoPreviewBadge(iframe);
- vm.onLoaded();
- scope.$apply();
- });
+ 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.document.getElementById("umbracoPreviewBadge")) {
- iframe.document.getElementById("umbracoPreviewBadge").style.display = "none";
+ if (iframe && iframe.contentDocument && iframe.contentDocument.getElementById("umbracoPreviewBadge")) {
+ iframe.contentDocument.getElementById("umbracoPreviewBadge").style.display = "none";
}
};
},
controllerAs: "vm",
bindings: {
- src: "@",
+ src: "<",
onLoaded: "&"
}
diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj
index e277a40319..4df862dcb3 100644
--- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj
+++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj
@@ -426,18 +426,7 @@
-
-
-
-
-
-
-
-
-
-
-
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 21b7d3cbb2..4924985689 100644
--- a/src/Umbraco.Web.UI/Umbraco/Views/Preview/Index.cshtml
+++ b/src/Umbraco.Web.UI/Umbraco/Views/Preview/Index.cshtml
@@ -1,16 +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)
@@ -18,8 +32,8 @@
@Html.Partial(Model.PreviewExtendedHeaderView)
}
-
+
-
+
+
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
-
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/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 f5e9074e7d..94979dfd63 100644
--- a/src/Umbraco.Web/Editors/PreviewController.cs
+++ b/src/Umbraco.Web/Editors/PreviewController.cs
@@ -1,6 +1,7 @@
using System;
using System.Web;
using System.Web.Mvc;
+using System.Web.UI;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Web.Composing;
@@ -8,6 +9,7 @@ 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
@@ -29,13 +31,10 @@ namespace Umbraco.Web.Editors
}
[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)
{
@@ -49,6 +48,20 @@ namespace Umbraco.Web.Editors
return View(_globalSettings.Path.EnsureEndsWith('/') + "Views/Preview/" + "Index.cshtml", model);
}
+ ///
+ /// Returns the JavaScript file for preview
+ ///
+ ///
+ [MinifyJavaScriptResult(Order = 0)]
+ [OutputCache(Order = 1, VaryByParam = "none", Location = OutputCacheLocation.Server, Duration = 5000)]
+ public JavaScriptResult Application()
+ {
+ 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
///
@@ -68,11 +81,11 @@ namespace Umbraco.Web.Editors
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");
- }
+ ////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..83682c8573 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,13 @@ namespace Umbraco.Web.Mvc
return;
}
+ if (filterContext.IsChildAction)
+ {
+ 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/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 1e1fab758a..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 @@
-
@@ -1451,6 +1450,7 @@
+
ASPXCodeBehind