From 95a36b3064c186c53b9cc3dc052bdaa131852dfa Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 2 Apr 2020 21:19:42 +1100 Subject: [PATCH] Changes namesspace, fixes cdf registrations, fixes bundle registrations, cleanup --- src/Umbraco.Core/IO/IIOHelper.cs | 3 + .../WebAssets/BackOfficeWebAssets.cs | 55 ++++++++----------- .../WebAssets/PropertyEditorAssetAttribute.cs | 2 +- .../WebAssets/Resources.Designer.cs | 3 +- .../WebAssets/RuntimeMinifierExtensions.cs | 2 +- .../WebAssets/ServerVariablesParser.cs | 3 +- .../WebAssets/WebAssetsComponent.cs | 20 +------ .../WebAssets/WebAssetsComposer.cs | 14 +++++ .../Compose/ModelsBuilderComponent.cs | 2 +- .../JsInitializationTests.cs | 2 +- .../ServerVariablesParserTests.cs | 2 +- .../Controllers/BackOfficeController.cs | 2 +- .../SmidgeRuntimeMinifier.cs | 8 --- .../Umbraco/Views/AuthorizeUpgrade.cshtml | 2 +- .../Umbraco/Views/Default.cshtml | 12 ++-- .../Umbraco/Views/Preview/Index.cshtml | 4 +- .../Editors/BackOfficeController.cs | 2 +- .../Editors/PackageInstallController.cs | 3 - src/Umbraco.Web/Editors/PreviewController.cs | 2 +- .../HtmlHelperBackOfficeExtensions.cs | 2 +- .../Install/Controllers/InstallController.cs | 6 +- .../Runtime/WebInitialComponent.cs | 14 +---- src/Umbraco.Web/Umbraco.Web.csproj | 1 - .../CDF/ClientDependencyRuntimeMinifier.cs | 25 +++------ 24 files changed, 72 insertions(+), 119 deletions(-) rename src/{Umbraco.Web => Umbraco.Infrastructure}/WebAssets/WebAssetsComponent.cs (58%) create mode 100644 src/Umbraco.Infrastructure/WebAssets/WebAssetsComposer.cs diff --git a/src/Umbraco.Core/IO/IIOHelper.cs b/src/Umbraco.Core/IO/IIOHelper.cs index f478b49de6..3795e1905a 100644 --- a/src/Umbraco.Core/IO/IIOHelper.cs +++ b/src/Umbraco.Core/IO/IIOHelper.cs @@ -73,6 +73,9 @@ namespace Umbraco.Core.IO /// /// Gets the root path of the application /// + /// + /// This is (should be) the same as IHostingEnvironment.ApplicationVirtualPath + /// string Root { get; diff --git a/src/Umbraco.Infrastructure/WebAssets/BackOfficeWebAssets.cs b/src/Umbraco.Infrastructure/WebAssets/BackOfficeWebAssets.cs index cdb34ce567..04f725bd5d 100644 --- a/src/Umbraco.Infrastructure/WebAssets/BackOfficeWebAssets.cs +++ b/src/Umbraco.Infrastructure/WebAssets/BackOfficeWebAssets.cs @@ -1,18 +1,16 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Umbraco.Core; using Umbraco.Core.Hosting; +using Umbraco.Core.IO; using Umbraco.Core.Manifest; using Umbraco.Core.PropertyEditors; using Umbraco.Core.WebAssets; -using Umbraco.Infrastructure.WebAssets; -using Umbraco.Web.PropertyEditors; -namespace Umbraco.Web.JavaScript +namespace Umbraco.Web.WebAssets { public class BackOfficeWebAssets { @@ -24,20 +22,20 @@ namespace Umbraco.Web.JavaScript public const string UmbracoTinyMceJsBundleName = "umbraco-tinymce-js"; public const string UmbracoUpgradeCssBundleName = "umbraco-authorize-upgrade-css"; - private readonly IHostingEnvironment _hostingEnvironment; private readonly IRuntimeMinifier _runtimeMinifier; private readonly IManifestParser _parser; + private readonly IIOHelper _ioHelper; private readonly PropertyEditorCollection _propertyEditorCollection; public BackOfficeWebAssets( - IHostingEnvironment hostingEnvironment, IRuntimeMinifier runtimeMinifier, IManifestParser parser, + IIOHelper ioHelper, PropertyEditorCollection propertyEditorCollection) { - _hostingEnvironment = hostingEnvironment; _runtimeMinifier = runtimeMinifier; _parser = parser; + _ioHelper = ioHelper; _propertyEditorCollection = propertyEditorCollection; } @@ -64,33 +62,26 @@ namespace Umbraco.Web.JavaScript _runtimeMinifier.CreateJsBundle(UmbracoTinyMceJsBundleName, GetScriptsForTinyMce().ToArray()); - var propertyEditorAssets = ScanPropertyEditors().GroupBy(x => x.AssetType); - foreach (var assetGroup in propertyEditorAssets) - { - switch (assetGroup.Key) - { - case AssetType.Javascript: - _runtimeMinifier.CreateJsBundle( - UmbracoJsBundleName, - GetScriptsForBackoffice(assetGroup.Select(x => x.FilePath)).ToArray()); - break; - case AssetType.Css: - _runtimeMinifier.CreateCssBundle( - UmbracoCssBundleName, - GetStylesheetsForBackoffice(assetGroup.Select(x => x.FilePath)).ToArray()); - break; - default: - throw new ArgumentOutOfRangeException(); - } - } + var propertyEditorAssets = ScanPropertyEditors() + .GroupBy(x => x.AssetType) + .ToDictionary(x => x.Key, x => x.Select(c => c.FilePath)); + _runtimeMinifier.CreateJsBundle( + UmbracoJsBundleName, + 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())); } /// /// Returns scripts used to load the back office /// /// - private IEnumerable GetScriptsForBackoffice(IEnumerable propertyEditorScripts) + private string[] GetScriptsForBackoffice(IEnumerable propertyEditorScripts) { var umbracoInit = JsInitialization.GetDefaultInitialization(); var scripts = new HashSet(); @@ -101,14 +92,14 @@ namespace Umbraco.Web.JavaScript foreach (var script in propertyEditorScripts) scripts.Add(script); - return new HashSet(FormatPaths(scripts)); + return new HashSet(FormatPaths(scripts)).ToArray(); } /// /// Returns stylesheets used to load the back office /// /// - private IEnumerable GetStylesheetsForBackoffice(IEnumerable propertyEditorStyles) + private string[] GetStylesheetsForBackoffice(IEnumerable propertyEditorStyles) { var stylesheets = new HashSet(); @@ -117,7 +108,7 @@ namespace Umbraco.Web.JavaScript foreach (var stylesheet in propertyEditorStyles) stylesheets.Add(stylesheet); - return new HashSet(FormatPaths(stylesheets)); + return new HashSet(FormatPaths(stylesheets)).ToArray(); } /// @@ -147,12 +138,14 @@ namespace Umbraco.Web.JavaScript /// private IEnumerable FormatPaths(IEnumerable assets) { + var umbracoPath = _ioHelper.GetUmbracoMvcArea(); + return assets .Where(x => x.IsNullOrWhiteSpace() == false) .Select(x => !x.StartsWith("/") && Uri.IsWellFormedUriString(x, UriKind.Relative) // 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 - ? _hostingEnvironment.ApplicationVirtualPath.EnsureStartsWith('/').TrimEnd("/") + x.EnsureStartsWith('/') + ? umbracoPath.EnsureStartsWith('/').TrimEnd("/") + x.EnsureStartsWith('/') : x).ToList(); } diff --git a/src/Umbraco.Infrastructure/WebAssets/PropertyEditorAssetAttribute.cs b/src/Umbraco.Infrastructure/WebAssets/PropertyEditorAssetAttribute.cs index 5c6de949ff..74bb792653 100644 --- a/src/Umbraco.Infrastructure/WebAssets/PropertyEditorAssetAttribute.cs +++ b/src/Umbraco.Infrastructure/WebAssets/PropertyEditorAssetAttribute.cs @@ -1,7 +1,7 @@ using System; using Umbraco.Core.WebAssets; -namespace Umbraco.Web.PropertyEditors +namespace Umbraco.Web.WebAssets { /// /// Indicates that the property editor requires this asset be loaded when the back office is loaded diff --git a/src/Umbraco.Infrastructure/WebAssets/Resources.Designer.cs b/src/Umbraco.Infrastructure/WebAssets/Resources.Designer.cs index ad696497d4..f48386c570 100644 --- a/src/Umbraco.Infrastructure/WebAssets/Resources.Designer.cs +++ b/src/Umbraco.Infrastructure/WebAssets/Resources.Designer.cs @@ -8,7 +8,8 @@ // //------------------------------------------------------------------------------ -namespace Umbraco.Infrastructure.WebAssets { +namespace Umbraco.Web.WebAssets +{ using System; diff --git a/src/Umbraco.Infrastructure/WebAssets/RuntimeMinifierExtensions.cs b/src/Umbraco.Infrastructure/WebAssets/RuntimeMinifierExtensions.cs index e5c7d20ec5..090995879a 100644 --- a/src/Umbraco.Infrastructure/WebAssets/RuntimeMinifierExtensions.cs +++ b/src/Umbraco.Infrastructure/WebAssets/RuntimeMinifierExtensions.cs @@ -3,7 +3,7 @@ using Umbraco.Core.Configuration; using Umbraco.Core.IO; using Umbraco.Core.WebAssets; -namespace Umbraco.Web.JavaScript +namespace Umbraco.Web.WebAssets { public static class RuntimeMinifierExtensions { diff --git a/src/Umbraco.Infrastructure/WebAssets/ServerVariablesParser.cs b/src/Umbraco.Infrastructure/WebAssets/ServerVariablesParser.cs index 07b29d7098..618c3d7703 100644 --- a/src/Umbraco.Infrastructure/WebAssets/ServerVariablesParser.cs +++ b/src/Umbraco.Infrastructure/WebAssets/ServerVariablesParser.cs @@ -1,9 +1,8 @@ using System; using System.Collections.Generic; using Newtonsoft.Json.Linq; -using Umbraco.Infrastructure.WebAssets; -namespace Umbraco.Web.JavaScript +namespace Umbraco.Web.WebAssets { public class ServerVariablesParser { diff --git a/src/Umbraco.Web/WebAssets/WebAssetsComponent.cs b/src/Umbraco.Infrastructure/WebAssets/WebAssetsComponent.cs similarity index 58% rename from src/Umbraco.Web/WebAssets/WebAssetsComponent.cs rename to src/Umbraco.Infrastructure/WebAssets/WebAssetsComponent.cs index 4c60b03b44..54ba82a1fc 100644 --- a/src/Umbraco.Web/WebAssets/WebAssetsComponent.cs +++ b/src/Umbraco.Infrastructure/WebAssets/WebAssetsComponent.cs @@ -1,25 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Umbraco.Core; -using Umbraco.Core.Composing; -using Umbraco.Core.Hosting; -using Umbraco.Core.Manifest; -using Umbraco.Core.PropertyEditors; -using Umbraco.Core.WebAssets; -using Umbraco.Web.JavaScript; -using Umbraco.Web.PropertyEditors; -using Umbraco.Infrastructure.WebAssets; +using Umbraco.Core.Composing; namespace Umbraco.Web.WebAssets { - public sealed class WebAssetsComposer : ComponentComposer - { - } - public sealed class WebAssetsComponent : IComponent { private readonly BackOfficeWebAssets _backOfficeWebAssets; diff --git a/src/Umbraco.Infrastructure/WebAssets/WebAssetsComposer.cs b/src/Umbraco.Infrastructure/WebAssets/WebAssetsComposer.cs new file mode 100644 index 0000000000..bea056c69c --- /dev/null +++ b/src/Umbraco.Infrastructure/WebAssets/WebAssetsComposer.cs @@ -0,0 +1,14 @@ +using Umbraco.Core; +using Umbraco.Core.Composing; + +namespace Umbraco.Web.WebAssets +{ + public sealed class WebAssetsComposer : ComponentComposer + { + public override void Compose(Composition composition) + { + base.Compose(composition); + composition.RegisterUnique(); + } + } +} diff --git a/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComponent.cs b/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComponent.cs index 769cca7317..32cfd3057e 100644 --- a/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComponent.cs +++ b/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComponent.cs @@ -13,8 +13,8 @@ using Umbraco.Core.Services.Implement; using Umbraco.Core.Strings; using Umbraco.ModelsBuilder.Embedded.BackOffice; using Umbraco.Web; -using Umbraco.Web.JavaScript; using Umbraco.Web.Mvc; +using Umbraco.Web.WebAssets; namespace Umbraco.ModelsBuilder.Embedded.Compose { diff --git a/src/Umbraco.Tests/Web/AngularIntegration/JsInitializationTests.cs b/src/Umbraco.Tests/Web/AngularIntegration/JsInitializationTests.cs index 79b331327e..d2ea411db8 100644 --- a/src/Umbraco.Tests/Web/AngularIntegration/JsInitializationTests.cs +++ b/src/Umbraco.Tests/Web/AngularIntegration/JsInitializationTests.cs @@ -1,7 +1,7 @@ using System.Linq; using NUnit.Framework; using Umbraco.Core; -using Umbraco.Web.JavaScript; +using Umbraco.Web.WebAssets; namespace Umbraco.Tests.Web.AngularIntegration { diff --git a/src/Umbraco.Tests/Web/AngularIntegration/ServerVariablesParserTests.cs b/src/Umbraco.Tests/Web/AngularIntegration/ServerVariablesParserTests.cs index 42abecd06b..74ec6e0034 100644 --- a/src/Umbraco.Tests/Web/AngularIntegration/ServerVariablesParserTests.cs +++ b/src/Umbraco.Tests/Web/AngularIntegration/ServerVariablesParserTests.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using NUnit.Framework; using Umbraco.Core; -using Umbraco.Web.JavaScript; +using Umbraco.Web.WebAssets; namespace Umbraco.Tests.Web.AngularIntegration { diff --git a/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs b/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs index fdaf131212..5c65b638c5 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs @@ -6,7 +6,7 @@ using Umbraco.Core.Runtime; using Umbraco.Core.WebAssets; using Umbraco.Web.BackOffice.Filters; using Umbraco.Web.Common.ActionResults; -using Umbraco.Web.JavaScript; +using Umbraco.Web.WebAssets; namespace Umbraco.Web.BackOffice.Controllers { diff --git a/src/Umbraco.Web.Common/RuntimeMinification/SmidgeRuntimeMinifier.cs b/src/Umbraco.Web.Common/RuntimeMinification/SmidgeRuntimeMinifier.cs index 9d6fcc9d22..b56a392bf3 100644 --- a/src/Umbraco.Web.Common/RuntimeMinification/SmidgeRuntimeMinifier.cs +++ b/src/Umbraco.Web.Common/RuntimeMinification/SmidgeRuntimeMinifier.cs @@ -9,9 +9,7 @@ using Smidge.Nuglify; using Umbraco.Core; using Umbraco.Core.Configuration; using Umbraco.Core.Hosting; -using Umbraco.Core.IO; using Umbraco.Core.WebAssets; -using Umbraco.Web.JavaScript; using CssFile = Smidge.Models.CssFile; using JavaScriptFile = Smidge.Models.JavaScriptFile; @@ -19,8 +17,6 @@ namespace Umbraco.Web.Common.RuntimeMinification { public class SmidgeRuntimeMinifier : IRuntimeMinifier { - private readonly IGlobalSettings _globalSettings; - private readonly IIOHelper _ioHelper; private readonly IHostingEnvironment _hostingEnvironment; private readonly ISmidgeConfig _smidgeConfig; private readonly IConfigManipulator _configManipulator; @@ -35,8 +31,6 @@ namespace Umbraco.Web.Common.RuntimeMinification BundleManager bundles, SmidgeHelper smidge, PreProcessPipelineFactory preProcessPipelineFactory, - IGlobalSettings globalSettings, - IIOHelper ioHelper, IHostingEnvironment hostingEnvironment, ISmidgeConfig smidgeConfig, IConfigManipulator configManipulator) @@ -44,8 +38,6 @@ namespace Umbraco.Web.Common.RuntimeMinification _bundles = bundles; _smidge = smidge; _preProcessPipelineFactory = preProcessPipelineFactory; - _globalSettings = globalSettings; - _ioHelper = ioHelper; _hostingEnvironment = hostingEnvironment; _smidgeConfig = smidgeConfig; _configManipulator = configManipulator; diff --git a/src/Umbraco.Web.UI/Umbraco/Views/AuthorizeUpgrade.cshtml b/src/Umbraco.Web.UI/Umbraco/Views/AuthorizeUpgrade.cshtml index 89cf6f9136..8321256d0a 100644 --- a/src/Umbraco.Web.UI/Umbraco/Views/AuthorizeUpgrade.cshtml +++ b/src/Umbraco.Web.UI/Umbraco/Views/AuthorizeUpgrade.cshtml @@ -1,7 +1,7 @@ @using Umbraco.Core @using Umbraco.Web.Composing @using Umbraco.Web -@using Umbraco.Web.JavaScript +@using Umbraco.Web.WebAssets @inherits System.Web.Mvc.WebViewPage @{ diff --git a/src/Umbraco.Web.UI/Umbraco/Views/Default.cshtml b/src/Umbraco.Web.UI/Umbraco/Views/Default.cshtml index 96c26e9848..135d01755f 100644 --- a/src/Umbraco.Web.UI/Umbraco/Views/Default.cshtml +++ b/src/Umbraco.Web.UI/Umbraco/Views/Default.cshtml @@ -1,7 +1,7 @@ @using Umbraco.Core @using Umbraco.Web.Composing @using Umbraco.Web -@using Umbraco.Web.JavaScript +@using Umbraco.Web.WebAssets @inherits WebViewPage @@ -72,9 +72,8 @@ - + @@ -102,9 +101,8 @@ parent-scope="overlay.parentScope"> - + @Html.BareMinimumServerVariablesScript(Url, Url.Action("ExternalLogin", "BackOffice", new { area = ViewData.GetUmbracoPath() }), Model.Features, Model.GlobalSettings, Model.UmbracoVersion, Model.ContentSettings, Model.IOHelper, Model.TreeCollection, Model.HttpContextAccessor, Model.HostingEnvironment, Model.RuntimeSettings, Model.SecuritySettings, Current.RuntimeMinifier) diff --git a/src/Umbraco.Web.UI/Umbraco/Views/Preview/Index.cshtml b/src/Umbraco.Web.UI/Umbraco/Views/Preview/Index.cshtml index 2c0e272dbd..43558816a4 100644 --- a/src/Umbraco.Web.UI/Umbraco/Views/Preview/Index.cshtml +++ b/src/Umbraco.Web.UI/Umbraco/Views/Preview/Index.cshtml @@ -1,5 +1,5 @@ @using Umbraco.Web.Composing -@using Umbraco.Web.JavaScript +@using Umbraco.Web.WebAssets @inherits System.Web.Mvc.WebViewPage @{ @@ -16,7 +16,7 @@ - @Html.Raw(runtimeMinifier.RenderCssHere(BackOfficeWebAssets.UmbracoPreviewCssBundleName)) + @Html.Raw(runtimeMinifier.RenderCssHere(BackOfficeWebAssets.UmbracoPreviewCssBundleName)) diff --git a/src/Umbraco.Web/Editors/BackOfficeController.cs b/src/Umbraco.Web/Editors/BackOfficeController.cs index f2133256e2..22c744621a 100644 --- a/src/Umbraco.Web/Editors/BackOfficeController.cs +++ b/src/Umbraco.Web/Editors/BackOfficeController.cs @@ -21,7 +21,6 @@ using Umbraco.Web.Models; using Umbraco.Web.Mvc; using Umbraco.Core.Services; using Umbraco.Web.Features; -using Umbraco.Web.JavaScript; using Umbraco.Web.Models.Identity; using Umbraco.Web.Security; using Constants = Umbraco.Core.Constants; @@ -33,6 +32,7 @@ using Umbraco.Core.IO; using Umbraco.Core.Runtime; using Umbraco.Core.WebAssets; using Umbraco.Web.Trees; +using Umbraco.Web.WebAssets; namespace Umbraco.Web.Editors { diff --git a/src/Umbraco.Web/Editors/PackageInstallController.cs b/src/Umbraco.Web/Editors/PackageInstallController.cs index 9d15dc2841..650050ff66 100644 --- a/src/Umbraco.Web/Editors/PackageInstallController.cs +++ b/src/Umbraco.Web/Editors/PackageInstallController.cs @@ -17,12 +17,9 @@ using Umbraco.Core.Models.Packaging; using Umbraco.Net; using Umbraco.Core.Packaging; using Umbraco.Core.Persistence; -using Umbraco.Core.Runtime; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Core.WebAssets; -using Umbraco.Net; -using Umbraco.Web.JavaScript; using Umbraco.Web.Models; using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Mvc; diff --git a/src/Umbraco.Web/Editors/PreviewController.cs b/src/Umbraco.Web/Editors/PreviewController.cs index 7c4305d038..ed4746f342 100644 --- a/src/Umbraco.Web/Editors/PreviewController.cs +++ b/src/Umbraco.Web/Editors/PreviewController.cs @@ -14,10 +14,10 @@ using Umbraco.Core.Services; using Umbraco.Core.WebAssets; using Umbraco.Web.Composing; using Umbraco.Web.Features; -using Umbraco.Web.JavaScript; using Umbraco.Web.Mvc; using Umbraco.Web.PublishedCache; using Umbraco.Web.Trees; +using Umbraco.Web.WebAssets; using Constants = Umbraco.Core.Constants; namespace Umbraco.Web.Editors diff --git a/src/Umbraco.Web/HtmlHelperBackOfficeExtensions.cs b/src/Umbraco.Web/HtmlHelperBackOfficeExtensions.cs index eecdf1a816..c20b82a6de 100644 --- a/src/Umbraco.Web/HtmlHelperBackOfficeExtensions.cs +++ b/src/Umbraco.Web/HtmlHelperBackOfficeExtensions.cs @@ -14,9 +14,9 @@ using Umbraco.Core.WebAssets; using Umbraco.Web.Composing; using Umbraco.Web.Editors; using Umbraco.Web.Features; -using Umbraco.Web.JavaScript; using Umbraco.Web.Models; using Umbraco.Web.Trees; +using Umbraco.Web.WebAssets; namespace Umbraco.Web { diff --git a/src/Umbraco.Web/Install/Controllers/InstallController.cs b/src/Umbraco.Web/Install/Controllers/InstallController.cs index b2e9647d61..02824489ee 100644 --- a/src/Umbraco.Web/Install/Controllers/InstallController.cs +++ b/src/Umbraco.Web/Install/Controllers/InstallController.cs @@ -1,13 +1,9 @@ -using System; -using System.Web.Mvc; +using System.Web.Mvc; using Umbraco.Core; -using Umbraco.Web.Composing; using Umbraco.Core.Configuration; using Umbraco.Core.IO; using Umbraco.Core.Logging; -using Umbraco.Core.Runtime; using Umbraco.Core.WebAssets; -using Umbraco.Web.JavaScript; using Umbraco.Web.Mvc; using Umbraco.Web.Security; diff --git a/src/Umbraco.Web/Runtime/WebInitialComponent.cs b/src/Umbraco.Web/Runtime/WebInitialComponent.cs index 9e317e5114..37d989edef 100644 --- a/src/Umbraco.Web/Runtime/WebInitialComponent.cs +++ b/src/Umbraco.Web/Runtime/WebInitialComponent.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Collections.Specialized; -using System.IO; using System.Linq; using System.Web.Http; using System.Web.Http.Dispatcher; @@ -10,7 +8,6 @@ using System.Web.Routing; using Umbraco.Core; using Umbraco.Core.Composing; using Umbraco.Core.Configuration; -using Umbraco.Core.Hosting; using Umbraco.Core.Strings; using Umbraco.Core.IO; using Umbraco.Web.Install; @@ -27,33 +24,24 @@ namespace Umbraco.Web.Runtime private readonly IUmbracoContextAccessor _umbracoContextAccessor; private readonly SurfaceControllerTypeCollection _surfaceControllerTypes; private readonly UmbracoApiControllerTypeCollection _apiControllerTypes; - private readonly IHostingSettings _hostingSettings; private readonly IGlobalSettings _globalSettings; - private readonly IHostingEnvironment _hostingEnvironment; private readonly IIOHelper _ioHelper; private readonly IShortStringHelper _shortStringHelper; - private readonly IRuntimeSettings _settings; public WebInitialComponent( IUmbracoContextAccessor umbracoContextAccessor, SurfaceControllerTypeCollection surfaceControllerTypes, UmbracoApiControllerTypeCollection apiControllerTypes, - IHostingSettings hostingSettings, IGlobalSettings globalSettings, - IHostingEnvironment hostingEnvironment, IIOHelper ioHelper, - IShortStringHelper shortStringHelper, - IRuntimeSettings settings) + IShortStringHelper shortStringHelper) { _umbracoContextAccessor = umbracoContextAccessor; _surfaceControllerTypes = surfaceControllerTypes; _apiControllerTypes = apiControllerTypes; - _hostingSettings = hostingSettings; _globalSettings = globalSettings; - _hostingEnvironment = hostingEnvironment; _ioHelper = ioHelper; _shortStringHelper = shortStringHelper; - _settings = settings; } public void Initialize() diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 596b80e0fd..407af7d366 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -547,7 +547,6 @@ Component - diff --git a/src/Umbraco.Web/WebAssets/CDF/ClientDependencyRuntimeMinifier.cs b/src/Umbraco.Web/WebAssets/CDF/ClientDependencyRuntimeMinifier.cs index 6f5c3ad8f9..528b30088b 100644 --- a/src/Umbraco.Web/WebAssets/CDF/ClientDependencyRuntimeMinifier.cs +++ b/src/Umbraco.Web/WebAssets/CDF/ClientDependencyRuntimeMinifier.cs @@ -5,18 +5,15 @@ using System.Linq; using System.Reflection; using System.Threading.Tasks; using System.Web; -using System.Web.Mvc; using ClientDependency.Core; using ClientDependency.Core.CompositeFiles; using ClientDependency.Core.Config; -using ClientDependency.Core.Mvc; using Umbraco.Core.Configuration; using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Core.Manifest; using Umbraco.Core.PropertyEditors; using Umbraco.Core.WebAssets; -using Umbraco.Web.JavaScript; using CssFile = ClientDependency.Core.CssFile; using JavascriptFile = ClientDependency.Core.JavascriptFile; @@ -87,13 +84,9 @@ namespace Umbraco.Web.WebAssets.CDF var assetType = bundleFiles[0].DependencyType == ClientDependencyType.Css ? AssetType.Css : AssetType.Javascript; - // get the output string for these registrations which will be processed by CDF correctly to stagger the output based - // on internal vs external resources. The output will be delimited based on our custom Umbraco.Web.JavaScript.DependencyPathRenderer - var dependencies = new List(); - // This is a hack on CDF so that we can resolve CDF urls directly since that isn't directly supported by the lib var renderer = ClientDependencySettings.Instance.MvcRendererCollection["Umbraco.DependencyPathRenderer"]; - renderer.RegisterDependencies(dependencies, new HashSet(), out var scripts, out var stylesheets, _httpContextAccessor.HttpContext); + renderer.RegisterDependencies(bundleFiles, new HashSet(), out var scripts, out var stylesheets, _httpContextAccessor.HttpContext); var toParse = assetType == AssetType.Javascript ? scripts : stylesheets; return Task.FromResult>(toParse.Split(new[] { DependencyPathRenderer.Delimiter }, StringSplitOptions.RemoveEmptyEntries)); @@ -133,28 +126,26 @@ namespace Umbraco.Web.WebAssets.CDF new HashSet(), out var jsOutput, out var cssOutput, _httpContextAccessor.GetRequiredHttpContext()); - return HttpUtility.HtmlEncode(assetType == AssetType.Css ? cssOutput : jsOutput); + return assetType == AssetType.Css ? cssOutput : jsOutput; } private IEnumerable GetCssBundleFiles(string bundleName) { - // the result of this is internal too, so use dynamic - dynamic bundle = typeof(BundleManager) + // internal methods needs reflection + var bundle = typeof(BundleManager) .GetMethod("GetCssBundle", BindingFlags.NonPublic | BindingFlags.Static) .Invoke(null, new object[] { bundleName }); - if (bundle == null) return null; - IEnumerable bundleFiles = bundle.Files; + var bundleFiles = (IEnumerable) bundle?.GetType().GetProperty("Files").GetValue(bundle, null); return bundleFiles; } private IEnumerable GetJsBundleFiles(string bundleName) { - // the result of this is internal too, so use dynamic - dynamic bundle = typeof(BundleManager) + // internal methods needs reflection + var bundle = typeof(BundleManager) .GetMethod("GetJsBundle", BindingFlags.NonPublic | BindingFlags.Static) .Invoke(null, new object[] { bundleName }); - if (bundle == null) return null; - IEnumerable bundleFiles = bundle.Files; + var bundleFiles = (IEnumerable)bundle?.GetType().GetProperty("Files").GetValue(bundle, null); return bundleFiles; }