-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Start of settings with controller and basic view (#43)
* Adding setting tree and api controller * fixed build warning * Renames * Changed version
- Loading branch information
1 parent
ff96e83
commit 1523e8b
Showing
13 changed files
with
241 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8" standalone="yes"?> | ||
<language alias="en" intName="English (US)" localName="English (US)" lcid="" culture="en-US"> | ||
<area alias="treeHeaders"> | ||
<key alias="sync">Synchronization</key> | ||
<key alias="uactivitypub">uActivityPub</key> | ||
</area> | ||
</language> |
17 changes: 17 additions & 0 deletions
17
uActivityPub/App_Plugins/uActivityPub/backoffice/uactivitypub/dashboard.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<div ng-controller="uActivityPubSettingsDashboardController as vm"> | ||
<umb-editor-view footer="false"> | ||
<umb-editor-header name="vm.page.title" | ||
description="vm.page.description" | ||
hide-description="false" | ||
name-locked="true" | ||
description-locked="true" | ||
hide-alias="true" | ||
hide-icon="true" | ||
navigation="vm.page.navigation" | ||
on-select-navigation-item="vm.selectNavigationItem(item)"> | ||
</umb-editor-header> | ||
<umb-editor-container class="form-horizontal"> | ||
<umb-editor-sub-views sub-views="vm.page.navigation" model="vm"></umb-editor-sub-views> | ||
</umb-editor-container> | ||
</umb-editor-view> | ||
</div> |
48 changes: 48 additions & 0 deletions
48
...Pub/App_Plugins/uActivityPub/backoffice/uactivitypub/uactivitypub.dashboard.controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
(function () { | ||
'use strict'; | ||
|
||
function dashboardController($controller, | ||
$scope, $timeout, navigationService, eventsService) { | ||
|
||
var vm = this; | ||
|
||
var _settingsFolder = Umbraco.Sys.ServerVariables.umbracoSettings.appPluginsPath + '/uActivityPub/settings'; | ||
|
||
vm.selectNavigationItem = function (item) { | ||
eventsService.emit('uactivitypub-dashboard.tab.change', item); | ||
} | ||
|
||
vm.page = { | ||
title: 'uActivityPub', | ||
description: '...', | ||
navigation: [ ] | ||
}; | ||
|
||
var uSyncSettings = Umbraco.Sys.ServerVariables.uSync; | ||
|
||
if (!uSyncSettings.disabledDashboard) { | ||
vm.page.navigation.push({ | ||
'name': 'uActivityPub', | ||
'alias': 'uActivityPub', | ||
'icon': 'icon-mastodon-fill', | ||
'view': _settingsFolder + '/default.html', | ||
'active': true | ||
}); | ||
} | ||
|
||
vm.page.navigation.push({ | ||
'name': 'Settings', | ||
'alias': 'settings', | ||
'icon': 'icon-settings', | ||
'view': _settingsFolder + '/settings.html', | ||
}); | ||
|
||
|
||
$timeout(function () { | ||
navigationService.syncTree({ tree: "uActivityPub", path: "-1" }); | ||
}); | ||
} | ||
|
||
angular.module('umbraco') | ||
.controller('uActivityPubSettingsDashboardController', dashboardController); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace uActivityPub.Authorization; | ||
|
||
/// <summary> | ||
/// Security policy constants used in Umbraco by uSync | ||
/// </summary> | ||
public static class SyncAuthorizationPolicies | ||
{ | ||
/// <summary> | ||
/// name of the uSyncTreeAccess policy. | ||
/// </summary> | ||
public const string TreeAccessUActivityPub = nameof(TreeAccessUActivityPub); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
uActivityPub/Controllers/PluginControllers/UActivityPubDashboardApiController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Microsoft.AspNetCore.Authorization; | ||
using uActivityPub.Authorization; | ||
using Umbraco.Cms.Web.BackOffice.Controllers; | ||
using Umbraco.Cms.Web.Common.Attributes; | ||
|
||
namespace uActivityPub.Controllers.PluginControllers; | ||
|
||
[PluginController("uActivityPub")] | ||
[Authorize(Policy = SyncAuthorizationPolicies.TreeAccessUActivityPub)] | ||
public class UActivityPubDashboardApiController : UmbracoAuthorizedJsonController | ||
{ | ||
|
||
/// <summary> | ||
/// Stub - get API used to locate API in umbraco | ||
/// </summary> | ||
/// <returns></returns> | ||
public bool GetApi() => true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Umbraco.Cms.Core; | ||
using Umbraco.Cms.Core.Actions; | ||
using Umbraco.Cms.Core.Events; | ||
using Umbraco.Cms.Core.Models.Trees; | ||
using Umbraco.Cms.Core.Services; | ||
using Umbraco.Cms.Core.Trees; | ||
using Umbraco.Cms.Web.BackOffice.Trees; | ||
using Umbraco.Extensions; | ||
|
||
namespace uActivityPub.Expansions; | ||
|
||
[Tree("settings", "uActivityPubAlias", TreeTitle = "uActivityPub", TreeGroup = "sync", SortOrder = 5)] | ||
public class SettingsTreeController( | ||
ILocalizedTextService localizedTextService, | ||
UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, | ||
IMenuItemCollectionFactory menuItemCollectionFactory, | ||
IEventAggregator eventAggregator) | ||
: TreeController(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator) | ||
{ | ||
private readonly IMenuItemCollectionFactory _menuItemCollectionFactory = menuItemCollectionFactory ?? throw new ArgumentNullException(nameof(menuItemCollectionFactory)); | ||
|
||
protected override ActionResult<TreeNodeCollection> GetTreeNodes(string id, FormCollection queryStrings) | ||
{ | ||
var nodes = new TreeNodeCollection(); | ||
return nodes; | ||
} | ||
|
||
protected override ActionResult<MenuItemCollection> GetMenuForNode(string id, FormCollection queryStrings) | ||
{ | ||
var menu = _menuItemCollectionFactory.Create(); | ||
|
||
return menu; | ||
} | ||
|
||
protected override ActionResult<TreeNode?> CreateRootNode(FormCollection queryStrings) | ||
{ | ||
var rootResult = base.CreateRootNode(queryStrings); | ||
if (rootResult.Result is not null) | ||
{ | ||
return rootResult; | ||
} | ||
|
||
var root = rootResult.Value ?? throw new NullReferenceException(nameof(rootResult)); | ||
|
||
//set the route | ||
root.RoutePath = $"{SectionAlias}/uactivitypub/dashboard"; | ||
// set the icon | ||
root.Icon = "icon-mastodon-fill"; | ||
// could be set to false for a custom tree with a single node. | ||
root.HasChildren = false; | ||
//url for menu | ||
root.MenuUrl = null; | ||
|
||
return root; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
uActivityPub/Notifications/uActivityPubServerVariablesHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Microsoft.AspNetCore.Routing; | ||
using uActivityPub.Controllers.PluginControllers; | ||
using Umbraco.Cms.Core.Events; | ||
using Umbraco.Cms.Core.Notifications; | ||
using Umbraco.Extensions; | ||
|
||
namespace uActivityPub.Notifications; | ||
|
||
public class uActivityPubServerVariablesHandler : INotificationHandler<ServerVariablesParsingNotification> | ||
{ | ||
private readonly LinkGenerator _linkGenerator; | ||
|
||
/// <inheritdoc cref="INotificationHandler{TNotification}" /> | ||
public uActivityPubServerVariablesHandler(LinkGenerator linkGenerator) | ||
{ | ||
_linkGenerator = linkGenerator; | ||
} | ||
|
||
public void Handle(ServerVariablesParsingNotification notification) | ||
{ | ||
notification.ServerVariables.Add("uActivityPub", new Dictionary<string, object> | ||
{ | ||
{ "uActivityPubService", _linkGenerator.GetUmbracoApiServiceBaseUrl<UActivityPubDashboardApiController>(controller => controller.GetApi()) } | ||
Check warning on line 23 in uActivityPub/Notifications/uActivityPubServerVariablesHandler.cs GitHub Actions / create_nuget
Check warning on line 23 in uActivityPub/Notifications/uActivityPubServerVariablesHandler.cs GitHub Actions / run_test
Check warning on line 23 in uActivityPub/Notifications/uActivityPubServerVariablesHandler.cs GitHub Actions / create_nuget
|
||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup> | ||
<uSyncPackageFolder Include="$(MSBuildProjectDirectory)\App_Plugins\uActivityPub\" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace uActivityPub; | ||
|
||
// ReSharper disable once InconsistentNaming | ||
public static class uActivityPubConstants | ||
{ | ||
public static class Package | ||
{ | ||
/// <summary> | ||
/// Name of the Package | ||
/// </summary> | ||
public const string Name = "uActivityPub"; | ||
|
||
/// <summary> | ||
/// Virtual path to the plugin files | ||
/// </summary> | ||
public const string PluginPath = "/App_Plugins/uActivityPub"; | ||
} | ||
} |