https://github.com/ontopiccms/ontopic-editor-aspnetcore
ASP.NET Core version of an editor for Ignia's OnTopic CMS.
https://github.com/ontopiccms/ontopic-editor-aspnetcore
administration-interface asp-net asp-net-core aspnetcore cms content-editor content-management-system editor ignia ontopic ontopic-library web-application
Last synced: 3 months ago
JSON representation
ASP.NET Core version of an editor for Ignia's OnTopic CMS.
- Host: GitHub
- URL: https://github.com/ontopiccms/ontopic-editor-aspnetcore
- Owner: OnTopicCMS
- Created: 2017-10-07T20:39:30.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-02-04T13:44:14.000Z (over 3 years ago)
- Last Synced: 2025-04-03T22:03:10.730Z (about 1 year ago)
- Topics: administration-interface, asp-net, asp-net-core, aspnetcore, cms, content-editor, content-management-system, editor, ignia, ontopic, ontopic-library, web-application
- Language: JavaScript
- Homepage:
- Size: 3.74 MB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# OnTopic Editor
The `OnTopic.Editor.AspNetCore` project provides a web-based interface for the [**OnTopic Library**](https://github.com/OnTopicCMS/OnTopic-Library). The editor is distributed as a **Razor Class Library** via **NuGet** so it can easily be added to a website that implements the [`OnTopic.AspNetCore.Mvc`](https://github.com/OnTopicCMS/OnTopic-Library/tree/master/OnTopic.AspNetCore.Mvc) library.
[](https://www.nuget.org/packages/OnTopic.Editor.AspNetCore.All/)
[](https://igniasoftware.visualstudio.com/OnTopic/_build/latest?definitionId=8&branchName=master)

### Contents
- [Installation](#installation)
- [Configuration](#configuration)
- [Services](#services)
- [Routes](#routes)
- [Dependencies](#dependencies)
- [`IControllerActivator`](#icontrolleractivator)
- [`IViewComponentActivator`](#iviewcomponentactivator)
## Installation
Installation can be performed by providing a `` to the [`OnTopic.Editor.AspNetCore.All`](OnTopic.Editor.AspNetCore.All/README.md) **NuGet** metapackage.
```xml
�
```
## Configuration
There are a lot of moving parts to the editor, and it requires the configuration of services, routes, and service dependencies. This process is aided by a set of extension methods, which are recommended.
### Services
The editor necessitates a custom model binder�[`AttributeBindingModelBinderProvider`](OnTopic.Editor.AspNetCore/Infrastructure/AttributeBindingModelBinderProvider.cs)�in order to work properly. This can be manually configured via `AddMvcOptions()`, or can be added using the `AddTopicEditor()` extension method:
```c#
public class Startup {
�
public void ConfigureServices(IServiceCollection services) {
services.AddControllersWithViews()
.AddTopicSupport()
.AddTopicEditor();
}
}
```
### Routes
The editor lives in an area called `Editor` and a controller called `EditorController`. A custom route can be conigured using the `MapTopicEditorRoute()` extension method to setup the `/OnTopic` route (e.g., `/OnTopic/Edit/Root/Web`):
```c#
public class Startup {
�
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
app.UseEndpoints(endpoints => {
endpoints.MapTopicEditorRoute();
});
}
}
```
### Dependencies
The editor is implemented through a set of **ASP.NET Core View Components**, some of which have external dependencies on a `ITopicRepository`. These should be configured via dependency injection. If you're using a _dependency injection container_, those dependencies should be the same as those required for the **OnTopic Library**. If you are manually configuring your dependencies, however, then the following provides a bare-bones example:
#### `IControllerActivator`
```c#
public class ControllerActivator : IControllerActivator {
�
public object Create(ControllerContext context) {
var type = context.ActionDescriptor.ControllerTypeInfo.AsType();
if (type == typeof(EditorController)) {
return new EditorController(_topicRepository, _topicMappingService);
}
}
}
```
> _Note:_ This assumes a `_topicRepository` and `_topicMappingService` have already been configured; see the [`OnTopic.AspNetCore.Mvc`](https://github.com/OnTopicCMS/OnTopic-Library/tree/master/OnTopic.AspNetCore.Mvc#composition-root) documentation for details.
#### `IViewComponentActivator`
The [`StandardEditorComposer`](OnTopic.Editor.AspNetCore.Attributes/StandardEditorComposer.cs) class acts as a clearing house for accepting common dependencies and then composing the appropriate dependency graph for the view components:
```c#
public class ViewComponentActivator : IViewComponentActivator {
�
public object Create(ViewComponentContext context) {
var standardEditorComposer = new StandardEditorComposer(_topicRepository, _webHostEnvironment);
var type = context.ViewComponentDescriptor.TypeInfo.AsType();
if (standardEditorComposer.IsEditorComponent(type)) {
return standardEditorComposer.ActivateEditorComponent(type, _topicRepository);
}
}
}
```
> _Note:_ For a full example, see the [`SampleActivator`](OnTopic.Editor.AspNetCore.Host/SampleActivator.cs) in the [`OnTopic.Editor.AspNetCore.Host`](OnTopic.Editor.AspNetCore.Host) project.