Introduced Umbraco.Web.UI.Backoffice

This commit is contained in:
Bjarke Berg
2020-02-18 08:32:06 +01:00
parent 2b8be2cf00
commit 5e79585149
20 changed files with 298 additions and 38 deletions

View File

@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;
using Umbraco.Core.Composing;
using Umbraco.Core.Composing;
using Umbraco.Web.Dashboards;
namespace Umbraco.Core
{
@@ -16,6 +14,13 @@ namespace Umbraco.Core
public static ComponentCollectionBuilder Components(this Composition composition)
=> composition.WithCollectionBuilder<ComponentCollectionBuilder>();
/// <summary>
/// Gets the backoffice dashboards collection builder.
/// </summary>
/// <param name="composition">The composition.</param>
public static DashboardCollectionBuilder Dashboards(this Composition composition)
=> composition.WithCollectionBuilder<DashboardCollectionBuilder>();
#endregion
}
}

View File

@@ -109,10 +109,6 @@
<Project>{3ae7bf57-966b-45a5-910a-954d7c554441}</Project>
<Name>Umbraco.Infrastructure</Name>
</ProjectReference>
<ProjectReference Include="..\Umbraco.Web.BackOffice\Umbraco.Web.BackOffice.csproj">
<Project>{9b95eef7-63fe-4432-8c63-166be9c1a929}</Project>
<Name>Umbraco.Web.BackOffice</Name>
</ProjectReference>
<ProjectReference Include="..\Umbraco.Web\Umbraco.Web.csproj">
<Project>{651e1350-91b6-44b7-bd60-7207006d7003}</Project>
<Name>Umbraco.Web</Name>

View File

@@ -0,0 +1,55 @@
using System;
using Microsoft.AspNetCore.Hosting;
using Umbraco.Core;
using Umbraco.Core.Configuration;
namespace Umbraco.Web.BackOffice.AspNetCore
{
public class AspNetCoreHostingEnvironment : Umbraco.Core.Hosting.IHostingEnvironment
{
private readonly IHostingSettings _hostingSettings;
public AspNetCoreHostingEnvironment(IHostingSettings hostingSettings, IHostingEnvironment hostingEnvironment)
{
// _hostingSettings = hostingSettings ?? throw new ArgumentNullException(nameof(hostingSettings));
// SiteName = hostingEnvironment.ApplicationName;
// ApplicationId = hostingEnvironment.ApplicationID;
// ApplicationPhysicalPath = hostingEnvironment.WebRootPath;
// ApplicationVirtualPath = hostingEnvironment.ApplicationVirtualPath;
// CurrentDomainId = AppDomain.CurrentDomain.Id;
// IISVersion = HttpRuntime.IISVersion;
}
public string SiteName { get; }
public string ApplicationId { get; }
public string ApplicationPhysicalPath { get; }
public string LocalTempPath { get; }
public string ApplicationVirtualPath { get; }
public int CurrentDomainId { get; }
public bool IsDebugMode { get; }
public bool IsHosted { get; }
public Version IISVersion { get; }
public string MapPath(string path) => throw new NotImplementedException();
public string ToAbsolute(string virtualPath, string root) => throw new NotImplementedException();
public void LazyRestartApplication()
{
throw new NotImplementedException();
}
public void RegisterObject(IRegisteredObject registeredObject)
{
throw new NotImplementedException();
}
public void UnregisterObject(IRegisteredObject registeredObject)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Web;
using Microsoft.AspNetCore.Http;
namespace Umbraco.Web.BackOffice.AspNetCore
{
internal class AspNetCoreHttpContextAccessor //: IHttpContextAccessor
{
private readonly IHttpContextAccessor _httpContextAccessor;
public AspNetCoreHttpContextAccessor(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor;
}
public HttpContext HttpContext => _httpContextAccessor.HttpContext;
}
}

View File

@@ -0,0 +1,18 @@
using System;
using Microsoft.AspNetCore.Http;
using Umbraco.Net;
namespace Umbraco.Web.BackOffice.AspNetCore
{
internal class AspNetIpResolver : IIpResolver
{
private readonly IHttpContextAccessor _httpContextAccessor;
public AspNetIpResolver(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor;
}
public string GetCurrentRequestIpAddress() => _httpContextAccessor?.HttpContext?.Connection?.RemoteIpAddress?.ToString() ?? String.Empty;
}
}

View File

@@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Http;
using Umbraco.Net;
namespace Umbraco.Web.BackOffice.AspNetCore
{
internal class AspNetSessionIdResolver : ISessionIdResolver
{
private readonly IHttpContextAccessor _httpContextAccessor;
public AspNetSessionIdResolver(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor;
}
public string SessionId => _httpContextAccessor?.HttpContext.Session?.Id;
}
}

View File

@@ -0,0 +1,18 @@
using System;
using Microsoft.AspNetCore.Builder;
namespace Umbraco.Web.BackOffice.AspNetCore
{
public static class UmbracoBackOfficeApplicationBuilderExtensions
{
public static IApplicationBuilder UseUmbracoBackOffice(this IApplicationBuilder builder)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
return builder.UseMiddleware<UmbracoMiddleware>();
}
}
}

View File

@@ -0,0 +1,13 @@
using Microsoft.Extensions.DependencyInjection;
namespace Umbraco.Web.BackOffice.AspNetCore
{
public static class UmbracoBackOfficeServiceCollectionExtensions
{
public static IServiceCollection AddUmbracoBackOffice(this IServiceCollection services)
{
return services;
}
}
}

View File

@@ -0,0 +1,21 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
namespace Umbraco.Web.BackOffice.AspNetCore
{
public class UmbracoMiddleware
{
private readonly RequestDelegate _next;
public UmbracoMiddleware(RequestDelegate next)
{
_next = next;
}
public async Task InvokeAsync(HttpContext context)
{
// Call the next delegate/middleware in the pipeline
await _next(context);
}
}
}

View File

@@ -1,24 +0,0 @@
using Umbraco.Core.Composing;
using Umbraco.Web.Dashboards;
// ReSharper disable once CheckNamespace
namespace Umbraco.Web
{
/// <summary>
/// Provides extension methods to the <see cref="Composition"/> class.
/// </summary>
public static class WebCompositionExtensions
{
#region Collection Builders
/// <summary>
/// Gets the backoffice dashboards collection builder.
/// </summary>
/// <param name="composition">The composition.</param>
public static DashboardCollectionBuilder Dashboards(this Composition composition)
=> composition.WithCollectionBuilder<DashboardCollectionBuilder>();
#endregion
}
}

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace Umbraco.Web.UI.BackOffice
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
}
}

