Skip to content

Commit

Permalink
Merge pull request #2 from NikRimington/develop
Browse files Browse the repository at this point in the history
Merging beta 4 into Master
  • Loading branch information
NikRimington authored Aug 20, 2021
2 parents 6dc605c + 82ae042 commit fe5b72e
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 21 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Bjarke Berg
Copyright (c) 2021 Nik Rimington

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@ To [install from NuGet](https://www.nuget.org/packages/HotChilli.Umbraco.PageNot

PM> Install-Package HotChilli.Umbraco.PageNotFound

## How to use

*Improved documentation will come in time*

Once the package has been installed there are two approaches to configuration. Out of the box, it will be loaded via an Umbraco Composer, but if you wish to have more control over when it loads, there is an extension method for `IUmbracoBuilder` called `UsePageNotFoundManager`.

Once installed and running, Page Not Found Manager extends the "Do Something Else" context menu with a new entry for picking a 404 page off of a content node.

This allows for multiple different 404 pages to be configured for different parts of the website.

## Future Plans

There is currently a plan to investigate and see if this same 404 page can be served for missing media items. In IIS, this would fall back to the default 404 page from IIS but I'm yet to understand this pipeline and if this is possible - I'm open to PR's and suggestions on improvements as well.

## Special Thanks

This package is a port of [PageNotFoundManager](https://github.com/TimGeyssens/UmbracoPageNotFoundManager) by [Tim Geyssens](https://twitter.com/timgeyssens) and was created with his permission. The code based used as a point of reference was taken prior to the Licesencing Model change.

## Credits

The logo uses [404](https://thenounproject.com/term/404/3283006 ) from the [Noun Project](https://thenounproject.com) by [Ilham Fitrotul Hayat](https://thenounproject.com/fhilham), licensed under [CC BY 3.0 US](https://creativecommons.org/licenses/by/3.0/us/).
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void Handle(MenuRenderingNotification notification)

var menuItem = new MenuItem(Constants.MenuAlias, Constants.MenuLabel)
{
Icon = Umbraco.Cms.Core.Constants.Icons.Content,
Icon = "alert red",
SeparatorBefore = true
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<AssemblyVersion>1.0.0</AssemblyVersion>
<Version>1.0.0</Version>
<VersionSuffix>beta-004</VersionSuffix>
<InformationalVersion>1.0.0</InformationalVersion>
<TargetFramework>net5.0</TargetFramework>
<Authors>Nik Rimington</Authors>
Expand All @@ -22,11 +23,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Umbraco.Cms.Core" Version="9.0.0-rc001" />
<PackageReference Include="Umbraco.Cms.Infrastructure" Version="9.0.0-rc001" />
<PackageReference Include="Umbraco.Cms.Web.BackOffice" Version="9.0.0-rc001" />
<PackageReference Include="Umbraco.Cms.Web.Common" Version="9.0.0-rc001" />
<PackageReference Include="Umbraco.Cms.Web.Website" Version="9.0.0-rc001" />
<PackageReference Include="Umbraco.Cms.Core" Version="9.0.0-rc002" />
<PackageReference Include="Umbraco.Cms.Infrastructure" Version="9.0.0-rc002" />
<PackageReference Include="Umbraco.Cms.Web.BackOffice" Version="9.0.0-rc002" />
<PackageReference Include="Umbraco.Cms.Web.Common" Version="9.0.0-rc002" />
<PackageReference Include="Umbraco.Cms.Web.Website" Version="9.0.0-rc002" />
</ItemGroup>
<ItemGroup>
<None Include="../../docs/img/logo.png" Pack="true" PackPath="\" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<strong>{{target.name}}</strong> is set as the 404 page for
<strong>{{currentNode.name}}</strong> and it's child pages
</div>
<button class="btn btn-primary" ng-click="nav.hideDialog()">Ok</button>
<button class="btn btn-primary" ng-click="vm.close()">Ok</button>
</div>

<p class="abstract" ng-hide="success">
Expand Down Expand Up @@ -49,7 +49,7 @@
section="{{section}}">
</umb-tree-search-box>

<br/>
<br />

<umb-tree-search-results ng-if="searchInfo.showSearch"
results="searchInfo.results"
Expand Down Expand Up @@ -81,7 +81,7 @@
</div>

<div class="umb-dialog-footer btn-toolbar umb-btn-toolbar" ng-hide="success || busy">
<a class="btn btn-link" ng-click="nav.hideDialog()">
<a class="btn btn-link" ng-click="vm.close()">
<localize key="general_cancel">Cancel</localize>
</a>
<button class="btn btn-primary" ng-click="setNotFoundPage()">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(function() {
(function () {
"use strict";
function PageNotFoundManagerDialog($scope, pageNotFoundManagerResource, navigationService, userService, entityResource, iconHelper) {
var node = $scope.currentNode;
Expand Down Expand Up @@ -34,7 +34,7 @@
const val = parseInt(resp.data);
if (!isNaN(val) && angular.isNumber(val) && val > 0) {
$scope.pageNotFoundId = val;
entityResource.getById(val, "Document").then(function(item) {
entityResource.getById(val, "Document").then(function (item) {
item.icon = iconHelper.convertFromLegacyIcon(item.icon);
$scope.pageNotFoundNode = item;
});
Expand All @@ -43,6 +43,8 @@
initNotFound = true;
vm.busy = !(initNotFound && initUserDetails);
});

vm.close = close;
}


Expand All @@ -69,26 +71,30 @@
}
}

$scope.hideSearch = function() {
function close() {
$scope.nav.hideDialog();
}

$scope.hideSearch = function () {
$scope.searchInfo.showSearch = false;
$scope.searchInfo.searchFromId = null;
$scope.searchInfo.searchFromName = null;
$scope.searchInfo.results = [];
};

// method to select a search result
$scope.selectResult = function(evt, result) {
$scope.selectResult = function (evt, result) {
result.selected = result.selected === true ? false : true;
nodeSelectHandler(evt, { event: evt, node: result });
};

//callback when there are search results
$scope.onSearchResults = function(results) {
$scope.onSearchResults = function (results) {
$scope.searchInfo.results = results;
$scope.searchInfo.showSearch = true;
};

$scope.setNotFoundPage = function() {
$scope.setNotFoundPage = function () {

vm.busy = true;
$scope.error = false;
Expand All @@ -101,11 +107,11 @@
if ($scope.target !== undefined && $scope.target !== null)
notFoundPageId = $scope.target.id;

pageNotFoundManagerResource.setNotFoundPage(parentId, notFoundPageId).then(function() {
pageNotFoundManagerResource.setNotFoundPage(parentId, notFoundPageId).then(function () {
$scope.error = false;
$scope.success = true;
vm.busy = false;
}, function(err) {
}, function (err) {
$scope.success = false;
$scope.error = err;
vm.busy = false;
Expand All @@ -120,7 +126,7 @@
}
}

$scope.onTreeInit = function() {
$scope.onTreeInit = function () {
$scope.dialogTreeApi.callbacks.treeLoaded(treeLoadedHandler);
$scope.dialogTreeApi.callbacks.treeNodeSelect(nodeSelectHandler);
$scope.dialogTreeApi.callbacks.treeNodeExpanded(nodeExpandedHandler);
Expand All @@ -130,6 +136,6 @@
}

angular.module("umbraco").controller("hc.pagenotfound.dialog.controller",
['$scope', 'hc.pageNotFoundManagerResource', 'notificationsService',
'userService', 'entityResource', 'iconHelper', PageNotFoundManagerDialog]);
['$scope', 'hc.pageNotFoundManagerResource', 'navigationService',
'userService', 'entityResource', 'iconHelper', PageNotFoundManagerDialog]);
})();
4 changes: 4 additions & 0 deletions src/HC.PageNotFoundManager/HC.PageNotFoundManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<AssemblyVersion>1.0.0</AssemblyVersion>
<Version>1.0.0</Version>
<VersionSuffix>beta-004</VersionSuffix>
<InformationalVersion>1.0.0</InformationalVersion>
<TargetFramework>net5.0</TargetFramework>
<Authors>Nik Rimington</Authors>
Expand Down Expand Up @@ -37,4 +38,7 @@
<None Include="../../docs/img/logo.png" Pack="true" PackPath="\" />
<None Include="../../LICENSE" Pack="true" PackPath="" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Umbraco.Cms.Core" Version="9.0.0-rc002" />
</ItemGroup>
</Project>

0 comments on commit fe5b72e

Please sign in to comment.