Skip to content

Commit

Permalink
Umbraco 9!
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickdemooij9 committed Sep 29, 2021
1 parent dfc62d7 commit 4541139
Show file tree
Hide file tree
Showing 293 changed files with 12,127 additions and 5,509 deletions.
23 changes: 21 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
[Rr]eleases/
x64/
x86/
build/
bld/
[Bb]in/
[Oo]bj/
Expand Down Expand Up @@ -199,4 +198,24 @@ FakesAssemblies/

TEMP/
Logs/
App_Data/

# Umbraco
# Ignore unimportant folders generated by Umbraco
**/App_Data/Logs/
**/App_Data/[Pp]review/
**/App_Data/TEMP/
**/App_Data/NuGetBackup/

# Ignore Umbraco content cache file
**/App_Data/umbraco.config

## this [Uu]mbraco/ folder should be created by cmd like `Install-Package UmbracoCms -Version 8.5.3`
## you can find your Umbraco version in your Web.config. (i.e. <add key="Umbraco.Core.ConfigurationStatus" value="8.5.3" />)
## Uncomment this line if you think it fits the way you work on your project.
## **/[Uu]mbraco/

# ImageProcessor DiskCache
**/App_Data/cache/

# Ignore the Models Builder models out of date flag
**/ood.flag
33 changes: 33 additions & 0 deletions source/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/InboundLinkErrors.Website/bin/Debug/net5.0/InboundLinkErrors.Website.dll",
"args": [],
"cwd": "${workspaceFolder}/InboundLinkErrors.Website",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}
42 changes: 42 additions & 0 deletions source/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/InboundLinkErrors.Website/InboundLinkErrors.Website.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/InboundLinkErrors.Website/InboundLinkErrors.Website.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/InboundLinkErrors.Website/InboundLinkErrors.Website.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}
4 changes: 2 additions & 2 deletions source/InboundLinkErrors.Core/InboundLinkErrors.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Umbraco.Cms.Web.Website" Version="9.0.0-rc001" />
<PackageReference Include="Umbraco.Cms.Web.BackOffice" Version="9.0.0-rc001" />
<PackageReference Include="Umbraco.Cms.Web.Website" Version="9.0.0" />
<PackageReference Include="Umbraco.Cms.Web.BackOffice" Version="9.0.0" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion source/InboundLinkErrors.Core/LinkErrorsDashboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace InboundLinkErrors.Core
public class LinkErrorsDashboard : IDashboard
{
public string Alias => "linkErrorsDashboard";
public string View => "/App_Plugins/LinkErrors/app.html";
public string View => "/App_Plugins/InboundLinkErrors/app.html";
public string[] Sections => new string[] {"Content"};
public IAccessRule[] AccessRules => Array.Empty<IAccessRule>();
}
Expand Down
7 changes: 6 additions & 1 deletion source/InboundLinkErrors.Core/LinkErrorsUserComposer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
using InboundLinkErrors.Core.ConfigurationProvider;
using InboundLinkErrors.Core.Interfaces;
using InboundLinkErrors.Core.Mappers;
using InboundLinkErrors.Core.MiddleWare;
using InboundLinkErrors.Core.Middleware;
using InboundLinkErrors.Core.Options;
using InboundLinkErrors.Core.Processor;
using InboundLinkErrors.Core.Repositories;
using InboundLinkErrors.Core.Services;
using InboundLinkErrors.Core.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Umbraco.Cms.Core;
Expand Down Expand Up @@ -37,8 +38,12 @@ public void Compose(IUmbracoBuilder composition)
composition.Services.AddUnique<IRedirectAdapter, UmbracoRedirectAdapter>();
composition.Services.AddUnique<ILinkErrorConfigurationProvider, LinkErrorConfigurationProvider>();

composition.Services.AddHostedService<LinkErrorsCleanupTask>();
composition.Services.AddHostedService<LinkErrorsDatabaseSyncTask>();

composition.Services.Configure<LinkErrorsOptions>(composition.Config.GetSection(
LinkErrorsOptions.Position));