View File

@@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:36804",
"sslPort": 44354
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Umbraco.Web.UI.BackOffice": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Umbraco.Web.BackOffice.AspNetCore;
namespace Umbraco.Web.UI.BackOffice
{
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddUmbracoBackOffice();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseUmbracoBackOffice();
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/", async context => { await context.Response.WriteAsync("Hello World!"); });
});
}
}
}

View File

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Umbraco.Web.BackOffice\Umbraco.Web.BackOffice.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

View File

@@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}

View File

@@ -128,10 +128,6 @@
<Project>{f6de8da0-07cc-4ef2-8a59-2bc81dbb3830}</Project>
<Name>Umbraco.PublishedCache.NuCache</Name>
</ProjectReference>
<ProjectReference Include="..\Umbraco.Web.BackOffice\Umbraco.Web.BackOffice.csproj">
<Project>{9b95eef7-63fe-4432-8c63-166be9c1a929}</Project>
<Name>Umbraco.Web.BackOffice</Name>
</ProjectReference>
<ProjectReference Include="..\Umbraco.Web\Umbraco.Web.csproj">
<Project>{651e1350-91b6-44b7-bd60-7207006d7003}</Project>
<Name>Umbraco.Web</Name>

View File

@@ -119,6 +119,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Examine.Lucene", "U
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Web.BackOffice", "Umbraco.Web.BackOffice\Umbraco.Web.BackOffice.csproj", "{9B95EEF7-63FE-4432-8C63-166BE9C1A929}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Web.UI.BackOffice", "Umbraco.Web.UI.BackOffice\Umbraco.Web.UI.BackOffice.csproj", "{DCDFE97C-5630-4F6F-855D-8AEEB96556A5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -183,6 +185,10 @@ Global
{9B95EEF7-63FE-4432-8C63-166BE9C1A929}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9B95EEF7-63FE-4432-8C63-166BE9C1A929}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9B95EEF7-63FE-4432-8C63-166BE9C1A929}.Release|Any CPU.Build.0 = Release|Any CPU
{DCDFE97C-5630-4F6F-855D-8AEEB96556A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DCDFE97C-5630-4F6F-855D-8AEEB96556A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DCDFE97C-5630-4F6F-855D-8AEEB96556A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DCDFE97C-5630-4F6F-855D-8AEEB96556A5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE