diff --git a/.gitignore b/.gitignore index 36834898be..b1688a6811 100644 --- a/.gitignore +++ b/.gitignore @@ -170,3 +170,8 @@ build/temp/ /src/Umbraco.Web.UI.NetCore/wwwroot/Media/* /src/Umbraco.Web.UI.NetCore/wwwroot/is-cache/* /src/Umbraco.Tests.Integration/App_Data/* +/src/Umbraco.Web.UI.NetCore/wwwroot/Umbraco/assets/* +/src/Umbraco.Web.UI.NetCore/wwwroot/Umbraco/js/* +/src/Umbraco.Web.UI.NetCore/wwwroot/Umbraco/lib/* +/src/Umbraco.Web.UI.NetCore/wwwroot/Umbraco/views/* +/src/Umbraco.Web.UI.NetCore/wwwroot/App_Data/TEMP/* diff --git a/src/Umbraco.Core/WebAssets/IRuntimeMinifier.cs b/src/Umbraco.Core/WebAssets/IRuntimeMinifier.cs index 3cf2e9d722..5170ce243b 100644 --- a/src/Umbraco.Core/WebAssets/IRuntimeMinifier.cs +++ b/src/Umbraco.Core/WebAssets/IRuntimeMinifier.cs @@ -19,6 +19,12 @@ namespace Umbraco.Core.WebAssets /// /// /// + /// + /// All files must be absolute paths, relative paths will throw + /// + /// + /// Thrown if any of the paths specified are not absolute + /// void CreateCssBundle(string bundleName, params string[] filePaths); /// @@ -35,6 +41,12 @@ namespace Umbraco.Core.WebAssets /// /// /// + /// + /// All files must be absolute paths, relative paths will throw + /// + /// + /// Thrown if any of the paths specified are not absolute + /// void CreateJsBundle(string bundleName, params string[] filePaths); /// diff --git a/src/Umbraco.Infrastructure/WebAssets/BackOfficeWebAssets.cs b/src/Umbraco.Infrastructure/WebAssets/BackOfficeWebAssets.cs index e2364074fb..612e3d6b53 100644 --- a/src/Umbraco.Infrastructure/WebAssets/BackOfficeWebAssets.cs +++ b/src/Umbraco.Infrastructure/WebAssets/BackOfficeWebAssets.cs @@ -44,23 +44,23 @@ namespace Umbraco.Web.WebAssets // Create bundles _runtimeMinifier.CreateCssBundle(UmbracoInitCssBundleName, - "lib/bootstrap-social/bootstrap-social.css", + FormatPaths("lib/bootstrap-social/bootstrap-social.css", "assets/css/umbraco.css", - "lib/font-awesome/css/font-awesome.min.css"); + "lib/font-awesome/css/font-awesome.min.css")); _runtimeMinifier.CreateCssBundle(UmbracoUpgradeCssBundleName, - "assets/css/umbraco.css", + FormatPaths("assets/css/umbraco.css", "lib/bootstrap-social/bootstrap-social.css", - "lib/font-awesome/css/font-awesome.min.css"); + "lib/font-awesome/css/font-awesome.min.css")); _runtimeMinifier.CreateCssBundle(UmbracoPreviewCssBundleName, - "assets/css/canvasdesigner.css"); + FormatPaths("assets/css/canvasdesigner.css")); _runtimeMinifier.CreateJsBundle(UmbracoPreviewJsBundleName, - GetScriptsForPreview().ToArray()); + FormatPaths(GetScriptsForPreview())); _runtimeMinifier.CreateJsBundle(UmbracoTinyMceJsBundleName, - GetScriptsForTinyMce().ToArray()); + FormatPaths(GetScriptsForTinyMce())); var propertyEditorAssets = ScanPropertyEditors() .GroupBy(x => x.AssetType) @@ -68,13 +68,15 @@ namespace Umbraco.Web.WebAssets _runtimeMinifier.CreateJsBundle( UmbracoJsBundleName, - GetScriptsForBackoffice( - propertyEditorAssets.TryGetValue(AssetType.Javascript, out var scripts) ? scripts : Enumerable.Empty())); + FormatPaths( + GetScriptsForBackoffice( + propertyEditorAssets.TryGetValue(AssetType.Javascript, out var scripts) ? scripts : Enumerable.Empty()))); _runtimeMinifier.CreateCssBundle( UmbracoCssBundleName, - GetStylesheetsForBackoffice( - propertyEditorAssets.TryGetValue(AssetType.Css, out var styles) ? styles : Enumerable.Empty())); + FormatPaths( + GetStylesheetsForBackoffice( + propertyEditorAssets.TryGetValue(AssetType.Css, out var styles) ? styles : Enumerable.Empty()))); } /// @@ -92,7 +94,7 @@ namespace Umbraco.Web.WebAssets foreach (var script in propertyEditorScripts) scripts.Add(script); - return new HashSet(FormatPaths(scripts)).ToArray(); + return scripts.ToArray(); } /// @@ -118,27 +120,27 @@ namespace Umbraco.Web.WebAssets foreach (var stylesheet in propertyEditorStyles) stylesheets.Add(stylesheet); - return new HashSet(FormatPaths(stylesheets)).ToArray(); + return stylesheets.ToArray(); } /// /// Returns the scripts used for tinymce /// /// - private IEnumerable GetScriptsForTinyMce() + private string[] GetScriptsForTinyMce() { var resources = JsonConvert.DeserializeObject(Resources.TinyMceInitialize); - return resources.Where(x => x.Type == JTokenType.String).Select(x => x.ToString()); + return resources.Where(x => x.Type == JTokenType.String).Select(x => x.ToString()).ToArray(); } /// /// Returns the scripts used for preview /// /// - private IEnumerable GetScriptsForPreview() + private string[] GetScriptsForPreview() { var resources = JsonConvert.DeserializeObject(Resources.PreviewInitialize); - return resources.Where(x => x.Type == JTokenType.String).Select(x => x.ToString()); + return resources.Where(x => x.Type == JTokenType.String).Select(x => x.ToString()).ToArray(); } /// @@ -146,7 +148,7 @@ namespace Umbraco.Web.WebAssets /// /// /// - private IEnumerable FormatPaths(IEnumerable assets) + private string[] FormatPaths(params string[] assets) { var umbracoPath = _ioHelper.GetUmbracoMvcArea(); @@ -156,7 +158,7 @@ namespace Umbraco.Web.WebAssets // most declarations with be made relative to the /umbraco folder, so things // like lib/blah/blah.js so we need to turn them into absolutes here ? umbracoPath.EnsureStartsWith('/').TrimEnd("/") + x.EnsureStartsWith('/') - : x).ToList(); + : x).ToArray(); } /// diff --git a/src/Umbraco.Infrastructure/WebAssets/PreviewInitialize.js b/src/Umbraco.Infrastructure/WebAssets/PreviewInitialize.js index 0b0c24f378..764e354d5f 100644 --- a/src/Umbraco.Infrastructure/WebAssets/PreviewInitialize.js +++ b/src/Umbraco.Infrastructure/WebAssets/PreviewInitialize.js @@ -1,14 +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' + '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.Common/RuntimeMinification/SmidgeRuntimeMinifier.cs b/src/Umbraco.Web.Common/RuntimeMinification/SmidgeRuntimeMinifier.cs index b56a392bf3..c279fd0280 100644 --- a/src/Umbraco.Web.Common/RuntimeMinification/SmidgeRuntimeMinifier.cs +++ b/src/Umbraco.Web.Common/RuntimeMinification/SmidgeRuntimeMinifier.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Smidge; using Smidge.CompositeFiles; @@ -51,6 +52,9 @@ namespace Umbraco.Web.Common.RuntimeMinification // only issue with creating bundles like this is that we don't have full control over the bundle options, though that could public void CreateCssBundle(string bundleName, params string[] filePaths) { + if (filePaths.Any(f => !f.StartsWith("/") && !f.StartsWith("~/"))) + throw new InvalidOperationException("All file paths must be absolute"); + if (_bundles.Exists(bundleName)) throw new InvalidOperationException($"The bundle name {bundleName} already exists"); @@ -65,6 +69,9 @@ namespace Umbraco.Web.Common.RuntimeMinification public void CreateJsBundle(string bundleName, params string[] filePaths) { + if (filePaths.Any(f => !f.StartsWith("/") && !f.StartsWith("~/"))) + throw new InvalidOperationException("All file paths must be absolute"); + if (_bundles.Exists(bundleName)) throw new InvalidOperationException($"The bundle name {bundleName} already exists"); diff --git a/src/Umbraco.Web.UI.NetCore/HomeController.cs b/src/Umbraco.Web.UI.NetCore/HomeController.cs new file mode 100644 index 0000000000..15d6d055d2 --- /dev/null +++ b/src/Umbraco.Web.UI.NetCore/HomeController.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; + +// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 + +namespace Umbraco.Web.UI.BackOffice +{ + public class HomeController : Controller + { + // GET: // + public IActionResult Index() + { + return View(); + } + } +} diff --git a/src/Umbraco.Web/WebAssets/CDF/ClientDependencyRuntimeMinifier.cs b/src/Umbraco.Web/WebAssets/CDF/ClientDependencyRuntimeMinifier.cs index 528b30088b..cf0e001d3b 100644 --- a/src/Umbraco.Web/WebAssets/CDF/ClientDependencyRuntimeMinifier.cs +++ b/src/Umbraco.Web/WebAssets/CDF/ClientDependencyRuntimeMinifier.cs @@ -25,9 +25,6 @@ namespace Umbraco.Web.WebAssets.CDF private readonly IIOHelper _ioHelper; private readonly ILogger _logger; private readonly IUmbracoVersion _umbracoVersion; - private readonly IManifestParser _manifestParser; - private readonly IGlobalSettings _globalSettings; - private readonly PropertyEditorCollection _propertyEditorCollection; public string CacheBuster => ClientDependencySettings.Instance.Version.ToString(); @@ -35,22 +32,19 @@ namespace Umbraco.Web.WebAssets.CDF IHttpContextAccessor httpContextAccessor, IIOHelper ioHelper, ILogger logger, - IUmbracoVersion umbracoVersion, - IManifestParser manifestParser, - IGlobalSettings globalSettings, - PropertyEditorCollection propertyEditorCollection) + IUmbracoVersion umbracoVersion) { _httpContextAccessor = httpContextAccessor; _ioHelper = ioHelper; _logger = logger; _umbracoVersion = umbracoVersion; - _manifestParser = manifestParser; - _globalSettings = globalSettings; - _propertyEditorCollection = propertyEditorCollection; } public void CreateCssBundle(string bundleName, params string[] filePaths) { + if (filePaths.Any(f => !f.StartsWith("/") && !f.StartsWith("~/"))) + throw new InvalidOperationException("All file paths must be absolute"); + BundleManager.CreateCssBundle( bundleName, filePaths.Select(x => new CssFile(x)).ToArray()); @@ -65,6 +59,9 @@ namespace Umbraco.Web.WebAssets.CDF public void CreateJsBundle(string bundleName, params string[] filePaths) { + if (filePaths.Any(f => !f.StartsWith("/") && !f.StartsWith("~/"))) + throw new InvalidOperationException("All file paths must be absolute"); + BundleManager.CreateJsBundle( bundleName, filePaths.Select(x => new JavascriptFile(x)).ToArray());