Merge branch 'v9/dev' into v10/feature/merge-v9-dev
# Conflicts: # build/templates/UmbracoPackage/.template.config/template.json # build/templates/UmbracoProject/.template.config/template.json # src/Directory.Build.props # src/Umbraco.Core/Actions/ActionAssignDomain.cs # src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.Services.cs # src/Umbraco.Web.BackOffice/Controllers/AuthenticationController.cs # src/Umbraco.Web.BackOffice/DependencyInjection/UmbracoBuilderExtensions.cs # src/Umbraco.Web.Common/Extensions/ApplicationBuilderExtensions.cs
This commit is contained in:
@@ -1,18 +1,20 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Dazinator.Extensions.FileProviders.PrependBasePath;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Serilog.Context;
|
||||
using StackExchange.Profiling;
|
||||
using Umbraco.Cms.Core;
|
||||
using Umbraco.Cms.Core.Configuration.Models;
|
||||
using Umbraco.Cms.Core.Hosting;
|
||||
using Umbraco.Cms.Core.Logging.Serilog.Enrichers;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Cms.Web.Common.ApplicationBuilder;
|
||||
using Umbraco.Cms.Web.Common.Middleware;
|
||||
using Umbraco.Cms.Web.Common.Plugins;
|
||||
using IHostingEnvironment = Umbraco.Cms.Core.Hosting.IHostingEnvironment;
|
||||
|
||||
namespace Umbraco.Extensions
|
||||
{
|
||||
@@ -94,7 +96,8 @@ namespace Umbraco.Extensions
|
||||
throw new ArgumentNullException(nameof(app));
|
||||
}
|
||||
|
||||
if (!app.UmbracoCanBoot()) return app;
|
||||
if (!app.UmbracoCanBoot())
|
||||
return app;
|
||||
|
||||
app.UseMiddleware<UmbracoRequestLoggingMiddleware>();
|
||||
|
||||
@@ -109,25 +112,21 @@ namespace Umbraco.Extensions
|
||||
public static IApplicationBuilder UseUmbracoPluginsStaticFiles(this IApplicationBuilder app)
|
||||
{
|
||||
var hostingEnvironment = app.ApplicationServices.GetRequiredService<IHostingEnvironment>();
|
||||
var umbracoPluginSettings = app.ApplicationServices.GetRequiredService<IOptionsMonitor<UmbracoPluginSettings>>();
|
||||
|
||||
var pluginFolder = hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.AppPlugins);
|
||||
|
||||
// Ensure the plugin folder exists
|
||||
Directory.CreateDirectory(pluginFolder);
|
||||
|
||||
var fileProvider = new UmbracoPluginPhysicalFileProvider(
|
||||
pluginFolder,
|
||||
umbracoPluginSettings);
|
||||
|
||||
app.UseStaticFiles(new StaticFileOptions
|
||||
if (Directory.Exists(pluginFolder))
|
||||
{
|
||||
FileProvider = fileProvider,
|
||||
RequestPath = Constants.SystemDirectories.AppPlugins
|
||||
});
|
||||
var umbracoPluginSettings = app.ApplicationServices.GetRequiredService<IOptionsMonitor<UmbracoPluginSettings>>();
|
||||
|
||||
var pluginFileProvider = new UmbracoPluginPhysicalFileProvider(
|
||||
pluginFolder,
|
||||
umbracoPluginSettings);
|
||||
|
||||
IWebHostEnvironment webHostEnvironment = app.ApplicationServices.GetService<IWebHostEnvironment>();
|
||||
webHostEnvironment.WebRootFileProvider = webHostEnvironment.WebRootFileProvider.ConcatComposite(new PrependBasePathFileProvider(Constants.SystemDirectories.AppPlugins, pluginFileProvider));
|
||||
}
|
||||
|
||||
return app;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
19
src/Umbraco.Web.Common/Extensions/FileProviderExtensions.cs
Normal file
19
src/Umbraco.Web.Common/Extensions/FileProviderExtensions.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
|
||||
namespace Umbraco.Extensions
|
||||
{
|
||||
internal static class FileProviderExtensions
|
||||
{
|
||||
public static IFileProvider ConcatComposite(this IFileProvider fileProvider, params IFileProvider[] fileProviders)
|
||||
{
|
||||
var existingFileProviders = fileProvider switch
|
||||
{
|
||||
CompositeFileProvider compositeFileProvider => compositeFileProvider.FileProviders,
|
||||
_ => new[] { fileProvider }
|
||||
};
|
||||
|
||||
return new CompositeFileProvider(existingFileProviders.Concat(fileProviders));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.Extensions;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Umbraco.Cms.Core.Configuration.Models;
|
||||
using Umbraco.Cms.Core.Routing;
|
||||
|
||||
namespace Umbraco.Extensions
|
||||
@@ -107,5 +110,31 @@ namespace Umbraco.Extensions
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the application URI, will use the one specified in settings if present
|
||||
/// </summary>
|
||||
public static Uri GetApplicationUri(this HttpRequest request, WebRoutingSettings routingSettings)
|
||||
{
|
||||
if (request == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(request));
|
||||
}
|
||||
|
||||
if (routingSettings == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(routingSettings));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(routingSettings.UmbracoApplicationUrl))
|
||||
{
|
||||
var requestUri = new Uri(request.GetDisplayUrl());
|
||||
|
||||
// Create a new URI with the relative uri as /, this ensures that only the base path is returned.
|
||||
return new Uri(requestUri, "/");
|
||||
}
|
||||
|
||||
return new Uri(routingSettings.UmbracoApplicationUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user