composition.Services.Configure<UmbracoPipelineOptions>(options => {
options.AddFilter(new UmbracoPipelineFilter(
"InboundLinkErrors",
Expand Down
27 changes: 18 additions & 9 deletions source/InboundLinkErrors.Core/MiddleWare/LinkErrorsMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,50 @@
using InboundLinkErrors.Core.Processor;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Extensions;
using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Core.Web;

namespace InboundLinkErrors.Core.MiddleWare
namespace InboundLinkErrors.Core.Middleware
{
public class LinkErrorsMiddleware
{
private readonly RequestDelegate _next;
private readonly ILinkErrorsProcessor _processor;
private readonly LinkErrorConfiguration _configuration;
private readonly IUmbracoContextAccessor _umbracoContextAccessor;

public LinkErrorsMiddleware(RequestDelegate next, ILinkErrorsProcessor processor, ILinkErrorConfigurationProvider configurationProvider)
public LinkErrorsMiddleware(RequestDelegate next, ILinkErrorsProcessor processor, ILinkErrorConfigurationProvider configurationProvider, IUmbracoContextAccessor umbracoContextAccessor)
{
_umbracoContextAccessor = umbracoContextAccessor;
_next = next;
_processor = processor;
_configuration = configurationProvider.GetConfiguration();
}

public async Task InvokeAsync(HttpContext context)
{
if (context.Response.StatusCode != (int)HttpStatusCode.NotFound)
var pathAndQuery = context.Request.GetEncodedPathAndQuery();

if (pathAndQuery.IndexOf("/umbraco", StringComparison.InvariantCultureIgnoreCase) == 0)
{
await _next(context);
return;
}

var pathAndQuery = context.Request.GetEncodedPathAndQuery();
if (!_configuration.TrackMedia && Path.HasExtension(pathAndQuery))
{
await _next(context);
return;
}

// Ignore all /umbraco/ requests
if (pathAndQuery.IndexOf("/umbraco/", StringComparison.InvariantCultureIgnoreCase) == 0)
if (!_umbracoContextAccessor.TryGetUmbracoContext(out var umbracoContext))
{
await _next(context);
return;
}
var publishedRequest = umbracoContext?.PublishedRequest;

if (!_configuration.TrackMedia && Path.HasExtension(pathAndQuery))
if (publishedRequest is not null && publishedRequest.ResponseStatusCode != StatusCodes.Status404NotFound)
{
await _next(context);
return;
Expand All @@ -50,8 +59,8 @@ public async Task InvokeAsync(HttpContext context)
var referrer = _configuration.TrackReferrer ? headers.Referer?.AbsoluteUri : null;
var userAgent = _configuration.TrackUserAgents ? headers.Headers["User-Agent"].ToString() : null;

_processor.AddRequest(pathAndQuery, referrer, userAgent);
_processor.AddRequest(context.Request.GetEncodedUrl(), referrer, userAgent);
await _next(context);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ namespace InboundLinkErrors.Core.Repositories
public class LinkErrorsRepository : ILinkErrorsRepository
{
private readonly IScopeProvider _scopeProvider;
private readonly UmbracoMapper _umbracoMapper;
private readonly IUmbracoMapper _umbracoMapper;

public LinkErrorsRepository(IScopeProvider scopeProvider, UmbracoMapper umbracoMapper)
public LinkErrorsRepository(IScopeProvider scopeProvider, IUmbracoMapper umbracoMapper)
{
_scopeProvider = scopeProvider;
_umbracoMapper = umbracoMapper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ angular.module("umbraco").controller("LinkErrorsController", function ($scope, $
$scope.openRedirectDialog = function (linkError) {
var redirectDialogOptions = {
title: "Set redirect",
view: "/App_Plugins/LinkErrors/assets/views/createRedirect.html",
view: "/App_Plugins/InboundLinkErrors/assets/views/createRedirect.html",
size: "small",
submit: function (model) {
var selectedNodeId = model.selectedNode.id;
Expand All @@ -58,7 +58,7 @@ angular.module("umbraco").controller("LinkErrorsController", function ($scope, $
$scope.openDetailDialog = function (linkError) {
var detailDialogOptions = {
title: "Details",
view: "/App_Plugins/LinkErrors/assets/views/detail.html",
view: "/App_Plugins/InboundLinkErrors/assets/views/detail.html",
size: "small",
linkError: linkError,
close: function () {
Expand Down Expand Up @@ -203,7 +203,7 @@ angular.module("umbraco.resources").factory("LinkErrorsApi", function ($http) {
},
//Remove / Delete an existing redirect
remove: function (id) {
return $http.delete("backoffice/LinkErrors/LinkErrorsApi/Delete/" + id);
return $http.delete("backoffice/LinkErrors/LinkErrorsApi/Delete/?id=" + id);
},
setRedirect: function (linkErrorId, nodeId, culture) {
return $http.post("backoffice/LinkErrors/LinkErrorsApi/SetRedirect?linkErrorId=" + linkErrorId + "&nodeId=" + nodeId + "&culture=" + culture);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Umbraco.Cms" Version="9.0.0-rc001" />
<PackageReference Include="Umbraco.Cms" Version="9.0.0" />
<PackageReference Include="Umbraco.Cms.SqlCe" Version="9.0.0" />
<PackageReference Include="Umbraco.SqlServerCE" Version="4.0.0.1" />
</ItemGroup>

<Import Project="..\InboundLinkErrors\build\InboundLinkErrors.targets" />
<ItemGroup>
<ProjectReference Include="..\InboundLinkErrors.Core\InboundLinkErrors.Core.csproj" />
<ProjectReference Include="..\InboundLinkErrors\InboundLinkErrors.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Remove="umbraco\Data\**" />
Expand Down Expand Up @@ -41,6 +38,10 @@
<Content Remove="umbraco\logs\**" />
<Content Remove="umbraco\MediaCache\**" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\InboundLinkErrors.Core\InboundLinkErrors.Core.csproj" />
<ProjectReference Include="..\InboundLinkErrors\InboundLinkErrors.csproj" />
</ItemGroup>

<!-- Set this to true if ModelsBuilder mode is not InMemoryAuto-->
<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:26438",
"sslPort": 44369
"applicationUrl": "http://localhost:47665",
"sslPort": 44325
}
},
"profiles": {
Expand All @@ -20,7 +20,7 @@
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:44369;http://localhost:26438",
"applicationUrl": "https://localhost:44325;http://localhost:47665",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
Expand Down
4 changes: 2 additions & 2 deletions source/InboundLinkErrors.Website/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
app.UseUmbraco()
.WithMiddleware(u =>
{
u.WithBackOffice();
u.WithWebsite();
u.UseBackOffice();
u.UseWebsite();
})
.WithEndpoints(u =>
{
Expand Down
Loading

0 comments on commit 4541139

Please sign in to comment.