Merge branch 'netcore/netcore' into netcore/feature/migrate_custom_view_engines
This commit is contained in:
@@ -52,7 +52,7 @@
|
||||
|
||||
public string MainDomLock { get; set; } = string.Empty;
|
||||
|
||||
public string NoNodesViewPath { get; set; } = "~/config/splashes/NoNodes.cshtml";
|
||||
public string NoNodesViewPath { get; set; } = "~/umbraco/UmbracoWebsite/NoNodes.cshtml";
|
||||
|
||||
public bool IsSmtpServerConfigured => !string.IsNullOrWhiteSpace(Smtp?.Host);
|
||||
|
||||
|
||||
@@ -56,19 +56,11 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Web.Common.Routing
|
||||
|
||||
Assert.AreEqual(1, endpoints.DataSources.Count);
|
||||
var route = endpoints.DataSources.First();
|
||||
Assert.AreEqual(4, route.Endpoints.Count);
|
||||
|
||||
Assert.AreEqual(3, route.Endpoints.Count);
|
||||
|
||||
AssertMinimalBackOfficeRoutes(route);
|
||||
|
||||
var endpoint3 = (RouteEndpoint)route.Endpoints[2];
|
||||
var previewControllerName = ControllerExtensions.GetControllerName<PreviewController>();
|
||||
Assert.AreEqual($"umbraco/{previewControllerName.ToLowerInvariant()}/{{action}}/{{id?}}", endpoint3.RoutePattern.RawText);
|
||||
Assert.AreEqual(Constants.Web.Mvc.BackOfficeArea, endpoint3.RoutePattern.Defaults["area"]);
|
||||
Assert.AreEqual("Index", endpoint3.RoutePattern.Defaults["action"]);
|
||||
Assert.AreEqual(previewControllerName, endpoint3.RoutePattern.Defaults["controller"]);
|
||||
Assert.AreEqual(endpoint3.RoutePattern.Defaults["area"], typeof(PreviewController).GetCustomAttribute<AreaAttribute>(false).RouteValue);
|
||||
|
||||
var endpoint4 = (RouteEndpoint)route.Endpoints[3];
|
||||
var endpoint4 = (RouteEndpoint)route.Endpoints[2];
|
||||
var apiControllerName = ControllerExtensions.GetControllerName<Testing1Controller>();
|
||||
Assert.AreEqual($"umbraco/backoffice/api/{apiControllerName.ToLowerInvariant()}/{{action}}/{{id?}}", endpoint4.RoutePattern.RawText);
|
||||
Assert.IsFalse(endpoint4.RoutePattern.Defaults.ContainsKey("area"));
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Web.Common.Routing
|
||||
Assert.AreEqual(0, endpoints.DataSources.Count);
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Test]
|
||||
public void RuntimeState_Run()
|
||||
{
|
||||
@@ -44,16 +44,25 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Web.Common.Routing
|
||||
var endpoints = new TestRouteBuilder();
|
||||
routes.CreateRoutes(endpoints);
|
||||
|
||||
Assert.AreEqual(1, endpoints.DataSources.Count);
|
||||
Assert.AreEqual(2, endpoints.DataSources.Count);
|
||||
var route = endpoints.DataSources.First();
|
||||
Assert.AreEqual(2, route.Endpoints.Count);
|
||||
|
||||
var endpoint0 = (RouteEndpoint) route.Endpoints[0];
|
||||
Assert.AreEqual($"{routes.GetPreviewHubRoute()}/negotiate", endpoint0.RoutePattern.RawText);
|
||||
Assert.AreEqual($"{routes.GetPreviewHubRoute()}/negotiate", endpoint0.RoutePattern.RawText);
|
||||
var endpoint1 = (RouteEndpoint) route.Endpoints[1];
|
||||
Assert.AreEqual($"{routes.GetPreviewHubRoute()}", endpoint1.RoutePattern.RawText);
|
||||
|
||||
|
||||
var endpoint3 = (RouteEndpoint)endpoints.DataSources.Last().Endpoints[0];
|
||||
var previewControllerName = ControllerExtensions.GetControllerName<PreviewController>();
|
||||
Assert.AreEqual($"umbraco/{previewControllerName.ToLowerInvariant()}/{{action}}/{{id?}}", endpoint3.RoutePattern.RawText);
|
||||
Assert.AreEqual(Constants.Web.Mvc.BackOfficeArea, endpoint3.RoutePattern.Defaults["area"]);
|
||||
Assert.AreEqual("Index", endpoint3.RoutePattern.Defaults["action"]);
|
||||
Assert.AreEqual(previewControllerName, endpoint3.RoutePattern.Defaults["controller"]);
|
||||
Assert.AreEqual(endpoint3.RoutePattern.Defaults["area"], typeof(PreviewController).GetCustomAttribute<AreaAttribute>(false).RouteValue);
|
||||
|
||||
|
||||
}
|
||||
private PreviewRoutes GetRoutes(RuntimeLevel level)
|
||||
{
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
using System.Web.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.Models;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Tests.Common;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.Models;
|
||||
using Umbraco.Web.Mvc;
|
||||
using Umbraco.Web.Website.Controllers;
|
||||
using Umbraco.Web.Website.Models;
|
||||
|
||||
namespace Umbraco.Tests.Web.Mvc
|
||||
namespace Umbraco.Tests.UnitTests.Umbraco.Web.Website.Controllers
|
||||
{
|
||||
[TestFixture]
|
||||
public class RenderNoContentControllerTests
|
||||
@@ -21,7 +21,7 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
var mockUmbracoContext = new Mock<IUmbracoContext>();
|
||||
mockUmbracoContext.Setup(x => x.Content.HasContent()).Returns(true);
|
||||
var mockIOHelper = new Mock<IIOHelper>();
|
||||
var controller = new RenderNoContentController(new TestUmbracoContextAccessor(mockUmbracoContext.Object), mockIOHelper.Object, new GlobalSettings());
|
||||
var controller = new RenderNoContentController(new TestUmbracoContextAccessor(mockUmbracoContext.Object), mockIOHelper.Object, Options.Create(new GlobalSettings()));
|
||||
|
||||
var result = controller.Index() as RedirectResult;
|
||||
|
||||
@@ -39,11 +39,12 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
mockUmbracoContext.Setup(x => x.Content.HasContent()).Returns(false);
|
||||
var mockIOHelper = new Mock<IIOHelper>();
|
||||
mockIOHelper.Setup(x => x.ResolveUrl(It.Is<string>(y => y == UmbracoPathSetting))).Returns(UmbracoPath);
|
||||
var globalSettings = new GlobalSettings()
|
||||
|
||||
var globalSettings = Options.Create(new GlobalSettings()
|
||||
{
|
||||
UmbracoPath = UmbracoPathSetting,
|
||||
NoNodesViewPath = ViewPath,
|
||||
};
|
||||
});
|
||||
var controller = new RenderNoContentController(new TestUmbracoContextAccessor(mockUmbracoContext.Object), mockIOHelper.Object, globalSettings);
|
||||
|
||||
var result = controller.Index() as ViewResult;
|
||||
@@ -208,7 +208,6 @@
|
||||
<Compile Include="Persistence\NPocoTests\PetaPocoCachesTest.cs" />
|
||||
<Compile Include="Routing\RoutesCacheTests.cs" />
|
||||
<Compile Include="Routing\UrlRoutingTestBase.cs" />
|
||||
<Compile Include="Web\Mvc\RenderNoContentControllerTests.cs" />
|
||||
<Compile Include="Web\Mvc\ValidateUmbracoFormRouteStringAttributeTests.cs" />
|
||||
<Compile Include="Web\PublishedContentQueryTests.cs" />
|
||||
<Compile Include="Migrations\Stubs\FiveZeroMigration.cs" />
|
||||
|
||||
@@ -49,7 +49,6 @@ namespace Umbraco.Web.BackOffice.Routing
|
||||
case RuntimeLevel.Run:
|
||||
|
||||
MapMinimalBackOffice(endpoints);
|
||||
endpoints.MapUmbracoRoute<PreviewController>(_umbracoPathSegment, Constants.Web.Mvc.BackOfficeArea, null);
|
||||
AutoRouteBackOfficeControllers(endpoints);
|
||||
break;
|
||||
case RuntimeLevel.BootFailed:
|
||||
|
||||
@@ -5,6 +5,7 @@ using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.Models;
|
||||
using Umbraco.Core.Hosting;
|
||||
using Umbraco.Web.BackOffice.Controllers;
|
||||
using Umbraco.Web.BackOffice.SignalR;
|
||||
using Umbraco.Web.Common.Routing;
|
||||
|
||||
@@ -37,6 +38,7 @@ namespace Umbraco.Web.BackOffice.Routing
|
||||
break;
|
||||
case RuntimeLevel.Run:
|
||||
endpoints.MapHub<PreviewHub>(GetPreviewHubRoute());
|
||||
endpoints.MapUmbracoRoute<PreviewController>(_umbracoPathSegment, Constants.Web.Mvc.BackOfficeArea, null);
|
||||
break;
|
||||
case RuntimeLevel.BootFailed:
|
||||
case RuntimeLevel.Unknown:
|
||||
|
||||
@@ -49,6 +49,7 @@ namespace Umbraco.Web.UI.NetCore
|
||||
}
|
||||
|
||||
app.UseUmbraco();
|
||||
app.UseUmbracoWebsite();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
<ItemGroup>
|
||||
<Folder Include="Views" />
|
||||
<Folder Include="wwwroot\Media" />
|
||||
<Folder Include="umbraco" />
|
||||
<Folder Include="Views" />
|
||||
<Folder Include="wwwroot\Media" />
|
||||
</ItemGroup>
|
||||
@@ -55,6 +54,7 @@
|
||||
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
|
||||
</None>
|
||||
<None Remove="App_Data\**" />
|
||||
<None Include="umbraco\UmbracoWebsite\NoNodes.cshtml" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- We don't want to include the generated files, they will throw a lot of errors -->
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
},
|
||||
"RuntimeMinification": {
|
||||
"dataFolder": "App_Data/TEMP/Smidge",
|
||||
"version": "1"
|
||||
"version": "637395756047165417"
|
||||
},
|
||||
"Security": {
|
||||
"KeepUserLoggedIn": false,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@inherits System.Web.Mvc.WebViewPage<Umbraco.Web.Models.NoNodesViewModel>
|
||||
@model Umbraco.Web.Website.Models.NoNodesViewModel
|
||||
<!doctype html>
|
||||
<html class="no-js" lang="en">
|
||||
<head>
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<title>Umbraco: No Published Content</title>
|
||||
|
||||
<link rel="stylesheet" href="../../Umbraco/assets/css/nonodes.style.min.css" />
|
||||
<link rel="stylesheet" href="../../umbraco/assets/css/nonodes.style.min.css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -137,7 +137,6 @@
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
<None Include="Config\splashes\NoNodes.cshtml" />
|
||||
<None Include="Config\ClientDependency.Release.config">
|
||||
<DependentUpon>ClientDependency.config</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
@@ -351,4 +350,4 @@
|
||||
<Message Text="ConfigFile: $(OriginalFileName) -> $(OutputFileName)" Importance="high" Condition="Exists('$(ModifiedFileName)')" />
|
||||
<Copy SourceFiles="$(ModifiedFileName)" DestinationFiles="$(OutputFileName)" OverwriteReadOnlyFiles="true" SkipUnchangedFiles="false" Condition="Exists('$(ModifiedFileName)')" />
|
||||
</Target>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
using System;
|
||||
using System.Web.Mvc;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Umbraco.Core.Configuration.Models;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Web.Models;
|
||||
using Umbraco.Web.Website.Models;
|
||||
|
||||
namespace Umbraco.Web.Mvc
|
||||
namespace Umbraco.Web.Website.Controllers
|
||||
{
|
||||
public class RenderNoContentController : Controller
|
||||
{
|
||||
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
private readonly IIOHelper _ioHelper;
|
||||
private readonly GlobalSettings _globalSettings;
|
||||
private readonly IOptions<GlobalSettings> _globalSettings;
|
||||
|
||||
public RenderNoContentController(IUmbracoContextAccessor umbracoContextAccessor, IIOHelper ioHelper, GlobalSettings globalSettings)
|
||||
public RenderNoContentController(IUmbracoContextAccessor umbracoContextAccessor, IIOHelper ioHelper, IOptions<GlobalSettings> globalSettings)
|
||||
{
|
||||
_umbracoContextAccessor = umbracoContextAccessor ?? throw new ArgumentNullException(nameof(umbracoContextAccessor));
|
||||
_ioHelper = ioHelper ?? throw new ArgumentNullException(nameof(ioHelper));
|
||||
@@ -31,10 +31,10 @@ namespace Umbraco.Web.Mvc
|
||||
|
||||
var model = new NoNodesViewModel
|
||||
{
|
||||
UmbracoPath = _ioHelper.ResolveUrl(_globalSettings.UmbracoPath),
|
||||
UmbracoPath = _ioHelper.ResolveUrl(_globalSettings.Value.UmbracoPath),
|
||||
};
|
||||
|
||||
return View(_globalSettings.NoNodesViewPath, model);
|
||||
return View(_globalSettings.Value.NoNodesViewPath, model);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ namespace Umbraco.Extensions
|
||||
// typeof(UmbRegisterController),//TODO introduce when migrated
|
||||
// typeof(UmbLoginController),//TODO introduce when migrated
|
||||
typeof(RenderMvcController),
|
||||
typeof(RenderNoContentController),
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using SixLabors.ImageSharp.Web.DependencyInjection;
|
||||
using Umbraco.Web.Website.Routing;
|
||||
|
||||
namespace Umbraco.Extensions
|
||||
{
|
||||
@@ -16,6 +18,18 @@ namespace Umbraco.Extensions
|
||||
// TODO: Since we are dependent on these we need to register them but what happens when we call this multiple times since we are dependent on this for UseUmbracoBackOffice too?
|
||||
app.UseImageSharp();
|
||||
app.UseStaticFiles();
|
||||
app.UseUmbracoNoContentPage();
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
public static IApplicationBuilder UseUmbracoNoContentPage(this IApplicationBuilder app)
|
||||
{
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
var noContentRoutes = app.ApplicationServices.GetRequiredService<NoContentRoutes>();
|
||||
noContentRoutes.CreateRoutes(endpoints);
|
||||
});
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Umbraco.Web.Models
|
||||
namespace Umbraco.Web.Website.Models
|
||||
{
|
||||
public class NoNodesViewModel
|
||||
{
|
||||
52
src/Umbraco.Web.Website/Routing/NoContentRoutes.cs
Normal file
52
src/Umbraco.Web.Website/Routing/NoContentRoutes.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.Models;
|
||||
using Umbraco.Core.Hosting;
|
||||
using Umbraco.Web.Common.Routing;
|
||||
|
||||
namespace Umbraco.Web.Website.Routing
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates route for the no content page
|
||||
/// </summary>
|
||||
public class NoContentRoutes : IAreaRoutes
|
||||
{
|
||||
private readonly IRuntimeState _runtimeState;
|
||||
private readonly string _umbracoPathSegment;
|
||||
|
||||
public NoContentRoutes(
|
||||
IOptions<GlobalSettings> globalSettings,
|
||||
IHostingEnvironment hostingEnvironment,
|
||||
IRuntimeState runtimeState)
|
||||
{
|
||||
_runtimeState = runtimeState;
|
||||
_umbracoPathSegment = globalSettings.Value.GetUmbracoMvcArea(hostingEnvironment);
|
||||
}
|
||||
|
||||
public void CreateRoutes(IEndpointRouteBuilder endpoints)
|
||||
{
|
||||
switch (_runtimeState.Level)
|
||||
{
|
||||
case RuntimeLevel.Install:
|
||||
break;
|
||||
case RuntimeLevel.Upgrade:
|
||||
break;
|
||||
case RuntimeLevel.Run:
|
||||
endpoints.MapControllerRoute(
|
||||
// named consistently
|
||||
Constants.Web.NoContentRouteName,
|
||||
_umbracoPathSegment + "/UmbNoContent",
|
||||
new { controller = "RenderNoContent", action = "Index" }
|
||||
);
|
||||
break;
|
||||
case RuntimeLevel.BootFailed:
|
||||
case RuntimeLevel.Unknown:
|
||||
case RuntimeLevel.Boot:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Extensions;
|
||||
using Umbraco.Web.Website.Routing;
|
||||
using Umbraco.Web.Common.Runtime;
|
||||
using Umbraco.Web.Website.Controllers;
|
||||
|
||||
namespace Umbraco.Web.Website.Runtime
|
||||
{
|
||||
@@ -12,12 +13,12 @@ namespace Umbraco.Web.Website.Runtime
|
||||
{
|
||||
public void Compose(Composition composition)
|
||||
{
|
||||
composition.Services.AddUnique<NoContentRoutes>();
|
||||
|
||||
composition
|
||||
.ComposeWebsiteUmbracoControllers()
|
||||
//.SetDefaultRenderMvcController<RenderMvcController>()// default controller for template views
|
||||
;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,9 +122,6 @@ namespace Umbraco.Web.Runtime
|
||||
);
|
||||
defaultRoute.RouteHandler = new RenderRouteHandler(umbracoContextAccessor, ControllerBuilder.Current.GetControllerFactory(), shortStringHelper);
|
||||
|
||||
// register no content route
|
||||
RouteNoContentController(umbracoPath);
|
||||
|
||||
// register install routes
|
||||
// RouteTable.Routes.RegisterArea<UmbracoInstallArea>();
|
||||
|
||||
@@ -135,14 +132,6 @@ namespace Umbraco.Web.Runtime
|
||||
RoutePluginControllers(globalSettings, surfaceControllerTypes, apiControllerTypes, hostingEnvironment);
|
||||
}
|
||||
|
||||
private static void RouteNoContentController(string umbracoPath)
|
||||
{
|
||||
RouteTable.Routes.MapRoute(
|
||||
Constants.Web.NoContentRouteName,
|
||||
umbracoPath + "/UmbNoContent",
|
||||
new { controller = "RenderNoContent", action = "Index" });
|
||||
}
|
||||
|
||||
private static void RoutePluginControllers(
|
||||
GlobalSettings globalSettings,
|
||||
SurfaceControllerTypeCollection surfaceControllerTypes,
|
||||
|
||||
@@ -151,8 +151,6 @@
|
||||
<Compile Include="WebApi\Filters\EnableOverrideAuthorizationAttribute.cs" />
|
||||
<Compile Include="WebApi\Filters\OverridableAuthorizationAttribute.cs" />
|
||||
<Compile Include="WebAssets\CDF\ClientDependencyRuntimeMinifier.cs" />
|
||||
<Compile Include="Models\NoNodesViewModel.cs" />
|
||||
<Compile Include="Mvc\RenderNoContentController.cs" />
|
||||
<Compile Include="HttpContextAccessorExtensions.cs" />
|
||||
<Compile Include="Logging\OwinLogger.cs" />
|
||||
<Compile Include="Logging\OwinLoggerFactory.cs" />
|
||||
|
||||
Reference in New Issue
Block a user